X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4f5b9e125ac4d5e4fc68290eabf29366318c37b2..4968ee492739671ebdd6f94aba8ec7456e1e89b1:/src/simix/smx_user.c diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index e27464e046..3c75b3c0d5 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1,6 +1,9 @@ #include "private.h" #include "mc/mc.h" +#define _ISO_C99_SOURCE +#include /* isfinite() */ + XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); static const char* request_names[] = { @@ -154,6 +157,10 @@ smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host, double computation_amount, double priority) { + /* checking for infinite values */ + xbt_assert(isfinite(computation_amount), "computation_amount is not finite!"); + xbt_assert(isfinite(priority), "priority is not finite!"); + smx_req_t req = SIMIX_req_mine(); req->call = REQ_HOST_EXECUTE; @@ -186,6 +193,19 @@ smx_action_t SIMIX_req_host_parallel_execute(const char *name, double amount, double rate) { + int i,j; + /* checking for infinite values */ + for (i = 0 ; i < host_nb ; ++i) { + xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i); + for (j = 0 ; j < host_nb ; ++j) { + xbt_assert(isfinite(communication_amount[i + host_nb * j]), + "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j); + } + } + + xbt_assert(isfinite(amount), "amount is not finite!"); + xbt_assert(isfinite(rate), "rate is not finite!"); + smx_req_t req = SIMIX_req_mine(); req->call = REQ_HOST_PARALLEL_EXECUTE; @@ -271,6 +291,9 @@ e_smx_state_t SIMIX_req_host_execution_get_state(smx_action_t execution) */ void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priority) { + /* checking for infinite values */ + xbt_assert(isfinite(priority), "priority is not finite!"); + smx_req_t req = SIMIX_req_mine(); req->call = REQ_HOST_EXECUTION_SET_PRIORITY; @@ -345,6 +368,28 @@ void SIMIX_req_process_kill(smx_process_t process) SIMIX_request_push(); } +/** \brief Kills all SIMIX processes. + */ +void SIMIX_req_process_killall(void) +{ + smx_req_t req = SIMIX_req_mine(); + + req->call = REQ_PROCESS_KILLALL; + SIMIX_request_push(); +} + +/** \brief Cleans up a SIMIX process. + * \param process poor victim (must have already been killed) + */ +void SIMIX_req_process_cleanup(smx_process_t process) +{ + smx_req_t req = SIMIX_req_mine(); + + req->call = REQ_PROCESS_CLEANUP; + req->process_cleanup.process = process; + SIMIX_request_push(); +} + /** * \brief Migrates an agent to another location. * @@ -354,13 +399,12 @@ void SIMIX_req_process_kill(smx_process_t process) * \param source name of the previous host * \param dest name of the new host */ -void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest) +void SIMIX_req_process_change_host(smx_process_t process, smx_host_t dest) { smx_req_t req = SIMIX_req_mine(); req->call = REQ_PROCESS_CHANGE_HOST; req->process_change_host.process = process; - req->process_change_host.source = source; req->process_change_host.dest = dest; SIMIX_request_push(); } @@ -375,7 +419,7 @@ void SIMIX_req_process_change_host(smx_process_t process, const char *source, co */ void SIMIX_req_process_suspend(smx_process_t process) { - xbt_assert0(process, "Invalid parameters"); + xbt_assert(process, "Invalid parameters"); smx_req_t req = SIMIX_req_mine(); @@ -424,6 +468,11 @@ int SIMIX_req_process_count(void) */ void* SIMIX_req_process_get_data(smx_process_t process) { + if (process == SIMIX_process_self()) { + /* avoid a request if this function is called by the process itself */ + return SIMIX_process_self_get_data(); + } + smx_req_t req = SIMIX_req_mine(); req->call = REQ_PROCESS_GET_DATA; @@ -441,12 +490,19 @@ void* SIMIX_req_process_get_data(smx_process_t process) */ void SIMIX_req_process_set_data(smx_process_t process, void *data) { - smx_req_t req = SIMIX_req_mine(); + if (process == SIMIX_process_self()) { + /* avoid a request if this function is called by the process itself */ + SIMIX_process_self_set_data(data); + } + else { - req->call = REQ_PROCESS_SET_DATA; - req->process_set_data.process = process; - req->process_set_data.data = data; - SIMIX_request_push(); + smx_req_t req = SIMIX_req_mine(); + + req->call = REQ_PROCESS_SET_DATA; + req->process_set_data.process = process; + req->process_set_data.data = data; + SIMIX_request_push(); + } } /** @@ -475,6 +531,11 @@ smx_host_t SIMIX_req_process_get_host(smx_process_t process) */ const char* SIMIX_req_process_get_name(smx_process_t process) { + if (process == SIMIX_process_self()) { + /* avoid a request if this function is called by the process itself */ + return process->name; + } + smx_req_t req = SIMIX_req_mine(); req->call = REQ_PROCESS_GET_NAME; @@ -526,6 +587,9 @@ xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process) */ e_smx_state_t SIMIX_req_process_sleep(double duration) { + /* checking for infinite values */ + xbt_assert(isfinite(duration), "duration is not finite!"); + smx_req_t req = SIMIX_req_mine(); req->call = REQ_PROCESS_SLEEP; @@ -567,7 +631,7 @@ void SIMIX_req_rdv_destroy(smx_rdv_t rdv) smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name) { - xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)"); + xbt_assert(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)"); /* FIXME: this is a horrible lost of performance, so we hack it out by * skipping the request (for now). It won't work on distributed but @@ -622,7 +686,12 @@ void SIMIX_req_comm_send(smx_rdv_t rdv, double task_size, double rate, int (*match_fun)(void *, void *), void *data, double timeout) { - xbt_assert0(rdv, "No rendez-vous point defined for send"); + /* checking for infinite values */ + xbt_assert(isfinite(task_size), "task_size is not finite!"); + xbt_assert(isfinite(rate), "rate is not finite!"); + xbt_assert(isfinite(timeout), "timeout is not finite!"); + + xbt_assert(rdv, "No rendez-vous point defined for send"); if (MC_IS_ENABLED) { /* the model-checker wants two separate requests */ @@ -652,7 +721,11 @@ smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate, int (*match_fun)(void *, void *), void *data, int detached) { - xbt_assert0(rdv, "No rendez-vous point defined for isend"); + /* checking for infinite values */ + xbt_assert(isfinite(task_size), "task_size is not finite!"); + xbt_assert(isfinite(rate), "rate is not finite!"); + + xbt_assert(rdv, "No rendez-vous point defined for isend"); smx_req_t req = SIMIX_req_mine(); @@ -673,7 +746,8 @@ smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate, void SIMIX_req_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, int (*match_fun)(void *, void *), void *data, double timeout) { - xbt_assert0(rdv, "No rendez-vous point defined for recv"); + xbt_assert(isfinite(timeout), "timeout is not finite!"); + xbt_assert(rdv, "No rendez-vous point defined for recv"); if (MC_IS_ENABLED) { /* the model-checker wants two separate requests */ @@ -699,7 +773,7 @@ void SIMIX_req_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, int (*match_fun)(void *, void *), void *data) { - xbt_assert0(rdv, "No rendez-vous point defined for irecv"); + xbt_assert(rdv, "No rendez-vous point defined for irecv"); smx_req_t req = SIMIX_req_mine(); @@ -716,7 +790,7 @@ smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_bu void SIMIX_req_comm_destroy(smx_action_t comm) { - xbt_assert0(comm, "Invalid parameter"); + xbt_assert(comm, "Invalid parameter"); /* FIXME remove this request type: comms are auto-destroyed now, * but what happens with unfinished comms? */ @@ -767,6 +841,8 @@ int SIMIX_req_comm_testany(xbt_dynar_t comms) void SIMIX_req_comm_wait(smx_action_t comm, double timeout) { + xbt_assert(isfinite(timeout), "timeout is not finite!"); + smx_req_t req = SIMIX_req_mine(); req->call = REQ_COMM_WAIT; @@ -987,6 +1063,8 @@ void SIMIX_req_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout) { + xbt_assert(isfinite(timeout), "timeout is not finite!"); + smx_req_t req = SIMIX_req_mine(); req->call = REQ_COND_WAIT_TIMEOUT; @@ -1062,6 +1140,8 @@ void SIMIX_req_sem_acquire(smx_sem_t sem) void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout) { + xbt_assert(isfinite(timeout), "timeout is not finite!"); + smx_req_t req = SIMIX_req_mine(); req->call = REQ_SEM_ACQUIRE_TIMEOUT;