Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added missing MPI call.
authorpini <pini@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 6 Sep 2010 09:12:15 +0000 (09:12 +0000)
committerpini <pini@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 6 Sep 2010 09:12:15 +0000 (09:12 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8168 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/smpi/smpi.h
src/smpi/private.h
src/smpi/smpi_base.c
src/smpi/smpi_mpi.c

index 5d5dfb5..1bae75b 100644 (file)
@@ -64,6 +64,7 @@ typedef struct {
   int MPI_SOURCE;
   int MPI_TAG;
   int MPI_ERROR;
+  int count;
 } MPI_Status;
 
 #define MPI_STATUS_IGNORE NULL
@@ -184,6 +185,7 @@ XBT_PUBLIC(int) MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MP
 XBT_PUBLIC(int) MPI_Comm_rank(MPI_Comm comm, int* rank);
 XBT_PUBLIC(int) MPI_Comm_size(MPI_Comm comm, int* size);
 XBT_PUBLIC(int) MPI_Get_processor_name(char *name, int *resultlen);
+XBT_PUBLIC(int) MPI_Get_count(MPI_Status* status, MPI_Datatype datatype, int* count);
           
 XBT_PUBLIC(int) MPI_Comm_group(MPI_Comm comm, MPI_Group* group);
 XBT_PUBLIC(int) MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int* result);
index 244af7a..a604da4 100644 (file)
@@ -94,6 +94,7 @@ void smpi_mpi_send(void* buf, int count, MPI_Datatype datatype, int dst, int tag
 void smpi_mpi_sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
 int smpi_mpi_test(MPI_Request* request, MPI_Status* status);
 int smpi_mpi_testany(int count, MPI_Request requests[], int* index, MPI_Status* status);
+int smpi_mpi_get_count(MPI_Status* status, MPI_Datatype datatype);
 void smpi_mpi_wait(MPI_Request* request, MPI_Status* status);
 int smpi_mpi_waitany(int count, MPI_Request requests[], MPI_Status* status);
 void smpi_mpi_waitall(int count, MPI_Request requests[],  MPI_Status status[]);
index ed9620b..e82e6d0 100644 (file)
@@ -158,11 +158,16 @@ void smpi_mpi_sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int
   }
 }
 
+int smpi_mpi_get_count(MPI_Status* status, MPI_Datatype datatype) {
+   return status->count / smpi_datatype_size(datatype);
+}
+
 static void finish_wait(MPI_Request* request, MPI_Status* status) {
   if(status != MPI_STATUS_IGNORE) {
     status->MPI_SOURCE = (*request)->src;
     status->MPI_TAG = (*request)->tag;
     status->MPI_ERROR = MPI_SUCCESS;
+    status->count = SIMIX_communication_get_dst_buf_size((*request)->pair);
   }
   print_request("finishing wait", *request);
   if((*request)->complete == 1) {
index 4a5cd8d..05a6369 100644 (file)
@@ -1465,8 +1465,9 @@ int MPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype s
 }
 
 
-int MPI_Get_processor_name( char *name, int *resultlen ) {
+int MPI_Get_processor_name(char* name, int* resultlen) {
   int retval = MPI_SUCCESS;
+
   smpi_bench_end(-1, NULL);
   strncpy( name , SIMIX_host_get_name(SIMIX_host_self()), MPI_MAX_PROCESSOR_NAME-1);
   *resultlen= strlen(name) > MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
@@ -1475,3 +1476,25 @@ int MPI_Get_processor_name( char *name, int *resultlen ) {
   return retval;
 }
 
+int MPI_Get_count(MPI_Status* status, MPI_Datatype datatype, int* count) {
+  int retval = MPI_SUCCESS;
+  size_t size;
+
+  smpi_bench_end(-1, NULL);
+  if (status == NULL || count == NULL) {
+    retval = MPI_ERR_ARG;
+  } else if (datatype == MPI_DATATYPE_NULL) {
+    retval = MPI_ERR_TYPE;
+  } else {
+    size = smpi_datatype_size(datatype);
+    if (size == 0) {
+       *count = 0;
+    } else if (status->count % size != 0) {
+       retval = MPI_UNDEFINED;
+    } else {
+       *count = smpi_mpi_get_count(status, datatype);
+    }
+  }
+  smpi_bench_begin(-1, NULL);
+  return retval;
+}