From: degomme Date: Wed, 11 Apr 2018 20:05:58 +0000 (+0200) Subject: basic implem of MPI_Win_allocate_shared, MPI_Win_shared_query, MPI_Comm_split_type X-Git-Tag: v3.20~472 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c505117d2d46a87d2a637e17f1027f2ca37c3f14 basic implem of MPI_Win_allocate_shared, MPI_Win_shared_query, MPI_Comm_split_type --- diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index e82e2bbea5..4ef2ae6354 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -198,6 +198,8 @@ SG_BEGIN_DECL() #define MPI_WIN_BASE -1 #define MPI_WIN_SIZE -2 #define MPI_WIN_DISP_UNIT -3 +#define MPI_WIN_CREATE_FLAVOR -4 +#define MPI_WIN_MODEL -5 typedef ptrdiff_t MPI_Aint; typedef long long MPI_Offset; @@ -308,6 +310,11 @@ XBT_PUBLIC_DATA const MPI_Datatype MPI_INTEGER16; #define MPI_DOUBLE_PRECISION MPI_DOUBLE #define MPI_2DOUBLE_PRECISION MPI_2DOUBLE +#define MPI_WIN_FLAVOR_CREATE 0 +#define MPI_WIN_FLAVOR_ALLOCATE 1 +#define MPI_WIN_FLAVOR_DYNAMIC 2 +#define MPI_WIN_FLAVOR_SHARED 3 + typedef void MPI_User_function(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype); typedef SMPI_Op *MPI_Op; @@ -589,6 +596,8 @@ MPI_CALL(XBT_PUBLIC int, MPI_Win_create, (void* base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win* win)); MPI_CALL(XBT_PUBLIC int, MPI_Win_allocate, (MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void* base, MPI_Win* win)); +MPI_CALL(XBT_PUBLIC int, MPI_Win_allocate_shared, + (MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void* base, MPI_Win* win)); MPI_CALL(XBT_PUBLIC int, MPI_Win_create_dynamic, (MPI_Info info, MPI_Comm comm, MPI_Win* win)); MPI_CALL(XBT_PUBLIC int, MPI_Win_attach, (MPI_Win win, void* base, MPI_Aint size)); MPI_CALL(XBT_PUBLIC int, MPI_Win_detach, (MPI_Win win, void* base)); @@ -617,6 +626,8 @@ MPI_CALL(XBT_PUBLIC int, MPI_Win_flush, (int rank, MPI_Win win)); MPI_CALL(XBT_PUBLIC int, MPI_Win_flush_local, (int rank, MPI_Win win)); MPI_CALL(XBT_PUBLIC int, MPI_Win_flush_all, (MPI_Win win)); MPI_CALL(XBT_PUBLIC int, MPI_Win_flush_local_all, (MPI_Win win)); +MPI_CALL(XBT_PUBLIC int, MPI_Win_shared_query, (MPI_Win win, int rank, MPI_Aint* size, int* disp_unit, void* baseptr)); +MPI_CALL(XBT_PUBLIC int, MPI_Win_sync, (MPI_Win win)); MPI_CALL(XBT_PUBLIC MPI_Win, MPI_Win_f2c, (MPI_Fint win)); MPI_CALL(XBT_PUBLIC MPI_Fint, MPI_Win_c2f, (MPI_Win win)); diff --git a/src/smpi/bindings/smpi_mpi.cpp b/src/smpi/bindings/smpi_mpi.cpp index ddf92bd214..a708a8df5f 100644 --- a/src/smpi/bindings/smpi_mpi.cpp +++ b/src/smpi/bindings/smpi_mpi.cpp @@ -92,6 +92,7 @@ WRAPPED_PMPI_CALL(int,MPI_Comm_rank,(MPI_Comm comm, int *rank),(comm, rank)) WRAPPED_PMPI_CALL(int,MPI_Comm_set_attr ,(MPI_Comm comm, int comm_keyval, void *attribute_val),( comm, comm_keyval, attribute_val)) WRAPPED_PMPI_CALL(int,MPI_Comm_size,(MPI_Comm comm, int *size),(comm, size)) WRAPPED_PMPI_CALL(int,MPI_Comm_split,(MPI_Comm comm, int color, int key, MPI_Comm* comm_out),(comm, color, key, comm_out)) +WRAPPED_PMPI_CALL(int,MPI_Comm_split_type,(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm),(comm, split_type, key, info, newcomm)) WRAPPED_PMPI_CALL(int,MPI_Comm_create_group,(MPI_Comm comm, MPI_Group group, int tag, MPI_Comm* comm_out),(comm, group, tag, comm_out)) WRAPPED_PMPI_CALL(int,MPI_Compare_and_swap,(void *origin_addr, void *compare_addr, void *result_addr, MPI_Datatype datatype, int target_rank, MPI_Aint target_disp, MPI_Win win), (origin_addr, compare_addr, result_addr, datatype, target_rank, target_disp, win)) @@ -215,6 +216,7 @@ WRAPPED_PMPI_CALL(int,MPI_Waitsome,(int incount, MPI_Request requests[], int *ou WRAPPED_PMPI_CALL(int,MPI_Win_complete,(MPI_Win win),(win)) WRAPPED_PMPI_CALL(int,MPI_Win_create,( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win),( base, size, disp_unit, info, comm,win)) WRAPPED_PMPI_CALL(int,MPI_Win_allocate,(MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win),(size, disp_unit, info, comm, base, win)) +WRAPPED_PMPI_CALL(int,MPI_Win_allocate_shared,(MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win),(size, disp_unit, info, comm, base, win)) WRAPPED_PMPI_CALL(int,MPI_Win_attach,(MPI_Win win, void *base, MPI_Aint size),(win, base, size)) WRAPPED_PMPI_CALL(int,MPI_Win_detach,(MPI_Win win, void *base),(win, base)) WRAPPED_PMPI_CALL(int,MPI_Win_create_dynamic,( MPI_Info info, MPI_Comm comm, MPI_Win *win),(info, comm,win)) @@ -242,6 +244,7 @@ WRAPPED_PMPI_CALL(int,MPI_Win_delete_attr, (MPI_Win type, int comm_keyval), (typ WRAPPED_PMPI_CALL(int,MPI_Win_create_keyval,(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval, void* extra_state), (copy_fn, delete_fn, keyval, extra_state)) WRAPPED_PMPI_CALL(int,MPI_Win_free_keyval,(int* keyval), (keyval)) +WRAPPED_PMPI_CALL(int,MPI_Win_shared_query,(MPI_Win win, int rank, MPI_Aint* size, int* disp_unit, void* baseptr),(win, rank, size, disp_unit, baseptr)) WRAPPED_PMPI_CALL(MPI_Comm, MPI_Comm_f2c,(MPI_Fint comm),(comm)) WRAPPED_PMPI_CALL(MPI_Datatype, MPI_Type_f2c,(MPI_Fint datatype),(datatype)) WRAPPED_PMPI_CALL(MPI_Fint, MPI_Comm_c2f,(MPI_Comm comm),(comm)) @@ -292,7 +295,6 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_info ,(MPI_Comm comm, MP UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_name ,(MPI_Comm comm, char* name),(comm, name)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn,( char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes),( command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn_multiple,(int count, char **array_of_commands, char*** array_of_argv, int* array_of_maxprocs, MPI_Info* array_of_info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes), (count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm, intercomm, array_of_errcodes)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_split_type,(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm),(comm, split_type, key, info, newcomm)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_test_inter,(MPI_Comm comm, int* flag) ,(comm, flag)) UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Errhandler_create,(MPI_Handler_function* function, MPI_Errhandler* errhandler) ,(function, errhandler)) UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Errhandler_free,(MPI_Errhandler* errhandler) ,(errhandler)) @@ -395,5 +397,6 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Unpack_external,(char *datarep, void *in UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Unpublish_name,( char *service_name, MPI_Info info, char *port_name),( service_name, info, port_name)) UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Win_set_errhandler,(MPI_Win win, MPI_Errhandler errhandler) ,(win, errhandler)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Win_test,(MPI_Win win, int *flag),(win, flag)) +UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Win_sync,(MPI_Win win),(win)) UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(MPI_Errhandler, MPI_Errhandler_f2c,(MPI_Fint errhandler),(errhandler)) UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(MPI_Fint, MPI_Errhandler_c2f,(MPI_Errhandler errhandler),(errhandler)) diff --git a/src/smpi/bindings/smpi_pmpi_comm.cpp b/src/smpi/bindings/smpi_pmpi_comm.cpp index be802069a9..4775ea2c4f 100644 --- a/src/smpi/bindings/smpi_pmpi_comm.cpp +++ b/src/smpi/bindings/smpi_pmpi_comm.cpp @@ -156,6 +156,24 @@ int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out) return retval; } +int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm) +{ + int retval = 0; + smpi_bench_end(); + + if (newcomm == nullptr) { + retval = MPI_ERR_ARG; + } else if (comm == MPI_COMM_NULL) { + retval = MPI_ERR_COMM; + } else { + *newcomm = comm->split_type(split_type, key, info); + retval = MPI_SUCCESS; + } + smpi_bench_begin(); + + return retval; +} + int PMPI_Comm_create_group(MPI_Comm comm, MPI_Group group, int, MPI_Comm* comm_out) { int retval = 0; diff --git a/src/smpi/bindings/smpi_pmpi_win.cpp b/src/smpi/bindings/smpi_pmpi_win.cpp index 3842cbb304..3dfcf2e2cc 100644 --- a/src/smpi/bindings/smpi_pmpi_win.cpp +++ b/src/smpi/bindings/smpi_pmpi_win.cpp @@ -49,6 +49,33 @@ int PMPI_Win_allocate( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm com return retval; } +int PMPI_Win_allocate_shared( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win){ + int retval = 0; + smpi_bench_end(); + if (comm == MPI_COMM_NULL) { + retval= MPI_ERR_COMM; + }else if (disp_unit <= 0 || size < 0 ){ + retval= MPI_ERR_OTHER; + }else{ + void* ptr = nullptr; + int rank = comm->rank(); + if(rank==0){ + ptr = xbt_malloc(size*comm->size()); + if(ptr==nullptr) + return MPI_ERR_NO_MEM; + } + + simgrid::smpi::Colls::bcast(&ptr, sizeof(void*), MPI_BYTE, 0, comm); + simgrid::smpi::Colls::barrier(comm); + + *static_cast(base) = (char*)ptr+rank*size; + *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,rank==0); + retval = MPI_SUCCESS; + } + smpi_bench_begin(); + return retval; +} + int PMPI_Win_create_dynamic( MPI_Info info, MPI_Comm comm, MPI_Win *win){ int retval = 0; smpi_bench_end(); @@ -746,6 +773,13 @@ int PMPI_Win_flush_local_all(MPI_Win win){ return retval; } +int PMPI_Win_shared_query (MPI_Win win, int rank, MPI_Aint* size, int* disp_unit, void* baseptr) +{ + if (win==MPI_WIN_NULL) + return MPI_ERR_TYPE; + else + return win->shared_query(rank, size, disp_unit, baseptr); +} int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag) { diff --git a/src/smpi/include/smpi_comm.hpp b/src/smpi/include/smpi_comm.hpp index d0727c0780..5cb1b7a7ff 100644 --- a/src/smpi/include/smpi_comm.hpp +++ b/src/smpi/include/smpi_comm.hpp @@ -69,6 +69,7 @@ class Comm : public F2C, public Keyval{ void add_rma_win(MPI_Win win); void remove_rma_win(MPI_Win win); void finish_rma_calls(); + MPI_Comm split_type(int type, int key, MPI_Info info); }; diff --git a/src/smpi/include/smpi_win.hpp b/src/smpi/include/smpi_win.hpp index 20010ad51d..d29f96a907 100644 --- a/src/smpi/include/smpi_win.hpp +++ b/src/smpi/include/smpi_win.hpp @@ -90,6 +90,7 @@ public: int flush_local_all(); int finish_comms(); int finish_comms(int rank); + int shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr); }; diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index af7bd41886..5a7ddbbaa8 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -491,6 +491,17 @@ void Comm::finish_rma_calls(){ } } +MPI_Comm Comm::split_type(int type, int key, MPI_Info info) +{ + if(type != MPI_COMM_TYPE_SHARED){ + return MPI_COMM_NULL; + } + this->init_smp(); + this->ref(); + this->get_intra_comm()->ref(); + return this->get_intra_comm(); +} + } } diff --git a/src/smpi/mpi/smpi_win.cpp b/src/smpi/mpi/smpi_win.cpp index d56451151d..39d47562ab 100644 --- a/src/smpi/mpi/smpi_win.cpp +++ b/src/smpi/mpi/smpi_win.cpp @@ -44,6 +44,7 @@ Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, mode_=0; comm->add_rma_win(this); + comm->ref(); Colls::allgather(&(connected_wins_[rank_]), sizeof(MPI_Win), MPI_BYTE, connected_wins_, sizeof(MPI_Win), MPI_BYTE, comm); @@ -72,6 +73,8 @@ Win::~Win(){ comm_->remove_rma_win(this); Colls::barrier(comm_); + Comm::unref(comm_); + if (rank_ == 0) MSG_barrier_destroy(bar_); xbt_mutex_destroy(mut_); @@ -719,5 +722,27 @@ int Win::finish_comms(int rank){ } +int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr){ + + if(rank!=MPI_PROC_NULL){ + MPI_Win target_win = connected_wins_[rank]; + *size=target_win->size_; + *disp_unit=target_win->disp_unit_; + *static_cast(baseptr)=target_win->base_; + }else{ + for(int i=0; isize();i++){ + MPI_Win target_win = connected_wins_[i]; + if(target_win->size_>0){ + *size=target_win->size_; + *disp_unit=target_win->disp_unit_; + *static_cast(baseptr)=target_win->base_; + return MPI_SUCCESS; + } + } + *size=0; + *static_cast(baseptr)=xbt_malloc(0); + } + return MPI_SUCCESS; + } } } diff --git a/teshsuite/smpi/mpich3-test/rma/CMakeLists.txt b/teshsuite/smpi/mpich3-test/rma/CMakeLists.txt index 51bcf55e8b..3b4dcd3ff4 100644 --- a/teshsuite/smpi/mpich3-test/rma/CMakeLists.txt +++ b/teshsuite/smpi/mpich3-test/rma/CMakeLists.txt @@ -19,12 +19,12 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite) strided_acc_onelock strided_get_indexed strided_putget_indexed contention_put contention_putget adlb_mimic1 lock_contention_dt acc-loc get_acc_local get_accumulate put_base put_bottom linked_list_bench_lock_all linked_list_bench_lock_excl manyrma2 pscw_ordering rma-contig get-struct - rput_local_comp racc_local_comp rget-testall) + rput_local_comp racc_local_comp rget-testall win_shared) # fence_shm fetchandadd_am fetchandadd fetchandadd_tree_am fetchandadd_tree # linked_list_bench_lock_shr linked_list linked_list_fop linked_list_lockall # mcs-mutex mixedsync mutex_bench lockcontention3 reqops # strided_getacc_indexed_shared rget-unlock - # win_flavors win_shared win_shared_noncontig win_shared_noncontig_put + # win_flavors win_shared_noncontig win_shared_noncontig_put # win_large_shm win_zero wintest atomic_rmw_fop atomic_rmw_gacc atomic_get atomic_rmw_cas # win_shared_zerobyte aint derived-acc-flush_local large-acc-flush_local # win_shared_create win_shared_put_flush_get win_shared_rma_flush_load diff --git a/teshsuite/smpi/mpich3-test/rma/testlist b/teshsuite/smpi/mpich3-test/rma/testlist index 527b45b423..e2562a80a7 100644 --- a/teshsuite/smpi/mpich3-test/rma/testlist +++ b/teshsuite/smpi/mpich3-test/rma/testlist @@ -84,7 +84,7 @@ put_bottom 2 #win_flavors 3 mpiversion=3.0 manyrma2 2 timeLimit=500 manyrma3 2 -#win_shared 4 mpiversion=3.0 +win_shared 4 #win_shared_create_allocshm 4 mpiversion=3.0 #win_shared_create_no_allocshm 4 mpiversion=3.0 #win_shared_noncontig 4 mpiversion=3.0