From 731c4a5371dc691c8eb833f7d4617c7a94f91680 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 7 Feb 2016 11:50:31 +0100 Subject: [PATCH] compile SMPI as C++ source Agreed, that's not real C++ code. We would need to objectify everything, and kill our XBT containers, at the very least. But this will allow to further objectify the kernel. I'll deal with the user interfaces later. --- include/smpi/smpi.h | 6 ++-- include/xbt/hash.h | 5 ++- src/include/smpi/smpi_interface.h | 4 ++- src/smpi/colls/colls.h | 5 ++- src/smpi/{instr_smpi.c => instr_smpi.cpp} | 6 ++-- src/smpi/{smpi_base.c => smpi_base.cpp} | 20 +++++------ src/smpi/{smpi_bench.c => smpi_bench.cpp} | 18 +++++----- src/smpi/{smpi_c99.c => smpi_c99.cpp} | 0 src/smpi/{smpi_coll.c => smpi_coll.cpp} | 31 ++++++++--------- src/smpi/{smpi_comm.c => smpi_comm.cpp} | 24 ++++++------- ...{smpi_deployment.c => smpi_deployment.cpp} | 5 ++- src/smpi/{smpi_dvfs.c => smpi_dvfs.cpp} | 10 +++--- src/smpi/{smpi_f77.c => smpi_f77.cpp} | 22 ++++++------ src/smpi/{smpi_global.c => smpi_global.cpp} | 16 +++++---- src/smpi/{smpi_group.c => smpi_group.cpp} | 2 +- src/smpi/{smpi_mpi.c => smpi_mpi.cpp} | 0 src/smpi/{smpi_mpi_dt.c => smpi_mpi_dt.cpp} | 34 ++++++++++--------- src/smpi/smpi_mpi_dt_private.h | 4 +++ src/smpi/{smpi_pmpi.c => smpi_pmpi.cpp} | 18 +++++----- src/smpi/{smpi_replay.c => smpi_replay.cpp} | 18 +++++----- src/smpi/{smpi_rma.c => smpi_rma.cpp} | 8 ++--- src/smpi/{smpi_topo.c => smpi_topo.cpp} | 14 ++++---- tools/cmake/DefinePackages.cmake | 34 +++++++++---------- 23 files changed, 158 insertions(+), 146 deletions(-) rename src/smpi/{instr_smpi.c => instr_smpi.cpp} (98%) rename src/smpi/{smpi_base.c => smpi_base.cpp} (98%) rename src/smpi/{smpi_bench.c => smpi_bench.cpp} (97%) rename src/smpi/{smpi_c99.c => smpi_c99.cpp} (100%) rename src/smpi/{smpi_coll.c => smpi_coll.cpp} (96%) rename src/smpi/{smpi_comm.c => smpi_comm.cpp} (94%) rename src/smpi/{smpi_deployment.c => smpi_deployment.cpp} (93%) rename src/smpi/{smpi_dvfs.c => smpi_dvfs.cpp} (88%) rename src/smpi/{smpi_f77.c => smpi_f77.cpp} (99%) rename src/smpi/{smpi_global.c => smpi_global.cpp} (97%) rename src/smpi/{smpi_group.c => smpi_group.cpp} (98%) rename src/smpi/{smpi_mpi.c => smpi_mpi.cpp} (100%) rename src/smpi/{smpi_mpi_dt.c => smpi_mpi_dt.cpp} (97%) rename src/smpi/{smpi_pmpi.c => smpi_pmpi.cpp} (99%) rename src/smpi/{smpi_replay.c => smpi_replay.cpp} (98%) rename src/smpi/{smpi_rma.c => smpi_rma.cpp} (97%) rename src/smpi/{smpi_topo.c => smpi_topo.cpp} (96%) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 180258ab1c..60dfc5430a 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -214,7 +214,8 @@ typedef enum MPIR_Combiner_enum{ typedef enum MPIR_Topo_type { MPI_GRAPH=1, MPI_CART=2, - MPI_DIST_GRAPH=3 + MPI_DIST_GRAPH=3, + MPI_INVALID_TOPO=-1 } MPIR_Topo_type; typedef ptrdiff_t MPI_Aint; @@ -832,9 +833,6 @@ XBT_PUBLIC(int) smpi_global_size(void); XBT_PUBLIC(MPI_Comm) smpi_process_comm_self(void); XBT_PUBLIC(void*) smpi_process_get_user_data(void); XBT_PUBLIC(void) smpi_process_set_user_data(void *); -/* -XBT_PUBLIC(void) smpi_exit(int); -*/ XBT_PUBLIC(void) smpi_execute_flops(double flops); XBT_PUBLIC(void) smpi_execute(double duration); diff --git a/include/xbt/hash.h b/include/xbt/hash.h index a5014dd525..d66ec43e38 100644 --- a/include/xbt/hash.h +++ b/include/xbt/hash.h @@ -10,7 +10,9 @@ #define XBT_HASH_H #include "xbt/str.h" -/* Chord needs a SHA1 algorithm. Let's drop it in there */ +SG_BEGIN_DECL() + +/* The classical SHA1 algorithm */ typedef struct s_xbt_sha_ s_xbt_sha_t, *xbt_sha_t; XBT_PUBLIC(xbt_sha_t) xbt_sha_new(void); @@ -25,5 +27,6 @@ XBT_PUBLIC(char *) xbt_sha_read(xbt_sha_t sha); XBT_PUBLIC(void) xbt_sha(const char *data, char *hash); +SG_END_DECL() #endif /* XBT_HASH_H */ diff --git a/src/include/smpi/smpi_interface.h b/src/include/smpi/smpi_interface.h index 7b37c8e785..d139ada9df 100644 --- a/src/include/smpi/smpi_interface.h +++ b/src/include/smpi/smpi_interface.h @@ -8,7 +8,7 @@ #define _SMPI_INTERFACE_H #include "smpi/smpi.h" - +SG_BEGIN_DECL() /** \brief MPI collective description */ @@ -123,4 +123,6 @@ extern XBT_PRIVATE double smpi_wtime_sleep; extern XBT_PRIVATE double smpi_iprobe_sleep; extern XBT_PRIVATE double smpi_test_sleep; +SG_END_DECL() + #endif /* _SMPI_INTERFAC_H */ diff --git a/src/smpi/colls/colls.h b/src/smpi/colls/colls.h index ffd791abd6..be58707f4f 100644 --- a/src/smpi/colls/colls.h +++ b/src/smpi/colls/colls.h @@ -13,10 +13,12 @@ #include "xbt/ex.h" #include "xbt.h" +SG_BEGIN_DECL() + #define COLL_DESCRIPTION(cat, ret, args, name) \ {# name,\ # cat " " # name " collective",\ - smpi_coll_tuned_ ## cat ## _ ## name} + (void*)smpi_coll_tuned_ ## cat ## _ ## name} #define COLL_PROTO(cat, ret, args, name) \ ret smpi_coll_tuned_ ## cat ## _ ## name(COLL_UNPAREN args); @@ -333,5 +335,6 @@ COLL_APPLY(action, COLL_BARRIER_SIG, automatic) COLL_BARRIERS(COLL_PROTO, COLL_NOsep) +SG_END_DECL() #endif diff --git a/src/smpi/instr_smpi.c b/src/smpi/instr_smpi.cpp similarity index 98% rename from src/smpi/instr_smpi.c rename to src/smpi/instr_smpi.cpp index 101de29f2f..9c8448d323 100644 --- a/src/smpi/instr_smpi.c +++ b/src/smpi/instr_smpi.cpp @@ -97,7 +97,7 @@ static char *TRACE_smpi_put_key(int src, int dst, char *key, int n) //get the dynar for src#dst char aux[INSTR_DEFAULT_STR_SIZE]; snprintf(aux, INSTR_DEFAULT_STR_SIZE, "%d#%d", src, dst); - xbt_dynar_t d = xbt_dict_get_or_null(keys, aux); + xbt_dynar_t d = static_cast(xbt_dict_get_or_null(keys, aux)); if(!xbt_dynar_is_empty(d)){ @@ -127,7 +127,7 @@ static char *TRACE_smpi_get_key(int src, int dst, char *key, int n) { char aux[INSTR_DEFAULT_STR_SIZE]; snprintf(aux, INSTR_DEFAULT_STR_SIZE, "%d#%d", src, dst); - xbt_dynar_t d = xbt_dict_get_or_null(keys, aux); + xbt_dynar_t d = static_cast(xbt_dict_get_or_null(keys, aux)); // xbt_assert(!xbt_dynar_is_empty(d), // "Trying to get a link key (for message reception) that has no corresponding send (%s).", __FUNCTION__); @@ -177,7 +177,7 @@ const char *TRACE_internal_smpi_get_category (void) char processid[INSTR_DEFAULT_STR_SIZE]; snprintf (processid, INSTR_DEFAULT_STR_SIZE, "%p", SIMIX_process_self()); - return xbt_dict_get_or_null (process_category, processid); + return static_cast(xbt_dict_get_or_null (process_category, processid)); } void TRACE_smpi_alloc() diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.cpp similarity index 98% rename from src/smpi/smpi_base.c rename to src/smpi/smpi_base.cpp index 8b0c747e0b..ddaffbc077 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.cpp @@ -94,7 +94,7 @@ static xbt_dynar_t parse_factor(const char *smpi_coef_string) unsigned int iter = 0; s_smpi_factor_t fact; fact.nb_values=0; - int i=0; + unsigned int i=0; xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL; smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL); @@ -242,7 +242,7 @@ static MPI_Request build_request(void *buf, int count, request = xbt_new(s_smpi_mpi_request_t, 1); - s_smpi_subtype_t *subtype = datatype->substruct; + s_smpi_subtype_t *subtype = static_cast(datatype->substruct); if(((flags & RECV) && (flags & ACCUMULATE)) || (datatype->has_subtype == 1)){ // This part handles the problem of non-contiguous memory @@ -298,7 +298,7 @@ void smpi_empty_status(MPI_Status * status) static void smpi_mpi_request_free_voidp(void* request) { - MPI_Request req = request; + MPI_Request req = static_cast(request); smpi_mpi_request_free(&req); } @@ -351,7 +351,7 @@ void smpi_mpi_start(MPI_Request request) if (async_small_thresh == 0 && !(request->flags & RMA)) { mailbox = smpi_process_mailbox(); } - else if (request->flags & RMA || request->size < async_small_thresh){ + else if (request->flags & RMA || static_cast(request->size) < async_small_thresh){ //We have to check both mailboxes (because SSEND messages are sent to the large mbox). begin with the more appropriate one : the small one. mailbox = smpi_process_mailbox_small(); XBT_DEBUG("Is there a corresponding send already posted in the small mailbox %p (in case of SSEND)?", mailbox); @@ -399,7 +399,7 @@ void smpi_mpi_start(MPI_Request request) request, -1.0); XBT_DEBUG("recv simcall posted"); - if (async_small_thresh != 0 || request->flags & RMA) + if (async_small_thresh != 0 || (request->flags & RMA)) xbt_mutex_release(mut); } else { @@ -428,13 +428,13 @@ void smpi_mpi_start(MPI_Request request) xbt_mutex_t mut=smpi_process_remote_mailboxes_mutex(receiver); - if (async_small_thresh != 0 || request->flags & RMA) + if (async_small_thresh != 0 || (request->flags & RMA)) xbt_mutex_acquire(mut); - if (!(async_small_thresh != 0 || request->flags & RMA)) { + if (!(async_small_thresh != 0 || (request->flags & RMA))) { mailbox = smpi_process_remote_mailbox(receiver); } - else if (request->flags & RMA || request->size < async_small_thresh) { // eager mode + else if (request->flags & RMA || static_cast(request->size) < async_small_thresh) { // eager mode mailbox = smpi_process_remote_mailbox(receiver); XBT_DEBUG("Is there a corresponding recv already posted in the large mailbox %p?", mailbox); smx_synchro_t action = simcall_comm_iprobe(mailbox, 1,request->dst, request->tag, &match_send, (void*)request); @@ -460,7 +460,7 @@ void smpi_mpi_start(MPI_Request request) } void* buf = request->buf; - if ( (! (request->flags & SSEND)) && (request->size < sg_cfg_get_int("smpi/send_is_detached_thresh"))) { + if ( (! (request->flags & SSEND)) && (static_cast(request->size) < sg_cfg_get_int("smpi/send_is_detached_thresh"))) { void *oldbuf = NULL; request->detached = 1; XBT_DEBUG("Send request %p is detached", request); @@ -719,7 +719,7 @@ static void finish_wait(MPI_Request * request, MPI_Status * status) if(datatype->has_subtype == 1){ // This part handles the problem of non-contignous memory // the unserialization at the reception - s_smpi_subtype_t *subtype = datatype->substruct; + s_smpi_subtype_t *subtype = static_cast(datatype->substruct); if(req->flags & RECV) subtype->unserialize(req->buf, req->old_buf, req->real_size/smpi_datatype_size(datatype) , datatype->substruct, req->op); if(req->detached == 0) free(req->buf); diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.cpp similarity index 97% rename from src/smpi/smpi_bench.c rename to src/smpi/smpi_bench.cpp index 8ed76a50a5..ea344a06ee 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.cpp @@ -139,13 +139,13 @@ void smpi_bench_destroy(void) xbt_dict_free(&calls); } -XBT_PUBLIC(void) smpi_execute_flops_(double *flops); +extern "C" XBT_PUBLIC(void) smpi_execute_flops_(double *flops); void smpi_execute_flops_(double *flops) { smpi_execute_flops(*flops); } -XBT_PUBLIC(void) smpi_execute_(double *duration); +extern "C" XBT_PUBLIC(void) smpi_execute_(double *duration); void smpi_execute_(double *duration) { smpi_execute(*duration); @@ -327,7 +327,7 @@ void smpi_sample_1(int global, const char *file, int line, int iters, double thr if (!samples) samples = xbt_dict_new_homogeneous(free); - data = xbt_dict_get_or_null(samples, loc); + data = static_cast(xbt_dict_get_or_null(samples, loc)); if (!data) { xbt_assert(threshold>0 || iters>0, "You should provide either a positive amount of iterations to bench, or a positive maximal stderr (or both)"); @@ -362,7 +362,7 @@ int smpi_sample_2(int global, const char *file, int line) int res; xbt_assert(samples, "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!"); - data = xbt_dict_get(samples, loc); + data = static_cast(xbt_dict_get(samples, loc)); XBT_DEBUG("sample2 %s",loc); xbt_free(loc); @@ -391,7 +391,7 @@ void smpi_sample_3(int global, const char *file, int line) local_data_t *data; xbt_assert(samples, "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!"); - data = xbt_dict_get(samples, loc); + data = static_cast(xbt_dict_get(samples, loc)); XBT_DEBUG("sample3 %s",loc); xbt_free(loc); @@ -424,7 +424,7 @@ void smpi_sample_3(int global, const char *file, int line) #ifndef WIN32 static void smpi_shared_alloc_free(void *p) { - shared_data_t *data = p; + shared_data_t *data = static_cast(p); xbt_free(data->loc); xbt_free(data); } @@ -439,7 +439,7 @@ static char *smpi_shared_alloc_hash(char *loc) xbt_sha(loc, hash); hash[41] = '\0'; s[6] = '\0'; - loc = xbt_realloc(loc, 30); + loc = static_cast(xbt_realloc(loc, 30)); loc[0] = '/'; for (i = 0; i < 40; i += 6) { /* base64 encode */ memcpy(s, hash + i, 6); @@ -466,7 +466,7 @@ void *smpi_shared_malloc(size_t size, const char *file, int line) if (!allocs) { allocs = xbt_dict_new_homogeneous(smpi_shared_alloc_free); } - data = xbt_dict_get_or_null(allocs, loc); + data = static_cast(xbt_dict_get_or_null(allocs, loc)); if (!data) { fd = shm_open(loc, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); @@ -652,7 +652,7 @@ void smpi_initialize_global_memory_segments(){ return; #else - unsigned int i = 0; + int i = 0; smpi_get_executable_global_size(); XBT_DEBUG ("bss+data segment found : size %d starting at %p", diff --git a/src/smpi/smpi_c99.c b/src/smpi/smpi_c99.cpp similarity index 100% rename from src/smpi/smpi_c99.c rename to src/smpi/smpi_c99.cpp diff --git a/src/smpi/smpi_coll.c b/src/smpi/smpi_coll.cpp similarity index 96% rename from src/smpi/smpi_coll.c rename to src/smpi/smpi_coll.cpp index 4e1fdea6de..faa8d3cb8a 100644 --- a/src/smpi/smpi_coll.c +++ b/src/smpi/smpi_coll.cpp @@ -20,7 +20,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, s_mpi_coll_description_t mpi_coll_gather_description[] = { {"default", "gather default collective", - smpi_mpi_gather}, + (void*)smpi_mpi_gather}, COLL_GATHERS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -29,7 +29,7 @@ COLL_GATHERS(COLL_DESCRIPTION, COLL_COMMA), s_mpi_coll_description_t mpi_coll_allgather_description[] = { {"default", "allgather default collective", - smpi_mpi_allgather}, + (void*)smpi_mpi_allgather}, COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -37,7 +37,7 @@ COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA), s_mpi_coll_description_t mpi_coll_allgatherv_description[] = { {"default", "allgatherv default collective", - smpi_mpi_allgatherv}, + (void*)smpi_mpi_allgatherv}, COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -45,7 +45,7 @@ COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA), s_mpi_coll_description_t mpi_coll_allreduce_description[] = { {"default", "allreduce default collective", - smpi_mpi_allreduce}, + (void*)smpi_mpi_allreduce}, COLL_ALLREDUCES(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -53,7 +53,7 @@ COLL_ALLREDUCES(COLL_DESCRIPTION, COLL_COMMA), s_mpi_coll_description_t mpi_coll_reduce_scatter_description[] = { {"default", "reduce_scatter default collective", - smpi_mpi_reduce_scatter}, + (void*)smpi_mpi_reduce_scatter}, COLL_REDUCE_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -61,7 +61,7 @@ COLL_REDUCE_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), s_mpi_coll_description_t mpi_coll_scatter_description[] = { {"default", "scatter default collective", - smpi_mpi_scatter}, + (void*)smpi_mpi_scatter}, COLL_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -69,28 +69,28 @@ COLL_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), s_mpi_coll_description_t mpi_coll_barrier_description[] = { {"default", "barrier default collective", - smpi_mpi_barrier}, + (void*)smpi_mpi_barrier}, COLL_BARRIERS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; s_mpi_coll_description_t mpi_coll_alltoall_description[] = { {"default", "Ompi alltoall default collective", - smpi_coll_tuned_alltoall_ompi2}, + (void*)smpi_coll_tuned_alltoall_ompi2}, COLL_ALLTOALLS(COLL_DESCRIPTION, COLL_COMMA), {"bruck", "Alltoall Bruck (SG) collective", - smpi_coll_tuned_alltoall_bruck}, + (void*)smpi_coll_tuned_alltoall_bruck}, {"basic_linear", "Alltoall basic linear (SG) collective", - smpi_coll_tuned_alltoall_basic_linear}, + (void*)smpi_coll_tuned_alltoall_basic_linear}, {NULL, NULL, NULL} /* this array must be NULL terminated */ }; s_mpi_coll_description_t mpi_coll_alltoallv_description[] = { {"default", "Ompi alltoallv default collective", - smpi_coll_basic_alltoallv}, + (void*)smpi_coll_basic_alltoallv}, COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -98,7 +98,7 @@ COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA), s_mpi_coll_description_t mpi_coll_bcast_description[] = { {"default", "bcast default collective ", - smpi_mpi_bcast}, + (void*)smpi_mpi_bcast}, COLL_BCASTS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -106,7 +106,7 @@ COLL_BCASTS(COLL_DESCRIPTION, COLL_COMMA), s_mpi_coll_description_t mpi_coll_reduce_description[] = { {"default", "reduce default collective", - smpi_mpi_reduce}, + (void*)smpi_mpi_reduce}, COLL_REDUCES(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ }; @@ -152,9 +152,8 @@ int find_coll_description(s_mpi_coll_description_t * table, xbt_die("No collective is valid for '%s'! This is a bug.",name); name_list = xbt_strdup(table[0].name); for (i = 1; table[i].name; i++) { - name_list = - xbt_realloc(name_list, - strlen(name_list) + strlen(table[i].name) + 3); + name_list = static_cast(xbt_realloc(name_list, + strlen(name_list) + strlen(table[i].name) + 3)); strcat(name_list, ", "); strcat(name_list, table[i].name); } diff --git a/src/smpi/smpi_comm.c b/src/smpi/smpi_comm.cpp similarity index 94% rename from src/smpi/smpi_comm.c rename to src/smpi/smpi_comm.cpp index 9f38c44267..c3937c2c0c 100644 --- a/src/smpi/smpi_comm.c +++ b/src/smpi/smpi_comm.cpp @@ -67,7 +67,7 @@ MPI_Comm smpi_comm_new(MPI_Group group, MPI_Topology topo) comm->group = group; smpi_group_use(comm->group); comm->refcount=1; - comm->topoType = -1; + comm->topoType = MPI_INVALID_TOPO; comm->topo = topo; comm->intra_comm = MPI_COMM_NULL; comm->leaders_comm = MPI_COMM_NULL; @@ -121,7 +121,7 @@ int smpi_comm_dup(MPI_Comm comm, MPI_Comm* newcomm){ void* value_in; void* value_out; xbt_dict_foreach(comm->attributes, cursor, key, value_in){ - smpi_comm_key_elem elem = xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)key, sizeof(int)); + smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)key, sizeof(int))); if(elem && elem->copy_fn!=MPI_NULL_COPY_FN){ ret = elem->copy_fn(comm, *key, NULL, value_in, &value_out, &flag ); if(ret!=MPI_SUCCESS){ @@ -333,7 +333,7 @@ void smpi_comm_unuse(MPI_Comm comm){ void * value; int flag; xbt_dict_foreach(comm->attributes, cursor, key, value){ - smpi_comm_key_elem elem = xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)key); + smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)key)); if(elem && elem->delete_fn) elem->delete_fn(comm, *key, value, &flag); } @@ -483,7 +483,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ // Are the nodes uniform ? = same number of process/node int my_local_size=smpi_comm_size(comm_intra); if(smpi_comm_rank(comm_intra)==0) { - int* non_uniform_map = xbt_malloc0(sizeof(int)*leader_group_size); + int* non_uniform_map = xbt_new0(int,leader_group_size); smpi_coll_tuned_allgather_mpich(&my_local_size, 1, MPI_INT, non_uniform_map, 1, MPI_INT, leader_comm); for(i=0; i < leader_group_size; i++) { @@ -508,19 +508,19 @@ void smpi_comm_init_smp(MPI_Comm comm){ int is_blocked=1; int prev=smpi_group_rank(smpi_comm_group(comm), smpi_group_index(smpi_comm_group(comm_intra), 0)); for (i=1; iis_blocked=global_blocked; } @@ -534,7 +534,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ } int smpi_comm_attr_delete(MPI_Comm comm, int keyval){ - smpi_comm_key_elem elem = xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)&keyval, sizeof(int)); + smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)&keyval, sizeof(int))); if(!elem) return MPI_ERR_ARG; if(elem->delete_fn!=MPI_NULL_DELETE_FN){ @@ -553,7 +553,7 @@ int smpi_comm_attr_delete(MPI_Comm comm, int keyval){ } int smpi_comm_attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag){ - smpi_comm_key_elem elem = xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)&keyval, sizeof(int)); + smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)&keyval, sizeof(int))); if(!elem) return MPI_ERR_ARG; xbt_ex_t ex; @@ -575,7 +575,7 @@ int smpi_comm_attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag){ int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){ if(!smpi_comm_keyvals) smpi_comm_keyvals = xbt_dict_new(); - smpi_comm_key_elem elem = xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)&keyval, sizeof(int)); + smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)&keyval, sizeof(int))); if(!elem ) return MPI_ERR_ARG; int flag; @@ -609,7 +609,7 @@ int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delet } int smpi_comm_keyval_free(int* keyval){ - smpi_comm_key_elem elem = xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)keyval, sizeof(int)); + smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)keyval, sizeof(int))); if(!elem){ return MPI_ERR_ARG; } diff --git a/src/smpi/smpi_deployment.c b/src/smpi/smpi_deployment.cpp similarity index 93% rename from src/smpi/smpi_deployment.c rename to src/smpi/smpi_deployment.cpp index 30df611365..e832caafcc 100644 --- a/src/smpi/smpi_deployment.c +++ b/src/smpi/smpi_deployment.cpp @@ -67,9 +67,8 @@ void smpi_deployment_register_process(const char* instance_id, int rank, int ind return; } - s_smpi_mpi_instance_t* instance = xbt_dict_get_or_null(smpi_instances, instance_id); - if (!instance) - xbt_die("Error, unknown instance %s", instance_id); + s_smpi_mpi_instance_t* instance = static_cast(xbt_dict_get_or_null(smpi_instances, instance_id)); + xbt_assert(instance, "Error, unknown instance %s", instance_id); if(instance->comm_world == MPI_COMM_NULL){ MPI_Group group = smpi_group_new(instance->size); diff --git a/src/smpi/smpi_dvfs.c b/src/smpi/smpi_dvfs.cpp similarity index 88% rename from src/smpi/smpi_dvfs.c rename to src/smpi/smpi_dvfs.cpp index 6b8d99e186..c0b01ac9ed 100644 --- a/src/smpi/smpi_dvfs.c +++ b/src/smpi/smpi_dvfs.cpp @@ -86,31 +86,31 @@ typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; -XBT_PUBLIC(doublereal) smpi_get_host_power_peak_at_(integer *pstate_index); +extern "C" XBT_PUBLIC(doublereal) smpi_get_host_power_peak_at_(integer *pstate_index); doublereal smpi_get_host_power_peak_at_(integer *pstate_index) { return (doublereal)smpi_get_host_power_peak_at((int)*pstate_index); } -XBT_PUBLIC(doublereal) smpi_get_host_current_power_peak_(void); +extern "C" XBT_PUBLIC(doublereal) smpi_get_host_current_power_peak_(void); doublereal smpi_get_host_current_power_peak_(void) { return smpi_get_host_current_power_peak(); } -XBT_PUBLIC(integer) smpi_get_host_nb_pstates_(void); +extern "C" XBT_PUBLIC(integer) smpi_get_host_nb_pstates_(void); integer smpi_get_host_nb_pstates_(void) { return (integer)smpi_get_host_nb_pstates(); } -XBT_PUBLIC(void) smpi_set_host_pstate_(integer *pstate_index); +extern "C" XBT_PUBLIC(void) smpi_set_host_pstate_(integer *pstate_index); void smpi_set_host_pstate_(integer *pstate_index) { smpi_set_host_pstate((int)*pstate_index); } -XBT_PUBLIC(doublereal) smpi_get_host_consumed_energy_(void); +extern "C" XBT_PUBLIC(doublereal) smpi_get_host_consumed_energy_(void); doublereal smpi_get_host_consumed_energy_(void) { return (doublereal)smpi_get_host_consumed_energy(); diff --git a/src/smpi/smpi_f77.c b/src/smpi/smpi_f77.cpp similarity index 99% rename from src/smpi/smpi_f77.c rename to src/smpi/smpi_f77.cpp index 03e1f24f29..f946d5c592 100644 --- a/src/smpi/smpi_f77.c +++ b/src/smpi/smpi_f77.cpp @@ -45,8 +45,8 @@ typedef unsigned long int uinteger; ? (val) : (void *)(addr)) #define FORT_BOTTOM(addr) FORT_ADDR(addr, MPI_BOTTOM) #define FORT_IN_PLACE(addr) FORT_ADDR(addr, MPI_IN_PLACE) -#define FORT_STATUS_IGNORE(addr) FORT_ADDR(addr, MPI_STATUS_IGNORE) -#define FORT_STATUSES_IGNORE(addr) FORT_ADDR(addr, MPI_STATUSES_IGNORE) +#define FORT_STATUS_IGNORE(addr) static_cast(FORT_ADDR(addr, MPI_STATUS_IGNORE)) +#define FORT_STATUSES_IGNORE(addr) static_cast(FORT_ADDR(addr, MPI_STATUSES_IGNORE)) #define KEY_SIZE (sizeof(int) * 2 + 1) @@ -786,7 +786,7 @@ void mpi_win_set_name_ (int* win, char * name, int* ierr, int size){ size --; name++; } - char* tname = xbt_malloc((size+1)*sizeof(char)); + char* tname = xbt_new(char,size+1); strncpy(tname, name, size); tname[size]='\0'; *ierr = MPI_Win_set_name(smpi_win_f2c(*win), tname); @@ -813,7 +813,7 @@ void mpi_info_set_( int *info, char *key, char *value, int* ierr, unsigned int k keylen --; key++; } - char* tkey = xbt_malloc((keylen+1)*sizeof(char)); + char* tkey = xbt_new(char,keylen+1); strncpy(tkey, key, keylen); tkey[keylen]='\0'; @@ -822,7 +822,7 @@ void mpi_info_set_( int *info, char *key, char *value, int* ierr, unsigned int k valuelen --; value++; } - char* tvalue = xbt_malloc((valuelen+1)*sizeof(char)); + char* tvalue = xbt_new(char,valuelen+1); strncpy(tvalue, value, valuelen); tvalue[valuelen]='\0'; @@ -835,7 +835,7 @@ void mpi_info_get_ (int* info,char *key,int* valuelen, char *value, int *flag, i while(*key==' '){//handle leading blanks keylen --; key++; - } char* tkey = xbt_malloc((keylen+1)*sizeof(char)); + } char* tkey = xbt_new(char,keylen+1); strncpy(tkey, key, keylen); tkey[keylen]='\0'; *ierr = MPI_Info_get(smpi_info_f2c(*info),tkey,*valuelen, value, flag); @@ -913,7 +913,7 @@ void mpi_type_dup_ (int* datatype, int* newdatatype, int* ierr){ } void mpi_type_set_name_ (int* datatype, char * name, int* ierr, int size){ - char* tname = xbt_malloc((size+1)*sizeof(char)); + char* tname = xbt_new(char, size+1); strncpy(tname, name, size); tname[size]='\0'; *ierr = MPI_Type_set_name(smpi_type_f2c(*datatype), tname); @@ -1570,7 +1570,7 @@ void mpi_exscan_ (void *sendbuf, void *recvbuf, int* count, int* datatype, int* } void mpi_comm_set_name_ (int* comm, char* name, int* ierr, int size){ - char* tname = xbt_malloc((size+1)*sizeof(char)); + char* tname = xbt_new(char, size+1); strncpy(tname, name, size); tname[size]='\0'; *ierr = MPI_Comm_set_name (smpi_comm_f2c(*comm), tname); @@ -1640,7 +1640,7 @@ void mpi_info_get_valuelen_ ( int* info, char *key, int *valuelen, int *flag, in keylen --; key++; } - char* tkey = xbt_malloc((keylen+1)*sizeof(char)); + char* tkey = xbt_new(char, keylen+1); strncpy(tkey, key, keylen); tkey[keylen]='\0'; *ierr = MPI_Info_get_valuelen( smpi_info_f2c(*info), tkey, valuelen, flag); @@ -1653,7 +1653,7 @@ void mpi_info_delete_ (int* info, char *key, int* ierr, unsigned int keylen){ keylen --; key++; } - char* tkey = xbt_malloc((keylen+1)*sizeof(char)); + char* tkey = xbt_new(char, keylen+1); strncpy(tkey, key, keylen); tkey[keylen]='\0'; *ierr = MPI_Info_delete(smpi_info_f2c(*info), tkey); @@ -1666,7 +1666,7 @@ void mpi_info_get_nkeys_ ( int* info, int *nkeys, int* ierr){ void mpi_info_get_nthkey_ ( int* info, int* n, char *key, int* ierr, unsigned int keylen){ *ierr = MPI_Info_get_nthkey( smpi_info_f2c(*info), *n, key); - int i = 0; + unsigned int i = 0; for (i=strlen(key); ireplaying = 0; //xbt_free(simcall_process_get_data(proc)); - simdata_process_t simdata = simcall_process_get_data(proc); + simdata_process_t simdata = static_cast(simcall_process_get_data(proc)); simdata->data = data; if (*argc > 3) { @@ -124,8 +124,8 @@ void smpi_process_init(int *argc, char ***argv) XBT_DEBUG("<%d> New process in the game: %p", index, proc); } - if (smpi_process_data() == NULL) - xbt_die("smpi_process_data() returned NULL. You probably gave a NULL parameter to MPI_Init. Although it's required by MPI-2, this is currently not supported by SMPI."); + xbt_assert(smpi_process_data(), + "smpi_process_data() returned NULL. You probably gave a NULL parameter to MPI_Init. Although it's required by MPI-2, this is currently not supported by SMPI."); } void smpi_process_destroy(void) @@ -218,8 +218,8 @@ int smpi_global_size(void) smpi_process_data_t smpi_process_data(void) { - simdata_process_t simdata = SIMIX_process_self_get_data(SIMIX_process_self()); - return simdata->data; + simdata_process_t simdata = static_cast(SIMIX_process_self_get_data(SIMIX_process_self())); + return static_cast(simdata->data); } smpi_process_data_t smpi_process_remote_data(int index) @@ -537,13 +537,16 @@ int __attribute__ ((weak)) main(int argc, char **argv) #endif +extern "C" { static void smpi_init_logs(){ /* Connect log categories. See xbt/log.c */ + XBT_LOG_CONNECT(smpi); /* Keep this line as soon as possible in this function: xbt_log_appender_file.c depends on it DO NOT connect this in XBT or so, or it will be useless to xbt_log_appender_file.c */ + XBT_LOG_CONNECT(instr_smpi); XBT_LOG_CONNECT(smpi_base); XBT_LOG_CONNECT(smpi_bench); @@ -558,9 +561,8 @@ static void smpi_init_logs(){ XBT_LOG_CONNECT(smpi_pmpi); XBT_LOG_CONNECT(smpi_replay); XBT_LOG_CONNECT(smpi_rma); - } - +} static void smpi_init_options(){ int gather_id = find_coll_description(mpi_coll_gather_description, diff --git a/src/smpi/smpi_group.c b/src/smpi/smpi_group.cpp similarity index 98% rename from src/smpi/smpi_group.c rename to src/smpi/smpi_group.cpp index 33f99023c0..22fd814ff5 100644 --- a/src/smpi/smpi_group.c +++ b/src/smpi/smpi_group.cpp @@ -119,7 +119,7 @@ int smpi_group_rank(MPI_Group group, int index) char * key; int size = asprintf(&key, "%d", index); if (size!=-1){ - ptr_rank = xbt_dict_get_or_null(group->index_to_rank_map, key); + ptr_rank = static_cast(xbt_dict_get_or_null(group->index_to_rank_map, key)); xbt_free(key); }else xbt_die("could not allocate memory for asprintf"); diff --git a/src/smpi/smpi_mpi.c b/src/smpi/smpi_mpi.cpp similarity index 100% rename from src/smpi/smpi_mpi.c rename to src/smpi/smpi_mpi.cpp diff --git a/src/smpi/smpi_mpi_dt.c b/src/smpi/smpi_mpi_dt.cpp similarity index 97% rename from src/smpi/smpi_mpi_dt.c rename to src/smpi/smpi_mpi_dt.cpp index 9342827d2a..e7097e30da 100644 --- a/src/smpi/smpi_mpi_dt.c +++ b/src/smpi/smpi_mpi_dt.cpp @@ -183,7 +183,7 @@ int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t) memcpy(*new_t, datatype, sizeof(s_smpi_mpi_datatype_t)); if (datatype->has_subtype){ //FIXME: may copy too much information. - (*new_t)->substruct=xbt_malloc(sizeof(s_smpi_mpi_struct_t)); + (*new_t)->substruct=xbt_new(s_smpi_mpi_struct_t,1); memcpy((*new_t)->substruct, datatype->substruct, sizeof(s_smpi_mpi_struct_t)); } if(datatype->name) @@ -196,7 +196,7 @@ int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t) void* value_in; void* value_out; xbt_dict_foreach(datatype->attributes, cursor, key, value_in){ - smpi_type_key_elem elem = xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)key, sizeof(int)); + smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)key, sizeof(int))); if(elem && elem->copy_fn!=MPI_NULL_COPY_FN){ ret = elem->copy_fn(datatype, *key, NULL, value_in, &value_out, &flag ); if(ret!=MPI_SUCCESS){ @@ -259,21 +259,21 @@ int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, } else if (sendtype->has_subtype == 0) { - s_smpi_subtype_t *subtype = recvtype->substruct; + s_smpi_subtype_t *subtype = static_cast(recvtype->substruct); 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; + s_smpi_subtype_t *subtype = static_cast(sendtype->substruct); subtype->serialize(sendbuf, recvbuf, sendcount/smpi_datatype_size(sendtype), subtype); }else{ - s_smpi_subtype_t *subtype = sendtype->substruct; + s_smpi_subtype_t *subtype = static_cast(sendtype->substruct); void * buf_tmp = xbt_malloc(count); subtype->serialize( sendbuf, buf_tmp,count/smpi_datatype_size(sendtype), subtype); - subtype = recvtype->substruct; + subtype = static_cast(recvtype->substruct); subtype->unserialize( buf_tmp, recvbuf,count/smpi_datatype_size(recvtype), subtype, MPI_REPLACE); free(buf_tmp); @@ -386,7 +386,7 @@ s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride, } void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int has_subtype, - void *struct_type, int flags){ + void *struct_type, int flags){ MPI_Datatype new_t= xbt_new(s_smpi_mpi_datatype_t,1); new_t->name = NULL; new_t->size = size; @@ -413,7 +413,7 @@ void smpi_datatype_free(MPI_Datatype* type){ void * value; int flag; xbt_dict_foreach((*type)->attributes, cursor, key, value){ - smpi_type_key_elem elem = xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)key, sizeof(int)); + smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)key, sizeof(int))); if(elem && elem->delete_fn) elem->delete_fn(*type,*key, value, &flag); } @@ -1060,7 +1060,8 @@ int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Dat if(indices[i]+smpi_datatype_lb(old_type)ub) ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_type); - if ( (i< count -1) && (indices[i]+blocklens[i]*smpi_datatype_size(old_type) != indices[i+1]) )contiguous=0; + if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast(smpi_datatype_size(old_type)) != indices[i+1]) ) + contiguous=0; } if (old_type->has_subtype == 1 || lb!=0) contiguous=0; @@ -1247,7 +1248,8 @@ int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datat if(!forced_lb && indices[i]+smpi_datatype_lb(old_types[i])ub) ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_types[i]); - if ( (i< count -1) && (indices[i]+blocklens[i]*smpi_datatype_size(old_types[i]) != indices[i+1]) )contiguous=0; + if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast(smpi_datatype_size(old_types[i])) != indices[i+1]) ) + contiguous=0; } if(!contiguous){ @@ -1676,7 +1678,7 @@ void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len, } int smpi_type_attr_delete(MPI_Datatype type, int keyval){ - smpi_type_key_elem elem = xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)&keyval, sizeof(int)); + smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)&keyval, sizeof(int))); if(!elem) return MPI_ERR_ARG; if(elem->delete_fn!=MPI_NULL_DELETE_FN){ @@ -1695,7 +1697,7 @@ int smpi_type_attr_delete(MPI_Datatype type, int keyval){ } int smpi_type_attr_get(MPI_Datatype type, int keyval, void* attr_value, int* flag){ - smpi_type_key_elem elem = xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)&keyval, sizeof(int)); + smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)&keyval, sizeof(int))); if(!elem) return MPI_ERR_ARG; xbt_ex_t ex; @@ -1717,7 +1719,7 @@ int smpi_type_attr_get(MPI_Datatype type, int keyval, void* attr_value, int* fla int smpi_type_attr_put(MPI_Datatype type, int keyval, void* attr_value){ if(!smpi_type_keyvals) smpi_type_keyvals = xbt_dict_new(); - smpi_type_key_elem elem = xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)&keyval, sizeof(int)); + smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)&keyval, sizeof(int))); if(!elem ) return MPI_ERR_ARG; int flag; @@ -1751,7 +1753,7 @@ int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delet } int smpi_type_keyval_free(int* keyval){ - smpi_type_key_elem elem = xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)keyval, sizeof(int)); + smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)keyval, sizeof(int))); if(!elem){ return MPI_ERR_ARG; } @@ -1762,7 +1764,7 @@ int smpi_type_keyval_free(int* keyval){ 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) + if (outcount - *position < incount*static_cast(size)) return MPI_ERR_BUFFER; smpi_datatype_copy(inbuf, incount, type, (char*)outbuf + *position, outcount, MPI_CHAR); @@ -1771,7 +1773,7 @@ int smpi_mpi_pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int } 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); + int size = static_cast(smpi_datatype_size(type)); if (outcount*size> insize) return MPI_ERR_BUFFER; smpi_datatype_copy((char*)inbuf + *position, insize, MPI_CHAR, diff --git a/src/smpi/smpi_mpi_dt_private.h b/src/smpi/smpi_mpi_dt_private.h index 79822efded..ef5f86e618 100644 --- a/src/smpi/smpi_mpi_dt_private.h +++ b/src/smpi/smpi_mpi_dt_private.h @@ -13,6 +13,8 @@ #include "private.h" +SG_BEGIN_DECL() + #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 */ #define DT_FLAG_CONTIGUOUS 0x0004 /**< contiguous datatype */ @@ -213,4 +215,6 @@ XBT_PRIVATE s_smpi_mpi_struct_t* smpi_datatype_struct_create(int* block_lengths, int block_count, MPI_Datatype* old_types); +SG_END_DECL() + #endif diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.cpp similarity index 99% rename from src/smpi/smpi_pmpi.c rename to src/smpi/smpi_pmpi.cpp index ba912ad870..91a5790c18 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.cpp @@ -1826,7 +1826,7 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, if(!known) dt_size_recv = smpi_datatype_size(recvtype); if((smpi_comm_rank(comm)==root)){ - extra->recvcounts= xbt_malloc(size*sizeof(int)); + extra->recvcounts= xbt_new(int,size); for(i=0; i< size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]*dt_size_recv; } @@ -1930,7 +1930,7 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int dt_size_recv = 1; if(!known) dt_size_recv = smpi_datatype_size(recvtype); - extra->recvcounts= xbt_malloc(size*sizeof(int)); + extra->recvcounts= xbt_new(int, size); for(i=0; i< size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]*dt_size_recv; @@ -2030,7 +2030,7 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, if(!known) dt_size_send = smpi_datatype_size(sendtype); if((smpi_comm_rank(comm)==root)){ - extra->sendcounts= xbt_malloc(size*sizeof(int)); + extra->sendcounts= xbt_new(int, size); for(i=0; i< size; i++)//copy data to avoid bad free extra->sendcounts[i] = sendcounts[i]*dt_size_send; } @@ -2244,7 +2244,7 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, if(!known) dt_size_send = smpi_datatype_size(datatype); extra->send_size = 0; - extra->recvcounts= xbt_malloc(size*sizeof(int)); + extra->recvcounts= xbt_new(int, size); for(i=0; i< size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]*dt_size_send; TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); @@ -2290,7 +2290,7 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount, if(!known) dt_size_send = smpi_datatype_size(datatype); extra->send_size = 0; - extra->recvcounts= xbt_malloc(count*sizeof(int)); + extra->recvcounts= xbt_new(int, count); for(i=0; i< count; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcount*dt_size_send; @@ -2373,8 +2373,8 @@ int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps, extra->type = TRACING_ALLTOALLV; extra->send_size = 0; extra->recv_size = 0; - extra->recvcounts= xbt_malloc(size*sizeof(int)); - extra->sendcounts= xbt_malloc(size*sizeof(int)); + extra->recvcounts= xbt_new(int, size); + extra->sendcounts= xbt_new(int, size); int known=0; extra->datatype1 = encode_datatype(sendtype, &known); int dt_size_send = 1; @@ -3255,7 +3255,7 @@ int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){ *flag=FALSE; char* tmpvalue=(char*)xbt_dict_get_or_null(info->info_dict, key); if(tmpvalue){ - memcpy(value,tmpvalue, (strlen(tmpvalue) + 1 < valuelen) ? + memcpy(value,tmpvalue, (strlen(tmpvalue) + 1 < static_cast(valuelen)) ? strlen(tmpvalue) + 1 : valuelen); *flag=TRUE; } @@ -3315,7 +3315,7 @@ int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){ } int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){ - if (info == NULL || key == NULL || valuelen <0) + if (info == NULL || key == NULL || *valuelen <0) return MPI_ERR_ARG; *flag=FALSE; char* tmpvalue=(char*)xbt_dict_get_or_null(info->info_dict, key); diff --git a/src/smpi/smpi_replay.c b/src/smpi/smpi_replay.cpp similarity index 98% rename from src/smpi/smpi_replay.c rename to src/smpi/smpi_replay.cpp index f1f5caa32a..4648703d05 100644 --- a/src/smpi/smpi_replay.c +++ b/src/smpi/smpi_replay.cpp @@ -62,7 +62,7 @@ void* smpi_get_tmp_sendbuffer(int size){ if (!smpi_process_get_replaying()) return xbt_malloc(size); if (sendbuffer_size(xbt_realloc(sendbuffer,size)); sendbuffer_size=size; } return sendbuffer; @@ -72,7 +72,7 @@ void* smpi_get_tmp_recvbuffer(int size){ if (!smpi_process_get_replaying()) return xbt_malloc(size); if (recvbuffer_size(xbt_realloc(recvbuffer,size)); recvbuffer_size=size; } return recvbuffer; @@ -470,7 +470,7 @@ static void action_waitall(const char *const *action){ xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), NULL); xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), NULL); xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), NULL); - for (i = 0; i < count_requests; i++) { + for (i = 0; (int)i < count_requests; i++) { if(requests[i]){ int *asrc = xbt_new(int, 1); int *adst = xbt_new(int, 1); @@ -500,7 +500,7 @@ static void action_waitall(const char *const *action){ smpi_mpi_waitall(count_requests, requests, status); - for (i = 0; i < count_requests; i++) { + for (i = 0; (int)i < count_requests; i++) { int src_traced, dst_traced, is_wait_for_receive; xbt_dynar_get_cpy(srcs, i, &src_traced); xbt_dynar_get_cpy(dsts, i, &dst_traced); @@ -776,7 +776,7 @@ static void action_gatherv(const char *const *action) { instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); extra->type = TRACING_GATHERV; extra->send_size = send_size; - extra->recvcounts= xbt_malloc(comm_size*sizeof(int)); + extra->recvcounts= xbt_new(int,comm_size); for(i=0; i< comm_size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]; extra->root = root; @@ -835,7 +835,7 @@ static void action_reducescatter(const char *const *action) { instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); extra->type = TRACING_REDUCE_SCATTER; extra->send_size = 0; - extra->recvcounts= xbt_malloc(comm_size*sizeof(int)); + extra->recvcounts= xbt_new(int, comm_size); for(i=0; i< comm_size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]; extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); @@ -952,7 +952,7 @@ static void action_allgatherv(const char *const *action) { instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); extra->type = TRACING_ALLGATHERV; extra->send_size = sendcount; - extra->recvcounts= xbt_malloc(comm_size*sizeof(int)); + extra->recvcounts= xbt_new(int, comm_size); for(i=0; i< comm_size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]; extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); @@ -1019,8 +1019,8 @@ static void action_allToAllv(const char *const *action) { int rank = smpi_process_index(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); extra->type = TRACING_ALLTOALLV; - extra->recvcounts= xbt_malloc(comm_size*sizeof(int)); - extra->sendcounts= xbt_malloc(comm_size*sizeof(int)); + extra->recvcounts= xbt_new(int, comm_size); + extra->sendcounts= xbt_new(int, comm_size); extra->num_processes = comm_size; for(i=0; i< comm_size; i++){//copy data to avoid bad free diff --git a/src/smpi/smpi_rma.c b/src/smpi/smpi_rma.cpp similarity index 97% rename from src/smpi/smpi_rma.c rename to src/smpi/smpi_rma.cpp index 859bd918db..c03f2b0313 100644 --- a/src/smpi/smpi_rma.c +++ b/src/smpi/smpi_rma.cpp @@ -50,7 +50,7 @@ MPI_Win smpi_mpi_win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info win->opened = 0; win->group = MPI_GROUP_NULL; win->requests = xbt_dynar_new(sizeof(MPI_Request), NULL); - win->connected_wins = xbt_malloc0(comm_size*sizeof(MPI_Win)); + win->connected_wins = xbt_new0(MPI_Win, comm_size); win->connected_wins[rank] = win; if(rank==0){ @@ -132,7 +132,7 @@ int smpi_mpi_win_fence( int assert, MPI_Win win){ if (req->flags & PREPARED) smpi_mpi_start(req); } - MPI_Request* treqs = xbt_dynar_to_array(reqs); + MPI_Request* treqs = static_cast(xbt_dynar_to_array(reqs)); smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE); xbt_free(treqs); win->requests=xbt_dynar_new(sizeof(MPI_Request), NULL); @@ -382,7 +382,7 @@ int smpi_mpi_win_complete(MPI_Win win){ if (req->flags & PREPARED) smpi_mpi_start(req); } - MPI_Request* treqs = xbt_dynar_to_array(reqqs); + MPI_Request* treqs = static_cast(xbt_dynar_to_array(reqqs)); smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE); xbt_free(treqs); win->requests=xbt_dynar_new(sizeof(MPI_Request), NULL); @@ -433,7 +433,7 @@ int smpi_mpi_win_wait(MPI_Win win){ if (req->flags & PREPARED) smpi_mpi_start(req); } - MPI_Request* treqs = xbt_dynar_to_array(reqqs); + MPI_Request* treqs = static_cast(xbt_dynar_to_array(reqqs)); smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE); xbt_free(treqs); win->requests=xbt_dynar_new(sizeof(MPI_Request), NULL); diff --git a/src/smpi/smpi_topo.c b/src/smpi/smpi_topo.cpp similarity index 96% rename from src/smpi/smpi_topo.c rename to src/smpi/smpi_topo.cpp index 55ba2b840b..cf596ca4a7 100644 --- a/src/smpi/smpi_topo.c +++ b/src/smpi/smpi_topo.cpp @@ -67,7 +67,7 @@ void smpi_topo_destroy(MPI_Topology topo) { } MPI_Topology smpi_topo_create(MPIR_Topo_type kind) { - MPI_Topology newTopo = xbt_malloc(sizeof(*newTopo)); + MPI_Topology newTopo = static_cast(xbt_malloc(sizeof(*newTopo))); newTopo->kind = kind; // Allocate and initialize the right topo should be done by the caller return newTopo; @@ -93,12 +93,12 @@ void smpi_cart_topo_destroy(MPIR_Cart_Topology cart) { MPI_Topology smpi_cart_topo_create(int ndims) { MPI_Topology newTopo = smpi_topo_create(MPI_CART); - MPIR_Cart_Topology newCart = xbt_malloc(sizeof(*newCart)); + MPIR_Cart_Topology newCart = static_cast(xbt_malloc(sizeof(*newCart))); newCart->nnodes = 0; newCart->ndims = ndims; - newCart->dims = xbt_malloc(ndims * sizeof(*newCart->dims)); - newCart->periodic = xbt_malloc(ndims * sizeof(*newCart->periodic)); - newCart->position = xbt_malloc(ndims * sizeof(*newCart->position)); + newCart->dims = xbt_new(int, ndims); + newCart->periodic = xbt_new(int, ndims); + newCart->position = xbt_new(int, ndims); newTopo->topo.cart = newCart; return newTopo; } @@ -178,8 +178,8 @@ int smpi_mpi_cart_sub(MPI_Comm comm, const int remain_dims[], MPI_Comm *newcomm) } if (newNDims > 0) { - newDims = xbt_malloc(newNDims * sizeof(*newDims)); - newPeriodic = xbt_malloc(newNDims * sizeof(*newPeriodic)); + newDims = xbt_new(int, newNDims); + newPeriodic = xbt_new(int, newNDims); // that should not segfault for (i = 0 ; j < newNDims ; i++) { diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index f511724b45..db533c0db4 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -227,24 +227,24 @@ set(SMPI_SRC src/smpi/colls/smpi_intel_mpi_selector.c src/smpi/colls/smpi_openmpi_selector.c src/smpi/colls/smpi_mvapich2_selector.c - src/smpi/instr_smpi.c - src/smpi/smpi_base.c - src/smpi/smpi_bench.c + src/smpi/instr_smpi.cpp + src/smpi/smpi_base.cpp + src/smpi/smpi_bench.cpp src/smpi/smpi_memory.cpp - src/smpi/smpi_c99.c - src/smpi/smpi_coll.c - src/smpi/smpi_comm.c - src/smpi/smpi_deployment.c - src/smpi/smpi_dvfs.c - src/smpi/smpi_global.c - src/smpi/smpi_group.c - src/smpi/smpi_mpi.c - src/smpi/smpi_mpi_dt.c - src/smpi/smpi_pmpi.c - src/smpi/smpi_replay.c - src/smpi/smpi_rma.c - src/smpi/smpi_topo.c - src/smpi/smpi_f77.c + src/smpi/smpi_c99.cpp + src/smpi/smpi_coll.cpp + src/smpi/smpi_comm.cpp + src/smpi/smpi_deployment.cpp + src/smpi/smpi_dvfs.cpp + src/smpi/smpi_global.cpp + src/smpi/smpi_group.cpp + src/smpi/smpi_mpi.cpp + src/smpi/smpi_mpi_dt.cpp + src/smpi/smpi_pmpi.cpp + src/smpi/smpi_replay.cpp + src/smpi/smpi_rma.cpp + src/smpi/smpi_topo.cpp + src/smpi/smpi_f77.cpp ) set(XBT_SRC -- 2.20.1