Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add preliminary support for MPI_Pack, MPI_Pack_size, and MPI_Unpack.
authorAugustin Degomme <augustin.degomme@imag.fr>
Mon, 3 Nov 2014 16:47:06 +0000 (17:47 +0100)
committerAugustin Degomme <augustin.degomme@imag.fr>
Mon, 3 Nov 2014 16:47:11 +0000 (17:47 +0100)
Activate tests for these functions. Somes cases with too complex imbricated datatypes are not supported (yet).

src/smpi/private.h
src/smpi/smpi_mpi_dt.c
src/smpi/smpi_pmpi.c
teshsuite/smpi/mpich3-test/datatype/CMakeLists.txt
teshsuite/smpi/mpich3-test/datatype/testlist

index 0ea0f25..c0d051f 100644 (file)
@@ -240,6 +240,9 @@ void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int h
 void smpi_datatype_free(MPI_Datatype* type);
 void smpi_datatype_commit(MPI_Datatype* datatype);
 
+int smpi_mpi_unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm);
+int smpi_mpi_pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm);
+
 void smpi_empty_status(MPI_Status * status);
 MPI_Op smpi_op_new(MPI_User_function * function, int commute);
 int smpi_op_is_commute(MPI_Op op);
index 350ee0f..54eecc2 100644 (file)
@@ -149,7 +149,7 @@ CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE_INT, long_double_int);
 
 CREATE_MPI_DATATYPE_NULL(MPI_UB);
 CREATE_MPI_DATATYPE_NULL(MPI_LB);
-CREATE_MPI_DATATYPE_NULL(MPI_PACKED);
+CREATE_MPI_DATATYPE(MPI_PACKED, char);
 // Internal use only
 CREATE_MPI_DATATYPE(MPI_PTR, void*);
 
@@ -259,12 +259,12 @@ int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
     else if (sendtype->has_subtype == 0)
     {
       s_smpi_subtype_t *subtype =  recvtype->substruct;
-      subtype->unserialize( sendbuf, recvbuf,1, subtype, MPI_REPLACE);
+      subtype->unserialize( sendbuf, recvbuf, recvcount/smpi_datatype_size(recvtype), subtype, MPI_REPLACE);
     }
     else if (recvtype->has_subtype == 0)
     {
       s_smpi_subtype_t *subtype =  sendtype->substruct;
-      subtype->serialize(sendbuf, recvbuf,1, subtype);
+      subtype->serialize(sendbuf, recvbuf, sendcount/smpi_datatype_size(sendtype), subtype);
     }else{
       s_smpi_subtype_t *subtype =  sendtype->substruct;
 
@@ -1770,3 +1770,24 @@ int smpi_type_keyval_free(int* keyval){
   xbt_free(tmpkey);
   return MPI_SUCCESS;
 }
+
+int smpi_mpi_pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm){
+  size_t size = smpi_datatype_size(type);
+  if (outcount - *position < incount*size)
+    return MPI_ERR_BUFFER;
+  smpi_datatype_copy(inbuf, incount, type,
+                   (char*)outbuf + *position, outcount, MPI_CHAR);
+  *position += incount * size;
+  return MPI_SUCCESS;
+}
+
+int smpi_mpi_unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm){
+  size_t size = smpi_datatype_size(type);
+  if (outcount*size> insize)
+    return MPI_ERR_BUFFER;
+  smpi_datatype_copy((char*)inbuf + *position, insize, MPI_CHAR,
+                   outbuf, outcount, type);
+  *position += outcount * size;
+  return MPI_SUCCESS;
+}
+
index d2fe7cf..0e3b7f2 100644 (file)
@@ -3209,6 +3209,40 @@ int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
   return MPI_SUCCESS;
 }
 
+int PMPI_Unpack(void* inbuf, int incount, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
+  if(incount<0 || outcount < 0 || inbuf==NULL || outbuf==NULL)
+    return MPI_ERR_ARG;
+  if(!is_datatype_valid(type))
+    return MPI_ERR_TYPE;
+  if(comm==MPI_COMM_NULL)
+    return MPI_ERR_COMM;
+  return smpi_mpi_unpack(inbuf, incount, position, outbuf,outcount,type, comm);
+}
+
+int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
+  if(incount<0 || outcount < 0|| inbuf==NULL || outbuf==NULL)
+    return MPI_ERR_ARG;
+  if(!is_datatype_valid(type))
+    return MPI_ERR_TYPE;
+  if(comm==MPI_COMM_NULL)
+    return MPI_ERR_COMM;
+  return smpi_mpi_pack(inbuf, incount, type, outbuf,outcount,position, comm);
+}
+
+int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
+  if(incount<0)
+    return MPI_ERR_ARG;
+  if(!is_datatype_valid(datatype))
+    return MPI_ERR_TYPE;
+  if(comm==MPI_COMM_NULL)
+    return MPI_ERR_COMM;
+    
+  *size=incount*smpi_datatype_size(datatype);
+  
+  return MPI_SUCCESS;
+}
+
+
 /* The following calls are not yet implemented and will fail at runtime. */
 /* Once implemented, please move them above this notice. */
 
@@ -3234,16 +3268,10 @@ MPI_Fint PMPI_Errhandler_c2f(MPI_Errhandler errhandler){
   NOT_YET_IMPLEMENTED
 }
 
-int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
-  NOT_YET_IMPLEMENTED
-}
-
-
 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
   NOT_YET_IMPLEMENTED
 }
 
-
 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
   NOT_YET_IMPLEMENTED
 }
@@ -3325,9 +3353,6 @@ int PMPI_Pcontrol(const int level )
   NOT_YET_IMPLEMENTED
 }
 
-int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
-  NOT_YET_IMPLEMENTED
-}
 
 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
   NOT_YET_IMPLEMENTED
@@ -3373,9 +3398,7 @@ int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
   NOT_YET_IMPLEMENTED
 }
 
-int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
-  NOT_YET_IMPLEMENTED
-}
+
 
 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
   NOT_YET_IMPLEMENTED
index 8f4b6c4..10f915e 100644 (file)
@@ -15,7 +15,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 #  add_executable(blockindexed-misc blockindexed-misc.c)
   add_executable(blockindexed-zero-count blockindexed-zero-count.c)
 #  add_executable(contents contents.c)
-#  add_executable(contigstruct contigstruct.c)
+  add_executable(contigstruct contigstruct.c)
   add_executable(contig-zero-count contig-zero-count.c)
   add_executable(cxx-types cxx-types.c)
 #  add_executable(darray-cyclic darray-cyclic.c)
@@ -35,7 +35,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 #  add_executable(large_type large_type.c)
 #  add_executable(large_type_sendrec large_type_sendrec.c)
 #  add_executable(lbub lbub.c)
-#  add_executable(localpack localpack.c)
+  add_executable(localpack localpack.c)
   add_executable(longdouble longdouble.c)
 #  add_executable(lots-of-types lots-of-types.c)
 #  add_executable(pairtype-pack pairtype-pack.c)
@@ -44,7 +44,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
   add_executable(sendrecvt2 ${CMAKE_CURRENT_SOURCE_DIR}/../util/dtypes.c sendrecvt2.c)
   add_executable(sendrecvt4 ${CMAKE_CURRENT_SOURCE_DIR}/../util/dtypes.c sendrecvt4.c)
   add_executable(simple-commit simple-commit.c)
-#  add_executable(simple-pack simple-pack.c)
+  add_executable(simple-pack simple-pack.c)
 #  add_executable(simple-pack-external simple-pack-external.c)
   add_executable(simple-resized simple-resized.c)
   add_executable(simple-size-extent simple-size-extent.c)
@@ -55,7 +55,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 #  add_executable(struct-empty-el struct-empty-el.c)
   add_executable(struct-ezhov struct-ezhov.c)
 #  add_executable(struct-no-real-types struct-no-real-types.c)
-#  add_executable(struct-pack struct-pack.c)
+  add_executable(struct-pack struct-pack.c)
 #  add_executable(structpack2 structpack2.c)
   add_executable(struct-verydeep struct-verydeep.c)
   add_executable(struct-zero-count struct-zero-count.c)
@@ -63,7 +63,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 #  add_executable(subarray-pack subarray-pack.c)
   add_executable(tfree tfree.c)
 #  add_executable(tmatchsize tmatchsize.c)
-#  add_executable(transpose-pack transpose-pack.c)
+  add_executable(transpose-pack transpose-pack.c)
   add_executable(tresized2 tresized2.c)
   add_executable(tresized tresized.c)
 #  add_executable(triangular-pack triangular-pack.c)
@@ -71,17 +71,17 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
   add_executable(typefree typefree.c)
   add_executable(typelb typelb.c)
   add_executable(typename typename.c)
-#  add_executable(unpack unpack.c)
+  add_executable(unpack unpack.c)
 #  add_executable(unusual-noncontigs unusual-noncontigs.c)
 #  add_executable(vecblklen vecblklen.c)
 #  add_executable(zero-blklen-vector zero-blklen-vector.c)
-#  add_executable(zeroblks zeroblks.c)
+  add_executable(zeroblks zeroblks.c)
   add_executable(zeroparms zeroparms.c)
 
 #  target_link_libraries(blockindexed-misc simgrid mtest_c)
   target_link_libraries(blockindexed-zero-count simgrid mtest_c)
 #  target_link_libraries(contents simgrid mtest_c)
-#  target_link_libraries(contigstruct simgrid mtest_c)
+  target_link_libraries(contigstruct simgrid mtest_c)
   target_link_libraries(contig-zero-count simgrid mtest_c)
   target_link_libraries(cxx-types simgrid mtest_c)
 #  target_link_libraries(darray-cyclic simgrid mtest_c)
@@ -101,7 +101,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 #  target_link_libraries(large_type simgrid mtest_c)
 #  target_link_libraries(large_type_sendrec simgrid mtest_c)
 #  target_link_libraries(lbub simgrid mtest_c)
-#  target_link_libraries(localpack simgrid mtest_c)
+  target_link_libraries(localpack simgrid mtest_c)
   target_link_libraries(longdouble simgrid mtest_c)
 #  target_link_libraries(lots-of-types simgrid mtest_c)
 #  target_link_libraries(pairtype-pack simgrid mtest_c)
@@ -110,7 +110,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
   target_link_libraries(sendrecvt2 simgrid mtest_c)
   target_link_libraries(sendrecvt4 simgrid mtest_c)
   target_link_libraries(simple-commit simgrid mtest_c)
-#  target_link_libraries(simple-pack simgrid mtest_c)
+  target_link_libraries(simple-pack simgrid mtest_c)
 #  target_link_libraries(simple-pack-external simgrid mtest_c)
   target_link_libraries(simple-resized simgrid mtest_c)
   target_link_libraries(simple-size-extent simgrid mtest_c)
@@ -121,7 +121,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 #  target_link_libraries(struct-empty-el simgrid mtest_c)
   target_link_libraries(struct-ezhov simgrid mtest_c)
 #  target_link_libraries(struct-no-real-types simgrid mtest_c)
-#  target_link_libraries(struct-pack simgrid mtest_c)
+  target_link_libraries(struct-pack simgrid mtest_c)
 #  target_link_libraries(structpack2 simgrid mtest_c)
   target_link_libraries(struct-verydeep simgrid mtest_c)
   target_link_libraries(struct-zero-count simgrid mtest_c)
@@ -129,7 +129,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 #  target_link_libraries(subarray-pack simgrid mtest_c)
   target_link_libraries(tfree simgrid mtest_c)
 #  target_link_libraries(tmatchsize simgrid mtest_c)
-#  target_link_libraries(transpose-pack simgrid mtest_c)
+  target_link_libraries(transpose-pack simgrid mtest_c)
   target_link_libraries(tresized2 simgrid mtest_c)
   target_link_libraries(tresized simgrid mtest_c)
 #  target_link_libraries(triangular-pack simgrid mtest_c)
@@ -137,11 +137,11 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
   target_link_libraries(typefree simgrid mtest_c)
   target_link_libraries(typelb simgrid mtest_c)
   target_link_libraries(typename simgrid mtest_c)
-#  target_link_libraries(unpack simgrid mtest_c)
+  target_link_libraries(unpack simgrid mtest_c)
 #  target_link_libraries(unusual-noncontigs simgrid mtest_c)
 #  target_link_libraries(vecblklen simgrid mtest_c)
 #  target_link_libraries(zero-blklen-vector simgrid mtest_c)
-#  target_link_libraries(zeroblks simgrid mtest_c)
+  target_link_libraries(zeroblks simgrid mtest_c)
   target_link_libraries(zeroparms simgrid mtest_c)
 
 endif()
index 23f42be..87fe388 100644 (file)
@@ -3,13 +3,12 @@
 gaddress 1
 #complex games with negative extents...
 #lbub 1
-#needs MPI_Pack, MPI_Unpack
-#localpack 1
-#simple-pack 1
+localpack 1
+simple-pack 1
 #simple-pack-external 1
-#transpose-pack 1
+transpose-pack 1
 #slice-pack 1
-#struct-pack 1
+struct-pack 1
 #structpack2 1
 typecommit 1
 typename 1
@@ -25,13 +24,11 @@ sendrecvt4 2
 #tmatchsize 1
 tfree 2
 typelb 1
-#needs MPI_Pack_size
-#contigstruct 1
+contigstruct 1
 struct-zero-count 1
 blockindexed-zero-count 1
-#needs MPI_Pack, MPI_unpack, MPI_Pack_size
+#needs better handling of lb/ub
 #blockindexed-misc 1
-#needs MPI_Pack, MPI_unpack, MPI_Pack_size
 #indexed-misc 1
 #needs MPI_Type_create_subarray
 #subarray-pack 1
@@ -57,10 +54,9 @@ simple-resized 1
 #hindexed-zeros 1
 #lots-of-types 1
 #get-elements-pairtype 1
-#unpack 1
+unpack 1
 struct-ezhov 1
-#needs MPI_Pack, MPI_Unpack
-#zeroblks 1
+zeroblks 1
 struct-derived-zeros 1
 struct-verydeep 1
 #get-elements 1