X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/aa419088c69d4d8398fd921eebcc3a83f5d0d789..21fe278c8460849931b37ccde22e944edec46f71:/src/smpi/bindings/smpi_pmpi_comm.cpp diff --git a/src/smpi/bindings/smpi_pmpi_comm.cpp b/src/smpi/bindings/smpi_pmpi_comm.cpp index f8869099cd..19d511ad25 100644 --- a/src/smpi/bindings/smpi_pmpi_comm.cpp +++ b/src/smpi/bindings/smpi_pmpi_comm.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -7,12 +7,13 @@ #include "private.hpp" #include "smpi_comm.hpp" -#include "smpi_process.hpp" +#include "smpi_info.hpp" +#include "smpi_errhandler.hpp" +#include "src/smpi/include/smpi_actor.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi); /* PMPI User level calls */ -extern "C" { // Obviously, the C MPI interface should use the C linkage int PMPI_Comm_rank(MPI_Comm comm, int *rank) { @@ -50,6 +51,18 @@ int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len) } } +int PMPI_Comm_set_name (MPI_Comm comm, const char* name) +{ + if (comm == MPI_COMM_NULL) { + return MPI_ERR_COMM; + } else if (name == nullptr) { + return MPI_ERR_ARG; + } else { + comm->set_name(name); + return MPI_SUCCESS; + } +} + int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group) { if (comm == MPI_COMM_NULL) { @@ -94,6 +107,18 @@ int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm) } } +int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm) +{ + if (comm == MPI_COMM_NULL) { + return MPI_ERR_COMM; + } else if (newcomm == nullptr) { + return MPI_ERR_ARG; + } else { + comm->dup_with_info(info, newcomm); + return MPI_SUCCESS; + } +} + int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm) { if (comm == MPI_COMM_NULL) { @@ -102,7 +127,7 @@ int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm) return MPI_ERR_GROUP; } else if (newcomm == nullptr) { return MPI_ERR_ARG; - } else if(group->rank(simgrid::s4u::Actor::self()->getPid())==MPI_UNDEFINED){ + } else if (group->rank(simgrid::s4u::this_actor::get_pid()) == MPI_UNDEFINED) { *newcomm= MPI_COMM_NULL; return MPI_SUCCESS; }else{ @@ -157,6 +182,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; @@ -175,10 +218,14 @@ int PMPI_Comm_create_group(MPI_Comm comm, MPI_Group group, int, MPI_Comm* comm_o } MPI_Comm PMPI_Comm_f2c(MPI_Fint comm){ + if(comm==-1) + return MPI_COMM_NULL; return static_cast(simgrid::smpi::Comm::f2c(comm)); } MPI_Fint PMPI_Comm_c2f(MPI_Comm comm){ + if(comm==MPI_COMM_NULL) + return -1; return comm->c2f(); } @@ -192,6 +239,26 @@ int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val) return PMPI_Attr_put(comm, comm_keyval, attribute_val); } +int PMPI_Comm_get_info(MPI_Comm comm, MPI_Info* info) +{ + if (comm == MPI_COMM_NULL) { + return MPI_ERR_WIN; + } else { + *info = comm->info(); + return MPI_SUCCESS; + } +} + +int PMPI_Comm_set_info(MPI_Comm comm, MPI_Info info) +{ + if (comm == MPI_COMM_NULL) { + return MPI_ERR_TYPE; + } else { + comm->set_info(info); + return MPI_SUCCESS; + } +} + int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval) { return PMPI_Attr_delete(comm, comm_keyval); @@ -222,6 +289,7 @@ int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) { static int zero = 0; static int tag_ub = INT_MAX; static int last_used_code = MPI_ERR_LASTCODE; + static int universe_size; if (comm==MPI_COMM_NULL){ *flag = 0; @@ -237,7 +305,8 @@ int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) { return MPI_SUCCESS; case MPI_UNIVERSE_SIZE: *flag = 1; - *static_cast(attr_value) = &smpi_universe_size; + universe_size = smpi_get_universe_size(); + *static_cast(attr_value) = &universe_size; return MPI_SUCCESS; case MPI_LASTUSEDCODE: *flag = 1; @@ -266,4 +335,53 @@ int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) { return comm->attr_put(keyval, attr_value); } +int PMPI_Errhandler_free(MPI_Errhandler* errhandler){ + if (errhandler==nullptr){ + return MPI_ERR_ARG; + } + simgrid::smpi::Errhandler::unref(*errhandler); + return MPI_SUCCESS; +} + +int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler){ + *errhandler=new simgrid::smpi::Errhandler(function); + return MPI_SUCCESS; +} + +int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler){ + if (comm == nullptr) { + return MPI_ERR_COMM; + } else if (errhandler==nullptr){ + return MPI_ERR_ARG; + } + *errhandler=comm->errhandler(); + return MPI_SUCCESS; +} + +int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler){ + if (comm == nullptr) { + return MPI_ERR_COMM; + } else if (errhandler==nullptr){ + return MPI_ERR_ARG; + } + comm->set_errhandler(errhandler); + return MPI_SUCCESS; +} + +int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){ + if (comm == nullptr) { + return MPI_ERR_COMM; + } + comm->errhandler()->call(comm, errorcode); + return MPI_SUCCESS; +} + +int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){ + return MPI_Errhandler_create(function, errhandler); +} +int PMPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler* errhandler){ + return PMPI_Errhandler_get(comm, errhandler); +} +int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler){ + return PMPI_Errhandler_set(comm, errhandler); }