X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4ff3a4cf6e03165421f65616a22be86b8f528e21..3297da9f47ce18371941b2b48a2f4018b4793ced:/src/smpi/bindings/smpi_pmpi_win.cpp diff --git a/src/smpi/bindings/smpi_pmpi_win.cpp b/src/smpi/bindings/smpi_pmpi_win.cpp index 77bd23e0e6..b3ca2d7134 100644 --- a/src/smpi/bindings/smpi_pmpi_win.cpp +++ b/src/smpi/bindings/smpi_pmpi_win.cpp @@ -8,8 +8,8 @@ #include "smpi_comm.hpp" #include "smpi_datatype_derived.hpp" #include "smpi_op.hpp" -#include "smpi_process.hpp" #include "smpi_win.hpp" +#include "src/smpi/include/smpi_actor.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi); @@ -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(); @@ -165,7 +192,7 @@ int PMPI_Win_fence( int assert, MPI_Win win){ if (win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_fence")); retval = win->fence(assert); TRACE_smpi_comm_out(my_proc_id); @@ -194,7 +221,7 @@ int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); TRACE_smpi_comm_in(my_proc_id, __func__, @@ -235,7 +262,7 @@ int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype } else if(request == nullptr){ retval = MPI_ERR_REQUEST; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); TRACE_smpi_comm_in(my_proc_id, __func__, @@ -273,7 +300,7 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); int dst_traced = group->actor(target_rank)->get_pid(); @@ -316,7 +343,7 @@ int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype } else if(request == nullptr){ retval = MPI_ERR_REQUEST; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); int dst_traced = group->actor(target_rank)->get_pid(); @@ -358,7 +385,7 @@ int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); TRACE_smpi_comm_in(my_proc_id, __func__, @@ -400,7 +427,7 @@ int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_d } else if(request == nullptr){ retval = MPI_ERR_REQUEST; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); TRACE_smpi_comm_in(my_proc_id, __func__, @@ -442,7 +469,7 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){ } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); TRACE_smpi_comm_in(my_proc_id, __func__, @@ -489,7 +516,7 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){ } else if(request == nullptr){ retval = MPI_ERR_REQUEST; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); TRACE_smpi_comm_in(my_proc_id, __func__, @@ -531,7 +558,7 @@ int PMPI_Compare_and_swap(void* origin_addr, void* compare_addr, void* result_ad } else if ((datatype == MPI_DATATYPE_NULL) || (not datatype->is_valid())) { retval = MPI_ERR_TYPE; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); MPI_Group group; win->get_group(&group); TRACE_smpi_comm_in(my_proc_id, __func__, @@ -555,7 +582,7 @@ int PMPI_Win_post(MPI_Group group, int assert, MPI_Win win){ } else if (group==MPI_GROUP_NULL){ retval = MPI_ERR_GROUP; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_post")); retval = win->post(group,assert); TRACE_smpi_comm_out(my_proc_id); @@ -572,7 +599,7 @@ int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){ } else if (group==MPI_GROUP_NULL){ retval = MPI_ERR_GROUP; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_start")); retval = win->start(group,assert); TRACE_smpi_comm_out(my_proc_id); @@ -587,7 +614,7 @@ int PMPI_Win_complete(MPI_Win win){ if (win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_complete")); retval = win->complete(); @@ -604,7 +631,7 @@ int PMPI_Win_wait(MPI_Win win){ if (win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_wait")); retval = win->wait(); @@ -626,7 +653,7 @@ int PMPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win){ } else if (rank == MPI_PROC_NULL){ retval = MPI_SUCCESS; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock")); retval = win->lock(lock_type,rank,assert); TRACE_smpi_comm_out(my_proc_id); @@ -643,7 +670,7 @@ int PMPI_Win_unlock(int rank, MPI_Win win){ } else if (rank == MPI_PROC_NULL){ retval = MPI_SUCCESS; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock")); retval = win->unlock(rank); TRACE_smpi_comm_out(my_proc_id); @@ -658,7 +685,7 @@ int PMPI_Win_lock_all(int assert, MPI_Win win){ if (win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock_all")); retval = win->lock_all(assert); TRACE_smpi_comm_out(my_proc_id); @@ -673,7 +700,7 @@ int PMPI_Win_unlock_all(MPI_Win win){ if (win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock_all")); retval = win->unlock_all(); TRACE_smpi_comm_out(my_proc_id); @@ -690,7 +717,7 @@ int PMPI_Win_flush(int rank, MPI_Win win){ } else if (rank == MPI_PROC_NULL){ retval = MPI_SUCCESS; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush")); retval = win->flush(rank); TRACE_smpi_comm_out(my_proc_id); @@ -707,7 +734,7 @@ int PMPI_Win_flush_local(int rank, MPI_Win win){ } else if (rank == MPI_PROC_NULL){ retval = MPI_SUCCESS; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local")); retval = win->flush_local(rank); TRACE_smpi_comm_out(my_proc_id); @@ -722,7 +749,7 @@ int PMPI_Win_flush_all(MPI_Win win){ if (win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_all")); retval = win->flush_all(); TRACE_smpi_comm_out(my_proc_id); @@ -737,7 +764,7 @@ int PMPI_Win_flush_local_all(MPI_Win win){ if (win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; } else { - int my_proc_id = simgrid::s4u::this_actor::getPid(); + int my_proc_id = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local_all")); retval = win->flush_local_all(); TRACE_smpi_comm_out(my_proc_id); @@ -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) { @@ -795,8 +829,8 @@ int PMPI_Win_delete_attr (MPI_Win win, int type_keyval) int PMPI_Win_create_keyval(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval, void* extra_state) { - smpi_copy_fn _copy_fn={nullptr, nullptr, copy_fn}; - smpi_delete_fn _delete_fn={nullptr, nullptr, delete_fn}; + smpi_copy_fn _copy_fn={nullptr, nullptr,copy_fn,nullptr, nullptr,nullptr}; + smpi_delete_fn _delete_fn={nullptr, nullptr,delete_fn,nullptr, nullptr,nullptr}; return simgrid::smpi::Keyval::keyval_create(_copy_fn, _delete_fn, keyval, extra_state); }