X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/af37805170a045ee594a2215a22dc9633f5386ed..91bb8b44ef09735fc79f40a3d9eeb69456a46909:/src/smpi/smpi_base.c diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 6aeceb5838..952db704fa 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -77,7 +77,8 @@ xbt_dynar_t smpi_ois_values = NULL; static int factor_cmp(const void *pa, const void *pb) { - return (((s_smpi_factor_t*)pa)->factor > ((s_smpi_factor_t*)pb)->factor); + return (((s_smpi_factor_t*)pa)->factor > ((s_smpi_factor_t*)pb)->factor) ? 1 : + (((s_smpi_factor_t*)pa)->factor < ((s_smpi_factor_t*)pb)->factor) ? -1 : 0; } @@ -86,13 +87,14 @@ static xbt_dynar_t parse_factor(const char *smpi_coef_string) char *value = NULL; unsigned int iter = 0; s_smpi_factor_t fact; + fact.nb_values=0; int i=0; xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL; smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL); radical_elements = xbt_str_split(smpi_coef_string, ";"); xbt_dynar_foreach(radical_elements, iter, value) { - fact.nb_values=0; + memset(&fact, 0, sizeof(s_smpi_factor_t)); radical_elements2 = xbt_str_split(value, ":"); if (xbt_dynar_length(radical_elements2) <2 || xbt_dynar_length(radical_elements2) > 5) xbt_die("Malformed radical for smpi factor!"); @@ -129,13 +131,13 @@ static double smpi_os(double size) double current=0.0; xbt_dynar_foreach(smpi_os_values, iter, fact) { if (size <= fact.factor) { - XBT_DEBUG("os : %lf <= %ld return %f", size, fact.factor, current); + XBT_DEBUG("os : %f <= %ld return %f", size, fact.factor, current); return current; }else{ current=fact.values[0]+fact.values[1]*size; } } - XBT_DEBUG("os : %lf > %ld return %f", size, fact.factor, current); + XBT_DEBUG("os : %f > %ld return %f", size, fact.factor, current); return current; } @@ -151,13 +153,13 @@ static double smpi_ois(double size) double current=0.0; xbt_dynar_foreach(smpi_ois_values, iter, fact) { if (size <= fact.factor) { - XBT_DEBUG("ois : %lf <= %ld return %f", size, fact.factor, current); + XBT_DEBUG("ois : %f <= %ld return %f", size, fact.factor, current); return current; }else{ current=fact.values[0]+fact.values[1]*size; } } - XBT_DEBUG("ois : %lf > %ld return %f", size, fact.factor, current); + XBT_DEBUG("ois : %f > %ld return %f", size, fact.factor, current); return current; } @@ -173,12 +175,12 @@ static double smpi_or(double size) double current=0.0; xbt_dynar_foreach(smpi_or_values, iter, fact) { if (size <= fact.factor) { - XBT_DEBUG("or : %lf <= %ld return %f", size, fact.factor, current); + XBT_DEBUG("or : %f <= %ld return %f", size, fact.factor, current); return current; }else current=fact.values[0]+fact.values[1]*size; } - XBT_DEBUG("or : %lf > %ld return %f", size, fact.factor, current); + XBT_DEBUG("or : %f > %ld return %f", size, fact.factor, current); return current; } @@ -285,7 +287,7 @@ static void smpi_mpi_request_free_voidp(void* request) MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, PERSISTENT | SEND | PREPARED); request->refcount++; @@ -295,7 +297,7 @@ MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, PERSISTENT | SSEND | SEND | PREPARED); request->refcount++; @@ -305,7 +307,7 @@ MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, comm, PERSISTENT | RECV | PREPARED); request->refcount++; @@ -335,7 +337,7 @@ void smpi_mpi_start(MPI_Request request) double sleeptime = request->detached ? smpi_or(request->size) : 0.0; if(sleeptime!=0.0){ simcall_process_sleep(sleeptime); - XBT_DEBUG("receiving size of %zu : sleep %lf ", request->size, smpi_or(request->size)); + XBT_DEBUG("receiving size of %zu : sleep %f ", request->size, smpi_or(request->size)); } } else { @@ -388,7 +390,7 @@ void smpi_mpi_start(MPI_Request request) if(sleeptime!=0.0){ simcall_process_sleep(sleeptime); - XBT_DEBUG("sending size of %zu : sleep %lf ", request->size, smpi_os(request->size)); + XBT_DEBUG("sending size of %zu : sleep %f ", request->size, smpi_os(request->size)); } request->action = @@ -414,6 +416,7 @@ void smpi_mpi_start(MPI_Request request) void smpi_mpi_startall(int count, MPI_Request * requests) { int i; + if(requests==NULL) return; for(i = 0; i < count; i++) { smpi_mpi_start(requests[i]); @@ -442,7 +445,7 @@ void smpi_mpi_request_free(MPI_Request * request) MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf , count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, NON_PERSISTENT | ISEND | SEND | PREPARED); return request; @@ -451,7 +454,7 @@ MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM?(void*)0:buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, NON_PERSISTENT | ISEND | SEND); smpi_mpi_start(request); @@ -461,7 +464,7 @@ MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, NON_PERSISTENT | ISEND | SSEND | SEND); smpi_mpi_start(request); @@ -473,7 +476,7 @@ MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, comm, NON_PERSISTENT | RECV | PREPARED); return request; @@ -482,7 +485,7 @@ MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, comm, NON_PERSISTENT | RECV); smpi_mpi_start(request); @@ -492,7 +495,7 @@ MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype, void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm); smpi_mpi_wait(&request, status); request = NULL; @@ -503,7 +506,7 @@ void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src, void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, NON_PERSISTENT | SEND); @@ -515,7 +518,7 @@ void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst, void smpi_mpi_ssend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; + MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ request = build_request(buf==MPI_BOTTOM ? (void*)0 : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, NON_PERSISTENT | SSEND | SEND);