From: Augustin Degomme Date: Wed, 3 Oct 2012 16:24:16 +0000 (+0200) Subject: merge with jean noel's commit X-Git-Tag: v3_8~146^2~4 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/06cfa81658af30df6373bf4cc6766646fec7c9af merge with jean noel's commit --- diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 1e768df20c..ad88e27507 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -440,6 +440,8 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Pack, (void* inbuf, int incount, MPI_Datatype type MPI_CALL(XBT_PUBLIC(int), MPI_Get_elements, (MPI_Status* status, MPI_Datatype datatype, int* elements)); MPI_CALL(XBT_PUBLIC(int), MPI_Dims_create, (int nnodes, int ndims, int* dims)); MPI_CALL(XBT_PUBLIC(int), MPI_Initialized, (int* flag)); +MPI_CALL(XBT_PUBLIC(int), MPI_Pcontrol, (const int level )); + //FIXME: End of all the not yet implemented stuff // smpi functions diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 1387109e0e..dde5b962f6 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -159,14 +159,18 @@ void smpi_mpi_start(MPI_Request request) // FIXME: SIMIX does not yet support non-contiguous datatypes request->action = simcall_comm_irecv(mailbox, request->buf, &request->size, &match_recv, request); } else { + + int receiver = smpi_group_index(smpi_comm_group(request->comm), request->dst); + if(receiver == MPI_UNDEFINED) { + XBT_WARN("Trying to send a message to a wrong rank"); + return; + } print_request("New send", request); if (request->size < xbt_cfg_get_int(_surf_cfg_set, "smpi/async_small_thres")) { // eager mode - mailbox = smpi_process_remote_mailbox_small( - smpi_group_index(smpi_comm_group(request->comm), request->dst)); + mailbox = smpi_process_remote_mailbox_small(receiver); }else{ XBT_DEBUG("Send request %p is not in the permanent receive mailbox (buf: %p)",request,request->buf); - mailbox = smpi_process_remote_mailbox( - smpi_group_index(smpi_comm_group(request->comm), request->dst)); + mailbox = smpi_process_remote_mailbox(receiver); } if (request->size < 64*1024 ) { //(FIXME: this limit should be configurable) void *oldbuf = request->buf; diff --git a/src/smpi/smpi_mpi.c b/src/smpi/smpi_mpi.c index 505d92d847..46f1abddfc 100644 --- a/src/smpi/smpi_mpi.c +++ b/src/smpi/smpi_mpi.c @@ -61,6 +61,11 @@ int MPI_Type_free(MPI_Datatype * datatype) return PMPI_Type_free(datatype); } +int MPI_Pcontrol(const int level ) +{ + return PMPI_Pcontrol(level); +} + int MPI_Type_size(MPI_Datatype datatype, int *size) { return PMPI_Type_size(datatype, size); diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index caf671ee4c..07f5101056 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -906,26 +906,35 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int retval; smpi_bench_end(); -#ifdef HAVE_TRACING - int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - int src_traced = smpi_group_index(smpi_comm_group(comm), src); - TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__); -#endif + if (request == NULL) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; - }else if (src == MPI_PROC_NULL) { + } else if (src == MPI_PROC_NULL) { *request = MPI_REQUEST_NULL; retval = MPI_SUCCESS; + } else if (count < 0) { + retval = MPI_ERR_COUNT; + } else if (datatype == MPI_DATATYPE_NULL){ + retval = MPI_ERR_TYPE; } else { + +#ifdef HAVE_TRACING + int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; + int src_traced = smpi_group_index(smpi_comm_group(comm), src); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__); +#endif + *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm); retval = MPI_SUCCESS; - } + #ifdef HAVE_TRACING TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__); (*request)->recv = 1; #endif + } + smpi_bench_begin(); return retval; } @@ -944,6 +953,10 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, } else if (dst == MPI_PROC_NULL) { *request = MPI_REQUEST_NULL; retval = MPI_SUCCESS; + } else if (count < 0) { + retval = MPI_ERR_COUNT; + } else if (datatype == MPI_DATATYPE_NULL){ + retval = MPI_ERR_TYPE; } else { #ifdef HAVE_TRACING @@ -983,6 +996,10 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, smpi_empty_status(status); status->MPI_SOURCE = MPI_PROC_NULL; retval = MPI_SUCCESS; + } else if (count < 0) { + retval = MPI_ERR_COUNT; + } else if (datatype == MPI_DATATYPE_NULL){ + retval = MPI_ERR_TYPE; } else { #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; @@ -1014,6 +1031,17 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, int retval; smpi_bench_end(); + + if (comm == MPI_COMM_NULL) { + retval = MPI_ERR_COMM; + } else if (dst == MPI_PROC_NULL) { + retval = MPI_SUCCESS; + } else if (count < 0) { + retval = MPI_ERR_COUNT; + } else if (datatype == MPI_DATATYPE_NULL){ + retval = MPI_ERR_TYPE; + } else { + #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; TRACE_smpi_computing_out(rank); @@ -1021,18 +1049,16 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__); TRACE_smpi_send(rank, rank, dst_traced); #endif - if (comm == MPI_COMM_NULL) { - retval = MPI_ERR_COMM; - } else if (dst == MPI_PROC_NULL) { - retval = MPI_SUCCESS; - } else { + smpi_mpi_send(buf, count, datatype, dst, tag, comm); retval = MPI_SUCCESS; - } + #ifdef HAVE_TRACING TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__); TRACE_smpi_computing_in(rank); #endif + } + smpi_bench_begin(); return retval; } @@ -1045,15 +1071,7 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int retval; smpi_bench_end(); -#ifdef HAVE_TRACING - int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_computing_out(rank); - int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); - int src_traced = smpi_group_index(smpi_comm_group(comm), src); - TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__); - TRACE_smpi_send(rank, rank, dst_traced); - TRACE_smpi_send(rank, src_traced, rank); -#endif + if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (sendtype == MPI_DATATYPE_NULL @@ -1063,18 +1081,34 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, smpi_empty_status(status); status->MPI_SOURCE = MPI_PROC_NULL; retval = MPI_SUCCESS; + } else if (sendcount < 0 || recvcount<0) { + retval = MPI_ERR_COUNT; } else { + +#ifdef HAVE_TRACING + int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; + TRACE_smpi_computing_out(rank); + int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); + int src_traced = smpi_group_index(smpi_comm_group(comm), src); + TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__); + TRACE_smpi_send(rank, rank, dst_traced); + TRACE_smpi_send(rank, src_traced, rank); +#endif + + smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf, recvcount, recvtype, src, recvtag, comm, status); retval = MPI_SUCCESS; - } + #ifdef HAVE_TRACING TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__); TRACE_smpi_recv(rank, rank, dst_traced); TRACE_smpi_recv(rank, src_traced, rank); TRACE_smpi_computing_in(rank); - #endif + + } + smpi_bench_begin(); return retval; } @@ -1278,20 +1312,23 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta retval = MPI_SUCCESS; } #ifdef HAVE_TRACING - int src_traced, dst_traced, is_wait_for_receive; - xbt_dynar_get_cpy(srcs, *index, &src_traced); - xbt_dynar_get_cpy(dsts, *index, &dst_traced); - xbt_dynar_get_cpy(recvs, *index, &is_wait_for_receive); - if (is_wait_for_receive) { - TRACE_smpi_recv(rank_traced, src_traced, dst_traced); + if(*index!=MPI_UNDEFINED){ + int src_traced, dst_traced, is_wait_for_receive; + xbt_dynar_get_cpy(srcs, *index, &src_traced); + xbt_dynar_get_cpy(dsts, *index, &dst_traced); + xbt_dynar_get_cpy(recvs, *index, &is_wait_for_receive); + if (is_wait_for_receive) { + TRACE_smpi_recv(rank_traced, src_traced, dst_traced); + } + TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__); + //clean-up of dynars + xbt_dynar_free(&srcs); + xbt_dynar_free(&dsts); + xbt_dynar_free(&recvs); } - TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__); - //clean-up of dynars - xbt_dynar_free(&srcs); - xbt_dynar_free(&dsts); - xbt_dynar_free(&recvs); TRACE_smpi_computing_in(rank_traced); + #endif smpi_bench_begin(); return retval; @@ -2101,6 +2138,11 @@ int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int return not_yet_implemented(); } +int PMPI_Pcontrol(const int level ) +{ + return not_yet_implemented(); +} + int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) { return not_yet_implemented(); }