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;
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);
#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);
XBT_PUBLIC(void) xbt_sha(const char *data, char *hash);
+SG_END_DECL()
#endif /* XBT_HASH_H */
#define _SMPI_INTERFACE_H
#include "smpi/smpi.h"
-
+SG_BEGIN_DECL()
/** \brief MPI collective description
*/
extern XBT_PRIVATE double smpi_iprobe_sleep;
extern XBT_PRIVATE double smpi_test_sleep;
+SG_END_DECL()
+
#endif /* _SMPI_INTERFAC_H */
#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);
COLL_BARRIERS(COLL_PROTO, COLL_NOsep)
+SG_END_DECL()
#endif
//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_dynar_t>(xbt_dict_get_or_null(keys, aux));
if(!xbt_dynar_is_empty(d)){
{
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_dynar_t>(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__);
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<char*>(xbt_dict_get_or_null (process_category, processid));
}
void TRACE_smpi_alloc()
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);
request = xbt_new(s_smpi_mpi_request_t, 1);
- s_smpi_subtype_t *subtype = datatype->substruct;
+ s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(datatype->substruct);
if(((flags & RECV) && (flags & ACCUMULATE)) || (datatype->has_subtype == 1)){
// This part handles the problem of non-contiguous memory
static void smpi_mpi_request_free_voidp(void* request)
{
- MPI_Request req = request;
+ MPI_Request req = static_cast<MPI_Request>(request);
smpi_mpi_request_free(&req);
}
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<int>(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);
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 {
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<int>(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);
}
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<int>(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);
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<s_smpi_subtype_t*>(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);
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);
if (!samples)
samples = xbt_dict_new_homogeneous(free);
- data = xbt_dict_get_or_null(samples, loc);
+ data = static_cast<local_data_t *>(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)");
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<local_data_t *>(xbt_dict_get(samples, loc));
XBT_DEBUG("sample2 %s",loc);
xbt_free(loc);
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<local_data_t *>(xbt_dict_get(samples, loc));
XBT_DEBUG("sample3 %s",loc);
xbt_free(loc);
#ifndef WIN32
static void smpi_shared_alloc_free(void *p)
{
- shared_data_t *data = p;
+ shared_data_t *data = static_cast<shared_data_t *>(p);
xbt_free(data->loc);
xbt_free(data);
}
xbt_sha(loc, hash);
hash[41] = '\0';
s[6] = '\0';
- loc = xbt_realloc(loc, 30);
+ loc = static_cast<char *>(xbt_realloc(loc, 30));
loc[0] = '/';
for (i = 0; i < 40; i += 6) { /* base64 encode */
memcpy(s, hash + i, 6);
if (!allocs) {
allocs = xbt_dict_new_homogeneous(smpi_shared_alloc_free);
}
- data = xbt_dict_get_or_null(allocs, loc);
+ data = static_cast<shared_data_t *>(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);
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",
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 */
};
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 */
};
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 */
};
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 */
};
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 */
};
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 */
};
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 */
};
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 */
};
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 */
};
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<char*>(xbt_realloc(name_list,
+ strlen(name_list) + strlen(table[i].name) + 3));
strcat(name_list, ", ");
strcat(name_list, table[i].name);
}
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;
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<smpi_comm_key_elem>(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){
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<smpi_comm_key_elem>(xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)key));
if(elem && elem->delete_fn)
elem->delete_fn(comm, *key, value, &flag);
}
// 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++) {
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; i<my_local_size; i++){
- int this=smpi_group_rank(smpi_comm_group(comm),smpi_group_index(smpi_comm_group(comm_intra), i));
- if(this!=prev+1){
+ int that=smpi_group_rank(smpi_comm_group(comm),smpi_group_index(smpi_comm_group(comm_intra), i));
+ if(that!=prev+1){
is_blocked=0;
break;
}
- prev = this;
+ prev = that;
}
int global_blocked;
smpi_mpi_allreduce(&is_blocked, &(global_blocked), 1,
MPI_INT, MPI_LAND, comm);
- if(MPI_COMM_WORLD==SMPI_UNINITIALIZED || comm==MPI_COMM_WORLD){
+ if(MPI_COMM_WORLD==MPI_COMM_UNINITIALIZED || comm==MPI_COMM_WORLD){
if(smpi_comm_rank(comm)==0){
comm->is_blocked=global_blocked;
}
}
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<smpi_comm_key_elem>(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){
}
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<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)&keyval, sizeof(int)));
if(!elem)
return MPI_ERR_ARG;
xbt_ex_t ex;
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<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)&keyval, sizeof(int)));
if(!elem )
return MPI_ERR_ARG;
int flag;
}
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<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)keyval, sizeof(int)));
if(!elem){
return MPI_ERR_ARG;
}
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<s_smpi_mpi_instance_t*>(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);
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();
? (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<MPI_Status*>(FORT_ADDR(addr, MPI_STATUS_IGNORE))
+#define FORT_STATUSES_IGNORE(addr) static_cast<MPI_Status*>(FORT_ADDR(addr, MPI_STATUSES_IGNORE))
#define KEY_SIZE (sizeof(int) * 2 + 1)
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);
keylen --;
key++;
}
- char* tkey = xbt_malloc((keylen+1)*sizeof(char));
+ char* tkey = xbt_new(char,keylen+1);
strncpy(tkey, key, keylen);
tkey[keylen]='\0';
valuelen --;
value++;
}
- char* tvalue = xbt_malloc((valuelen+1)*sizeof(char));
+ char* tvalue = xbt_new(char,valuelen+1);
strncpy(tvalue, value, valuelen);
tvalue[valuelen]='\0';
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);
}
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);
}
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);
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);
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);
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); i<keylen; i++)
key[i]=' ';
}
data->replaying = 0;
//xbt_free(simcall_process_get_data(proc));
- simdata_process_t simdata = simcall_process_get_data(proc);
+ simdata_process_t simdata = static_cast<simdata_process_t>(simcall_process_get_data(proc));
simdata->data = data;
if (*argc > 3) {
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)
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<simdata_process_t>(SIMIX_process_self_get_data(SIMIX_process_self()));
+ return static_cast<smpi_process_data_t>(simdata->data);
}
smpi_process_data_t smpi_process_remote_data(int index)
#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);
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,
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<int*>(xbt_dict_get_or_null(group->index_to_rank_map, key));
xbt_free(key);
}else
xbt_die("could not allocate memory for asprintf");
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)
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<smpi_type_key_elem>(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){
}
else if (sendtype->has_subtype == 0)
{
- s_smpi_subtype_t *subtype = recvtype->substruct;
+ s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(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<s_smpi_subtype_t*>(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<s_smpi_subtype_t*>(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<s_smpi_subtype_t*>(recvtype->substruct);
subtype->unserialize( buf_tmp, recvbuf,count/smpi_datatype_size(recvtype), subtype, MPI_REPLACE);
free(buf_tmp);
}
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;
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<smpi_type_key_elem>(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);
}
if(indices[i]+smpi_datatype_lb(old_type)<lb) lb = indices[i]+smpi_datatype_lb(old_type);
if(indices[i]+blocklens[i]*smpi_datatype_ub(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<int>(smpi_datatype_size(old_type)) != indices[i+1]) )
+ contiguous=0;
}
if (old_type->has_subtype == 1 || lb!=0)
contiguous=0;
if(!forced_lb && indices[i]+smpi_datatype_lb(old_types[i])<lb) lb = indices[i];
if(!forced_ub && indices[i]+blocklens[i]*smpi_datatype_ub(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<int>(smpi_datatype_size(old_types[i])) != indices[i+1]) )
+ contiguous=0;
}
if(!contiguous){
}
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<smpi_type_key_elem>(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){
}
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<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)&keyval, sizeof(int)));
if(!elem)
return MPI_ERR_ARG;
xbt_ex_t ex;
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<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)&keyval, sizeof(int)));
if(!elem )
return MPI_ERR_ARG;
int flag;
}
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<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, (const char*)keyval, sizeof(int)));
if(!elem){
return MPI_ERR_ARG;
}
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<int>(size))
return MPI_ERR_BUFFER;
smpi_datatype_copy(inbuf, incount, type,
(char*)outbuf + *position, outcount, MPI_CHAR);
}
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<int>(smpi_datatype_size(type));
if (outcount*size> insize)
return MPI_ERR_BUFFER;
smpi_datatype_copy((char*)inbuf + *position, insize, MPI_CHAR,
#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 */
int block_count,
MPI_Datatype* old_types);
+SG_END_DECL()
+
#endif
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;
}
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;
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;
}
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);
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;
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;
*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<size_t>(valuelen)) ?
strlen(tmpvalue) + 1 : valuelen);
*flag=TRUE;
}
}
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);
if (!smpi_process_get_replaying())
return xbt_malloc(size);
if (sendbuffer_size<size){
- sendbuffer=xbt_realloc(sendbuffer,size);
+ sendbuffer=static_cast<char*>(xbt_realloc(sendbuffer,size));
sendbuffer_size=size;
}
return sendbuffer;
if (!smpi_process_get_replaying())
return xbt_malloc(size);
if (recvbuffer_size<size){
- recvbuffer=xbt_realloc(recvbuffer,size);
+ recvbuffer=static_cast<char*>(xbt_realloc(recvbuffer,size));
recvbuffer_size=size;
}
return recvbuffer;
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);
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);
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;
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);
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);
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
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){
if (req->flags & PREPARED) smpi_mpi_start(req);
}
- MPI_Request* treqs = xbt_dynar_to_array(reqs);
+ MPI_Request* treqs = static_cast<MPI_Request*>(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);
if (req->flags & PREPARED) smpi_mpi_start(req);
}
- MPI_Request* treqs = xbt_dynar_to_array(reqqs);
+ MPI_Request* treqs = static_cast<MPI_Request*>(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);
if (req->flags & PREPARED) smpi_mpi_start(req);
}
- MPI_Request* treqs = xbt_dynar_to_array(reqqs);
+ MPI_Request* treqs = static_cast<MPI_Request*>(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);
}
MPI_Topology smpi_topo_create(MPIR_Topo_type kind) {
- MPI_Topology newTopo = xbt_malloc(sizeof(*newTopo));
+ MPI_Topology newTopo = static_cast<MPI_Topology>(xbt_malloc(sizeof(*newTopo)));
newTopo->kind = kind;
// Allocate and initialize the right topo should be done by the caller
return newTopo;
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<MPIR_Cart_Topology>(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;
}
}
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++) {
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