From 475ce4c065d733046aa0b5cb3912ab45a3ffe9d9 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Wed, 25 May 2016 16:35:10 +0200 Subject: [PATCH] [simix] Remove the notion of casted type in the simcall input language The C++ template magic is now responsible for this. --- src/simix/simcalls.in | 146 +++++++++++++++++++++--------------------- src/simix/simcalls.py | 41 ++---------- 2 files changed, 78 insertions(+), 109 deletions(-) diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index e08a38dfbb..bc322903e3 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -46,83 +46,83 @@ # ./include/simgrid/simix.h (otherwise you will get a warning at the # compilation time) -Proc H vm_suspend (void) (ind_vm, void*, sg_host_t) -Proc H vm_resume (void) (ind_vm, void*, sg_host_t) -Proc H vm_shutdown (void) (ind_vm, void*, sg_host_t) -Proc H vm_save (void) (ind_vm, void*, sg_host_t) -Proc H vm_restore (void) (ind_vm, void*, sg_host_t) +Proc H vm_suspend (void) (ind_vm, sg_host_t) +Proc H vm_resume (void) (ind_vm, sg_host_t) +Proc H vm_shutdown (void) (ind_vm, sg_host_t) +Proc H vm_save (void) (ind_vm, sg_host_t) +Proc H vm_restore (void) (ind_vm, sg_host_t) -Proc H process_kill (void) (process, void*, smx_process_t) +Proc H process_kill (void) (process, smx_process_t) Proc H process_killall (void) (reset_pid, int) -Proc - process_cleanup (void) (process, void*, smx_process_t) -Blck H process_suspend (void) (process, void*, smx_process_t) -Proc H process_resume (void) (process, void*, smx_process_t) -Proc H process_set_host (void) (process, void*, smx_process_t) (dest, void*, sg_host_t) -Func - process_is_suspended (int) (process, void*, smx_process_t) -Blck H process_join (int) (process, void*, smx_process_t) (timeout, double) +Proc - process_cleanup (void) (process, smx_process_t) +Blck H process_suspend (void) (process, smx_process_t) +Proc H process_resume (void) (process, smx_process_t) +Proc H process_set_host (void) (process, smx_process_t) (dest, sg_host_t) +Func - process_is_suspended (int) (process, smx_process_t) +Blck H process_join (int) (process, smx_process_t) (timeout, double) Blck H process_sleep (int) (duration, double) -Func H execution_start (void*, smx_synchro_t) (name, const char*) (flops_amount, double) (priority, double) (bound, double) (affinity_mask, unsigned long) -Func - execution_parallel_start (void*, smx_synchro_t) (name, const char*) (host_nb, int) (host_list, void*, sg_host_t*) (flops_amount, void*, double*) (bytes_amount, void*, double*) (amount, double) (rate, double) -Proc - execution_cancel (void) (execution, void*, smx_synchro_t) -Proc - execution_set_priority (void) (execution, void*, smx_synchro_t) (priority, double) -Proc - execution_set_bound (void) (execution, void*, smx_synchro_t) (bound, double) -Proc - execution_set_affinity (void) (execution, void*, smx_synchro_t) (ws, void*, sg_host_t) (mask, unsigned long) -Blck H execution_wait (int) (execution, void*, smx_synchro_t) - -Proc - process_on_exit (void) (process, void*, smx_process_t) (fun, FPtr, int_f_pvoid_pvoid_t) (data, void*) -Proc - process_auto_restart_set (void) (process, void*, smx_process_t) (auto_restart, int) -Func H process_restart (void*, smx_process_t) (process, void*, smx_process_t) - -Func - mbox_create (void*, smx_mailbox_t) (name, const char*) -Proc - mbox_set_receiver (void) (mbox, void*, smx_mailbox_t) (receiver, void*, smx_process_t) - -Func H comm_iprobe (void*, smx_synchro_t) (mbox, void*, smx_mailbox_t) (type, int) (src, int) (tag, int) (match_fun, FPtr, simix_match_func_t) (data, void*) -Blck H comm_send (void) (sender, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, FPtr, simix_match_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (timeout, double) -Func H comm_isend (void*, smx_synchro_t) (sender, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, FPtr, simix_match_func_t) (clean_fun, FPtr, simix_clean_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (detached, int) -Blck H comm_recv (void) (receiver, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (timeout, double) (rate, double) -Func H comm_irecv (void*, smx_synchro_t) (receiver, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (rate, double) -Blck H comm_waitany (int) (comms, void*, xbt_dynar_t) -Blck H comm_wait (void) (comm, void*, smx_synchro_t) (timeout, double) -Blck H comm_test (int) (comm, void*, smx_synchro_t) -Blck H comm_testany (int) (comms, void*, xbt_dynar_t) - -Func H mutex_init (void*, smx_mutex_t) -Blck H mutex_lock (void) (mutex, void*, smx_mutex_t) -Func H mutex_trylock (int) (mutex, void*, smx_mutex_t) -Proc H mutex_unlock (void) (mutex, void*, smx_mutex_t) - -Func - cond_init (void*, smx_cond_t) -Proc - cond_signal (void) (cond, void*, smx_cond_t) -Blck H cond_wait (void) (cond, void*, smx_cond_t) (mutex, void*, smx_mutex_t) -Blck H cond_wait_timeout (void) (cond, void*, smx_cond_t) (mutex, void*, smx_mutex_t) (timeout, double) -Proc - cond_broadcast (void) (cond, void*, smx_cond_t) - -Func - sem_init (void*, smx_sem_t) (capacity, unsigned int) -Proc H sem_release (void) (sem, void*, smx_sem_t) -Func H sem_would_block (int) (sem, void*, smx_sem_t) -Blck H sem_acquire (void) (sem, void*, smx_sem_t) -Blck H sem_acquire_timeout (void) (sem, void*, smx_sem_t) (timeout, double) -Func H sem_get_capacity (int) (sem, void*, smx_sem_t) - -Blck H file_read (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t) (host, void*, sg_host_t) -Blck H file_write (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t) (host, void*, sg_host_t) -Blck H file_open (void*, smx_file_t) (fullpath, const char*) (host, void*, sg_host_t) -Blck H file_close (int) (fd, void*, smx_file_t) (host, void*, sg_host_t) -Func - file_unlink (int) (fd, void*, smx_file_t) (host, void*, sg_host_t) -Func H file_get_size (sg_size_t) (fd, void*, smx_file_t) -Func H file_tell (sg_size_t) (fd, void*, smx_file_t) -Func H file_seek (int) (fd, void*, smx_file_t) (offset, sg_offset_t) (origin, int) -Func H file_get_info (void*, xbt_dynar_t) (fd, void*, smx_file_t) -Func H file_move (int) (fd, void*, smx_file_t) (fullpath, const char*) - -Func H storage_get_free_size (sg_size_t) (storage, void*, smx_storage_t) -Func H storage_get_used_size (sg_size_t) (name, void*, smx_storage_t) -Func - storage_get_properties (void*, xbt_dict_t) (storage, void*, smx_storage_t) -Func - storage_get_content (void*, xbt_dict_t) (storage, void*, smx_storage_t) - -Func H asr_get_properties (void*, xbt_dict_t) (name, const char*) +Func H execution_start (smx_synchro_t) (name, const char*) (flops_amount, double) (priority, double) (bound, double) (affinity_mask, unsigned long) +Func - execution_parallel_start (smx_synchro_t) (name, const char*) (host_nb, int) (host_list, sg_host_t*) (flops_amount, double*) (bytes_amount, double*) (amount, double) (rate, double) +Proc - execution_cancel (void) (execution, smx_synchro_t) +Proc - execution_set_priority (void) (execution, smx_synchro_t) (priority, double) +Proc - execution_set_bound (void) (execution, smx_synchro_t) (bound, double) +Proc - execution_set_affinity (void) (execution, smx_synchro_t) (ws, sg_host_t) (mask, unsigned long) +Blck H execution_wait (int) (execution, smx_synchro_t) + +Proc - process_on_exit (void) (process, smx_process_t) (fun, int_f_pvoid_pvoid_t) (data, void*) +Proc - process_auto_restart_set (void) (process, smx_process_t) (auto_restart, int) +Func H process_restart (smx_process_t) (process, smx_process_t) + +Func - mbox_create (smx_mailbox_t) (name, const char*) +Proc - mbox_set_receiver (void) (mbox, smx_mailbox_t) (receiver, smx_process_t) + +Func H comm_iprobe (smx_synchro_t) (mbox, smx_mailbox_t) (type, int) (src, int) (tag, int) (match_fun, simix_match_func_t) (data, void*) +Blck H comm_send (void) (sender, smx_process_t) (mbox, smx_mailbox_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, simix_match_func_t) (copy_data_fun, simix_copy_data_func_t) (data, void*) (timeout, double) +Func H comm_isend (smx_synchro_t) (sender, smx_process_t) (mbox, smx_mailbox_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, simix_match_func_t) (clean_fun, simix_clean_func_t) (copy_data_fun, simix_copy_data_func_t) (data, void*) (detached, int) +Blck H comm_recv (void) (receiver, smx_process_t) (mbox, smx_mailbox_t) (dst_buff, void*) (dst_buff_size, size_t*) (match_fun, simix_match_func_t) (copy_data_fun, simix_copy_data_func_t) (data, void*) (timeout, double) (rate, double) +Func H comm_irecv (smx_synchro_t) (receiver, smx_process_t) (mbox, smx_mailbox_t) (dst_buff, void*) (dst_buff_size, size_t*) (match_fun, simix_match_func_t) (copy_data_fun, simix_copy_data_func_t) (data, void*) (rate, double) +Blck H comm_waitany (int) (comms, xbt_dynar_t) +Blck H comm_wait (void) (comm, smx_synchro_t) (timeout, double) +Blck H comm_test (int) (comm, smx_synchro_t) +Blck H comm_testany (int) (comms, xbt_dynar_t) + +Func H mutex_init (smx_mutex_t) +Blck H mutex_lock (void) (mutex, smx_mutex_t) +Func H mutex_trylock (int) (mutex, smx_mutex_t) +Proc H mutex_unlock (void) (mutex, smx_mutex_t) + +Func - cond_init (smx_cond_t) +Proc - cond_signal (void) (cond, smx_cond_t) +Blck H cond_wait (void) (cond, smx_cond_t) (mutex, smx_mutex_t) +Blck H cond_wait_timeout (void) (cond, smx_cond_t) (mutex, smx_mutex_t) (timeout, double) +Proc - cond_broadcast (void) (cond, smx_cond_t) + +Func - sem_init (smx_sem_t) (capacity, unsigned int) +Proc H sem_release (void) (sem, smx_sem_t) +Func H sem_would_block (int) (sem, smx_sem_t) +Blck H sem_acquire (void) (sem, smx_sem_t) +Blck H sem_acquire_timeout (void) (sem, smx_sem_t) (timeout, double) +Func H sem_get_capacity (int) (sem, smx_sem_t) + +Blck H file_read (sg_size_t) (fd, smx_file_t) (size, sg_size_t) (host, sg_host_t) +Blck H file_write (sg_size_t) (fd, smx_file_t) (size, sg_size_t) (host, sg_host_t) +Blck H file_open (smx_file_t) (fullpath, const char*) (host, sg_host_t) +Blck H file_close (int) (fd, smx_file_t) (host, sg_host_t) +Func - file_unlink (int) (fd, smx_file_t) (host, sg_host_t) +Func H file_get_size (sg_size_t) (fd, smx_file_t) +Func H file_tell (sg_size_t) (fd, smx_file_t) +Func H file_seek (int) (fd, smx_file_t) (offset, sg_offset_t) (origin, int) +Func H file_get_info (xbt_dynar_t) (fd, smx_file_t) +Func H file_move (int) (fd, smx_file_t) (fullpath, const char*) + +Func H storage_get_free_size (sg_size_t) (storage, smx_storage_t) +Func H storage_get_used_size (sg_size_t) (name, smx_storage_t) +Func - storage_get_properties (xbt_dict_t) (storage, smx_storage_t) +Func - storage_get_content (xbt_dict_t) (storage, smx_storage_t) + +Func H asr_get_properties (xbt_dict_t) (name, const char*) Func H mc_random (int) (min, int) (max, int) -Proc - set_category (void) (synchro, void*, smx_synchro_t) (category, const char*) +Proc - set_category (void) (synchro, smx_synchro_t) (category, const char*) Proc - run_kernel (void) (code, void*) diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index c78d970296..aa6e1992a0 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -9,48 +9,17 @@ import re import glob -types = [ - ('char', 'c'), - ('const char*', 'cc'), - ('int', 'i'), - ('long', 'l'), - ('unsigned char', 'uc'), - ('unsigned short', 'us'), - ('unsigned int', 'ui'), - ('unsigned long', 'ul'), - ('float', 'f'), - ('double', 'd'), - ('void*', 'dp'), - ('FPtr', 'fp'), - ('const void*', 'cp'), - ('size_t', 'sz'), - ('sg_size_t', 'sgsz'), - ('sg_offset_t', 'sgoff'), - ('void', ''), - ('void*', 'dp'), - ('FPtr', 'fp'), - ] - - class Arg(object): - simcall_types = {k: v for k, v in types} - def __init__(self, name, type, casted=None): + def __init__(self, name, type): self.name = name self.type = type - self.casted = casted - assert type in self.simcall_types, '%s not in (%s)' % ( - type, ', '.join(self.simcall_types.keys())) def field(self): return self.simcall_types[self.type] def rettype(self): - return '%s' % self.casted if self.casted else self.type - - def cast(self): - return '(%s)' % self.casted if self.casted else '' - + return self.type class Simcall(object): simcalls_BODY = None @@ -208,10 +177,10 @@ def parse(fn): assert (handler == 'H' or handler == '-'), "Invalid need_handler indication: '%s'. Faulty line:\n%s\n" % ( handler, line) sargs = [] - for n, t, c in re.findall(r'\((.*?), *(.*?)(?:, *(.*?))?\)', args): - sargs.append(Arg(n, t, c)) + for n, t in re.findall(r'\((.*?), *(.*?)\)', args): + sargs.append(Arg(n, t)) sim = Simcall(name, handler == 'H', - Arg('result', rest, resc), sargs, ans) + Arg('result', rest), sargs, ans) if resdi is None: simcalls.append(sim) else: -- 2.20.1