class Topo_Cart;
class Topo_Graph;
class Topo_Dist_Graph;
-class Type_Contiguous;
-class Type_Hindexed;
-class Type_Hvector;
-class Type_Indexed;
-class Type_Struct;
-class Type_Vector;
class Win;
class Colls;
+class Coll;
}
}
typedef simgrid::smpi::Topo_Dist_Graph SMPI_Dist_Graph_topology;
typedef simgrid::smpi::Topo_Graph SMPI_Graph_topology;
typedef simgrid::smpi::Win SMPI_Win;
-typedef simgrid::smpi::Type_Contiguous SMPI_Type_Contiguous;
-typedef simgrid::smpi::Type_Hindexed SMPI_Type_Hindexed;
-typedef simgrid::smpi::Type_Hvector SMPI_Type_Hvector;
-typedef simgrid::smpi::Type_Indexed SMPI_Type_Indexed;
-typedef simgrid::smpi::Type_Struct SMPI_Type_Struct;
-typedef simgrid::smpi::Type_Vector SMPI_Type_Vector;
#else
typedef struct SMPI_Request SMPI_Request;
typedef struct SMPI_Topology SMPI_Topology;
typedef struct SMPI_Win SMPI_Win;
-typedef struct SMPI_Graph_topology SMPI_Graph_topology;
-typedef struct SMPI_Cart_topology SMPI_Cart_topology;
-typedef struct SMPI_Dist_Graph_topology SMPI_Dist_Graph_topology;
-typedef struct SMPI_Type_Contiguous SMPI_Type_Contiguous;
-typedef struct SMPI_Type_Hindexed SMPI_Type_Hindexed;
-typedef struct SMPI_Type_Hvector SMPI_Type_Hvector;
-typedef struct SMPI_Type_Indexed SMPI_Type_Indexed;
-typedef struct SMPI_Type_Struct SMPI_Type_Struct;
-typedef struct SMPI_Type_Vector SMPI_Type_Vector;
#endif
//defines for fortran compatibility
#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
- #define MPI_INTEGER MPI_INT
- #define MPI_2INTEGER MPI_2INT
- #define MPI_LOGICAL MPI_INT
+#define MPI_INTEGER MPI_INT
+#define MPI_2INTEGER MPI_2INT
+#define MPI_LOGICAL MPI_INT
#else
- #define MPI_INTEGER MPI_LONG
- #define MPI_2INTEGER MPI_2LONG
- #define MPI_LOGICAL MPI_LONG
+#define MPI_INTEGER MPI_LONG
+#define MPI_2INTEGER MPI_2LONG
+#define MPI_LOGICAL MPI_LONG
#endif
#define MPI_Fint int
//For accumulate
XBT_PUBLIC_DATA( MPI_Op ) MPI_REPLACE;
-typedef SMPI_Topology *MPI_Topology;
-
typedef SMPI_Group* MPI_Group;
#define MPI_GROUP_NULL ((MPI_Group)NULL)
#include "../colls_private.h"
-using namespace simgrid::smpi;
-
// Allgather - gather/bcast algorithm
int Coll_allgather_GB::allgather(void *send_buff, int send_count,
MPI_Datatype send_type, void *recv_buff,
*/
#include "../colls_private.h"
-using namespace simgrid::smpi;
-
int Coll_allgather_mvapich2_smp::allgather(void *sendbuf,int sendcnt, MPI_Datatype sendtype,
void *recvbuf, int recvcnt,MPI_Datatype recvtype,
MPI_Comm comm)
#include "../colls_private.h"
//#include <star-reduction.c>
-using namespace simgrid::smpi;
// NP pow of 2 for now
int Coll_allreduce_rab1::allreduce(void *sbuff, void *rbuff,
#include "../colls_private.h"
//#include <star-reduction.c>
-using namespace simgrid::smpi;
// this requires that count >= NP
int Coll_allreduce_rab2::allreduce(void *sbuff, void *rbuff,
#define MV2_MAX_NB_THRESHOLDS 32
-using namespace simgrid::smpi;
XBT_PUBLIC(void) smpi_coll_cleanup_mvapich2(void);
extern XBT_PRIVATE MPI_Comm MPI_COMM_UNINITIALIZED;
-
-
-typedef struct s_smpi_mpi_comm_key_elem {
- MPI_Comm_copy_attr_function* copy_fn;
- MPI_Comm_delete_attr_function* delete_fn;
-} s_smpi_mpi_comm_key_elem_t;
-typedef struct s_smpi_mpi_comm_key_elem *smpi_comm_key_elem;
-
-typedef struct s_smpi_mpi_type_key_elem {
- MPI_Type_copy_attr_function* copy_fn;
- MPI_Type_delete_attr_function* delete_fn;
-} s_smpi_mpi_type_key_elem_t;
-typedef struct s_smpi_mpi_type_key_elem *smpi_type_key_elem;
-
XBT_PRIVATE void smpi_process_destroy();
XBT_PRIVATE void smpi_process_finalize();
XBT_PRIVATE int smpi_process_finalized();
static void (*smpi_coll_cleanup_callback)();
};
-class Coll_algo{
- private:
- char* description_;
- public:
- char* description();
-};
-
-class Coll_gather : public Coll_algo {
- private:
+class Coll {
public:
static int gather (void *, int, MPI_Datatype, void*, int, MPI_Datatype, int root, MPI_Comm);
-};
-
-class Coll_allgather : public Coll_algo {
- private:
- public:
static int allgather (void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
-};
-
-class Coll_allgatherv : public Coll_algo {
- private:
- public:
static int allgatherv (void *, int, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
-};
-
-class Coll_allreduce : public Coll_algo {
- private:
- public:
static int allreduce (void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm);
-};
-
-class Coll_alltoall : public Coll_algo {
- private:
- public:
static int alltoall (void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
-};
-
-class Coll_alltoallv : public Coll_algo {
- private:
- public:
static int alltoallv (void *, int*, int*, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
-};
-
-class Coll_bcast : public Coll_algo {
- private:
- public:
static int bcast (void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm com);
-};
-
-class Coll_reduce : public Coll_algo {
- private:
- public:
static int reduce (void *buf, void *rbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
-};
-
-class Coll_reduce_scatter : public Coll_algo {
- private:
- public:
static int reduce_scatter (void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype,MPI_Op op,MPI_Comm comm);
-};
-
-class Coll_scatter : public Coll_algo {
- private:
- public:
static int scatter (void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbuf, int recvcount, MPI_Datatype recvtype,int root, MPI_Comm comm);
-};
-
-class Coll_barrier : public Coll_algo {
- private:
- public:
static int barrier (MPI_Comm);
};
(void*) Coll_ ## cat ## _ ## name::cat }
#define COLL_PROTO(cat, ret, args, name) \
-class Coll_ ## cat ## _ ## name : public Coll_ ## cat { \
+class Coll_ ## cat ## _ ## name : public Coll { \
public: \
static ret cat (COLL_UNPAREN args); \
};
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi, "Logging specific to SMPI (comm)");
-xbt_dict_t smpi_comm_keyvals = nullptr;
-int comm_keyval_id = 0;//avoid collisions
-
-
Comm mpi_MPI_COMM_UNINITIALIZED;
MPI_Comm MPI_COMM_UNINITIALIZED=&mpi_MPI_COMM_UNINITIALIZED;
namespace simgrid{
namespace smpi{
-Comm::Comm(){}
+xbt_dict_t Comm::keyvals_ = nullptr;
+int Comm::keyval_id_ = 0;//avoid collisions
Comm::Comm(MPI_Group group, MPI_Topology topo) : group_(group), topo_(topo)
{
void* value_out;
xbt_dict_foreach (attributes_, cursor, key, value_in) {
smpi_comm_key_elem elem =
- static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, key, sizeof(int)));
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(keyvals_, key, sizeof(int)));
if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) {
ret = elem->copy_fn(this, atoi(key), nullptr, value_in, &value_out, &flag);
if (ret != MPI_SUCCESS) {
void* value;
int flag;
xbt_dict_foreach (attributes_, cursor, key, value) {
- smpi_comm_key_elem elem = static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null(smpi_comm_keyvals, key));
+ smpi_comm_key_elem elem = static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null(keyvals_, key));
if (elem != nullptr && elem->delete_fn != nullptr)
elem->delete_fn(this, atoi(key), value, &flag);
}
int Comm::attr_delete(int keyval){
smpi_comm_key_elem elem =
- static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(keyvals_, reinterpret_cast<const char*>(&keyval), sizeof(int)));
if(elem==nullptr)
return MPI_ERR_ARG;
if(elem->delete_fn!=MPI_NULL_DELETE_FN){
int Comm::attr_get(int keyval, void* attr_value, int* flag){
smpi_comm_key_elem elem =
- static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(keyvals_, reinterpret_cast<const char*>(&keyval), sizeof(int)));
if(elem==nullptr)
return MPI_ERR_ARG;
if(attributes_==nullptr){
}
int Comm::attr_put(int keyval, void* attr_value){
- if(smpi_comm_keyvals==nullptr)
- smpi_comm_keyvals = xbt_dict_new_homogeneous(nullptr);
+ if(keyvals_==nullptr)
+ keyvals_ = xbt_dict_new_homogeneous(nullptr);
smpi_comm_key_elem elem =
- static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(keyvals_, reinterpret_cast<const char*>(&keyval), sizeof(int)));
if(elem==nullptr)
return MPI_ERR_ARG;
int flag;
return MPI_COMM_SELF;
} else if(id==0){
return MPI_COMM_WORLD;
- } else if(Comm::f2c_lookup_ != nullptr && id >= 0) {
+ } else if(F2C::f2c_lookup_ != nullptr && id >= 0) {
char key[KEY_SIZE];
- MPI_Comm tmp = static_cast<MPI_Comm>(xbt_dict_get_or_null(Comm::f2c_lookup_,get_key_id(key, id)));
+ MPI_Comm tmp = static_cast<MPI_Comm>(xbt_dict_get_or_null(F2C::f2c_lookup_,get_key_id(key, id)));
return tmp != nullptr ? tmp : MPI_COMM_NULL ;
} else {
return MPI_COMM_NULL;
void Comm::free_f(int id) {
char key[KEY_SIZE];
- xbt_dict_remove(Comm::f2c_lookup_, id==0? get_key(key, id) : get_key_id(key, id));
+ xbt_dict_remove(F2C::f2c_lookup_, id==0? get_key(key, id) : get_key_id(key, id));
}
int Comm::add_f() {
- if(Comm::f2c_lookup_==nullptr){
- Comm::f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
+ if(F2C::f2c_lookup_==nullptr){
+ F2C::f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
}
char key[KEY_SIZE];
- xbt_dict_set(Comm::f2c_lookup_, this==MPI_COMM_WORLD? get_key(key, Comm::f2c_id_) : get_key_id(key,Comm::f2c_id_), this, nullptr);
- Comm::f2c_id_++;
- return Comm::f2c_id_-1;
+ xbt_dict_set(F2C::f2c_lookup_, this==MPI_COMM_WORLD? get_key(key, F2C::f2c_id_) : get_key_id(key,F2C::f2c_id_), this, nullptr);
+ F2C::f2c_id_++;
+ return F2C::f2c_id_-1;
}
-
-}
-}
-
-int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval,
+int Comm::keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval,
void* extra_state){
- if(smpi_comm_keyvals==nullptr)
- smpi_comm_keyvals = xbt_dict_new_homogeneous(nullptr);
+ if(keyvals_==nullptr)
+ keyvals_ = xbt_dict_new_homogeneous(nullptr);
smpi_comm_key_elem value = static_cast<smpi_comm_key_elem>(xbt_new0(s_smpi_mpi_comm_key_elem_t,1));
value->copy_fn=copy_fn;
value->delete_fn=delete_fn;
- *keyval = comm_keyval_id;
- xbt_dict_set_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int),static_cast<void*>(value), nullptr);
- comm_keyval_id++;
+ *keyval = keyval_id_;
+ xbt_dict_set_ext(keyvals_, reinterpret_cast<const char*>(keyval), sizeof(int),static_cast<void*>(value), nullptr);
+ keyval_id_++;
return MPI_SUCCESS;
}
-int smpi_comm_keyval_free(int* keyval){
+int Comm::keyval_free(int* keyval){
smpi_comm_key_elem elem =
- static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int)));
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(keyvals_, reinterpret_cast<const char*>(keyval), sizeof(int)));
if(elem==nullptr)
return MPI_ERR_ARG;
- xbt_dict_remove_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int));
+ xbt_dict_remove_ext(keyvals_, reinterpret_cast<const char*>(keyval), sizeof(int));
xbt_free(elem);
return MPI_SUCCESS;
}
+
+void Comm::keyval_cleanup(){
+ if(Comm::keyvals_!=nullptr)
+ xbt_dict_free(&Comm::keyvals_);
+}
+
+
+}
+}
+
+
#include "private.h"
+
+typedef struct s_smpi_mpi_comm_key_elem {
+ MPI_Comm_copy_attr_function* copy_fn;
+ MPI_Comm_delete_attr_function* delete_fn;
+} s_smpi_mpi_comm_key_elem_t;
+typedef struct s_smpi_mpi_comm_key_elem *smpi_comm_key_elem;
+
namespace simgrid{
namespace smpi{
int is_blocked_;// are ranks allocated on the same smp node contiguous ?
xbt_dict_t attributes_;
+ static xbt_dict_t keyvals_;
+ static int keyval_id_;
+
public:
- Comm();
+ Comm() = default;
Comm(MPI_Group group, MPI_Topology topo);
static void free_f(int id);
static Comm* f2c(int);
+ static int keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state);
+ static int keyval_free(int* keyval);
+ static void keyval_cleanup();
+
};
}
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_datatype, smpi, "Logging specific to SMPI (datatype)");
-std::unordered_map<int, smpi_type_key_elem> smpi_type_keyvals;
-int type_keyval_id=0;//avoid collisions
-
-
#define CREATE_MPI_DATATYPE(name, type) \
static Datatype mpi_##name ( \
(char*) # name, \
namespace simgrid{
namespace smpi{
-MPI_Datatype Datatype::null_id_=MPI_DATATYPE_NULL;
+std::unordered_map<int, smpi_type_key_elem> Datatype::keyvals_;
+int Datatype::keyval_id_=0;
Datatype::Datatype(int size,MPI_Aint lb, MPI_Aint ub, int flags) : name_(nullptr), size_(size), lb_(lb), ub_(ub), flags_(flags), attributes_(nullptr), refcount_(1){
#if HAVE_MC
void* value_in;
void* value_out;
xbt_dict_foreach (datatype->attributes_, cursor, key, value_in) {
- smpi_type_key_elem elem = smpi_type_keyvals.at(atoi(key));
+ smpi_type_key_elem elem = keyvals_.at(atoi(key));
if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) {
*ret = elem->copy_fn(datatype, atoi(key), nullptr, value_in, &value_out, &flag);
if (*ret != MPI_SUCCESS) {
void * value;
int flag;
xbt_dict_foreach(attributes_, cursor, key, value){
- smpi_type_key_elem elem = smpi_type_keyvals.at(atoi(key));
+ smpi_type_key_elem elem = keyvals_.at(atoi(key));
if(elem!=nullptr && elem->delete_fn!=nullptr)
elem->delete_fn(this,*key, value, &flag);
}
}
int Datatype::attr_delete(int keyval){
- smpi_type_key_elem elem = smpi_type_keyvals.at(keyval);
+ smpi_type_key_elem elem = keyvals_.at(keyval);
if(elem==nullptr)
return MPI_ERR_ARG;
if(elem->delete_fn!=MPI_NULL_DELETE_FN){
int Datatype::attr_get(int keyval, void* attr_value, int* flag){
- smpi_type_key_elem elem = smpi_type_keyvals.at(keyval);
+ smpi_type_key_elem elem = keyvals_.at(keyval);
if(elem==nullptr)
return MPI_ERR_ARG;
if(attributes_==nullptr){
}
int Datatype::attr_put(int keyval, void* attr_value){
- smpi_type_key_elem elem = smpi_type_keyvals.at(keyval);
+ smpi_type_key_elem elem = keyvals_.at(keyval);
if(elem==nullptr)
return MPI_ERR_ARG;
int flag;
value->copy_fn=copy_fn;
value->delete_fn=delete_fn;
- *keyval = type_keyval_id;
- smpi_type_keyvals.insert({*keyval, value});
- type_keyval_id++;
+ *keyval = keyval_id_;
+ keyvals_.insert({*keyval, value});
+ keyval_id_++;
return MPI_SUCCESS;
}
int Datatype::keyval_free(int* keyval){
- smpi_type_key_elem elem = smpi_type_keyvals.at(*keyval);
+ smpi_type_key_elem elem = keyvals_.at(*keyval);
if(elem==0){
return MPI_ERR_ARG;
}
- smpi_type_keyvals.erase(*keyval);
+ keyvals_.erase(*keyval);
xbt_free(elem);
return MPI_SUCCESS;
}
#include <xbt/base.h>
#include "private.h"
+#include <unordered_map>
#define DT_FLAG_DESTROYED 0x0001 /**< user destroyed but some other layers still have a reference */
#define DT_FLAG_COMMITED 0x0002 /**< ready to be used for a send/recv operation */
extern const MPI_Datatype MPI_PTR;
+typedef struct s_smpi_mpi_type_key_elem {
+ MPI_Type_copy_attr_function* copy_fn;
+ MPI_Type_delete_attr_function* delete_fn;
+} s_smpi_mpi_type_key_elem_t;
+typedef struct s_smpi_mpi_type_key_elem *smpi_type_key_elem;
+
//The following are datatypes for the MPI functions MPI_MAXLOC and MPI_MINLOC.
typedef struct {
float value;
int flags_;
xbt_dict_t attributes_;
int refcount_;
+
+ static std::unordered_map<int, smpi_type_key_elem> keyvals_;
+ static int keyval_id_;
+
public:
static MPI_Datatype null_id_;
int smpi_universe_size = 0;
int* index_to_process_data = nullptr;
extern double smpi_total_benched_time;
-extern xbt_dict_t smpi_comm_keyvals;
xbt_os_timer_t global_timer;
MPI_Comm MPI_COMM_WORLD = MPI_COMM_UNINITIALIZED;
MPI_Errhandler *MPI_ERRORS_RETURN = nullptr;
}
xbt_free(index_to_process_data);
- if(smpi_comm_keyvals!=nullptr)
- xbt_dict_free(&smpi_comm_keyvals);
+ Comm::keyval_cleanup();
if(smpi_privatize_global_variables)
smpi_destroy_global_memory_segments();
smpi_free_static();
MPI_Group Group::f2c(int id) {
if(id == -2) {
return MPI_GROUP_EMPTY;
- } else if(f2c_lookup_ != nullptr && id >= 0) {
+ } else if(F2C::f2c_lookup_ != nullptr && id >= 0) {
char key[KEY_SIZE];
- return static_cast<MPI_Group>(xbt_dict_get_or_null(f2c_lookup_, get_key(key, id)));
+ return static_cast<MPI_Group>(xbt_dict_get_or_null(F2C::f2c_lookup_, get_key(key, id)));
} else {
return static_cast<MPI_Group>(MPI_GROUP_NULL);
}
}
int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
- return smpi_comm_keyval_create(copy_fn, delete_fn, keyval, extra_state);
+ return Comm::keyval_create(copy_fn, delete_fn, keyval, extra_state);
}
int PMPI_Keyval_free(int* keyval) {
- return smpi_comm_keyval_free(keyval);
+ return Comm::keyval_free(keyval);
}
int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
char key[KEY_SIZE];
if(id==MPI_FORTRAN_REQUEST_NULL)
return static_cast<MPI_Request>(MPI_REQUEST_NULL);
- return static_cast<MPI_Request>(xbt_dict_get(Request::f2c_lookup_, get_key_id(key, id)));
+ return static_cast<MPI_Request>(xbt_dict_get(F2C::f2c_lookup_, get_key_id(key, id)));
}
int Request::add_f() {
- if(Request::f2c_lookup_==nullptr){
- Request::f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
+ if(F2C::f2c_lookup_==nullptr){
+ F2C::f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
}
char key[KEY_SIZE];
- xbt_dict_set(Request::f2c_lookup_, get_key_id(key, Request::f2c_id_), this, nullptr);
- Request::f2c_id_++;
- return Request::f2c_id_-1;
+ xbt_dict_set(F2C::f2c_lookup_, get_key_id(key, F2C::f2c_id_), this, nullptr);
+ F2C::f2c_id_++;
+ return F2C::f2c_id_-1;
}
void Request::free_f(int id) {
char key[KEY_SIZE];
if(id!=MPI_FORTRAN_REQUEST_NULL)
- xbt_dict_remove(Request::f2c_lookup_, get_key_id(key, id));
+ xbt_dict_remove(F2C::f2c_lookup_, get_key_id(key, id));
}
MPI_INVALID_TOPO=-1
} MPIR_Topo_type;
+typedef SMPI_Topology *MPI_Topology;
+
namespace simgrid{
namespace smpi{