> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'SMPI'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP-gamma' to '4194304'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'smpi/cpu-threshold' to '-1'
-> [Tremblay:0:(1) 0.164463] [smpi_replay/VERBOSE] 0 send 1 1e6 0.164463
> [Jupiter:1:(2) 0.164463] [smpi_replay/VERBOSE] 1 recv 0 1e6 0.164463
+> [Tremblay:0:(1) 0.164463] [smpi_replay/VERBOSE] 0 send 1 1e6 0.164463
> [Jupiter:1:(2) 13.271310] [smpi_replay/VERBOSE] 1 compute 1e9 13.106847
> [Jupiter:1:(2) 13.271310] [smpi_replay/VERBOSE] 1 Isend 0 1e6 0.000000
> [Jupiter:1:(2) 13.271310] [smpi_replay/VERBOSE] 1 Irecv 0 1e6 0.000000
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'SMPI'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP-gamma' to '4194304'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'smpi/cpu-threshold' to '-1'
-> [Tremblay:0:(1) 1.491472] [smpi_replay/VERBOSE] 0 send 1 1e7 1.491472
> [Jupiter:1:(2) 1.491472] [smpi_replay/VERBOSE] 1 recv 0 1e7 1.491472
+> [Tremblay:0:(1) 1.491472] [smpi_replay/VERBOSE] 0 send 1 1e7 1.491472
> [Tremblay:0:(1) 1.493448] [smpi_replay/VERBOSE] 0 barrier 0.001976
> [Jupiter:1:(2) 1.494910] [smpi_replay/VERBOSE] 1 barrier 0.003438
> [Fafard:2:(3) 1.495424] [smpi_replay/VERBOSE] 2 barrier 1.495424
> [0.000000] [msg_test/INFO] Initializing instance 1 of size 32
> [0.000000] [msg_test/INFO] Initializing instance 2 of size 32
> [0.000000] [smpi_kernel/INFO] You did not set the power of the host running the simulation. The timings will certainly not be accurate. Use the option "--cfg=smpi/running-power:<flops>" to set its value.Check http://simgrid.org/simgrid/latest/doc/options.html#options_smpi_bench for more information.
-> [Jupiter:2:(52) 1140688.626959] [smpi_replay/INFO] Simulation time 1124371.274298
-> [1140688.626959] [msg_test/INFO] Simulation time 1.14069e+06
+> [Jupiter:2:(52) 1140688.585057] [smpi_replay/INFO] Simulation time 1124371.232395
+> [1140688.585057] [msg_test/INFO] Simulation time 1.14069e+06
+
const char *current = smpi_colors[i];
while ((current != NULL)){
if (strcmp (state, current) == 0 //exact match
- || strstr(target, current) ){//as substring
+ || strstr(target, current) != 0 ){//as substring
ret = smpi_colors[i+1];
break;
}
void TRACE_internal_smpi_set_category (const char *category)
{
- if (!TRACE_smpi_is_enabled()) return;
+ if (!TRACE_smpi_is_enabled())
+ return;
//declare category
TRACE_category (category);
const char *TRACE_internal_smpi_get_category (void)
{
- if (!TRACE_smpi_is_enabled()) return NULL;
+ if (!TRACE_smpi_is_enabled())
+ return NULL;
char processid[INSTR_DEFAULT_STR_SIZE];
snprintf (processid, INSTR_DEFAULT_STR_SIZE, "%p", SIMIX_process_self());
void TRACE_smpi_init(int rank)
{
- if (!TRACE_smpi_is_enabled()) return;
+ if (!TRACE_smpi_is_enabled())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
void TRACE_smpi_finalize(int rank)
{
- if (!TRACE_smpi_is_enabled()) return;
+ if (!TRACE_smpi_is_enabled())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
container_t container = PJ_container_get(smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE));
type_t type = PJ_type_get ("MPI_STATE", container->type);
const char *color = instr_find_color (operation);
val_t value = PJ_value_get_or_new (operation, color, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, (void*)extra);
+ new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_collective_out(int rank, int root, const char *operation)
{
- if (!TRACE_smpi_is_enabled()) return;
+ if (!TRACE_smpi_is_enabled())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
void TRACE_smpi_computing_init(int rank)
{
//first use, initialize the color in the trace
- //TODO : check with lucas and Pierre how to generalize this approach
- //to avoid unnecessary access to the color array
- if (!TRACE_smpi_is_enabled() || !TRACE_smpi_is_computing()) return;
+ if (!TRACE_smpi_is_enabled() || !TRACE_smpi_is_computing())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
val_t value = PJ_value_get_or_new ("computing", NULL, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, (void*)extra);
+ new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_computing_out(int rank)
{
- if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_computing()) return;
+ if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_computing())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
void TRACE_smpi_sleeping_init(int rank)
{
- //first use, initialize the color in the trace
- //TODO : check with lucas and Pierre how to generalize this approach
- //to avoid unnecessary access to the color array
- if (!TRACE_smpi_is_enabled() || !TRACE_smpi_is_sleeping()) return;
+ //first use, initialize the color in the trace
+ if (!TRACE_smpi_is_enabled() || !TRACE_smpi_is_sleeping())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
val_t value = PJ_value_get_or_new ("sleeping", NULL, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, (void*)extra);
+ new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_sleeping_out(int rank)
{
- if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_sleeping()) return;
+ if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_sleeping())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
val_t value = PJ_value_get_or_new ("test", NULL, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, (void*)extra);
+ new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_testing_out(int rank)
{
- if (!TRACE_smpi_is_enabled()) return;
+ if (!TRACE_smpi_is_enabled())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
const char *color = instr_find_color (operation);
val_t value = PJ_value_get_or_new (operation, color, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, (void*)extra);
+ new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation)
{
- if (!TRACE_smpi_is_enabled()) return;
+ if (!TRACE_smpi_is_enabled())
+ return;
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
void TRACE_smpi_send(int rank, int src, int dst, int size)
{
- if (!TRACE_smpi_is_enabled()) return;
+ if (!TRACE_smpi_is_enabled())
+ return;
char key[INSTR_DEFAULT_STR_SIZE] = {0};
TRACE_smpi_put_key(src, dst, key, INSTR_DEFAULT_STR_SIZE);
void TRACE_smpi_recv(int rank, int src, int dst)
{
- if (!TRACE_smpi_is_enabled()) return;
+ if (!TRACE_smpi_is_enabled())
+ return;
char key[INSTR_DEFAULT_STR_SIZE] = {0};
TRACE_smpi_get_key(src, dst, key, INSTR_DEFAULT_STR_SIZE);
XBT_PRIVATE void smpi_global_destroy(void);
XBT_PRIVATE double smpi_mpi_wtime(void);
-XBT_PRIVATE int is_datatype_valid(MPI_Datatype datatype);
+XBT_PRIVATE bool is_datatype_valid(MPI_Datatype datatype);
XBT_PRIVATE size_t smpi_datatype_size(MPI_Datatype datatype);
XBT_PRIVATE MPI_Aint smpi_datatype_lb(MPI_Datatype datatype);
XBT_PRIVATE MPI_Op smpi_op_new(MPI_User_function * function, int commute);
XBT_PRIVATE int smpi_op_is_commute(MPI_Op op);
XBT_PRIVATE void smpi_op_destroy(MPI_Op op);
-XBT_PRIVATE void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len, MPI_Datatype * datatype);
+XBT_PRIVATE void smpi_op_apply(MPI_Op op, const void *invec, void *inoutvec, int *len, MPI_Datatype * datatype);
XBT_PRIVATE MPI_Group smpi_group_new(int size);
XBT_PRIVATE MPI_Group smpi_group_copy(MPI_Group origin);
sleeptime = ((request->flags & ISEND) != 0)? smpi_ois(request->size) : smpi_os(request->size);
}
- if(sleeptime != 0.0){
+ if(sleeptime >= 0.0){
simcall_process_sleep(sleeptime);
XBT_DEBUG("sending size of %zu : sleep %f ", request->size, smpi_os(request->size));
}
if(fstat(fd, &st) < 0) {
xbt_die("Could not stat fd %d: %s", fd, strerror(errno));
}
- return (size_t)st.st_size;
+ return static_cast<size_t>(st.st_size);
}
#ifndef WIN32
char loc[PTR_STRLEN];
shared_metadata_t meta;
- if(size > shm_size(fd)) {
- if(ftruncate(fd, (off_t)size) < 0) {
+ if(size > shm_size(fd) && (ftruncate(fd, static_cast<off_t>(size)) < 0)) {
xbt_die("Could not truncate fd %d to %zu: %s", fd, size, strerror(errno));
- }
}
mem = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
double speedup = 1;
xbt_os_timer_t timer = smpi_process_timer();
xbt_os_threadtimer_stop(timer);
-// smpi_switch_data_segment(smpi_process_count());
if (smpi_process_get_sampling()) {
XBT_CRITICAL("Cannot do recursive benchmarks.");
XBT_CRITICAL("Are you trying to make a call to MPI within a SMPI_SAMPLE_ block?");
unsigned int smpi_sleep(unsigned int secs)
{
- return private_sleep((double)secs);
+ return private_sleep(static_cast<double>(secs));
}
int smpi_usleep(useconds_t usecs)
{
- return (int)private_sleep((double)usecs / 1000000.0);
+ return static_cast<int>(private_sleep(static_cast<double>(usecs) / 1000000.0));
}
int smpi_gettimeofday(struct timeval *tv, void* tz)
smpi_bench_end();
now = SIMIX_get_clock();
if (tv) {
- tv->tv_sec = (time_t)now;
+ tv->tv_sec = static_cast<time_t>(now);
#ifdef WIN32
- tv->tv_usec = (useconds_t)((now - tv->tv_sec) * 1e6);
+ tv->tv_usec = static_cast<useconds_t>((now - tv->tv_sec) * 1e6);
#else
- tv->tv_usec = (suseconds_t)((now - tv->tv_sec) * 1e6);
+ tv->tv_usec = static_cast<suseconds_t>((now - tv->tv_sec) * 1e6);
#endif
}
smpi_bench_begin();
smpi_bench_end();
double resolution = (1/sg_surf_precision);
smpi_bench_begin();
- return (unsigned long long)resolution;
+ return static_cast<unsigned long long>(resolution);
}
unsigned long long smpi_rastro_timestamp (void)
unsigned long long sec = (unsigned long long)now;
unsigned long long pre = (now - sec) * smpi_rastro_resolution();
smpi_bench_begin();
- return (unsigned long long)sec * smpi_rastro_resolution() + pre;
+ return static_cast<unsigned long long>(sec) * smpi_rastro_resolution() + pre;
}
/* ****************************** Functions related to the SMPI_SAMPLE_ macros ************************************/
smpi_bench_end(); /* Take time from previous, unrelated computation into account */
smpi_process_set_sampling(1);
- if (!samples)
+ if (samples==NULL)
samples = xbt_dict_new_homogeneous(free);
data = static_cast<local_data_t *>(xbt_dict_get_or_null(samples, loc));
- if (!data) {
+ if (data==NULL) {
xbt_assert(threshold>0 || iters>0,
"You should provide either a positive amount of iterations to bench, or a positive maximal stderr (or both)");
- data = (local_data_t *) xbt_new(local_data_t, 1);
+ data = static_cast<local_data_t *>( xbt_new(local_data_t, 1));
data->count = 0;
data->sum = 0.0;
data->sum_pow2 = 0.0;
sample = xbt_os_timer_elapsed(smpi_process_timer());
data->sum += sample;
data->sum_pow2 += sample * sample;
- n = (double)data->count;
+ n = static_cast<double>(data->count);
data->mean = data->sum / n;
data->relstderr = sqrt((data->sum_pow2 / n - data->mean * data->mean) / n) / data->mean;
- if (!sample_enough_benchs(data)) {
+ if (sample_enough_benchs(data)==0) {
data->mean = sample; // Still in benching process; We want sample_2 to simulate the exact time of this loop
// occurrence before leaving, not the mean over the history
}
snprintf(shmname, 31, "/shmalloc%p", &*data);
fd = shm_open(shmname, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
- switch(errno) {
- case EEXIST:
- xbt_die("Please cleanup /dev/shm/%s", shmname);
- default:
- xbt_die("An unhandled error occurred while opening %s. shm_open: %s", shmname, strerror(errno));
- }
+ if(errno==EEXIST)
+ xbt_die("Please cleanup /dev/shm/%s", shmname);
+ else
+ xbt_die("An unhandled error occurred while opening %s. shm_open: %s", shmname, strerror(errno));
}
data->second.fd = fd;
data->second.count = 1;
xbt_ex_t ex;
int known = 0;
- if (!calls) {
+ if (calls==NULL) {
calls = xbt_dict_new_homogeneous(NULL);
}
TRY {
char* loc = bprintf("%s:%s", func, input);
void* data;
- if(!calls) {
+ if(calls==NULL) {
calls = xbt_dict_new_homogeneous(NULL);
}
data = xbt_dict_get(calls, loc);
- free(loc);
+ xbt_free(loc);
return data;
}
calls = xbt_dict_new_homogeneous(NULL);
}
xbt_dict_set(calls, loc, data, NULL);
- free(loc);
+ xbt_free(loc);
return data;
}
}
smpi_privatisation_regions =
- (smpi_privatisation_region_t) malloc(smpi_process_count() * sizeof(struct s_smpi_privatisation_region));
+ static_cast<smpi_privatisation_region_t>( xbt_malloc(smpi_process_count() * sizeof(struct s_smpi_privatisation_region)));
for (int i=0; i< smpi_process_count(); i++){
//create SIMIX_process_count() mappings of this size with the same data inside
void smpi_register_static(void* arg, void_f_pvoid_t free_fn)
{
s_smpi_static_t elm = { arg, free_fn };
- if (!registered_static_stack)
+ if (registered_static_stack==NULL)
registered_static_stack = xbt_dynar_new(sizeof(s_smpi_static_t), NULL);
xbt_dynar_push_as(registered_static_stack, s_smpi_static_t, elm);
}
void smpi_free_static(void)
{
- while (!xbt_dynar_is_empty(registered_static_stack)) {
+ while (xbt_dynar_is_empty(registered_static_stack)==0) {
s_smpi_static_t elm =
xbt_dynar_pop_as(registered_static_stack, s_smpi_static_t);
elm.free_fn(elm.ptr);
static int smpi_compare_rankmap(const void *a, const void *b)
{
- const int* x = (const int*)a;
- const int* y = (const int*)b;
+ const int* x = static_cast<const int*>(a);
+ const int* y = static_cast<const int*>(b);
if (x[1] < y[1]) {
return -1;
MPI_Group cp=smpi_group_copy(smpi_comm_group(comm));
(*newcomm) = smpi_comm_new(cp, smpi_comm_topo(comm));
int ret = MPI_SUCCESS;
- //todo: faire en sorte que ça fonctionne avec un communicator dupliqué (refaire un init_smp ?)
-
- /* MPI_Comm tmp=smpi_comm_get_intra_comm(comm);
- if( tmp != MPI_COMM_NULL)
- smpi_comm_set_intra_comm((*newcomm), smpi_comm_dup(tmp));
- tmp=smpi_comm_get_leaders_comm(comm);
- if( tmp != MPI_COMM_NULL)
- smpi_comm_set_leaders_comm((*newcomm), smpi_comm_dup(tmp));
- if(comm->non_uniform_map !=NULL){
- (*newcomm)->non_uniform_map=
- xbt_malloc(smpi_comm_size(comm->leaders_comm)*sizeof(int));
- memcpy((*newcomm)->non_uniform_map,
- comm->non_uniform_map,smpi_comm_size(comm->leaders_comm)*sizeof(int) );
- }
- if(comm->leaders_map !=NULL){
- (*newcomm)->leaders_map=xbt_malloc(smpi_comm_size(comm)*sizeof(int));
- memcpy((*newcomm)->leaders_map,
- comm->leaders_map,smpi_comm_size(comm)*sizeof(int) );
- }*/
+
if(comm->attributes !=NULL){
(*newcomm)->attributes=xbt_dict_new();
xbt_dict_cursor_t cursor = NULL;
void* value_out;
xbt_dict_foreach(comm->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, (const char*)key, sizeof(int)));
- if(elem && elem->copy_fn!=MPI_NULL_COPY_FN){
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(key), sizeof(int)));
+ if(elem!=NULL && elem->copy_fn!=MPI_NULL_COPY_FN){
ret = elem->copy_fn(comm, *key, NULL, value_in, &value_out, &flag );
if(ret!=MPI_SUCCESS){
smpi_comm_destroy(*newcomm);
return ret;
}
if(flag)
- xbt_dict_set_ext((*newcomm)->attributes, (const char*)key, sizeof(int),value_out, NULL);
+ xbt_dict_set_ext((*newcomm)->attributes, reinterpret_cast<const char*>(key), sizeof(int),value_out, NULL);
}
}
}
if (comm == MPI_COMM_UNINITIALIZED)
comm = smpi_process_comm_world();
if(comm == MPI_COMM_WORLD) {
- strcpy(name, "WORLD");
+ strncpy(name, "WORLD",5);
*len = 5;
} else {
*len = snprintf(name, MPI_MAX_NAME_STRING, "%p", comm);
MPI_Group* group_snd;
MPI_Request* requests;
- group_root = group_out = NULL;
+ group_root = NULL;
+ group_out = NULL;
group = smpi_comm_group(comm);
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
group_snd = xbt_new(MPI_Group, size);
rankmap = xbt_new(int, 2 * size);
for(i = 0; i < size; i++) {
- if(recvbuf[2 * i] == MPI_UNDEFINED) {
- continue;
- }
- count = 0;
- for(j = i + 1; j < size; j++) {
- if(recvbuf[2 * i] == recvbuf[2 * j]) {
- recvbuf[2 * j] = MPI_UNDEFINED;
- rankmap[2 * count] = j;
- rankmap[2 * count + 1] = recvbuf[2 * j + 1];
- count++;
+ if(recvbuf[2 * i] != MPI_UNDEFINED) {
+
+ count = 0;
+ for(j = i + 1; j < size; j++) {
+ if(recvbuf[2 * i] == recvbuf[2 * j]) {
+ recvbuf[2 * j] = MPI_UNDEFINED;
+ rankmap[2 * count] = j;
+ rankmap[2 * count + 1] = recvbuf[2 * j + 1];
+ count++;
+ }
}
- }
- /* Add self in the group */
- recvbuf[2 * i] = MPI_UNDEFINED;
- rankmap[2 * count] = i;
- rankmap[2 * count + 1] = recvbuf[2 * i + 1];
- count++;
- qsort(rankmap, count, 2 * sizeof(int), &smpi_compare_rankmap);
- group_out = smpi_group_new(count);
- if(i == 0) {
- group_root = group_out; /* Save root's group */
- }
- for(j = 0; j < count; j++) {
- index = smpi_group_index(group, rankmap[2 * j]);
- smpi_group_set_mapping(group_out, index, j);
- }
- requests = xbt_new(MPI_Request, count);
- reqs = 0;
- for(j = 0; j < count; j++) {
- if(rankmap[2 * j] != 0) {
- group_snd[reqs]=smpi_group_copy(group_out);
- requests[reqs] = smpi_mpi_isend(&(group_snd[reqs]), 1, MPI_PTR, rankmap[2 * j], system_tag, comm);
- reqs++;
+ /* Add self in the group */
+ recvbuf[2 * i] = MPI_UNDEFINED;
+ rankmap[2 * count] = i;
+ rankmap[2 * count + 1] = recvbuf[2 * i + 1];
+ count++;
+ qsort(rankmap, count, 2 * sizeof(int), &smpi_compare_rankmap);
+ group_out = smpi_group_new(count);
+ if(i == 0) {
+ group_root = group_out; /* Save root's group */
}
+ for(j = 0; j < count; j++) {
+ index = smpi_group_index(group, rankmap[2 * j]);
+ smpi_group_set_mapping(group_out, index, j);
+ }
+ requests = xbt_new(MPI_Request, count);
+ reqs = 0;
+ for(j = 0; j < count; j++) {
+ if(rankmap[2 * j] != 0) {
+ group_snd[reqs]=smpi_group_copy(group_out);
+ requests[reqs] = smpi_mpi_isend(&(group_snd[reqs]), 1, MPI_PTR, rankmap[2 * j], system_tag, comm);
+ reqs++;
+ }
+ }
+ if(i != 0) {
+ smpi_group_destroy(group_out);
+ }
+ smpi_mpi_waitall(reqs, requests, MPI_STATUS_IGNORE);
+ xbt_free(requests);
}
- if(i != 0) {
- smpi_group_destroy(group_out);
- }
- smpi_mpi_waitall(reqs, requests, MPI_STATUS_IGNORE);
- xbt_free(requests);
}
xbt_free(recvbuf);
xbt_free(rankmap);
smpi_mpi_recv(&group_out, 1, MPI_PTR, 0, system_tag, comm, MPI_STATUS_IGNORE);
} /* otherwise, exit with group_out == NULL */
}
- return group_out ? smpi_comm_new(group_out, NULL) : MPI_COMM_NULL;
+ return group_out!=NULL ? smpi_comm_new(group_out, NULL) : MPI_COMM_NULL;
}
void smpi_comm_use(MPI_Comm comm){
int flag;
xbt_dict_foreach(comm->attributes, cursor, key, value){
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)
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null(smpi_comm_keyvals, reinterpret_cast<const char*>(key)));
+ if(elem!=NULL && elem->delete_fn)
elem->delete_fn(comm, *key, value, &flag);
}
xbt_dict_free(&comm->attributes);
static int compare_ints (const void *a, const void *b)
{
- const int *da = (const int *) a;
- const int *db = (const int *) b;
+ const int *da = static_cast<const int *>(a);
+ const int *db = static_cast<const int *>(b);
- return (*da > *db) - (*da < *db);
+ return static_cast<int>(*da > *db) - static_cast<int>(*da < *db);
}
void smpi_comm_init_smp(MPI_Comm comm){
//get the indexes of all processes sharing the same simix host
xbt_swag_t process_list = SIMIX_host_self()->processes();
int intra_comm_size = 0;
- //only one process/node, disable SMP support and return
-// if(intra_comm_size==1){
-// smpi_comm_set_intra_comm(comm, MPI_COMM_SELF);
-// //smpi_comm_set_leaders_comm(comm, comm);
-// smpi_process_set_comm_intra(MPI_COMM_SELF);
-// return;
-// }
int i =0;
int min_index=INT_MAX;//the minimum index will be the leader
smx_process_t process = NULL;
xbt_swag_foreach(process, process_list) {
- //is_in_comm=0;
int index = SIMIX_process_get_PID(process) -1;
if(smpi_group_rank(smpi_comm_group(comm), index)!=MPI_UNDEFINED){
i=0;
process = NULL;
xbt_swag_foreach(process, process_list) {
- //is_in_comm=0;
int index = SIMIX_process_get_PID(process) -1;
if(smpi_group_rank(smpi_comm_group(comm), index)!=MPI_UNDEFINED){
smpi_group_set_mapping(group_intra, index, i);
}
MPI_Comm comm_intra = smpi_comm_new(group_intra, NULL);
- //MPI_Comm shmem_comm = smpi_process_comm_intra();
- //int intra_rank = smpi_comm_rank(shmem_comm);
-
- //if(smpi_process_index()==min_index)
leader=min_index;
- int * leaders_map= (int*)xbt_malloc0(sizeof(int)*comm_size);
- int * leader_list= (int*)xbt_malloc0(sizeof(int)*comm_size);
+ int * leaders_map= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
+ int * leader_list= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
for(i=0; i<comm_size; i++){
leader_list[i]=-1;
}
smpi_switch_data_segment(smpi_process_index());
}
- if(!comm->leaders_map){
+ if(comm->leaders_map==NULL){
comm->leaders_map= leaders_map;
}else{
xbt_free(leaders_map);
already_done=1;
}
}
- if(!already_done){
+ if(already_done==0){
leader_list[leader_group_size]=comm->leaders_map[i];
leader_group_size++;
}
smpi_comm_set_intra_comm(comm, comm_intra);
//create intracommunicator
- // smpi_comm_set_intra_comm(comm, smpi_comm_split(comm, *(int*)SIMIX_host_self(), comm_rank));
}else{
for (i=0; i< leader_group_size;i++)
smpi_group_set_mapping(leaders_group, leader_list[i], i);
break;
}
}
- if(!is_uniform && smpi_comm_is_uniform(comm)){
+ if(is_uniform==0 && smpi_comm_is_uniform(comm)!=0){
comm->non_uniform_map= non_uniform_map;
}else{
xbt_free(non_uniform_map);
int smpi_comm_attr_delete(MPI_Comm comm, int keyval){
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)
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
+ if(elem==NULL)
return MPI_ERR_ARG;
if(elem->delete_fn!=MPI_NULL_DELETE_FN){
void * value;
int flag;
if(smpi_comm_attr_get(comm, keyval, &value, &flag)==MPI_SUCCESS){
int ret = elem->delete_fn(comm, keyval, value, &flag);
- if(ret!=MPI_SUCCESS) return ret;
+ if(ret!=MPI_SUCCESS)
+ return ret;
}
}
if(comm->attributes==NULL)
return MPI_ERR_ARG;
- xbt_dict_remove_ext(comm->attributes, (const char*)&keyval, sizeof(int));
+ xbt_dict_remove_ext(comm->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
return MPI_SUCCESS;
}
int smpi_comm_attr_get(MPI_Comm comm, 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, (const char*)&keyval, sizeof(int)));
- if(!elem)
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
+ if(elem==NULL)
return MPI_ERR_ARG;
xbt_ex_t ex;
if(comm->attributes==NULL){
return MPI_SUCCESS;
}
TRY {
- *(void**)attr_value = xbt_dict_get_ext(comm->attributes, (const char*)&keyval, sizeof(int));
+ *static_cast<void**>(attr_value) = xbt_dict_get_ext(comm->attributes,
+ reinterpret_cast<const char*>(&keyval), sizeof(int));
*flag=1;
} CATCH(ex) {
*flag=0;
}
int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){
- if(!smpi_comm_keyvals)
- smpi_comm_keyvals = xbt_dict_new();
+ if(smpi_comm_keyvals==NULL)
+ smpi_comm_keyvals = xbt_dict_new();
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 )
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
+ if(elem==NULL)
return MPI_ERR_ARG;
int flag;
void* value;
smpi_comm_attr_get(comm, keyval, &value, &flag);
- if(flag && elem->delete_fn!=MPI_NULL_DELETE_FN){
+ if(flag!=0 && elem->delete_fn!=MPI_NULL_DELETE_FN){
int ret = elem->delete_fn(comm, keyval, value, &flag);
- if(ret!=MPI_SUCCESS) return ret;
+ if(ret!=MPI_SUCCESS)
+ return ret;
}
if(comm->attributes==NULL)
comm->attributes=xbt_dict_new();
- xbt_dict_set_ext(comm->attributes, (const char*)&keyval, sizeof(int), attr_value, NULL);
+ xbt_dict_set_ext(comm->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int), attr_value, NULL);
return MPI_SUCCESS;
}
int smpi_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)
- smpi_comm_keyvals = xbt_dict_new();
+ if(smpi_comm_keyvals==NULL)
+ smpi_comm_keyvals = xbt_dict_new();
- smpi_comm_key_elem value = (smpi_comm_key_elem) xbt_new0(s_smpi_mpi_comm_key_elem_t,1);
+ 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, (const char*)keyval, sizeof(int),(void*)value, NULL);
+ xbt_dict_set_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int),static_cast<void*>(value), NULL);
comm_keyval_id++;
return MPI_SUCCESS;
}
int smpi_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, (const char*)keyval, sizeof(int)));
- if(!elem){
+ static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int)));
+ if(elem==NULL)
return MPI_ERR_ARG;
- }
- xbt_dict_remove_ext(smpi_comm_keyvals, (const char*)keyval, sizeof(int));
+ xbt_dict_remove_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int));
xbt_free(elem);
return MPI_SUCCESS;
}
}
static void smpi_init_fortran_types(){
- if(!comm_lookup){
+ if(comm_lookup == NULL){
comm_lookup = xbt_dict_new_homogeneous(NULL);
smpi_comm_c2f(MPI_COMM_WORLD);
group_lookup = xbt_dict_new_homogeneous(NULL);
info_lookup = xbt_dict_new_homogeneous(NULL);
smpi_type_c2f(MPI_BYTE);//MPI_BYTE
smpi_type_c2f(MPI_CHAR);//MPI_CHARACTER
- #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
+#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
smpi_type_c2f(MPI_INT);//MPI_LOGICAL
smpi_type_c2f(MPI_INT);//MPI_INTEGER
- #else
+#else
smpi_type_c2f(MPI_LONG);//MPI_LOGICAL
smpi_type_c2f(MPI_LONG);//MPI_INTEGER
- #endif
+#endif
smpi_type_c2f(MPI_INT8_T);//MPI_INTEGER1
smpi_type_c2f(MPI_INT16_T);//MPI_INTEGER2
smpi_type_c2f(MPI_INT32_T);//MPI_INTEGER4
smpi_type_c2f(MPI_DOUBLE);//MPI_DOUBLE_PRECISION
smpi_type_c2f(MPI_C_FLOAT_COMPLEX);//MPI_COMPLEX
smpi_type_c2f(MPI_C_DOUBLE_COMPLEX);//MPI_DOUBLE_COMPLEX
- #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
+#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
smpi_type_c2f(MPI_2INT);//MPI_2INTEGER
- #else
+#else
smpi_type_c2f(MPI_2LONG);//MPI_2INTEGER
- #endif
+#endif
smpi_type_c2f(MPI_UINT8_T);//MPI_LOGICAL1
smpi_type_c2f(MPI_UINT16_T);//MPI_LOGICAL2
smpi_type_c2f(MPI_UINT32_T);//MPI_LOGICAL4
smpi_init_fortran_types();
if(comm == -2) {
return MPI_COMM_SELF;
- }else if(comm==0){
+ } else if(comm==0){
return MPI_COMM_WORLD;
- } else if(comm_lookup && comm >= 0) {
+ } else if(comm_lookup != NULL && comm >= 0) {
char key[KEY_SIZE];
- MPI_Comm tmp = (MPI_Comm)xbt_dict_get_or_null(comm_lookup,get_key_id(key, comm));
+ MPI_Comm tmp = static_cast<MPI_Comm>(xbt_dict_get_or_null(comm_lookup,get_key_id(key, comm)));
return tmp != NULL ? tmp : MPI_COMM_NULL ;
+ } else {
+ return MPI_COMM_NULL;
}
- return MPI_COMM_NULL;
}
int smpi_group_c2f(MPI_Group group) {
smpi_init_fortran_types();
if(group == -2) {
return MPI_GROUP_EMPTY;
- } else if(group_lookup && group >= 0) {
+ } else if(group_lookup != NULL && group >= 0) {
char key[KEY_SIZE];
- return (MPI_Group)xbt_dict_get_or_null(group_lookup, get_key(key, group));
+ return static_cast<MPI_Group>(xbt_dict_get_or_null(group_lookup, get_key(key, group)));
+ } else {
+ return MPI_GROUP_NULL;
}
- return MPI_GROUP_NULL;
}
static void free_group(int group) {
MPI_Request smpi_request_f2c(int req) {
smpi_init_fortran_types();
char key[KEY_SIZE];
- if(req==MPI_FORTRAN_REQUEST_NULL)return MPI_REQUEST_NULL;
- return (MPI_Request)xbt_dict_get(request_lookup, get_key_id(key, req));
+ if(req==MPI_FORTRAN_REQUEST_NULL)
+ return MPI_REQUEST_NULL;
+ return static_cast<MPI_Request>(xbt_dict_get(request_lookup, get_key_id(key, req)));
}
static void free_request(int request) {
MPI_Datatype smpi_type_f2c(int datatype) {
smpi_init_fortran_types();
char key[KEY_SIZE];
- return datatype >= 0 ? (MPI_Datatype)xbt_dict_get_or_null(datatype_lookup, get_key(key, datatype)): MPI_DATATYPE_NULL;
+ return datatype >= 0 ? static_cast<MPI_Datatype>(xbt_dict_get_or_null(datatype_lookup, get_key(key, datatype))): MPI_DATATYPE_NULL;
}
static void free_datatype(int datatype) {
MPI_Op smpi_op_f2c(int op) {
smpi_init_fortran_types();
char key[KEY_SIZE];
- return op >= 0 ? (MPI_Op)xbt_dict_get_or_null(op_lookup, get_key(key, op)): MPI_OP_NULL;
+ return op >= 0 ? static_cast<MPI_Op>(xbt_dict_get_or_null(op_lookup, get_key(key, op))): MPI_OP_NULL;
}
static void free_op(int op) {
MPI_Win smpi_win_f2c(int win) {
smpi_init_fortran_types();
char key[KEY_SIZE];
- return win >= 0 ? (MPI_Win)xbt_dict_get_or_null(win_lookup, get_key(key, win)) : MPI_WIN_NULL;
+ return win >= 0 ? static_cast<MPI_Win>(xbt_dict_get_or_null(win_lookup, get_key(key, win))) : MPI_WIN_NULL;
}
static void free_win(int win) {
MPI_Info smpi_info_f2c(int info) {
smpi_init_fortran_types();
char key[KEY_SIZE];
- return info >= 0 ? (MPI_Info)xbt_dict_get_or_null(info_lookup, get_key(key, info)) : MPI_INFO_NULL;
+ return info >= 0 ? static_cast<MPI_Info>(xbt_dict_get_or_null(info_lookup, get_key(key, info))) : MPI_INFO_NULL;
}
static void free_info(int info) {
void mpi_send_init_(void *buf, int* count, int* datatype, int* dst, int* tag, int* comm, int* request, int* ierr) {
MPI_Request req;
- buf = (char *) FORT_BOTTOM(buf);
+ buf = static_cast<char *>(FORT_BOTTOM(buf));
*ierr = MPI_Send_init(buf, *count, smpi_type_f2c(*datatype), *dst, *tag, smpi_comm_f2c(*comm), &req);
if(*ierr == MPI_SUCCESS) {
*request = smpi_request_c2f(req);
void mpi_isend_(void *buf, int* count, int* datatype, int* dst, int* tag, int* comm, int* request, int* ierr) {
MPI_Request req;
- buf = (char *) FORT_BOTTOM(buf);
+ buf = static_cast<char *>(FORT_BOTTOM(buf));
*ierr = MPI_Isend(buf, *count, smpi_type_f2c(*datatype), *dst, *tag, smpi_comm_f2c(*comm), &req);
if(*ierr == MPI_SUCCESS) {
*request = smpi_request_c2f(req);
void mpi_irsend_(void *buf, int* count, int* datatype, int* dst, int* tag, int* comm, int* request, int* ierr) {
MPI_Request req;
- buf = (char *) FORT_BOTTOM(buf);
+ buf = static_cast<char *>(FORT_BOTTOM(buf));
*ierr = MPI_Irsend(buf, *count, smpi_type_f2c(*datatype), *dst, *tag, smpi_comm_f2c(*comm), &req);
if(*ierr == MPI_SUCCESS) {
*request = smpi_request_c2f(req);
}
void mpi_send_(void* buf, int* count, int* datatype, int* dst, int* tag, int* comm, int* ierr) {
- buf = (char *) FORT_BOTTOM(buf);
+ buf = static_cast<char *>(FORT_BOTTOM(buf));
*ierr = MPI_Send(buf, *count, smpi_type_f2c(*datatype), *dst, *tag, smpi_comm_f2c(*comm));
}
void mpi_rsend_(void* buf, int* count, int* datatype, int* dst, int* tag, int* comm, int* ierr) {
- buf = (char *) FORT_BOTTOM(buf);
+ buf = static_cast<char *>(FORT_BOTTOM(buf));
*ierr = MPI_Rsend(buf, *count, smpi_type_f2c(*datatype), *dst, *tag, smpi_comm_f2c(*comm));
}
void mpi_sendrecv_(void* sendbuf, int* sendcount, int* sendtype, int* dst, int* sendtag, void *recvbuf, int* recvcount,
int* recvtype, int* src, int* recvtag, int* comm, MPI_Status* status, int* ierr) {
- sendbuf = (char *) FORT_BOTTOM(sendbuf);
- recvbuf = (char *) FORT_BOTTOM(recvbuf);
+ sendbuf = static_cast<char *>( FORT_BOTTOM(sendbuf));
+ recvbuf = static_cast<char *>( FORT_BOTTOM(recvbuf));
*ierr = MPI_Sendrecv(sendbuf, *sendcount, smpi_type_f2c(*sendtype), *dst, *sendtag, recvbuf, *recvcount,
smpi_type_f2c(*recvtype), *src, *recvtag, smpi_comm_f2c(*comm), FORT_STATUS_IGNORE(status));
}
void mpi_recv_init_(void *buf, int* count, int* datatype, int* src, int* tag, int* comm, int* request, int* ierr) {
MPI_Request req;
- buf = (char *) FORT_BOTTOM(buf);
+ buf = static_cast<char *>( FORT_BOTTOM(buf));
*ierr = MPI_Recv_init(buf, *count, smpi_type_f2c(*datatype), *src, *tag, smpi_comm_f2c(*comm), &req);
if(*ierr == MPI_SUCCESS) {
*request = smpi_request_c2f(req);
void mpi_irecv_(void *buf, int* count, int* datatype, int* src, int* tag, int* comm, int* request, int* ierr) {
MPI_Request req;
- buf = (char *) FORT_BOTTOM(buf);
+ buf = static_cast<char *>( FORT_BOTTOM(buf));
*ierr = MPI_Irecv(buf, *count, smpi_type_f2c(*datatype), *src, *tag, smpi_comm_f2c(*comm), &req);
if(*ierr == MPI_SUCCESS) {
*request = smpi_request_c2f(req);
}
void mpi_recv_(void* buf, int* count, int* datatype, int* src, int* tag, int* comm, MPI_Status* status, int* ierr) {
- buf = (char *) FORT_BOTTOM(buf);
+ buf = static_cast<char *>( FORT_BOTTOM(buf));
*ierr = MPI_Recv(buf, *count, smpi_type_f2c(*datatype), *src, *tag, smpi_comm_f2c(*comm), status);
}
reqs[i] = smpi_request_f2c(requests[i]);
}
*ierr = MPI_Startall(*count, reqs);
- free(reqs);
+ xbt_free(reqs);
}
void mpi_wait_(int* request, MPI_Status* status, int* ierr) {
free_request(requests[*index]);
requests[*index]=MPI_FORTRAN_REQUEST_NULL;
}
- free(reqs);
+ xbt_free(reqs);
}
void mpi_waitall_(int* count, int* requests, MPI_Status* status, int* ierr) {
}
}
- free(reqs);
+ xbt_free(reqs);
}
void mpi_barrier_(int* comm, int* ierr) {
}
void mpi_reduce_(void* sendbuf, void* recvbuf, int* count, int* datatype, int* op, int* root, int* comm, int* ierr) {
- sendbuf = (char *) FORT_IN_PLACE(sendbuf);
- sendbuf = (char *) FORT_BOTTOM(sendbuf);
- recvbuf = (char *) FORT_BOTTOM(recvbuf);
+ sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
+ sendbuf = static_cast<char *>( FORT_BOTTOM(sendbuf));
+ recvbuf = static_cast<char *>( FORT_BOTTOM(recvbuf));
*ierr = MPI_Reduce(sendbuf, recvbuf, *count, smpi_type_f2c(*datatype), smpi_op_f2c(*op), *root, smpi_comm_f2c(*comm));
}
void mpi_allreduce_(void* sendbuf, void* recvbuf, int* count, int* datatype, int* op, int* comm, int* ierr) {
- sendbuf = (char *) FORT_IN_PLACE(sendbuf);
+ sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
*ierr = MPI_Allreduce(sendbuf, recvbuf, *count, smpi_type_f2c(*datatype), smpi_op_f2c(*op), smpi_comm_f2c(*comm));
}
void mpi_reduce_scatter_(void* sendbuf, void* recvbuf, int* recvcounts, int* datatype, int* op, int* comm, int* ierr) {
- sendbuf = (char *) FORT_IN_PLACE(sendbuf);
+ sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
*ierr = MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, smpi_type_f2c(*datatype),
smpi_op_f2c(*op), smpi_comm_f2c(*comm));
}
void mpi_scatter_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, int* recvcount, int* recvtype,
int* root, int* comm, int* ierr) {
- recvbuf = (char *) FORT_IN_PLACE(recvbuf);
+ recvbuf = static_cast<char *>( FORT_IN_PLACE(recvbuf));
*ierr = MPI_Scatter(sendbuf, *sendcount, smpi_type_f2c(*sendtype),
recvbuf, *recvcount, smpi_type_f2c(*recvtype), *root, smpi_comm_f2c(*comm));
}
void mpi_scatterv_(void* sendbuf, int* sendcounts, int* displs, int* sendtype,
void* recvbuf, int* recvcount, int* recvtype, int* root, int* comm, int* ierr) {
- recvbuf = (char *) FORT_IN_PLACE(recvbuf);
+ recvbuf = static_cast<char *>( FORT_IN_PLACE(recvbuf));
*ierr = MPI_Scatterv(sendbuf, sendcounts, displs, smpi_type_f2c(*sendtype),
recvbuf, *recvcount, smpi_type_f2c(*recvtype), *root, smpi_comm_f2c(*comm));
}
void mpi_gather_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, int* recvcount, int* recvtype,
int* root, int* comm, int* ierr) {
- sendbuf = (char *) FORT_IN_PLACE(sendbuf);
- sendbuf = (char *) FORT_BOTTOM(sendbuf);
- recvbuf = (char *) FORT_BOTTOM(recvbuf);
+ sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
+ sendbuf = static_cast<char *>( FORT_BOTTOM(sendbuf));
+ recvbuf = static_cast<char *>( FORT_BOTTOM(recvbuf));
*ierr = MPI_Gather(sendbuf, *sendcount, smpi_type_f2c(*sendtype),
recvbuf, *recvcount, smpi_type_f2c(*recvtype), *root, smpi_comm_f2c(*comm));
}
void mpi_gatherv_(void* sendbuf, int* sendcount, int* sendtype,
void* recvbuf, int* recvcounts, int* displs, int* recvtype, int* root, int* comm, int* ierr) {
- sendbuf = (char *) FORT_IN_PLACE(sendbuf);
- sendbuf = (char *) FORT_BOTTOM(sendbuf);
- recvbuf = (char *) FORT_BOTTOM(recvbuf);
+ sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
+ sendbuf = static_cast<char *>( FORT_BOTTOM(sendbuf));
+ recvbuf = static_cast<char *>( FORT_BOTTOM(recvbuf));
*ierr = MPI_Gatherv(sendbuf, *sendcount, smpi_type_f2c(*sendtype),
recvbuf, recvcounts, displs, smpi_type_f2c(*recvtype), *root, smpi_comm_f2c(*comm));
}
void mpi_allgather_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, int* recvcount, int* recvtype,
int* comm, int* ierr) {
- sendbuf = (char *) FORT_IN_PLACE(sendbuf);
+ sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
*ierr = MPI_Allgather(sendbuf, *sendcount, smpi_type_f2c(*sendtype),
recvbuf, *recvcount, smpi_type_f2c(*recvtype), smpi_comm_f2c(*comm));
}
void mpi_allgatherv_(void* sendbuf, int* sendcount, int* sendtype,
void* recvbuf, int* recvcounts,int* displs, int* recvtype, int* comm, int* ierr) {
- sendbuf = (char *) FORT_IN_PLACE(sendbuf);
+ sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
*ierr = MPI_Allgatherv(sendbuf, *sendcount, smpi_type_f2c(*sendtype),
recvbuf, recvcounts, displs, smpi_type_f2c(*recvtype), smpi_comm_f2c(*comm));
}
void mpi_win_create_( int *base, MPI_Aint* size, int* disp_unit, int* info, int* comm, int *win, int* ierr){
MPI_Win tmp;
- *ierr = MPI_Win_create( (void*)base, *size, *disp_unit, smpi_info_f2c(*info), smpi_comm_f2c(*comm),&tmp);
+ *ierr = MPI_Win_create( static_cast<void*>(base), *size, *disp_unit, smpi_info_f2c(*info), smpi_comm_f2c(*comm),&tmp);
if(*ierr == MPI_SUCCESS) {
*win = smpi_win_c2f(tmp);
}
}
void mpi_win_set_name_ (int* win, char * name, int* ierr, int size){
- //handle trailing blanks
- while(name[size-1]==' ')size--;
- while(*name==' '){//handle leading blanks
- size --;
- name++;
- }
- char* tname = xbt_new(char,size+1);
- strncpy(tname, name, size);
- tname[size]='\0';
- *ierr = MPI_Win_set_name(smpi_win_f2c(*win), tname);
- xbt_free(tname);
+ //handle trailing blanks
+ while(name[size-1]==' ')
+ size--;
+ while(*name==' '){//handle leading blanks
+ size--;
+ name++;
+ }
+ char* tname = xbt_new(char,size+1);
+ strncpy(tname, name, size);
+ tname[size]='\0';
+ *ierr = MPI_Win_set_name(smpi_win_f2c(*win), tname);
+ xbt_free(tname);
}
void mpi_win_get_name_ (int* win, char * name, int* len, int* ierr){
- *ierr = MPI_Win_get_name(smpi_win_f2c(*win),name,len);
- if(*len>0) name[*len]=' ';//blank padding, not \0
+ *ierr = MPI_Win_get_name(smpi_win_f2c(*win),name,len);
+ if(*len>0)
+ name[*len]=' ';//blank padding, not \0
}
void mpi_info_create_( int *info, int* ierr){
}
void mpi_info_set_( int *info, char *key, char *value, int* ierr, unsigned int keylen, unsigned int valuelen){
- //handle trailing blanks
- while(key[keylen-1]==' ')keylen--;
- while(*key==' '){//handle leading blanks
- keylen --;
- key++;
- }
- char* tkey = xbt_new(char,keylen+1);
- strncpy(tkey, key, keylen);
- tkey[keylen]='\0';
-
- while(value[valuelen-1]==' ')valuelen--;
- while(*value==' '){//handle leading blanks
- valuelen --;
- value++;
- }
- char* tvalue = xbt_new(char,valuelen+1);
- strncpy(tvalue, value, valuelen);
-
- tvalue[valuelen]='\0';
- *ierr = MPI_Info_set( smpi_info_f2c(*info), tkey, tvalue);
- xbt_free(tkey);
+ //handle trailing blanks
+ while(key[keylen-1]==' ')
+ keylen--;
+ while(*key==' '){//handle leading blanks
+ keylen--;
+ key++;
+ }
+ char* tkey = xbt_new(char,keylen+1);
+ strncpy(tkey, key, keylen);
+ tkey[keylen]='\0';
+
+ while(value[valuelen-1]==' ')
+ valuelen--;
+ while(*value==' '){//handle leading blanks
+ valuelen--;
+ value++;
+ }
+ char* tvalue = xbt_new(char,valuelen+1);
+ strncpy(tvalue, value, valuelen);
+
+ tvalue[valuelen]='\0';
+ *ierr = MPI_Info_set( smpi_info_f2c(*info), tkey, tvalue);
+ xbt_free(tkey);
}
void mpi_info_get_ (int* info,char *key,int* valuelen, char *value, int *flag, int* ierr, unsigned int keylen ){
- while(key[keylen-1]==' ')keylen--;
- while(*key==' '){//handle leading blanks
- keylen --;
- key++;
- } 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);
- xbt_free(tkey);
- if(*flag==true){
- int replace=0, i=0;
- for (i=0; i<*valuelen; i++){
- if(value[i]=='\0')
- replace=1;
- if(replace)
- value[i]=' ';
- }
- }
+ while(key[keylen-1]==' ')
+ keylen--;
+ while(*key==' '){//handle leading blanks
+ keylen--;
+ key++;
+ }
+ 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);
+ xbt_free(tkey);
+ if(*flag==true){
+ int replace=0;
+ int i=0;
+ for (i=0; i<*valuelen; i++){
+ if(value[i]=='\0')
+ replace=1;
+ if(replace)
+ value[i]=' ';
+ }
+ }
}
void mpi_info_free_(int* info, int* ierr){
void mpi_get_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* win, int* ierr){
- *ierr = MPI_Get( (void*)origin_addr,*origin_count, smpi_type_f2c(*origin_datatype),*target_rank,
+ *ierr = MPI_Get( static_cast<void*>(origin_addr),*origin_count, smpi_type_f2c(*origin_datatype),*target_rank,
*target_disp, *target_count,smpi_type_f2c(*tarsmpi_type_f2c), smpi_win_f2c(*win));
}
void mpi_accumulate_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* op, int* win, int* ierr){
- *ierr = MPI_Accumulate( (void*)origin_addr,*origin_count, smpi_type_f2c(*origin_datatype),*target_rank,
+ *ierr = MPI_Accumulate( static_cast<void *>(origin_addr),*origin_count, smpi_type_f2c(*origin_datatype),*target_rank,
*target_disp, *target_count,smpi_type_f2c(*tarsmpi_type_f2c), smpi_op_f2c(*op), smpi_win_f2c(*win));
}
void mpi_put_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* win, int* ierr){
- *ierr = MPI_Put( (void*)origin_addr,*origin_count, smpi_type_f2c(*origin_datatype),*target_rank,
+ *ierr = MPI_Put( static_cast<void *>(origin_addr),*origin_count, smpi_type_f2c(*origin_datatype),*target_rank,
*target_disp, *target_count,smpi_type_f2c(*tarsmpi_type_f2c), smpi_win_f2c(*win));
}
void mpi_type_get_name_ (int* datatype, char * name, int* len, int* ierr){
*ierr = MPI_Type_get_name(smpi_type_f2c(*datatype),name,len);
- if(*len>0) name[*len]=' ';
+ if(*len>0)
+ name[*len]=' ';
}
void mpi_type_get_attr_ (int* type, int* type_keyval, void *attribute_val, int* flag, int* ierr){
void mpi_type_create_keyval_ (void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr){
- *ierr = MPI_Type_create_keyval((MPI_Type_copy_attr_function*)copy_fn, (MPI_Type_delete_attr_function*) delete_fn,
+ *ierr = MPI_Type_create_keyval(reinterpret_cast<MPI_Type_copy_attr_function*>(copy_fn), reinterpret_cast<MPI_Type_delete_attr_function*>(delete_fn),
keyval, extra_state) ;
}
}
void mpi_pcontrol_ (int* level , int* ierr){
- *ierr = MPI_Pcontrol(*(const int*)level);
+ *ierr = MPI_Pcontrol(*static_cast<const int*>(level));
}
void mpi_type_get_extent_ (int* datatype, MPI_Aint * lb, MPI_Aint * extent, int* ierr){
void mpi_op_create_ (void * function, int* commute, int* op, int* ierr){
MPI_Op tmp;
- *ierr = MPI_Op_create((MPI_User_function*)function,* commute, &tmp);
+ *ierr = MPI_Op_create(reinterpret_cast<MPI_User_function*>(function),*commute, &tmp);
if(*ierr == MPI_SUCCESS) {
*op = smpi_op_c2f(tmp);
}
void mpi_comm_create_keyval_ (void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr){
- *ierr = MPI_Comm_create_keyval((MPI_Comm_copy_attr_function*)copy_fn, (MPI_Comm_delete_attr_function*)delete_fn,
+ *ierr = MPI_Comm_create_keyval(reinterpret_cast<MPI_Comm_copy_attr_function*>(copy_fn), reinterpret_cast<MPI_Comm_delete_attr_function*>(delete_fn),
keyval, extra_state) ;
}
void mpi_comm_get_name_ (int* comm, char* name, int* len, int* ierr){
*ierr = MPI_Comm_get_name(smpi_comm_f2c(*comm), name, len);
- if(*len>0) name[*len]=' ';
+ if(*len>0)
+ name[*len]=' ';
}
void mpi_comm_compare_ (int* comm1, int* comm2, int *result, int* ierr){
reqs[i] = smpi_request_f2c(requests[i]);
}
*ierr = MPI_Testany(*count, reqs, index, flag, FORT_STATUS_IGNORE(status));
- if(*index!=MPI_UNDEFINED)
- if(reqs[*index]==MPI_REQUEST_NULL){
+ if(*index!=MPI_UNDEFINED && reqs[*index]==MPI_REQUEST_NULL){
free_request(requests[*index]);
requests[*index]=MPI_FORTRAN_REQUEST_NULL;
}
- free(reqs);
+ xbt_free(reqs);
}
void mpi_waitsome_ (int* incount, int* requests, int *outcount, int *indices, MPI_Status* status, int* ierr)
requests[indices[i]]=MPI_FORTRAN_REQUEST_NULL;
}
}
- free(reqs);
+ xbt_free(reqs);
}
void mpi_reduce_local_ (void *inbuf, void *inoutbuf, int* count, int* datatype, int* op, int* ierr){
void mpi_reduce_scatter_block_ (void *sendbuf, void *recvbuf, int* recvcount, int* datatype, int* op, int* comm,
int* ierr)
{
- sendbuf = (char *) FORT_IN_PLACE(sendbuf);
+ sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
*ierr = MPI_Reduce_scatter_block(sendbuf, recvbuf, *recvcount, smpi_type_f2c(*datatype), smpi_op_f2c(*op),
smpi_comm_f2c(*comm));
}
}
void mpi_errhandler_create_ (void* function, void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_create((MPI_Handler_function*)function, (MPI_Errhandler*)errhandler);
+ *ierr = MPI_Errhandler_create(reinterpret_cast<MPI_Handler_function*>(function), static_cast<MPI_Errhandler*>(errhandler));
}
void mpi_errhandler_free_ (void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_free((MPI_Errhandler*)errhandler);
+ *ierr = MPI_Errhandler_free(static_cast<MPI_Errhandler*>(errhandler));
}
void mpi_errhandler_get_ (int* comm, void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_get(smpi_comm_f2c(*comm), (MPI_Errhandler*) errhandler);
+ *ierr = MPI_Errhandler_get(smpi_comm_f2c(*comm), static_cast<MPI_Errhandler*>(errhandler));
}
void mpi_errhandler_set_ (int* comm, void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_set(smpi_comm_f2c(*comm), *(MPI_Errhandler*)errhandler);
+ *ierr = MPI_Errhandler_set(smpi_comm_f2c(*comm), *static_cast<MPI_Errhandler*>(errhandler));
}
void mpi_comm_set_errhandler_ (int* comm, void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_set(smpi_comm_f2c(*comm), *(MPI_Errhandler*)errhandler);
+ *ierr = MPI_Errhandler_set(smpi_comm_f2c(*comm), *static_cast<MPI_Errhandler*>(errhandler));
}
void mpi_comm_get_errhandler_ (int* comm, void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_set(smpi_comm_f2c(*comm), (MPI_Errhandler*)errhandler);
+ *ierr = MPI_Errhandler_set(smpi_comm_f2c(*comm), static_cast<MPI_Errhandler*>(errhandler));
}
void mpi_type_contiguous_ (int* count, int* old_type, int* newtype, int* ierr) {
}
*ierr = MPI_Testsome(*incount, reqs, outcount, indices, FORT_STATUSES_IGNORE(statuses));
for(i=0;i<*incount;i++){
- if(indices[i]){
- if(reqs[indices[i]]==MPI_REQUEST_NULL){
- free_request(requests[indices[i]]);
- requests[indices[i]]=MPI_FORTRAN_REQUEST_NULL;
- }
+ if(indices[i] && reqs[indices[i]]==MPI_REQUEST_NULL){
+ free_request(requests[indices[i]]);
+ requests[indices[i]]=MPI_FORTRAN_REQUEST_NULL;
}
}
- free(reqs);
+ xbt_free(reqs);
}
void mpi_comm_test_inter_ (int* comm, int* flag, int* ierr) {
void mpi_type_struct_ (int* count, int* blocklens, MPI_Aint* indices, int* old_types, int* newtype, int* ierr) {
MPI_Datatype tmp;
int i=0;
- MPI_Datatype* types = (MPI_Datatype*)xbt_malloc(*count*sizeof(MPI_Datatype));
+ MPI_Datatype* types = static_cast<MPI_Datatype*>(xbt_malloc(*count*sizeof(MPI_Datatype)));
for(i=0; i< *count; i++){
types[i] = smpi_type_f2c(old_types[i]);
}
void mpi_type_create_struct_(int* count, int* blocklens, MPI_Aint* indices, int* old_types, int* newtype, int* ierr){
MPI_Datatype tmp;
int i=0;
- MPI_Datatype* types = (MPI_Datatype*)xbt_malloc(*count*sizeof(MPI_Datatype));
+ MPI_Datatype* types = static_cast<MPI_Datatype*>(xbt_malloc(*count*sizeof(MPI_Datatype)));
for(i=0; i< *count; i++){
types[i] = smpi_type_f2c(old_types[i]);
}
}
void mpi_keyval_create_ (void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr) {
- *ierr = MPI_Keyval_create((MPI_Copy_function*)copy_fn, (MPI_Delete_function*)delete_fn, keyval, extra_state);
+ *ierr = MPI_Keyval_create(reinterpret_cast<MPI_Copy_function*>(copy_fn),reinterpret_cast<MPI_Delete_function*>(delete_fn), keyval, extra_state);
}
void mpi_keyval_free_ (int* keyval, int* ierr) {
int* array_of_integers, MPI_Aint* array_of_addresses,
int* array_of_datatypes, int* ierr){
*ierr = MPI_Type_get_contents(smpi_type_f2c(*datatype), *max_integers, *max_addresses,*max_datatypes,
- array_of_integers, array_of_addresses, (MPI_Datatype*)array_of_datatypes);
+ array_of_integers, array_of_addresses, reinterpret_cast<MPI_Datatype*>(array_of_datatypes));
}
void mpi_type_create_darray_ (int* size, int* rank, int* ndims, int* array_of_gsizes, int* array_of_distribs,
void mpi_alltoallw_ ( void *sendbuf, int *sendcnts, int *sdispls, int* sendtypes, void *recvbuf, int *recvcnts,
int *rdispls, int* recvtypes, int* comm, int* ierr){
- *ierr = MPI_Alltoallw( sendbuf, sendcnts, sdispls, (MPI_Datatype*) sendtypes, recvbuf, recvcnts, rdispls,
- (MPI_Datatype*)recvtypes, smpi_comm_f2c(*comm));
+ *ierr = MPI_Alltoallw( sendbuf, sendcnts, sdispls, reinterpret_cast<MPI_Datatype*>(sendtypes), recvbuf, recvcnts, rdispls,
+ reinterpret_cast<MPI_Datatype*>(recvtypes), smpi_comm_f2c(*comm));
}
void mpi_exscan_ (void *sendbuf, void *recvbuf, int* count, int* datatype, int* op, int* comm, int* ierr){
}
void mpi_comm_create_errhandler_ ( void *function, void *errhandler, int* ierr){
- *ierr = MPI_Comm_create_errhandler( (MPI_Comm_errhandler_fn*) function, (MPI_Errhandler*)errhandler);
+ *ierr = MPI_Comm_create_errhandler( reinterpret_cast<MPI_Comm_errhandler_fn*>(function), static_cast<MPI_Errhandler*>(errhandler));
}
void mpi_add_error_class_ ( int *errorclass, int* ierr){
}
void mpi_info_get_valuelen_ ( int* info, char *key, int *valuelen, int *flag, int* ierr, unsigned int keylen){
- while(key[keylen-1]==' ')keylen--;
- while(*key==' '){//handle leading blanks
- keylen --;
- key++;
- }
- 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);
- xbt_free(tkey);
+ while(key[keylen-1]==' ')
+ keylen--;
+ while(*key==' '){//handle leading blanks
+ keylen--;
+ key++;
+ }
+ 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);
+ xbt_free(tkey);
}
void mpi_info_delete_ (int* info, char *key, int* ierr, unsigned int keylen){
- while(key[keylen-1]==' ')keylen--;
- while(*key==' '){//handle leading blanks
- keylen --;
- key++;
- }
- char* tkey = xbt_new(char, keylen+1);
- strncpy(tkey, key, keylen);
- tkey[keylen]='\0';
- *ierr = MPI_Info_delete(smpi_info_f2c(*info), tkey);
- xbt_free(tkey);
+ while(key[keylen-1]==' ')
+ keylen--;
+ while(*key==' '){//handle leading blanks
+ keylen--;
+ key++;
+ }
+ char* tkey = xbt_new(char, keylen+1);
+ strncpy(tkey, key, keylen);
+ tkey[keylen]='\0';
+ *ierr = MPI_Info_delete(smpi_info_f2c(*info), tkey);
+ xbt_free(tkey);
}
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);
- unsigned int i = 0;
- for (i=strlen(key); i<keylen; i++)
- key[i]=' ';
+ *ierr = MPI_Info_get_nthkey( smpi_info_f2c(*info), *n, key);
+ unsigned int i = 0;
+ for (i=strlen(key); i<keylen; i++)
+ key[i]=' ';
}
void mpi_get_version_ (int *version,int *subversion, int* ierr){
void mpi_grequest_start_ ( void *query_fn, void *free_fn, void *cancel_fn, void *extra_state, int*request, int* ierr){
MPI_Request tmp;
- *ierr = MPI_Grequest_start( (MPI_Grequest_query_function*)query_fn, (MPI_Grequest_free_function*)free_fn,
- (MPI_Grequest_cancel_function*)cancel_fn, extra_state, &tmp);
+ *ierr = MPI_Grequest_start( reinterpret_cast<MPI_Grequest_query_function*>(query_fn), reinterpret_cast<MPI_Grequest_free_function*>(free_fn),
+ reinterpret_cast<MPI_Grequest_cancel_function*>(cancel_fn), extra_state, &tmp);
if(*ierr == MPI_SUCCESS) {
*request = smpi_request_c2f(tmp);
}
void mpi_comm_connect_ ( char *port_name, int* info, int* root, int* comm, int*newcomm, int* ierr){
MPI_Comm tmp;
- *ierr = MPI_Comm_connect( port_name, *(MPI_Info*)info, *root, smpi_comm_f2c(*comm), &tmp);
+ *ierr = MPI_Comm_connect( port_name, *reinterpret_cast<MPI_Info*>(info), *root, smpi_comm_f2c(*comm), &tmp);
if(*ierr == MPI_SUCCESS) {
*newcomm = smpi_comm_c2f(tmp);
}
}
void mpi_publish_name_ ( char *service_name, int* info, char *port_name, int* ierr){
- *ierr = MPI_Publish_name( service_name, *(MPI_Info*)info, port_name);
+ *ierr = MPI_Publish_name( service_name, *reinterpret_cast<MPI_Info*>(info), port_name);
}
void mpi_unpublish_name_ ( char *service_name, int* info, char *port_name, int* ierr){
- *ierr = MPI_Unpublish_name( service_name, *(MPI_Info*)info, port_name);
+ *ierr = MPI_Unpublish_name( service_name, *reinterpret_cast<MPI_Info*>(info), port_name);
}
void mpi_lookup_name_ ( char *service_name, int* info, char *port_name, int* ierr){
- *ierr = MPI_Lookup_name( service_name, *(MPI_Info*)info, port_name);
+ *ierr = MPI_Lookup_name( service_name, *reinterpret_cast<MPI_Info*>(info), port_name);
}
void mpi_comm_join_ ( int* fd, int* intercomm, int* ierr){
}
void mpi_open_port_ ( int* info, char *port_name, int* ierr){
- *ierr = MPI_Open_port( *(MPI_Info*)info,port_name);
+ *ierr = MPI_Open_port( *reinterpret_cast<MPI_Info*>(info),port_name);
}
void mpi_close_port_ ( char *port_name, int* ierr){
void mpi_comm_accept_ ( char *port_name, int* info, int* root, int* comm, int*newcomm, int* ierr){
MPI_Comm tmp;
- *ierr = MPI_Comm_accept( port_name, *(MPI_Info*)info, *root, smpi_comm_f2c(*comm), &tmp);
+ *ierr = MPI_Comm_accept( port_name, *reinterpret_cast<MPI_Info*>(info), *root, smpi_comm_f2c(*comm), &tmp);
if(*ierr == MPI_SUCCESS) {
*newcomm = smpi_comm_c2f(tmp);
}
void mpi_comm_spawn_ ( char *command, char *argv, int* maxprocs, int* info, int* root, int* comm, int* intercomm,
int* array_of_errcodes, int* ierr){
MPI_Comm tmp;
- *ierr = MPI_Comm_spawn( command, NULL, *maxprocs, *(MPI_Info*)info, *root, smpi_comm_f2c(*comm), &tmp,
+ *ierr = MPI_Comm_spawn( command, NULL, *maxprocs, *reinterpret_cast<MPI_Info*>(info), *root, smpi_comm_f2c(*comm), &tmp,
array_of_errcodes);
if(*ierr == MPI_SUCCESS) {
*intercomm = smpi_comm_c2f(tmp);
int* comm, int* intercomm, int* array_of_errcodes, int* ierr){
MPI_Comm tmp;
*ierr = MPI_Comm_spawn_multiple(* count, &array_of_commands, &array_of_argv, array_of_maxprocs,
- (MPI_Info*)array_of_info, *root, smpi_comm_f2c(*comm), &tmp, array_of_errcodes);
+ reinterpret_cast<MPI_Info*>(array_of_info), *root, smpi_comm_f2c(*comm), &tmp, array_of_errcodes);
if(*ierr == MPI_SUCCESS) {
*intercomm = smpi_comm_c2f(tmp);
}
static char *get_mailbox_name(char *str, int index)
{
- snprintf(str, MAILBOX_NAME_MAXLEN, "SMPI-%0*x", (int) (sizeof(int) * 2), index);
+ snprintf(str, MAILBOX_NAME_MAXLEN, "SMPI-%0*x", static_cast<int> (sizeof(int) * 2), index);
return str;
}
static char *get_mailbox_name_small(char *str, int index)
{
- snprintf(str, MAILBOX_NAME_MAXLEN, "small%0*x", (int) (sizeof(int) * 2), index);
+ snprintf(str, MAILBOX_NAME_MAXLEN, "small%0*x", static_cast<int> (sizeof(int) * 2), index);
return str;
}
smpi_process_data_t data;
smx_process_t proc;
- if (argc && argv) {
+ if (argc != NULL && argv != NULL) {
proc = SIMIX_process_self();
- //FIXME: dirty cleanup method to avoid using msg cleanup functions on these processes when using MSG+SMPI
SIMIX_process_set_cleanup_function(proc, MSG_process_cleanup_from_SIMIX);
char* instance_id = (*argv)[1];
int rank = xbt_str_parse_int((*argv)[2], "Invalid rank: %s");
index = smpi_process_index_of_smx_process(proc);
- if(!index_to_process_data){
- index_to_process_data=(int*)xbt_malloc(SIMIX_process_count()*sizeof(int));
+ if(index_to_process_data == NULL){
+ index_to_process_data=static_cast<int*>(xbt_malloc(SIMIX_process_count()*sizeof(int)));
}
if(smpi_privatize_global_variables){
smpi_deployment_register_process(instance_id, rank, index, &temp_comm_world, &temp_bar);
data = smpi_process_remote_data(index);
data->comm_world = temp_comm_world;
- if(temp_bar != NULL) data->finalization_barrier = temp_bar;
+ if(temp_bar != NULL)
+ data->finalization_barrier = temp_bar;
data->index = index;
data->instance_id = instance_id;
data->replaying = false;
- //xbt_free(simcall_process_get_data(proc));
simdata_process_t simdata = static_cast<simdata_process_t>(simcall_process_get_data(proc));
simdata->data = data;
"MPI-2, this is currently not supported by SMPI.");
}
-void smpi_process_destroy(void)
+void smpi_process_destroy()
{
int index = smpi_process_index();
if(smpi_privatize_global_variables){
}
/** @brief Prepares the current process for termination. */
-void smpi_process_finalize(void)
+void smpi_process_finalize()
{
// This leads to an explosion of the search graph which cannot be reduced:
if(MC_is_active() || MC_record_replay_is_active())
}
/** @brief Check if a process is initialized */
-int smpi_process_initialized(void)
+int smpi_process_initialized()
{
- if (!index_to_process_data){
+ if (index_to_process_data == NULL){
return false;
} else{
int index = smpi_process_index();
}
/** @brief Mark a process as initialized (=MPI_Init called) */
-void smpi_process_mark_as_initialized(void)
+void smpi_process_mark_as_initialized()
{
int index = smpi_process_index();
if ((index != MPI_UNDEFINED) && (process_data[index_to_process_data[index]]->state != SMPI_FINALIZED))
else return (_xbt_replay_is_active() != 0);
}
-int smpi_global_size(void)
+int smpi_global_size()
{
char *value = getenv("SMPI_GLOBAL_SIZE");
xbt_assert(value,"Please set env var SMPI_GLOBAL_SIZE to the expected number of processes.");
return xbt_str_parse_int(value, "SMPI_GLOBAL_SIZE contains a non-numerical value: %s");
}
-smpi_process_data_t smpi_process_data(void)
+smpi_process_data_t smpi_process_data()
{
simdata_process_t simdata = static_cast<simdata_process_t>(SIMIX_process_self_get_data());
return static_cast<smpi_process_data_t>(simdata->data);
return process_data->data;
}
-int smpi_process_count(void)
+int smpi_process_count()
{
return process_count;
}
*
* \see smpi_trace_set_call_location
*/
-smpi_trace_call_location_t* smpi_process_get_call_location(void)
+smpi_trace_call_location_t* smpi_process_get_call_location()
{
smpi_process_data_t process_data = smpi_process_data();
return process_data->trace_call_loc;
}
-int smpi_process_index(void)
+int smpi_process_index()
{
smpi_process_data_t data = smpi_process_data();
//return -1 if not initialized
- return data ? data->index : MPI_UNDEFINED;
+ return data != NULL ? data->index : MPI_UNDEFINED;
}
-MPI_Comm smpi_process_comm_world(void)
+MPI_Comm smpi_process_comm_world()
{
smpi_process_data_t data = smpi_process_data();
//return MPI_COMM_NULL if not initialized
- return data ? *data->comm_world : MPI_COMM_NULL;
+ return data != NULL ? *data->comm_world : MPI_COMM_NULL;
}
-smx_mailbox_t smpi_process_mailbox(void)
+smx_mailbox_t smpi_process_mailbox()
{
smpi_process_data_t data = smpi_process_data();
return data->mailbox;
}
-smx_mailbox_t smpi_process_mailbox_small(void)
+smx_mailbox_t smpi_process_mailbox_small()
{
smpi_process_data_t data = smpi_process_data();
return data->mailbox_small;
}
-xbt_mutex_t smpi_process_mailboxes_mutex(void)
+xbt_mutex_t smpi_process_mailboxes_mutex()
{
smpi_process_data_t data = smpi_process_data();
return data->mailboxes_mutex;
return data->mailboxes_mutex;
}
-xbt_os_timer_t smpi_process_timer(void)
+xbt_os_timer_t smpi_process_timer()
{
smpi_process_data_t data = smpi_process_data();
return data->timer;
}
-void smpi_process_simulated_start(void)
+void smpi_process_simulated_start()
{
smpi_process_data_t data = smpi_process_data();
data->simulated = SIMIX_get_clock();
}
-double smpi_process_simulated_elapsed(void)
+double smpi_process_simulated_elapsed()
{
smpi_process_data_t data = smpi_process_data();
return SIMIX_get_clock() - data->simulated;
}
-MPI_Comm smpi_process_comm_self(void)
+MPI_Comm smpi_process_comm_self()
{
smpi_process_data_t data = smpi_process_data();
if(data->comm_self==MPI_COMM_NULL){
return data->comm_self;
}
-MPI_Comm smpi_process_get_comm_intra(void)
+MPI_Comm smpi_process_get_comm_intra()
{
smpi_process_data_t data = smpi_process_data();
return data->comm_intra;
data->sampling = s;
}
-int smpi_process_get_sampling(void)
+int smpi_process_get_sampling()
{
smpi_process_data_t data = smpi_process_data();
return data->sampling;
void* tmpbuff=buff;
simgrid::simix::Comm *comm = dynamic_cast<simgrid::simix::Comm*>(synchro);
- if((smpi_privatize_global_variables) && ((char*)buff >= smpi_start_data_exe)
- && ((char*)buff < smpi_start_data_exe + smpi_size_data_exe )
+ if((smpi_privatize_global_variables) && (static_cast<char*>(buff) >= smpi_start_data_exe)
+ && (static_cast<char*>(buff) < smpi_start_data_exe + smpi_size_data_exe )
){
XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
- smpi_switch_data_segment(((smpi_process_data_t)(((simdata_process_t)SIMIX_process_get_data(comm->src_proc))->data))->index);
- tmpbuff = (void*)xbt_malloc(buff_size);
+ smpi_switch_data_segment((static_cast<smpi_process_data_t>((static_cast<simdata_process_t>(SIMIX_process_get_data(comm->src_proc))->data))->index));
+ tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
memcpy(tmpbuff, buff, buff_size);
}
if((smpi_privatize_global_variables) && ((char*)comm->dst_buff >= smpi_start_data_exe)
&& ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){
XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
- smpi_switch_data_segment(((smpi_process_data_t)(((simdata_process_t)SIMIX_process_get_data(comm->dst_proc))->data))->index);
+ smpi_switch_data_segment((static_cast<smpi_process_data_t>((static_cast<simdata_process_t>(SIMIX_process_get_data(comm->dst_proc))->data))->index));
}
memcpy(comm->dst_buff, tmpbuff, buff_size);
}
}
-int smpi_enabled(void) {
+int smpi_enabled() {
return process_data != NULL;
}
-void smpi_global_init(void)
+void smpi_global_init()
{
int i;
MPI_Group group;
process_data = xbt_new0(smpi_process_data_t, process_count);
for (i = 0; i < process_count; i++) {
process_data[i] = xbt_new(s_smpi_process_data_t, 1);
- //process_data[i]->index = i;
process_data[i]->argc = NULL;
process_data[i]->argv = NULL;
process_data[i]->mailbox = simcall_mbox_create(get_mailbox_name(name, i));
if(smpirun){
group = smpi_group_new(process_count);
MPI_COMM_WORLD = smpi_comm_new(group, NULL);
- MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, (void *)(MPI_Aint)process_count);
+ MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, reinterpret_cast<void *>(process_count));
xbt_bar_t bar=xbt_barrier_init(process_count);
for (i = 0; i < process_count; i++) {
}
}
-void smpi_global_destroy(void)
+void smpi_global_destroy()
{
int count = smpi_process_count();
int i;
static void smpi_init_options(){
int gather_id = find_coll_description(mpi_coll_gather_description, xbt_cfg_get_string("smpi/gather"),"gather");
- mpi_coll_gather_fun = (int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, int, MPI_Comm))
- mpi_coll_gather_description[gather_id].coll;
+ mpi_coll_gather_fun = reinterpret_cast<int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, int, MPI_Comm)>
+ (mpi_coll_gather_description[gather_id].coll);
int allgather_id = find_coll_description(mpi_coll_allgather_description,
xbt_cfg_get_string("smpi/allgather"),"allgather");
- mpi_coll_allgather_fun = (int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, MPI_Comm))
- mpi_coll_allgather_description[allgather_id].coll;
+ mpi_coll_allgather_fun = reinterpret_cast<int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, MPI_Comm)>
+ (mpi_coll_allgather_description[allgather_id].coll);
int allgatherv_id = find_coll_description(mpi_coll_allgatherv_description,
xbt_cfg_get_string("smpi/allgatherv"),"allgatherv");
- mpi_coll_allgatherv_fun = (int (*)(void *, int, MPI_Datatype, void *, int *, int *, MPI_Datatype, MPI_Comm))
- mpi_coll_allgatherv_description[allgatherv_id].coll;
+ mpi_coll_allgatherv_fun = reinterpret_cast<int (*)(void *, int, MPI_Datatype, void *, int *, int *, MPI_Datatype, MPI_Comm)>
+ (mpi_coll_allgatherv_description[allgatherv_id].coll);
int allreduce_id = find_coll_description(mpi_coll_allreduce_description,
xbt_cfg_get_string("smpi/allreduce"),"allreduce");
- mpi_coll_allreduce_fun = (int (*)(void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm))
- mpi_coll_allreduce_description[allreduce_id].coll;
+ mpi_coll_allreduce_fun = reinterpret_cast<int (*)(void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)>
+ (mpi_coll_allreduce_description[allreduce_id].coll);
int alltoall_id = find_coll_description(mpi_coll_alltoall_description,
xbt_cfg_get_string("smpi/alltoall"),"alltoall");
- mpi_coll_alltoall_fun = (int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, MPI_Comm))
- mpi_coll_alltoall_description[alltoall_id].coll;
+ mpi_coll_alltoall_fun = reinterpret_cast<int (*)(void *, int, MPI_Datatype, void *, int, MPI_Datatype, MPI_Comm)>
+ (mpi_coll_alltoall_description[alltoall_id].coll);
int alltoallv_id = find_coll_description(mpi_coll_alltoallv_description,
xbt_cfg_get_string("smpi/alltoallv"),"alltoallv");
- mpi_coll_alltoallv_fun = (int (*)(void *, int *, int *, MPI_Datatype, void *, int *, int *, MPI_Datatype, MPI_Comm))
- mpi_coll_alltoallv_description[alltoallv_id].coll;
+ mpi_coll_alltoallv_fun = reinterpret_cast<int (*)(void *, int *, int *, MPI_Datatype, void *, int *, int *, MPI_Datatype, MPI_Comm)>
+ (mpi_coll_alltoallv_description[alltoallv_id].coll);
int bcast_id = find_coll_description(mpi_coll_bcast_description, xbt_cfg_get_string("smpi/bcast"),"bcast");
- mpi_coll_bcast_fun = (int (*)(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm com))
- mpi_coll_bcast_description[bcast_id].coll;
+ mpi_coll_bcast_fun = reinterpret_cast<int (*)(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm com)>
+ (mpi_coll_bcast_description[bcast_id].coll);
int reduce_id = find_coll_description(mpi_coll_reduce_description, xbt_cfg_get_string("smpi/reduce"),"reduce");
- mpi_coll_reduce_fun = (int (*)(void *buf, void *rbuf, int count, MPI_Datatype datatype, MPI_Op op, int root,
- MPI_Comm comm)) mpi_coll_reduce_description[reduce_id].coll;
+ mpi_coll_reduce_fun = reinterpret_cast<int (*)(void *buf, void *rbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)>
+ (mpi_coll_reduce_description[reduce_id].coll);
int reduce_scatter_id =
find_coll_description(mpi_coll_reduce_scatter_description,
xbt_cfg_get_string("smpi/reduce-scatter"),"reduce_scatter");
- mpi_coll_reduce_scatter_fun = (int (*)(void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype, MPI_Op op,
- MPI_Comm comm)) mpi_coll_reduce_scatter_description[reduce_scatter_id].coll;
+ mpi_coll_reduce_scatter_fun = reinterpret_cast<int (*)(void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)>
+ (mpi_coll_reduce_scatter_description[reduce_scatter_id].coll);
int scatter_id = find_coll_description(mpi_coll_scatter_description, xbt_cfg_get_string("smpi/scatter"),"scatter");
- mpi_coll_scatter_fun = (int (*)(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf,
- int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm))
- mpi_coll_scatter_description[scatter_id].coll;
+ mpi_coll_scatter_fun = reinterpret_cast<int (*)(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf,int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)>
+ (mpi_coll_scatter_description[scatter_id].coll);
int barrier_id = find_coll_description(mpi_coll_barrier_description, xbt_cfg_get_string("smpi/barrier"),"barrier");
- mpi_coll_barrier_fun = (int (*)(MPI_Comm comm)) mpi_coll_barrier_description[barrier_id].coll;
+ mpi_coll_barrier_fun = reinterpret_cast<int (*)(MPI_Comm comm)>
+ (mpi_coll_barrier_description[barrier_id].coll);
smpi_coll_cleanup_callback=NULL;
smpi_cpu_threshold = xbt_cfg_get_double("smpi/cpu-threshold");
}
xbt_dict_foreach(origin->index_to_rank_map, cursor, key, ptr_rank) {
- int * cp = (int*)xbt_malloc(sizeof(int));
- *cp=*(int*)ptr_rank;
+ int * cp = static_cast<int*>(xbt_malloc(sizeof(int)));
+ *cp=*reinterpret_cast<int*>(ptr_rank);
xbt_dict_set(group->index_to_rank_map, key, cp, NULL);
}
}
if (rank < group->size) {
group->rank_to_index_map[rank] = index;
if (index!=MPI_UNDEFINED ) {
- val_rank = (int *) malloc(sizeof(int));
+ val_rank = static_cast<int *>(xbt_malloc(sizeof(int)));
*val_rank = rank;
char * key = bprintf("%d", index);
xbt_dict_set(group->index_to_rank_map, key, val_rank, NULL);
- free(key);
+ xbt_free(key);
}
}
}
-/* smpi_mpi_dt.c -- MPI primitives to handle datatypes */
-/* FIXME: a very incomplete implementation */
-
+/* smpi_mpi_dt.c -- MPI primitives to handle datatypes */
/* Copyright (c) 2009-2015. The SimGrid Team.
* All rights reserved. */
CREATE_MPI_DATATYPE(MPI_PTR, void*);
/** Check if the datatype is usable for communications */
-int is_datatype_valid(MPI_Datatype datatype) {
- return datatype != MPI_DATATYPE_NULL && (datatype->flags & DT_FLAG_COMMITED);
+bool is_datatype_valid(MPI_Datatype datatype) {
+ return datatype != MPI_DATATYPE_NULL && ((datatype->flags & DT_FLAG_COMMITED) != 0);
}
size_t smpi_datatype_size(MPI_Datatype datatype)
void* value_out;
xbt_dict_foreach(datatype->attributes, cursor, key, value_in){
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){
+ static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(key), sizeof(int)));
+ if(elem != NULL && elem->copy_fn!=MPI_NULL_COPY_FN){
ret = elem->copy_fn(datatype, *key, NULL, value_in, &value_out, &flag );
if(ret!=MPI_SUCCESS){
smpi_datatype_unuse(*new_t);
return ret;
}
if(flag)
- xbt_dict_set_ext((*new_t)->attributes, (const char*)key, sizeof(int),value_out, NULL);
+ xbt_dict_set_ext((*new_t)->attributes, reinterpret_cast<const char*>(key), sizeof(int),value_out, NULL);
}
}
}
void smpi_datatype_get_name(MPI_Datatype datatype, char* name, int* length){
*length = strlen(datatype->name);
- strcpy(name, datatype->name);
+ strncpy(name, datatype->name, *length+1);
}
void smpi_datatype_set_name(MPI_Datatype datatype, char* name){
- if(datatype->name!=NULL && !(datatype->flags & DT_FLAG_PREDEFINED))
+ if(datatype->name!=NULL && (datatype->flags & DT_FLAG_PREDEFINED) == 0)
xbt_free(datatype->name);
- datatype->name = xbt_strdup(name);;
+ datatype->name = xbt_strdup(name);
}
int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
count = sendcount < recvcount ? sendcount : recvcount;
if(sendtype->sizeof_substruct == 0 && recvtype->sizeof_substruct == 0) {
- if(!smpi_process_get_replaying()) memcpy(recvbuf, sendbuf, count);
+ if(!smpi_process_get_replaying())
+ memcpy(recvbuf, sendbuf, count);
}
else if (sendtype->sizeof_substruct == 0)
{
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);
+ xbt_free(buf_tmp);
}
}
*/
void serialize_vector( const void *noncontiguous_vector, void *contiguous_vector, int count, void *type)
{
- s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)type;
+ s_smpi_mpi_vector_t* type_c = reinterpret_cast<s_smpi_mpi_vector_t*>(type);
int i;
- char* contiguous_vector_char = (char*)contiguous_vector;
- char* noncontiguous_vector_char = (char*)noncontiguous_vector;
+ char* contiguous_vector_char = static_cast<char*>(contiguous_vector);
+ const char* noncontiguous_vector_char = static_cast<const char*>(noncontiguous_vector);
for (i = 0; i < type_c->block_count * count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_vector_char, noncontiguous_vector_char, type_c->block_length * type_c->size_oldtype);
else
- ((s_smpi_subtype_t*)type_c->old_type->substruct)->serialize( noncontiguous_vector_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->serialize( noncontiguous_vector_char,
contiguous_vector_char,
type_c->block_length, type_c->old_type->substruct);
*/
void unserialize_vector( const void *contiguous_vector, void *noncontiguous_vector, int count, void *type, MPI_Op op)
{
- s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)type;
+ s_smpi_mpi_vector_t* type_c = reinterpret_cast<s_smpi_mpi_vector_t*>(type);
int i;
- char* contiguous_vector_char = (char*)contiguous_vector;
- char* noncontiguous_vector_char = (char*)noncontiguous_vector;
+ const char* contiguous_vector_char = static_cast<const char*>(contiguous_vector);
+ char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_vector);
for (i = 0; i < type_c->block_count * count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_vector_char, noncontiguous_vector_char, &type_c->block_length,
&type_c->old_type);
- /* memcpy(noncontiguous_vector_char,
- contiguous_vector_char, type_c->block_length * type_c->size_oldtype);*/
else
- ((s_smpi_subtype_t*)type_c->old_type->substruct)->unserialize(contiguous_vector_char, noncontiguous_vector_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->unserialize(contiguous_vector_char, noncontiguous_vector_char,
type_c->block_length,type_c->old_type->substruct,
op);
contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
void smpi_datatype_free(MPI_Datatype* type){
xbt_assert((*type)->in_use >= 0);
- if((*type)->flags & DT_FLAG_PREDEFINED)return;
+ if((*type)->flags & DT_FLAG_PREDEFINED)
+ return;
//if still used, mark for deletion
if((*type)->in_use!=0){
int flag;
xbt_dict_foreach((*type)->attributes, cursor, key, value){
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)
+ static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(key), sizeof(int)));
+ if(elem!=NULL && elem->delete_fn)
elem->delete_fn(*type,*key, value, &flag);
}
xbt_dict_free(&(*type)->attributes);
void smpi_datatype_use(MPI_Datatype type){
- if(type)type->in_use++;
+ if(type != MPI_DATATYPE_NULL)
+ type->in_use++;
if(type->sizeof_substruct!=0){
- ((s_smpi_subtype_t *)(type)->substruct)->subtype_use(&type);
+ static_cast<s_smpi_subtype_t *>((type)->substruct)->subtype_use(&type);
}
#if HAVE_MC
if(MC_is_active())
type->in_use--;
if(type->sizeof_substruct!=0){
- ((s_smpi_subtype_t *)(type)->substruct)->subtype_free(&type);
+ static_cast<s_smpi_subtype_t *>((type)->substruct)->subtype_free(&type);
}
- if(type && type->in_use == 0){
+ if(type != MPI_DATATYPE_NULL && type->in_use == 0){
smpi_datatype_free(&type);
}
#if HAVE_MC
*/
void serialize_contiguous( const void *noncontiguous_hvector, void *contiguous_hvector, int count, void *type)
{
- s_smpi_mpi_contiguous_t* type_c = (s_smpi_mpi_contiguous_t*)type;
- char* contiguous_vector_char = (char*)contiguous_hvector;
- char* noncontiguous_vector_char = (char*)noncontiguous_hvector+type_c->lb;
+ s_smpi_mpi_contiguous_t* type_c = reinterpret_cast<s_smpi_mpi_contiguous_t*>(type);
+ char* contiguous_vector_char = static_cast<char*>(contiguous_hvector);
+ const char* noncontiguous_vector_char = static_cast<const char*>(noncontiguous_hvector)+type_c->lb;
memcpy(contiguous_vector_char, noncontiguous_vector_char, count* type_c->block_count * type_c->size_oldtype);
}
/* Copies contiguous data into noncontiguous memory.
*/
void unserialize_contiguous(const void *contiguous_vector, void *noncontiguous_vector, int count, void *type, MPI_Op op)
{
- s_smpi_mpi_contiguous_t* type_c = (s_smpi_mpi_contiguous_t*)type;
- char* contiguous_vector_char = (char*)contiguous_vector;
- char* noncontiguous_vector_char = (char*)noncontiguous_vector+type_c->lb;
+ s_smpi_mpi_contiguous_t* type_c = reinterpret_cast<s_smpi_mpi_contiguous_t*>(type);
+ const char* contiguous_vector_char = static_cast<const char*>(contiguous_vector);
+ char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_vector)+type_c->lb;
int n= count* type_c->block_count;
smpi_op_apply(op, contiguous_vector_char, noncontiguous_vector_char, &n, &type_c->old_type);
- /*memcpy(noncontiguous_vector_char, contiguous_vector_char, count* type_c->block_count * type_c->size_oldtype);*/
}
void free_contiguous(MPI_Datatype* d){
- smpi_datatype_unuse(((s_smpi_mpi_contiguous_t *)(*d)->substruct)->old_type);
+ smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_contiguous_t*>((*d)->substruct)->old_type);
}
void use_contiguous(MPI_Datatype* d){
- smpi_datatype_use(((s_smpi_mpi_contiguous_t *)(*d)->substruct)->old_type);
+ smpi_datatype_use(reinterpret_cast<s_smpi_mpi_contiguous_t*>((*d)->substruct)->old_type);
}
/* Create a Sub type contiguous to be able to serialize and unserialize it the structure s_smpi_mpi_contiguous_t is
* erived from s_smpi_subtype which required the functions unserialize and serialize */
s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb, int block_count, MPI_Datatype old_type,
int size_oldtype){
- if(block_count==0)return NULL;
+ if(block_count==0)
+ return NULL;
s_smpi_mpi_contiguous_t *new_t= xbt_new(s_smpi_mpi_contiguous_t,1);
new_t->base.serialize = &serialize_contiguous;
new_t->base.unserialize = &unserialize_contiguous;
int smpi_datatype_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type)
{
int retval;
- if (blocklen<0) return MPI_ERR_ARG;
+ if (blocklen<0)
+ return MPI_ERR_ARG;
MPI_Aint lb = 0;
MPI_Aint ub = 0;
if(count>0){
lb=smpi_datatype_lb(old_type);
ub=((count-1)*stride+blocklen-1)*smpi_datatype_get_extent(old_type)+smpi_datatype_ub(old_type);
}
- if(old_type->sizeof_substruct || stride != blocklen){
+ if(old_type->sizeof_substruct != 0 || stride != blocklen){
s_smpi_mpi_vector_t* subtype = smpi_datatype_vector_create(stride, blocklen, count, old_type,
smpi_datatype_size(old_type));
}
void free_vector(MPI_Datatype* d){
- smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
+ smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_indexed_t*>((*d)->substruct)->old_type);
}
void use_vector(MPI_Datatype* d){
- smpi_datatype_use(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
+ smpi_datatype_use(reinterpret_cast<s_smpi_mpi_indexed_t*>((*d)->substruct)->old_type);
}
/* Hvector Implementation - Vector with stride in bytes */
*/
void serialize_hvector( const void *noncontiguous_hvector, void *contiguous_hvector, int count, void *type)
{
- s_smpi_mpi_hvector_t* type_c = (s_smpi_mpi_hvector_t*)type;
+ s_smpi_mpi_hvector_t* type_c = reinterpret_cast<s_smpi_mpi_hvector_t*>(type);
int i;
- char* contiguous_vector_char = (char*)contiguous_hvector;
- char* noncontiguous_vector_char = (char*)noncontiguous_hvector;
+ char* contiguous_vector_char = static_cast<char*>(contiguous_hvector);
+ const char* noncontiguous_vector_char = static_cast<const char*>(noncontiguous_hvector);
for (i = 0; i < type_c->block_count * count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_vector_char, noncontiguous_vector_char, type_c->block_length * type_c->size_oldtype);
else
- ((s_smpi_subtype_t*)type_c->old_type->substruct)->serialize( noncontiguous_vector_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->serialize( noncontiguous_vector_char,
contiguous_vector_char,
type_c->block_length, type_c->old_type->substruct);
*/
void unserialize_hvector( const void *contiguous_vector, void *noncontiguous_vector, int count, void *type, MPI_Op op)
{
- s_smpi_mpi_hvector_t* type_c = (s_smpi_mpi_hvector_t*)type;
+ s_smpi_mpi_hvector_t* type_c = reinterpret_cast<s_smpi_mpi_hvector_t*>(type);
int i;
- char* contiguous_vector_char = (char*)contiguous_vector;
- char* noncontiguous_vector_char = (char*)noncontiguous_vector;
+ const char* contiguous_vector_char = static_cast<const char*>(contiguous_vector);
+ char* noncontiguous_vector_char = static_cast<char*>(noncontiguous_vector);
for (i = 0; i < type_c->block_count * count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_vector_char, noncontiguous_vector_char, &type_c->block_length, &type_c->old_type);
- /*memcpy(noncontiguous_vector_char,
- contiguous_vector_char, type_c->block_length * type_c->size_oldtype);*/
else
- ((s_smpi_subtype_t*)type_c->old_type->substruct)->unserialize( contiguous_vector_char, noncontiguous_vector_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->unserialize( contiguous_vector_char, noncontiguous_vector_char,
type_c->block_length, type_c->old_type->substruct,
op);
contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
//do nothing for vector types
void free_hvector(MPI_Datatype* d){
- smpi_datatype_unuse(((s_smpi_mpi_hvector_t *)(*d)->substruct)->old_type);
+ smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_hvector_t*>((*d)->substruct)->old_type);
}
void use_hvector(MPI_Datatype* d){
- smpi_datatype_use(((s_smpi_mpi_hvector_t *)(*d)->substruct)->old_type);
+ smpi_datatype_use(reinterpret_cast<s_smpi_mpi_hvector_t*>((*d)->substruct)->old_type);
}
int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type)
{
int retval;
- if (blocklen<0) return MPI_ERR_ARG;
+ if (blocklen<0)
+ return MPI_ERR_ARG;
MPI_Aint lb = 0;
MPI_Aint ub = 0;
if(count>0){
lb=smpi_datatype_lb(old_type);
ub=((count-1)*stride)+(blocklen-1)*smpi_datatype_get_extent(old_type)+smpi_datatype_ub(old_type);
}
- if(old_type->sizeof_substruct || stride != blocklen*smpi_datatype_get_extent(old_type)){
+ if(old_type->sizeof_substruct != 0 || stride != blocklen*smpi_datatype_get_extent(old_type)){
s_smpi_mpi_hvector_t* subtype = smpi_datatype_hvector_create( stride, blocklen, count, old_type,
smpi_datatype_size(old_type));
*/
void serialize_indexed( const void *noncontiguous_indexed, void *contiguous_indexed, int count, void *type)
{
- s_smpi_mpi_indexed_t* type_c = (s_smpi_mpi_indexed_t*)type;
+ s_smpi_mpi_indexed_t* type_c = reinterpret_cast<s_smpi_mpi_indexed_t*>(type);
int i,j;
- char* contiguous_indexed_char = (char*)contiguous_indexed;
- char* noncontiguous_indexed_char = (char*)noncontiguous_indexed+type_c->block_indices[0] * type_c->size_oldtype;
+ char* contiguous_indexed_char = static_cast<char*>(contiguous_indexed);
+ const char* noncontiguous_indexed_char = static_cast<const char*>(noncontiguous_indexed)+type_c->block_indices[0] * type_c->size_oldtype;
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_indexed_char, noncontiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
else
- ((s_smpi_subtype_t*)type_c->old_type->substruct)->serialize( noncontiguous_indexed_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->serialize( noncontiguous_indexed_char,
contiguous_indexed_char,
type_c->block_lengths[i],
type_c->old_type->substruct);
contiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
if (i<type_c->block_count-1)
noncontiguous_indexed_char =
- (char*)noncontiguous_indexed + type_c->block_indices[i+1]*smpi_datatype_get_extent(type_c->old_type);
+ static_cast<const char*>(noncontiguous_indexed) + type_c->block_indices[i+1]*smpi_datatype_get_extent(type_c->old_type);
else
noncontiguous_indexed_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_type);
}
- noncontiguous_indexed=(void*)noncontiguous_indexed_char;
+ noncontiguous_indexed=static_cast<const void*>(noncontiguous_indexed_char);
}
}
/* Copies contiguous data into noncontiguous memory.
*/
void unserialize_indexed( const void *contiguous_indexed, void *noncontiguous_indexed, int count, void *type, MPI_Op op)
{
- s_smpi_mpi_indexed_t* type_c = (s_smpi_mpi_indexed_t*)type;
+ s_smpi_mpi_indexed_t* type_c = reinterpret_cast<s_smpi_mpi_indexed_t*>(type);
int i,j;
- char* contiguous_indexed_char = (char*)contiguous_indexed;
+ const char* contiguous_indexed_char = static_cast<const char*>(contiguous_indexed);
char* noncontiguous_indexed_char =
- (char*)noncontiguous_indexed+type_c->block_indices[0]*smpi_datatype_get_extent(type_c->old_type);
+ static_cast<char*>(noncontiguous_indexed)+type_c->block_indices[0]*smpi_datatype_get_extent(type_c->old_type);
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_indexed_char, noncontiguous_indexed_char, &type_c->block_lengths[i],
&type_c->old_type);
- /*memcpy(noncontiguous_indexed_char ,
- contiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);*/
else
- ((s_smpi_subtype_t*)type_c->old_type->substruct)->unserialize( contiguous_indexed_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->unserialize( contiguous_indexed_char,
noncontiguous_indexed_char,
type_c->block_lengths[i],
type_c->old_type->substruct, op);
contiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
if (i<type_c->block_count-1)
noncontiguous_indexed_char =
- (char*)noncontiguous_indexed + type_c->block_indices[i+1]*smpi_datatype_get_extent(type_c->old_type);
+ static_cast<char*>(noncontiguous_indexed) + type_c->block_indices[i+1]*smpi_datatype_get_extent(type_c->old_type);
else
noncontiguous_indexed_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_type);
}
- noncontiguous_indexed=(void*)noncontiguous_indexed_char;
+ noncontiguous_indexed=static_cast<void*>(noncontiguous_indexed_char);
}
}
void free_indexed(MPI_Datatype* type){
if((*type)->in_use==0){
- xbt_free(((s_smpi_mpi_indexed_t *)(*type)->substruct)->block_lengths);
- xbt_free(((s_smpi_mpi_indexed_t *)(*type)->substruct)->block_indices);
+ xbt_free(reinterpret_cast<s_smpi_mpi_indexed_t*>((*type)->substruct)->block_lengths);
+ xbt_free(reinterpret_cast<s_smpi_mpi_indexed_t*>((*type)->substruct)->block_indices);
}
- smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*type)->substruct)->old_type);
+ smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_indexed_t*>((*type)->substruct)->old_type);
}
void use_indexed(MPI_Datatype* type){
- smpi_datatype_use(((s_smpi_mpi_indexed_t *)(*type)->substruct)->old_type);
+ smpi_datatype_use(reinterpret_cast<s_smpi_mpi_indexed_t*>((*type)->substruct)->old_type);
}
if(indices[i]*smpi_datatype_get_extent(old_type)+blocklens[i]*smpi_datatype_ub(old_type)>ub)
ub = indices[i]*smpi_datatype_get_extent(old_type)+blocklens[i]*smpi_datatype_ub(old_type);
- if ( (i< count -1) && (indices[i]+blocklens[i] != indices[i+1]) )contiguous=0;
+ if ( (i< count -1) && (indices[i]+blocklens[i] != indices[i+1]) )
+ contiguous=0;
}
if (old_type->sizeof_substruct != 0)
contiguous=0;
*/
void serialize_hindexed( const void *noncontiguous_hindexed, void *contiguous_hindexed, int count, void *type)
{
- s_smpi_mpi_hindexed_t* type_c = (s_smpi_mpi_hindexed_t*)type;
+ s_smpi_mpi_hindexed_t* type_c = reinterpret_cast<s_smpi_mpi_hindexed_t*>(type);
int i,j;
- char* contiguous_hindexed_char = (char*)contiguous_hindexed;
- char* noncontiguous_hindexed_char = (char*)noncontiguous_hindexed+ type_c->block_indices[0];
+ char* contiguous_hindexed_char = static_cast<char*>(contiguous_hindexed);
+ const char* noncontiguous_hindexed_char = static_cast<const char*>(noncontiguous_hindexed)+ type_c->block_indices[0];
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_hindexed_char, noncontiguous_hindexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
else
- ((s_smpi_subtype_t*)type_c->old_type->substruct)->serialize( noncontiguous_hindexed_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->serialize( noncontiguous_hindexed_char,
contiguous_hindexed_char,
type_c->block_lengths[i],
type_c->old_type->substruct);
contiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
if (i<type_c->block_count-1)
- noncontiguous_hindexed_char = (char*)noncontiguous_hindexed + type_c->block_indices[i+1];
+ noncontiguous_hindexed_char = static_cast<const char*>(noncontiguous_hindexed) + type_c->block_indices[i+1];
else
noncontiguous_hindexed_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_type);
}
- noncontiguous_hindexed=(void*)noncontiguous_hindexed_char;
+ noncontiguous_hindexed=reinterpret_cast<const void*>(noncontiguous_hindexed_char);
}
}
/* Copies contiguous data into noncontiguous memory.
void unserialize_hindexed( const void *contiguous_hindexed, void *noncontiguous_hindexed, int count, void *type,
MPI_Op op)
{
- s_smpi_mpi_hindexed_t* type_c = (s_smpi_mpi_hindexed_t*)type;
+ s_smpi_mpi_hindexed_t* type_c = reinterpret_cast<s_smpi_mpi_hindexed_t*>(type);
int i,j;
- char* contiguous_hindexed_char = (char*)contiguous_hindexed;
- char* noncontiguous_hindexed_char = (char*)noncontiguous_hindexed+ type_c->block_indices[0];
+ const char* contiguous_hindexed_char = static_cast<const char*>(contiguous_hindexed);
+ char* noncontiguous_hindexed_char = static_cast<char*>(noncontiguous_hindexed)+ type_c->block_indices[0];
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_hindexed_char, noncontiguous_hindexed_char, &type_c->block_lengths[i],
&type_c->old_type);
- /*memcpy(noncontiguous_hindexed_char,contiguous_hindexed_char,type_c->block_lengths[i]*type_c->size_oldtype);*/
else
- ((s_smpi_subtype_t*)type_c->old_type->substruct)->unserialize( contiguous_hindexed_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_type->substruct)->unserialize( contiguous_hindexed_char,
noncontiguous_hindexed_char,
type_c->block_lengths[i],
type_c->old_type->substruct, op);
contiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
if (i<type_c->block_count-1)
- noncontiguous_hindexed_char = (char*)noncontiguous_hindexed + type_c->block_indices[i+1];
+ noncontiguous_hindexed_char = static_cast<char*>(noncontiguous_hindexed) + type_c->block_indices[i+1];
else
noncontiguous_hindexed_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_type);
}
- noncontiguous_hindexed=(void*)noncontiguous_hindexed_char;
+ noncontiguous_hindexed=reinterpret_cast<void*>(noncontiguous_hindexed_char);
}
}
void free_hindexed(MPI_Datatype* type){
if((*type)->in_use==0){
- xbt_free(((s_smpi_mpi_hindexed_t *)(*type)->substruct)->block_lengths);
- xbt_free(((s_smpi_mpi_hindexed_t *)(*type)->substruct)->block_indices);
+ xbt_free(reinterpret_cast<s_smpi_mpi_hindexed_t*>((*type)->substruct)->block_lengths);
+ xbt_free(reinterpret_cast<s_smpi_mpi_hindexed_t*>((*type)->substruct)->block_indices);
}
- smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*type)->substruct)->old_type);
+ smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_hindexed_t*>((*type)->substruct)->old_type);
}
void use_hindexed(MPI_Datatype* type){
- smpi_datatype_use(((s_smpi_mpi_hindexed_t *)(*type)->substruct)->old_type);
+ smpi_datatype_use(reinterpret_cast<s_smpi_mpi_hindexed_t*>((*type)->substruct)->old_type);
}
/* Create a Sub type hindexed to be able to serialize and unserialize it the structure s_smpi_mpi_hindexed_t is derived
return MPI_ERR_ARG;
size += blocklens[i];
- 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(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]*static_cast<int>(smpi_datatype_size(old_type)) != indices[i+1]) )
+ if ( (i< count -1) && (indices[i]+blocklens[i]*(static_cast<int>(smpi_datatype_size(old_type))) != indices[i+1]) )
contiguous=0;
}
if (old_type->sizeof_substruct != 0 || lb!=0)
*/
void serialize_struct( const void *noncontiguous_struct, void *contiguous_struct, int count, void *type)
{
- s_smpi_mpi_struct_t* type_c = (s_smpi_mpi_struct_t*)type;
+ s_smpi_mpi_struct_t* type_c = reinterpret_cast<s_smpi_mpi_struct_t*>(type);
int i,j;
- char* contiguous_struct_char = (char*)contiguous_struct;
- char* noncontiguous_struct_char = (char*)noncontiguous_struct+ type_c->block_indices[0];
+ char* contiguous_struct_char = static_cast<char*>(contiguous_struct);
+ const char* noncontiguous_struct_char = static_cast<const char*>(noncontiguous_struct)+ type_c->block_indices[0];
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_types[i]->sizeof_substruct == 0)
memcpy(contiguous_struct_char, noncontiguous_struct_char,
type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));
else
- ((s_smpi_subtype_t*)type_c->old_types[i]->substruct)->serialize( noncontiguous_struct_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_types[i]->substruct)->serialize( noncontiguous_struct_char,
contiguous_struct_char,
type_c->block_lengths[i],
type_c->old_types[i]->substruct);
contiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);
if (i<type_c->block_count-1)
- noncontiguous_struct_char = (char*)noncontiguous_struct + type_c->block_indices[i+1];
+ noncontiguous_struct_char = static_cast<const char*>(noncontiguous_struct) + type_c->block_indices[i+1];
else //let's hope this is MPI_UB ?
noncontiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_types[i]);
}
- noncontiguous_struct=(void*)noncontiguous_struct_char;
+ noncontiguous_struct=reinterpret_cast<const void*>(noncontiguous_struct_char);
}
}
*/
void unserialize_struct( const void *contiguous_struct, void *noncontiguous_struct, int count, void *type, MPI_Op op)
{
- s_smpi_mpi_struct_t* type_c = (s_smpi_mpi_struct_t*)type;
+ s_smpi_mpi_struct_t* type_c = reinterpret_cast<s_smpi_mpi_struct_t*>(type);
int i,j;
- char* contiguous_struct_char = (char*)contiguous_struct;
- char* noncontiguous_struct_char = (char*)noncontiguous_struct+ type_c->block_indices[0];
+ const char* contiguous_struct_char = static_cast<const char*>(contiguous_struct);
+ char* noncontiguous_struct_char = static_cast<char*>(noncontiguous_struct)+ type_c->block_indices[0];
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_types[i]->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_struct_char, noncontiguous_struct_char, &type_c->block_lengths[i],
& type_c->old_types[i]);
- /*memcpy(noncontiguous_struct_char,
- contiguous_struct_char, type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));*/
else
- ((s_smpi_subtype_t*)type_c->old_types[i]->substruct)->unserialize( contiguous_struct_char,
+ static_cast<s_smpi_subtype_t*>(type_c->old_types[i]->substruct)->unserialize( contiguous_struct_char,
noncontiguous_struct_char,
type_c->block_lengths[i],
type_c->old_types[i]->substruct, op);
contiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);
if (i<type_c->block_count-1)
- noncontiguous_struct_char = (char*)noncontiguous_struct + type_c->block_indices[i+1];
+ noncontiguous_struct_char = static_cast<char*>(noncontiguous_struct) + type_c->block_indices[i+1];
else
noncontiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_get_extent(type_c->old_types[i]);
}
- noncontiguous_struct=(void*)noncontiguous_struct_char;
+ noncontiguous_struct=reinterpret_cast<void*>(noncontiguous_struct_char);
}
}
void free_struct(MPI_Datatype* type){
int i=0;
- for (i = 0; i < ((s_smpi_mpi_struct_t *)(*type)->substruct)->block_count; i++)
- smpi_datatype_unuse(((s_smpi_mpi_struct_t *)(*type)->substruct)->old_types[i]);
+ for (i = 0; i < reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_count; i++)
+ smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->old_types[i]);
if((*type)->in_use==0){
- xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->block_lengths);
- xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->block_indices);
- xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->old_types);
+ xbt_free(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_lengths);
+ xbt_free(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_indices);
+ xbt_free(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->old_types);
}
}
void use_struct(MPI_Datatype* type){
int i=0;
- for (i = 0; i < ((s_smpi_mpi_struct_t *)(*type)->substruct)->block_count; i++)
- smpi_datatype_use(((s_smpi_mpi_struct_t *)(*type)->substruct)->old_types[i]);
+ for (i = 0; i < reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_count; i++)
+ smpi_datatype_use(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->old_types[i]);
}
/* Create a Sub type struct to be able to serialize and unserialize it the structure s_smpi_mpi_struct_t is derived
forced_ub=1;
}
- if(!forced_lb && indices[i]+smpi_datatype_lb(old_types[i])<lb) lb = indices[i];
+ 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]);
contiguous=0;
}
- if(!contiguous){
+ if(contiguous==0){
s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create( blocklens, indices, count, old_types);
smpi_datatype_create(new_type, size, lb, ub,sizeof(s_smpi_mpi_struct_t), subtype, DT_FLAG_DATA);
static void max_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, MAX_OP);
+ APPLY_FUNC(a, b, length, char, MAX_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, MAX_OP);
+ APPLY_FUNC(a, b, length, short, MAX_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, MAX_OP);
+ APPLY_FUNC(a, b, length, int, MAX_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, MAX_OP);
+ APPLY_FUNC(a, b, length, long, MAX_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, MAX_OP);
+ APPLY_FUNC(a, b, length, unsigned short, MAX_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, MAX_OP);
+ APPLY_FUNC(a, b, length, unsigned int, MAX_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, MAX_OP);
+ APPLY_FUNC(a, b, length, unsigned long, MAX_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, MAX_OP);
+ APPLY_FUNC(a, b, length, unsigned char, MAX_OP)
} else if (*datatype == MPI_FLOAT) {
- APPLY_FUNC(a, b, length, float, MAX_OP);
+ APPLY_FUNC(a, b, length, float, MAX_OP)
} else if (*datatype == MPI_DOUBLE) {
- APPLY_FUNC(a, b, length, double, MAX_OP);
+ APPLY_FUNC(a, b, length, double, MAX_OP)
} else if (*datatype == MPI_LONG_DOUBLE) {
- APPLY_FUNC(a, b, length, long double, MAX_OP);
+ APPLY_FUNC(a, b, length, long double, MAX_OP)
+ } else {
+ xbt_die("Failed to apply MAX_OP to type %s", (*datatype)->name);
}
}
static void min_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, MIN_OP);
+ APPLY_FUNC(a, b, length, char, MIN_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, MIN_OP);
+ APPLY_FUNC(a, b, length, short, MIN_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, MIN_OP);
+ APPLY_FUNC(a, b, length, int, MIN_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, MIN_OP);
+ APPLY_FUNC(a, b, length, long, MIN_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, MIN_OP);
+ APPLY_FUNC(a, b, length, unsigned short, MIN_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, MIN_OP);
+ APPLY_FUNC(a, b, length, unsigned int, MIN_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, MIN_OP);
+ APPLY_FUNC(a, b, length, unsigned long, MIN_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, MIN_OP);
+ APPLY_FUNC(a, b, length, unsigned char, MIN_OP)
} else if (*datatype == MPI_FLOAT) {
- APPLY_FUNC(a, b, length, float, MIN_OP);
+ APPLY_FUNC(a, b, length, float, MIN_OP)
} else if (*datatype == MPI_DOUBLE) {
- APPLY_FUNC(a, b, length, double, MIN_OP);
+ APPLY_FUNC(a, b, length, double, MIN_OP)
} else if (*datatype == MPI_LONG_DOUBLE) {
- APPLY_FUNC(a, b, length, long double, MIN_OP);
+ APPLY_FUNC(a, b, length, long double, MIN_OP)
+ } else {
+ xbt_die("Failed to apply MIN_OP to type %s", (*datatype)->name);
}
}
static void sum_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, SUM_OP);
+ APPLY_FUNC(a, b, length, char, SUM_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, SUM_OP);
+ APPLY_FUNC(a, b, length, short, SUM_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, SUM_OP);
+ APPLY_FUNC(a, b, length, int, SUM_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, SUM_OP);
+ APPLY_FUNC(a, b, length, long, SUM_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, SUM_OP);
+ APPLY_FUNC(a, b, length, unsigned short, SUM_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, SUM_OP);
+ APPLY_FUNC(a, b, length, unsigned int, SUM_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, SUM_OP);
+ APPLY_FUNC(a, b, length, unsigned long, SUM_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, SUM_OP);
+ APPLY_FUNC(a, b, length, unsigned char, SUM_OP)
} else if (*datatype == MPI_FLOAT) {
- APPLY_FUNC(a, b, length, float, SUM_OP);
+ APPLY_FUNC(a, b, length, float, SUM_OP)
} else if (*datatype == MPI_DOUBLE) {
- APPLY_FUNC(a, b, length, double, SUM_OP);
+ APPLY_FUNC(a, b, length, double, SUM_OP)
} else if (*datatype == MPI_LONG_DOUBLE) {
- APPLY_FUNC(a, b, length, long double, SUM_OP);
+ APPLY_FUNC(a, b, length, long double, SUM_OP)
} else if (*datatype == MPI_C_FLOAT_COMPLEX) {
- APPLY_FUNC(a, b, length, float _Complex, SUM_OP);
+ APPLY_FUNC(a, b, length, float _Complex, SUM_OP)
} else if (*datatype == MPI_C_DOUBLE_COMPLEX) {
- APPLY_FUNC(a, b, length, double _Complex, SUM_OP);
+ APPLY_FUNC(a, b, length, double _Complex, SUM_OP)
} else if (*datatype == MPI_C_LONG_DOUBLE_COMPLEX) {
- APPLY_FUNC(a, b, length, long double _Complex, SUM_OP);
+ APPLY_FUNC(a, b, length, long double _Complex, SUM_OP)
+ } else {
+ xbt_die("Failed to apply SUM_OP to type %s", (*datatype)->name);
}
}
static void prod_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, PROD_OP);
+ APPLY_FUNC(a, b, length, char, PROD_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, PROD_OP);
+ APPLY_FUNC(a, b, length, short, PROD_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, PROD_OP);
+ APPLY_FUNC(a, b, length, int, PROD_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, PROD_OP);
+ APPLY_FUNC(a, b, length, long, PROD_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, PROD_OP);
+ APPLY_FUNC(a, b, length, unsigned short, PROD_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, PROD_OP);
+ APPLY_FUNC(a, b, length, unsigned int, PROD_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, PROD_OP);
+ APPLY_FUNC(a, b, length, unsigned long, PROD_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, PROD_OP);
+ APPLY_FUNC(a, b, length, unsigned char, PROD_OP)
} else if (*datatype == MPI_FLOAT) {
- APPLY_FUNC(a, b, length, float, PROD_OP);
+ APPLY_FUNC(a, b, length, float, PROD_OP)
} else if (*datatype == MPI_DOUBLE) {
- APPLY_FUNC(a, b, length, double, PROD_OP);
+ APPLY_FUNC(a, b, length, double, PROD_OP)
} else if (*datatype == MPI_LONG_DOUBLE) {
- APPLY_FUNC(a, b, length, long double, PROD_OP);
+ APPLY_FUNC(a, b, length, long double, PROD_OP)
} else if (*datatype == MPI_C_FLOAT_COMPLEX) {
- APPLY_FUNC(a, b, length, float _Complex, PROD_OP);
+ APPLY_FUNC(a, b, length, float _Complex, PROD_OP)
} else if (*datatype == MPI_C_DOUBLE_COMPLEX) {
- APPLY_FUNC(a, b, length, double _Complex, PROD_OP);
+ APPLY_FUNC(a, b, length, double _Complex, PROD_OP)
} else if (*datatype == MPI_C_LONG_DOUBLE_COMPLEX) {
- APPLY_FUNC(a, b, length, long double _Complex, PROD_OP);
+ APPLY_FUNC(a, b, length, long double _Complex, PROD_OP)
+ } else {
+ xbt_die("Failed to apply PROD_OP to type %s", (*datatype)->name);
}
}
static void land_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, LAND_OP);
+ APPLY_FUNC(a, b, length, char, LAND_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, LAND_OP);
+ APPLY_FUNC(a, b, length, short, LAND_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, LAND_OP);
+ APPLY_FUNC(a, b, length, int, LAND_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, LAND_OP);
+ APPLY_FUNC(a, b, length, long, LAND_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, LAND_OP);
+ APPLY_FUNC(a, b, length, unsigned short, LAND_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, LAND_OP);
+ APPLY_FUNC(a, b, length, unsigned int, LAND_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, LAND_OP);
+ APPLY_FUNC(a, b, length, unsigned long, LAND_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, LAND_OP);
+ APPLY_FUNC(a, b, length, unsigned char, LAND_OP)
} else if (*datatype == MPI_C_BOOL) {
- APPLY_FUNC(a, b, length, bool, LAND_OP);
+ APPLY_FUNC(a, b, length, bool, LAND_OP)
+ } else {
+ xbt_die("Failed to apply LAND_OP to type %s", (*datatype)->name);
}
}
static void lor_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, LOR_OP);
+ APPLY_FUNC(a, b, length, char, LOR_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, LOR_OP);
+ APPLY_FUNC(a, b, length, short, LOR_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, LOR_OP);
+ APPLY_FUNC(a, b, length, int, LOR_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, LOR_OP);
+ APPLY_FUNC(a, b, length, long, LOR_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, LOR_OP);
+ APPLY_FUNC(a, b, length, unsigned short, LOR_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, LOR_OP);
+ APPLY_FUNC(a, b, length, unsigned int, LOR_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, LOR_OP);
+ APPLY_FUNC(a, b, length, unsigned long, LOR_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, LOR_OP);
+ APPLY_FUNC(a, b, length, unsigned char, LOR_OP)
} else if (*datatype == MPI_C_BOOL) {
- APPLY_FUNC(a, b, length, bool, LOR_OP);
+ APPLY_FUNC(a, b, length, bool, LOR_OP)
+ } else {
+ xbt_die("Failed to apply LOR_OP to type %s", (*datatype)->name);
}
}
static void lxor_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, LXOR_OP);
+ APPLY_FUNC(a, b, length, char, LXOR_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, LXOR_OP);
+ APPLY_FUNC(a, b, length, short, LXOR_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, LXOR_OP);
+ APPLY_FUNC(a, b, length, int, LXOR_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, LXOR_OP);
+ APPLY_FUNC(a, b, length, long, LXOR_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, LXOR_OP);
+ APPLY_FUNC(a, b, length, unsigned short, LXOR_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, LXOR_OP);
+ APPLY_FUNC(a, b, length, unsigned int, LXOR_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, LXOR_OP);
+ APPLY_FUNC(a, b, length, unsigned long, LXOR_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, LXOR_OP);
+ APPLY_FUNC(a, b, length, unsigned char, LXOR_OP)
} else if (*datatype == MPI_C_BOOL) {
- APPLY_FUNC(a, b, length, bool, LXOR_OP);
+ APPLY_FUNC(a, b, length, bool, LXOR_OP)
+ } else {
+ xbt_die("Failed to apply LXOR_OP to type %s", (*datatype)->name);
}
}
static void band_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, BAND_OP);
+ APPLY_FUNC(a, b, length, char, BAND_OP)
}else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, BAND_OP);
+ APPLY_FUNC(a, b, length, short, BAND_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, BAND_OP);
+ APPLY_FUNC(a, b, length, int, BAND_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, BAND_OP);
+ APPLY_FUNC(a, b, length, long, BAND_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, BAND_OP);
+ APPLY_FUNC(a, b, length, unsigned short, BAND_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, BAND_OP);
+ APPLY_FUNC(a, b, length, unsigned int, BAND_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, BAND_OP);
+ APPLY_FUNC(a, b, length, unsigned long, BAND_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, BAND_OP);
+ APPLY_FUNC(a, b, length, unsigned char, BAND_OP)
} else if (*datatype == MPI_BYTE) {
- APPLY_FUNC(a, b, length, uint8_t, BAND_OP);
+ APPLY_FUNC(a, b, length, uint8_t, BAND_OP)
+ } else {
+ xbt_die("Failed to apply BAND_OP to type %s", (*datatype)->name);
}
}
static void bor_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, BOR_OP);
+ APPLY_FUNC(a, b, length, char, BOR_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, BOR_OP);
+ APPLY_FUNC(a, b, length, short, BOR_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, BOR_OP);
+ APPLY_FUNC(a, b, length, int, BOR_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, BOR_OP);
+ APPLY_FUNC(a, b, length, long, BOR_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, BOR_OP);
+ APPLY_FUNC(a, b, length, unsigned short, BOR_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, BOR_OP);
+ APPLY_FUNC(a, b, length, unsigned int, BOR_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, BOR_OP);
+ APPLY_FUNC(a, b, length, unsigned long, BOR_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, BOR_OP);
+ APPLY_FUNC(a, b, length, unsigned char, BOR_OP)
} else if (*datatype == MPI_BYTE) {
- APPLY_FUNC(a, b, length, uint8_t, BOR_OP);
+ APPLY_FUNC(a, b, length, uint8_t, BOR_OP)
+ } else {
+ xbt_die("Failed to apply BOR_OP to type %s", (*datatype)->name);
}
}
static void bxor_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, BXOR_OP);
+ APPLY_FUNC(a, b, length, char, BXOR_OP)
} else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, BXOR_OP);
+ APPLY_FUNC(a, b, length, short, BXOR_OP)
} else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, BXOR_OP);
+ APPLY_FUNC(a, b, length, int, BXOR_OP)
} else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, BXOR_OP);
+ APPLY_FUNC(a, b, length, long, BXOR_OP)
} else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, BXOR_OP);
+ APPLY_FUNC(a, b, length, unsigned short, BXOR_OP)
} else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, BXOR_OP);
+ APPLY_FUNC(a, b, length, unsigned int, BXOR_OP)
} else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, BXOR_OP);
+ APPLY_FUNC(a, b, length, unsigned long, BXOR_OP)
} else if (*datatype == MPI_UNSIGNED_CHAR) {
- APPLY_FUNC(a, b, length, unsigned char, BXOR_OP);
+ APPLY_FUNC(a, b, length, unsigned char, BXOR_OP)
} else if (*datatype == MPI_BYTE) {
- APPLY_FUNC(a, b, length, uint8_t, BXOR_OP);
+ APPLY_FUNC(a, b, length, uint8_t, BXOR_OP)
+ } else {
+ xbt_die("Failed to apply BXOR_OP to type %s", (*datatype)->name);
}
}
static void minloc_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_FLOAT_INT) {
- APPLY_FUNC(a, b, length, float_int, MINLOC_OP);
+ APPLY_FUNC(a, b, length, float_int, MINLOC_OP)
} else if (*datatype == MPI_LONG_INT) {
- APPLY_FUNC(a, b, length, long_int, MINLOC_OP);
+ APPLY_FUNC(a, b, length, long_int, MINLOC_OP)
} else if (*datatype == MPI_DOUBLE_INT) {
- APPLY_FUNC(a, b, length, double_int, MINLOC_OP);
+ APPLY_FUNC(a, b, length, double_int, MINLOC_OP)
} else if (*datatype == MPI_SHORT_INT) {
- APPLY_FUNC(a, b, length, short_int, MINLOC_OP);
+ APPLY_FUNC(a, b, length, short_int, MINLOC_OP)
} else if (*datatype == MPI_2LONG) {
- APPLY_FUNC(a, b, length, long_long, MINLOC_OP);
+ APPLY_FUNC(a, b, length, long_long, MINLOC_OP)
} else if (*datatype == MPI_2INT) {
- APPLY_FUNC(a, b, length, int_int, MINLOC_OP);
+ APPLY_FUNC(a, b, length, int_int, MINLOC_OP)
} else if (*datatype == MPI_LONG_DOUBLE_INT) {
- APPLY_FUNC(a, b, length, long_double_int, MINLOC_OP);
+ APPLY_FUNC(a, b, length, long_double_int, MINLOC_OP)
} else if (*datatype == MPI_2FLOAT) {
- APPLY_FUNC(a, b, length, float_float, MINLOC_OP);
+ APPLY_FUNC(a, b, length, float_float, MINLOC_OP)
} else if (*datatype == MPI_2DOUBLE) {
- APPLY_FUNC(a, b, length, double_double, MINLOC_OP);
+ APPLY_FUNC(a, b, length, double_double, MINLOC_OP)
+ } else {
+ xbt_die("Failed to apply MINLOC_OP to type %s", (*datatype)->name);
}
}
static void maxloc_func(void *a, void *b, int *length, MPI_Datatype * datatype)
{
if (*datatype == MPI_FLOAT_INT) {
- APPLY_FUNC(a, b, length, float_int, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, float_int, MAXLOC_OP)
} else if (*datatype == MPI_LONG_INT) {
- APPLY_FUNC(a, b, length, long_int, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, long_int, MAXLOC_OP)
} else if (*datatype == MPI_DOUBLE_INT) {
- APPLY_FUNC(a, b, length, double_int, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, double_int, MAXLOC_OP)
} else if (*datatype == MPI_SHORT_INT) {
- APPLY_FUNC(a, b, length, short_int, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, short_int, MAXLOC_OP)
} else if (*datatype == MPI_2LONG) {
- APPLY_FUNC(a, b, length, long_long, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, long_long, MAXLOC_OP)
} else if (*datatype == MPI_2INT) {
- APPLY_FUNC(a, b, length, int_int, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, int_int, MAXLOC_OP)
} else if (*datatype == MPI_LONG_DOUBLE_INT) {
- APPLY_FUNC(a, b, length, long_double_int, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, long_double_int, MAXLOC_OP)
} else if (*datatype == MPI_2FLOAT) {
- APPLY_FUNC(a, b, length, float_float, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, float_float, MAXLOC_OP)
} else if (*datatype == MPI_2DOUBLE) {
- APPLY_FUNC(a, b, length, double_double, MAXLOC_OP);
+ APPLY_FUNC(a, b, length, double_double, MAXLOC_OP)
+ } else {
+ xbt_die("Failed to apply MAXLOC_OP to type %s", (*datatype)->name);
}
}
xbt_free(op);
}
-void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len, MPI_Datatype * datatype)
+void smpi_op_apply(MPI_Op op, const void *invec, void *inoutvec, int *len, MPI_Datatype * datatype)
{
if(op==MPI_OP_NULL)
return;
}
if(!smpi_process_get_replaying())
- op->func(invec, inoutvec, len, datatype);
+ op->func(const_cast<void*>(invec), inoutvec, len, datatype);
}
int smpi_type_attr_delete(MPI_Datatype type, int keyval){
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)
+ static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
+ if(elem==NULL)
return MPI_ERR_ARG;
if(elem->delete_fn!=MPI_NULL_DELETE_FN){
void * value;
int flag;
if(smpi_type_attr_get(type, keyval, &value, &flag)==MPI_SUCCESS){
int ret = elem->delete_fn(type, keyval, value, &flag);
- if(ret!=MPI_SUCCESS) return ret;
+ if(ret!=MPI_SUCCESS)
+ return ret;
}
}
if(type->attributes==NULL)
return MPI_ERR_ARG;
- xbt_dict_remove_ext(type->attributes, (const char*)&keyval, sizeof(int));
+ xbt_dict_remove_ext(type->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
return MPI_SUCCESS;
}
int smpi_type_attr_get(MPI_Datatype type, int keyval, void* attr_value, int* flag){
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)));
+ static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
if(!elem)
return MPI_ERR_ARG;
xbt_ex_t ex;
return MPI_SUCCESS;
}
TRY {
- *(void**)attr_value = xbt_dict_get_ext(type->attributes, (const char*)&keyval, sizeof(int));
+ *static_cast<void**>(attr_value) = xbt_dict_get_ext(type->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
*flag=1;
}
CATCH(ex) {
if(!smpi_type_keyvals)
smpi_type_keyvals = xbt_dict_new();
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 )
+ static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
+ if(elem==NULL)
return MPI_ERR_ARG;
int flag;
void* value;
smpi_type_attr_get(type, keyval, &value, &flag);
if(flag && elem->delete_fn!=MPI_NULL_DELETE_FN){
int ret = elem->delete_fn(type, keyval, value, &flag);
- if(ret!=MPI_SUCCESS) return ret;
+ if(ret!=MPI_SUCCESS)
+ return ret;
}
if(type->attributes==NULL)
type->attributes=xbt_dict_new();
- xbt_dict_set_ext(type->attributes, (const char*)&keyval, sizeof(int), attr_value, NULL);
+ xbt_dict_set_ext(type->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int), attr_value, NULL);
return MPI_SUCCESS;
}
value->delete_fn=delete_fn;
*keyval = type_keyval_id;
- xbt_dict_set_ext(smpi_type_keyvals,(const char*)keyval, sizeof(int),(void*)value, NULL);
+ xbt_dict_set_ext(smpi_type_keyvals,reinterpret_cast<const char*>(keyval), sizeof(int),reinterpret_cast<void*>(value), NULL);
type_keyval_id++;
return MPI_SUCCESS;
}
int smpi_type_keyval_free(int* keyval){
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)));
+ static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int)));
if(!elem){
return MPI_ERR_ARG;
}
- xbt_dict_remove_ext(smpi_type_keyvals, (const char*)keyval, sizeof(int));
+ xbt_dict_remove_ext(smpi_type_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int));
xbt_free(elem);
return MPI_SUCCESS;
}
size_t size = smpi_datatype_size(type);
if (outcount - *position < incount*static_cast<int>(size))
return MPI_ERR_BUFFER;
- smpi_datatype_copy(inbuf, incount, type, (char*)outbuf + *position, outcount, MPI_CHAR);
+ smpi_datatype_copy(inbuf, incount, type, static_cast<char*>(outbuf) + *position, outcount, MPI_CHAR);
*position += incount * size;
return MPI_SUCCESS;
}
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, outbuf, outcount, type);
+ smpi_datatype_copy(static_cast<char*>(inbuf) + *position, insize, MPI_CHAR, outbuf, outcount, type);
*position += outcount * size;
return MPI_SUCCESS;
}
{
int retval = 0;
- if (!address) {
+ if (address==NULL) {
retval = MPI_ERR_ARG;
} else {
- *address = (MPI_Aint) location;
+ *address = reinterpret_cast<MPI_Aint>(location);
retval = MPI_SUCCESS;
}
return retval;
} else if (size == NULL) {
retval = MPI_ERR_ARG;
} else {
- *size = (int) smpi_datatype_size(datatype);
+ *size = static_cast<int>(smpi_datatype_size(datatype));
retval = MPI_SUCCESS;
}
return retval;
} else if (newgroup == NULL) {
retval = MPI_ERR_ARG;
} else {
- size = size2 = smpi_group_size(group1);
+ size = smpi_group_size(group1);
+ size2 = size;
for (i = 0; i < size2; i++) {
proc1 = smpi_group_index(group1, i);
proc2 = smpi_group_rank(group2, proc1);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request)
+ if (retval != MPI_SUCCESS && request != NULL)
*request = MPI_REQUEST_NULL;
return retval;
}
retval = MPI_SUCCESS;
}
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request)
+ if (retval != MPI_SUCCESS && request != NULL)
*request = MPI_REQUEST_NULL;
return retval;
}
retval = MPI_SUCCESS;
}
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request)
+ if (retval != MPI_SUCCESS && request != NULL)
*request = MPI_REQUEST_NULL;
return retval;
}
retval = MPI_SUCCESS;
} else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
retval = MPI_ERR_RANK;
- } else if (count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (buf==NULL && count > 0) {
+ } else if ((count < 0) || (buf==NULL && count > 0)) {
retval = MPI_ERR_COUNT;
} else if (!is_datatype_valid(datatype)) {
retval = MPI_ERR_TYPE;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
}
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request)
+ if (retval != MPI_SUCCESS && request != NULL)
*request = MPI_REQUEST_NULL;
return retval;
}
retval = MPI_SUCCESS;
} else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
retval = MPI_ERR_RANK;
- } else if (count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (buf==NULL && count > 0) {
+ } else if ((count < 0) || (buf==NULL && count > 0)) {
retval = MPI_ERR_COUNT;
} else if (!is_datatype_valid(datatype)) {
retval = MPI_ERR_TYPE;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
}
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request)
+ if (retval != MPI_SUCCESS && request!=NULL)
*request = MPI_REQUEST_NULL;
return retval;
}
retval = MPI_SUCCESS;
} else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
retval = MPI_ERR_RANK;
- } else if (count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (buf==NULL && count > 0) {
+ } else if ((count < 0)|| (buf==NULL && count > 0)) {
retval = MPI_ERR_COUNT;
} else if (!is_datatype_valid(datatype)) {
retval = MPI_ERR_TYPE;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
}
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request)
+ if (retval != MPI_SUCCESS && request!=NULL)
*request = MPI_REQUEST_NULL;
return retval;
}
retval = MPI_SUCCESS;
} else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
retval = MPI_ERR_RANK;
- } else if (count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (buf==NULL && count > 0) {
+ } else if ((count < 0) || (buf==NULL && count > 0)) {
retval = MPI_ERR_COUNT;
} else if (!is_datatype_valid(datatype)) {
retval = MPI_ERR_TYPE;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
retval = MPI_SUCCESS;
} else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
retval = MPI_ERR_RANK;
- } else if (count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (buf==NULL && count > 0) {
+ } else if ((count < 0) || (buf==NULL && count > 0)) {
retval = MPI_ERR_COUNT;
} else if (!is_datatype_valid(datatype)) {
retval = MPI_ERR_TYPE;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
retval = MPI_SUCCESS;
} else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
retval = MPI_ERR_RANK;
- } else if (count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (buf==NULL && count > 0) {
+ } else if ((count < 0) || (buf==NULL && count > 0)) {
retval = MPI_ERR_COUNT;
} else if (!is_datatype_valid(datatype)){
retval = MPI_ERR_TYPE;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
}else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
(src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
retval = MPI_ERR_RANK;
- } else if (sendcount < 0 || recvcount<0) {
- retval = MPI_ERR_COUNT;
- } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
+ } else if ((sendcount < 0 || recvcount<0) ||
+ (sendbuf==NULL && sendcount > 0) || (recvbuf==NULL && recvcount>0)) {
retval = MPI_ERR_COUNT;
} else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
retval = MPI_ERR_TAG;
int known=0;
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(sendtype);
extra->send_size = sendcount*dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
- if(!known)
+ if(known==0)
dt_size_recv = smpi_datatype_size(recvtype);
extra->recv_size = recvcount*dt_size_recv;
int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype, int dst, int sendtag, int src, int recvtag,
MPI_Comm comm, MPI_Status * status)
{
- //TODO: suboptimal implementation
void *recvbuf;
int retval = 0;
if (!is_datatype_valid(datatype)) {
smpi_empty_status(status);
retval = MPI_SUCCESS;
} else {
- int rank = request && (*request)->comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+ int rank = (request!=NULL && (*request)->comm != MPI_COMM_NULL) ? smpi_process_index() : -1;
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_TEST;
int retval = 0;
smpi_bench_end();
- if (flag == NULL) {
- retval = MPI_ERR_ARG;
- } else if (status == NULL) {
+ if ((flag == NULL) || (status == NULL)) {
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
retval = MPI_SUCCESS;
} else {
- int rank = request && (*request)->comm != MPI_COMM_NULL ? smpi_process_index() : -1;
+ int rank = (request!=NULL && (*request)->comm != MPI_COMM_NULL) ? smpi_process_index() : -1;
int src_traced = (*request)->src;
int dst_traced = (*request)->dst;
int *valid = xbt_new0(int, count);
MPI_Comm *comms = xbt_new0(MPI_Comm, count);
- //int valid_count = 0;
for (i = 0; i < count; i++) {
MPI_Request req = requests[i];
if(req!=MPI_REQUEST_NULL){
for (i = 0; i < count; i++) {
if(valid[i]){
- //int src_traced = srcs[*index];
//the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
int src_traced = srcs[i];
int dst_traced = dsts[i];
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
retval = MPI_ERR_COUNT;
} else {
- char* sendtmpbuf = (char*) sendbuf;
+ char* sendtmpbuf = static_cast<char*>(sendbuf);
int sendtmpcount = sendcount;
MPI_Datatype sendtmptype = sendtype;
if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
int known=0;
extra->datatype1 = encode_datatype(sendtmptype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(sendtmptype);
extra->send_size = sendtmpcount*dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
- if((smpi_comm_rank(comm)==root) && !known)
+ if((smpi_comm_rank(comm)==root) && known==0)
dt_size_recv = smpi_datatype_size(recvtype);
extra->recv_size = recvcount*dt_size_recv;
} else if (recvcounts == NULL || displs == NULL) {
retval = MPI_ERR_ARG;
} else {
- char* sendtmpbuf = (char*) sendbuf;
+ char* sendtmpbuf = static_cast<char*>(sendbuf);
int sendtmpcount = sendcount;
MPI_Datatype sendtmptype = sendtype;
if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
int known=0;
extra->datatype1 = encode_datatype(sendtmptype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(sendtype);
extra->send_size = sendtmpcount*dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
- if(!known)
+ if(known==0)
dt_size_recv = smpi_datatype_size(recvtype);
if((smpi_comm_rank(comm)==root)){
extra->recvcounts= xbt_new(int,size);
retval = MPI_ERR_COUNT;
} else {
if(sendbuf == MPI_IN_PLACE) {
- sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
+ sendbuf=static_cast<char*>(recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
sendcount=recvcount;
sendtype=recvtype;
}
int known=0;
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(sendtype);
extra->send_size = sendcount*dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
- if(!known)
+ if(known==0)
dt_size_recv = smpi_datatype_size(recvtype);
extra->recv_size = recvcount*dt_size_recv;
} else {
if(sendbuf == MPI_IN_PLACE) {
- sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
+ sendbuf=static_cast<char*>(recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
sendcount=recvcounts[smpi_comm_rank(comm)];
sendtype=recvtype;
}
int known=0;
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(sendtype);
extra->send_size = sendcount*dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
- if(!known)
+ if(known==0)
dt_size_recv = smpi_datatype_size(recvtype);
extra->recvcounts= xbt_new(int, size);
for(i=0; i< size; i++)//copy data to avoid bad free
int known=0;
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
- if((smpi_comm_rank(comm)==root) && !known)
+ if((smpi_comm_rank(comm)==root) && known==0)
dt_size_send = smpi_datatype_size(sendtype);
extra->send_size = sendcount*dt_size_send;
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
- if(!known)
+ if(known==0)
dt_size_recv = smpi_datatype_size(recvtype);
extra->recv_size = recvcount*dt_size_recv;
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
int known=0;
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(sendtype);
if((smpi_comm_rank(comm)==root)){
extra->sendcounts= xbt_new(int, size);
}
extra->datatype2 = encode_datatype(recvtype, &known);
int dt_size_recv = 1;
- if(!known)
+ if(known==0)
dt_size_recv = smpi_datatype_size(recvtype);
extra->recv_size = recvcount*dt_size_recv;
TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
extra->root = root_traced;
retval = MPI_ERR_OP;
} else {
- char* sendtmpbuf = (char*) sendbuf;
+ char* sendtmpbuf = static_cast<char*>(sendbuf);
if( sendbuf == MPI_IN_PLACE ) {
- sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
+ sendtmpbuf = static_cast<char*>(xbt_malloc(count*smpi_datatype_get_extent(datatype)));
smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
}
int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = count*dt_size_send;
TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = 0;
extra->recvcounts= xbt_new(int, size);
int known=0;
extra->datatype1 = encode_datatype(datatype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(datatype);
extra->send_size = 0;
extra->recvcounts= xbt_new(int, count);
TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
- int* recvcounts=(int*)xbt_malloc(count);
- for (i=0; i<count;i++)recvcounts[i]=recvcount;
+ int* recvcounts=static_cast<int*>(xbt_malloc(count));
+ for (i=0; i<count;i++)
+ recvcounts[i]=recvcount;
mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts, datatype, op, comm);
xbt_free(recvcounts);
retval = MPI_SUCCESS;
extra->type = TRACING_ALLTOALL;
int known=0;
extra->datatype1 = encode_datatype(sendtype, &known);
- if(!known)
+ if(known==0)
extra->send_size = sendcount*smpi_datatype_size(sendtype);
else
extra->send_size = sendcount;
extra->datatype2 = encode_datatype(recvtype, &known);
- if(!known)
+ if(known==0)
extra->recv_size = recvcount*smpi_datatype_size(recvtype);
else
extra->recv_size = recvcount;
int known=0;
extra->datatype1 = encode_datatype(sendtype, &known);
int dt_size_send = 1;
- if(!known)
+ if(known==0)
dt_size_send = smpi_datatype_size(sendtype);
int dt_size_recv = 1;
extra->datatype2 = encode_datatype(recvtype, &known);
- if(!known)
+ if(known==0)
dt_size_recv = smpi_datatype_size(recvtype);
for(i=0; i< size; i++){//copy data to avoid bad free
extra->send_size += sendcounts[i]*dt_size_send;
} else if (count<0){
retval = MPI_ERR_COUNT;
} else {
- int* blocklens=(int*)xbt_malloc(blocklength*count);
- for (i=0; i<count;i++)blocklens[i]=blocklength;
+ int* blocklens=static_cast<int*>(xbt_malloc(blocklength*count));
+ for (i=0; i<count;i++)
+ blocklens[i]=blocklength;
retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
xbt_free(blocklens);
}
retval = MPI_ERR_RANK;
} else if (target_disp <0){
retval = MPI_ERR_ARG;
- } else if (origin_count < 0 || target_count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (origin_addr==NULL && origin_count > 0){
+ } else if ((origin_count < 0 || target_count < 0) ||
+ (origin_addr==NULL && origin_count > 0)){
retval = MPI_ERR_COUNT;
} else if ((!is_datatype_valid(origin_datatype)) || (!is_datatype_valid(target_datatype))) {
retval = MPI_ERR_TYPE;
retval = MPI_ERR_RANK;
} else if (target_disp <0){
retval = MPI_ERR_ARG;
- } else if (origin_count < 0 || target_count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (origin_addr==NULL && origin_count > 0){
+ } else if ((origin_count < 0 || target_count < 0) ||
+ (origin_addr==NULL && origin_count > 0)){
retval = MPI_ERR_COUNT;
} else if ((!is_datatype_valid(origin_datatype)) || (!is_datatype_valid(target_datatype))) {
retval = MPI_ERR_TYPE;
retval = MPI_ERR_RANK;
} else if (target_disp <0){
retval = MPI_ERR_ARG;
- } else if (origin_count < 0 || target_count < 0) {
- retval = MPI_ERR_COUNT;
- } else if (origin_addr==NULL && origin_count > 0){
+ } else if ((origin_count < 0 || target_count < 0) ||
+ (origin_addr==NULL && origin_count > 0)){
retval = MPI_ERR_COUNT;
} else if ((!is_datatype_valid(origin_datatype)) ||
(!is_datatype_valid(target_datatype))) {
int PMPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr){
void *ptr = xbt_malloc(size);
- if(!ptr)
+ if(ptr==NULL)
return MPI_ERR_NO_MEM;
else {
- *(void **)baseptr = ptr;
+ *static_cast<void**>(baseptr) = ptr;
return MPI_SUCCESS;
}
}
case MPI_IO:
case MPI_APPNUM:
*flag = 1;
- *(int**)attr_value = &zero;
+ *static_cast<int**>(attr_value) = &zero;
return MPI_SUCCESS;
case MPI_UNIVERSE_SIZE:
*flag = 1;
- *(int**)attr_value = &smpi_universe_size;
+ *static_cast<int**>(attr_value) = &smpi_universe_size;
return MPI_SUCCESS;
case MPI_LASTUSEDCODE:
*flag = 1;
- *(int**)attr_value = &last_used_code;
+ *static_cast<int**>(attr_value) = &last_used_code;
return MPI_SUCCESS;
case MPI_TAG_UB:
*flag=1;
- *(int**)attr_value = &tag_ub;
+ *static_cast<int**>(attr_value) = &tag_ub;
return MPI_SUCCESS;
case MPI_WTIME_IS_GLOBAL:
*flag = 1;
- *(int**)attr_value = &one;
+ *static_cast<int**>(attr_value) = &one;
return MPI_SUCCESS;
default:
return smpi_comm_attr_get(comm, keyval, attr_value, flag);
return MPI_ERR_ARG;
if (value == NULL)
return MPI_ERR_INFO_VALUE;
- char* tmpvalue=(char*)xbt_dict_get_or_null(info->info_dict, key);
+ char* tmpvalue=static_cast<char*>(xbt_dict_get_or_null(info->info_dict, key));
if(tmpvalue){
memset(value, 0, valuelen);
memcpy(value,tmpvalue, (strlen(tmpvalue) + 1 < static_cast<size_t>(valuelen)) ? strlen(tmpvalue) + 1 : valuelen);
int *key;
void* data;
xbt_dict_foreach(info->info_dict,cursor,key,data){
- xbt_dict_set((*newinfo)->info_dict, (char*)key, data, NULL);
+ xbt_dict_set((*newinfo)->info_dict, reinterpret_cast<char*>(key), data, NULL);
}
return MPI_SUCCESS;
}
int num=0;
xbt_dict_foreach(info->info_dict,cursor,keyn,data){
if(num==n){
- strcpy(key,keyn);
+ strncpy(key,keyn,strlen(keyn)+1);
xbt_dict_cursor_free(&cursor);
return MPI_SUCCESS;
}
if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){
char *name = xbt_str_join_array(action, " ");
XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock);
- free(name);
+ xbt_free(name);
}
}
static xbt_dynar_t get_reqq_self()
{
char * key = bprintf("%d", smpi_process_index());
- xbt_dynar_t dynar_mpi_request = (xbt_dynar_t) xbt_dict_get(reqq, key);
- free(key);
+ xbt_dynar_t dynar_mpi_request = static_cast<xbt_dynar_t>(xbt_dict_get(reqq, key));
+ xbt_free(key);
return dynar_mpi_request;
}
{
char * key = bprintf("%d", smpi_process_index());
xbt_dict_set(reqq, key, mpi_request, free);
- free(key);
+ xbt_free(key);
}
//allocate a single buffer for all sends, growing it if needed
{
//default type for output is set to MPI_BYTE
// MPI_DEFAULT_TYPE is not set for output, use directly MPI_BYTE
- if(known)*known=1;
+ if(known!=NULL)
+ *known=1;
if (datatype==MPI_BYTE){
return "";
}
if(datatype==MPI_FLOAT)
return "5";
//tell that the datatype is not handled by replay, and that its size should be measured and replayed as size*MPI_BYTE
- if(known)*known=0;
+ if(known!=NULL)
+ *known=0;
// default - not implemented.
// do not warn here as we pass in this function even for other trace formats
return "-1";
static void action_init(const char *const *action)
{
XBT_DEBUG("Initialize the counters");
- CHECK_ACTION_PARAMS(action, 0, 1);
- if(action[2]) MPI_DEFAULT_TYPE= MPI_DOUBLE; // default MPE dataype
+ CHECK_ACTION_PARAMS(action, 0, 1)
+ if(action[2])
+ MPI_DEFAULT_TYPE=MPI_DOUBLE; // default MPE dataype
else MPI_DEFAULT_TYPE= MPI_BYTE; // default TAU datatype
/* start a simulated timer */
/*initialize the number of active processes */
active_processes = smpi_process_count();
- if (!reqq) {
+ if (reqq==NULL) {
reqq = xbt_dict_new();
}
static void action_finalize(const char *const *action)
{
+ /* do nothing */
}
static void action_comm_size(const char *const *action)
static void action_compute(const char *const *action)
{
- CHECK_ACTION_PARAMS(action, 1, 0);
+ CHECK_ACTION_PARAMS(action, 1, 0)
double clock = smpi_process_simulated_elapsed();
double flops= parse_double(action[2]);
int rank = smpi_process_index();
static void action_send(const char *const *action)
{
- CHECK_ACTION_PARAMS(action, 2, 1);
+ CHECK_ACTION_PARAMS(action, 2, 1)
int to = atoi(action[2]);
double size=parse_double(action[3]);
double clock = smpi_process_simulated_elapsed();
- if(action[4]) {
+ if(action[4])
MPI_CURRENT_TYPE=decode_datatype(action[4]);
- } else {
+ else
MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
- }
int rank = smpi_process_index();
static void action_Isend(const char *const *action)
{
- CHECK_ACTION_PARAMS(action, 2, 1);
+ CHECK_ACTION_PARAMS(action, 2, 1)
int to = atoi(action[2]);
double size=parse_double(action[3]);
double clock = smpi_process_simulated_elapsed();
MPI_Request request;
- if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]);
- else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
+ if(action[4])
+ MPI_CURRENT_TYPE=decode_datatype(action[4]);
+ else
+ MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
int rank = smpi_process_index();
int dst_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), to);
}
static void action_recv(const char *const *action) {
- CHECK_ACTION_PARAMS(action, 2, 1);
+ CHECK_ACTION_PARAMS(action, 2, 1)
int from = atoi(action[2]);
double size=parse_double(action[3]);
double clock = smpi_process_simulated_elapsed();
MPI_Status status;
- if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]);
- else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
+ if(action[4])
+ MPI_CURRENT_TYPE=decode_datatype(action[4]);
+ else
+ MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
int rank = smpi_process_index();
int src_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), from);
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
//unknow size from the receiver pov
- if(size==-1){
+ if(size<=0.0){
smpi_mpi_probe(from, 0, MPI_COMM_WORLD, &status);
size=status.count;
}
static void action_Irecv(const char *const *action)
{
- CHECK_ACTION_PARAMS(action, 2, 1);
+ CHECK_ACTION_PARAMS(action, 2, 1)
int from = atoi(action[2]);
double size=parse_double(action[3]);
double clock = smpi_process_simulated_elapsed();
MPI_Request request;
- if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]);
- else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
+ if(action[4])
+ MPI_CURRENT_TYPE=decode_datatype(action[4]);
+ else
+ MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
int rank = smpi_process_index();
int src_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), from);
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
MPI_Status status;
//unknow size from the receiver pov
- if(size==-1){
+ if(size<=0.0){
smpi_mpi_probe(from, 0, MPI_COMM_WORLD, &status);
size=status.count;
}
}
static void action_test(const char *const *action){
- CHECK_ACTION_PARAMS(action, 0, 0);
+ CHECK_ACTION_PARAMS(action, 0, 0)
double clock = smpi_process_simulated_elapsed();
MPI_Request request;
MPI_Status status;
//if request is null here, this may mean that a previous test has succeeded
//Different times in traced application and replayed version may lead to this
//In this case, ignore the extra calls.
- if(request){
+ if(request!=NULL){
int rank = smpi_process_index();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type=TRACING_TEST;
}
static void action_wait(const char *const *action){
- CHECK_ACTION_PARAMS(action, 0, 0);
+ CHECK_ACTION_PARAMS(action, 0, 0)
double clock = smpi_process_simulated_elapsed();
MPI_Request request;
MPI_Status status;
xbt_str_join_array(action," "));
request = xbt_dynar_pop_as(get_reqq_self(),MPI_Request);
- if (!request){
+ if (request==NULL){
/* Assume that the trace is well formed, meaning the comm might have been caught by a MPI_test. Then just return.*/
return;
}
}
static void action_waitall(const char *const *action){
- CHECK_ACTION_PARAMS(action, 0, 0);
+ CHECK_ACTION_PARAMS(action, 0, 0)
double clock = smpi_process_simulated_elapsed();
int count_requests=0;
unsigned int i=0;
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; (int)i < count_requests; i++) {
+ for (i = 0; static_cast<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; (int)i < count_requests; i++) {
+ for (i = 0; static_cast<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);
xbt_dynar_free(&srcs);
xbt_dynar_free(&dsts);
xbt_dynar_free(&recvs);
-
- //TODO xbt_dynar_free_container(get_reqq_self());
set_reqq_self(xbt_dynar_new(sizeof(MPI_Request),&xbt_free_ref));
}
log_timed_action (action, clock);
static void action_bcast(const char *const *action)
{
- CHECK_ACTION_PARAMS(action, 1, 2);
+ CHECK_ACTION_PARAMS(action, 1, 2)
double size = parse_double(action[2]);
double clock = smpi_process_simulated_elapsed();
int root=0;
static void action_reduce(const char *const *action)
{
- CHECK_ACTION_PARAMS(action, 2, 2);
+ CHECK_ACTION_PARAMS(action, 2, 2)
double comm_size = parse_double(action[2]);
double comp_size = parse_double(action[3]);
double clock = smpi_process_simulated_elapsed();
}
static void action_allReduce(const char *const *action) {
- CHECK_ACTION_PARAMS(action, 2, 1);
+ CHECK_ACTION_PARAMS(action, 2, 1)
double comm_size = parse_double(action[2]);
double comp_size = parse_double(action[3]);
- if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]);
- else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
+ if(action[4])
+ MPI_CURRENT_TYPE=decode_datatype(action[4]);
+ else
+ MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
double clock = smpi_process_simulated_elapsed();
int rank = smpi_process_index();
}
static void action_allToAll(const char *const *action) {
- CHECK_ACTION_PARAMS(action, 2, 2); //two mandatory (send and recv volumes)
+ CHECK_ACTION_PARAMS(action, 2, 2) //two mandatory (send and recv volumes)
//two optional (corresponding datatypes)
double clock = smpi_process_simulated_elapsed();
int comm_size = smpi_comm_size(MPI_COMM_WORLD);
4) 0 is the send datatype id, see decode_datatype()
5) 0 is the recv datatype id, see decode_datatype()
*/
- CHECK_ACTION_PARAMS(action, 2, 3);
+ CHECK_ACTION_PARAMS(action, 2, 3)
double clock = smpi_process_simulated_elapsed();
int comm_size = smpi_comm_size(MPI_COMM_WORLD);
int send_size = parse_double(action[2]);
double clock = smpi_process_simulated_elapsed();
int comm_size = smpi_comm_size(MPI_COMM_WORLD);
- CHECK_ACTION_PARAMS(action, comm_size+1, 2);
+ CHECK_ACTION_PARAMS(action, comm_size+1, 2)
int send_size = parse_double(action[2]);
int *disps = xbt_new0(int, comm_size);
int *recvcounts = xbt_new0(int, comm_size);
}
int root=atoi(action[3+comm_size]);
- int rank = smpi_comm_rank(MPI_COMM_WORLD);;
+ int rank = smpi_comm_rank(MPI_COMM_WORLD);
if(rank==root)
recv = smpi_get_tmp_recvbuffer(recv_sum* smpi_datatype_size(MPI_CURRENT_TYPE2));
We analyze a MPI_Reduce_scatter call to one MPI_Reduce and one MPI_Scatterv. */
double clock = smpi_process_simulated_elapsed();
int comm_size = smpi_comm_size(MPI_COMM_WORLD);
- CHECK_ACTION_PARAMS(action, comm_size+1, 1);
+ CHECK_ACTION_PARAMS(action, comm_size+1, 1)
int comp_size = parse_double(action[2+comm_size]);
int *recvcounts = xbt_new0(int, comm_size);
int *disps = xbt_new0(int, comm_size);
3) No more values mean that the datatype for sent and receive buffer is the default one, see decode_datatype(). */
double clock = smpi_process_simulated_elapsed();
- CHECK_ACTION_PARAMS(action, 2, 2);
+ CHECK_ACTION_PARAMS(action, 2, 2)
int sendcount=atoi(action[2]);
int recvcount=atoi(action[3]);
double clock = smpi_process_simulated_elapsed();
int comm_size = smpi_comm_size(MPI_COMM_WORLD);
- CHECK_ACTION_PARAMS(action, comm_size+1, 2);
+ CHECK_ACTION_PARAMS(action, comm_size+1, 2)
int i=0;
int sendcount=atoi(action[2]);
int *recvcounts = xbt_new0(int, comm_size);
double clock = smpi_process_simulated_elapsed();
int comm_size = smpi_comm_size(MPI_COMM_WORLD);
- CHECK_ACTION_PARAMS(action, 2*comm_size+2, 2);
+ CHECK_ACTION_PARAMS(action, 2*comm_size+2, 2)
int send_buf_size=0,recv_buf_size=0,i=0;
int *sendcounts = xbt_new0(int, comm_size);
int *recvcounts = xbt_new0(int, comm_size);
char *operation =bprintf("%s_init",__FUNCTION__);
TRACE_smpi_collective_in(rank, -1, operation, extra);
TRACE_smpi_collective_out(rank, -1, operation);
- free(operation);
+ xbt_free(operation);
- if (!_xbt_replay_action_init()) {
+ if (_xbt_replay_action_init()==0) {
xbt_replay_action_register("init", action_init);
xbt_replay_action_register("finalize", action_finalize);
xbt_replay_action_register("comm_size", action_comm_size);
double sim_time= 1.;
/* One active process will stop. Decrease the counter*/
XBT_DEBUG("There are %lu elements in reqq[*]", xbt_dynar_length(get_reqq_self()));
- if (!xbt_dynar_is_empty(get_reqq_self())){
+ if (xbt_dynar_is_empty(get_reqq_self())==0){
int count_requests=xbt_dynar_length(get_reqq_self());
MPI_Request requests[count_requests];
MPI_Status status[count_requests];
active_processes--;
}
- if(!active_processes){
+ if(active_processes==0){
/* Last process alive speaking */
/* end the simulated timer */
sim_time = smpi_process_simulated_elapsed();
- }
-
- //TODO xbt_dynar_free_container(get_reqq_self()));
-
- if(!active_processes){
XBT_INFO("Simulation time %f", sim_time);
_xbt_replay_action_exit();
xbt_free(sendbuffer);
xbt_free(recvbuffer);
- //xbt_free(reqq);
xbt_dict_free(&reqq); //not need, data have been freed ???
reqq = NULL;
}
TRACE_smpi_collective_out(rank, -1, operation);
TRACE_smpi_finalize(smpi_process_index());
smpi_process_destroy();
- free(operation);
+ xbt_free(operation);
}
return;
}
*length = strlen(win->name);
- strcpy(name, win->name);
+ strncpy(name, win->name, *length+1);
}
void smpi_mpi_win_get_group(MPI_Win win, MPI_Group* group){
}
void smpi_mpi_win_set_name(MPI_Win win, char* name){
- win->name = xbt_strdup(name);;
+ win->name = xbt_strdup(name);
}
int smpi_mpi_win_fence( int assert, MPI_Win win){
XBT_DEBUG("Entering fence");
- if(!win->opened)
+ if(win->opened==0)
win->opened=1;
if(assert != MPI_MODE_NOPRECEDE){
xbt_barrier_wait(win->bar);
MPI_Request req;
// start all requests that have been prepared by another process
xbt_dynar_foreach(reqs, cpt, req){
- if (req->flags & PREPARED) smpi_mpi_start(req);
+ if (req->flags & PREPARED)
+ smpi_mpi_start(req);
}
MPI_Request* treqs = static_cast<MPI_Request*>(xbt_dynar_to_array(reqs));
int smpi_mpi_put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win)
{
- if(!win->opened)//check that post/start has been done
+ if(win->opened==0)//check that post/start has been done
return MPI_ERR_WIN;
//get receiver pointer
MPI_Win recv_win = win->connected_wins[target_rank];
- void* recv_addr = (void*) ( ((char*)recv_win->base) + target_disp * recv_win->disp_unit);
+ void* recv_addr = static_cast<void*> ( static_cast<char*>(recv_win->base) + target_disp * recv_win->disp_unit);
XBT_DEBUG("Entering MPI_Put to %d", target_rank);
if(target_rank != smpi_comm_rank(win->comm)){
int smpi_mpi_get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win)
{
- if(!win->opened)//check that post/start has been done
+ if(win->opened==0)//check that post/start has been done
return MPI_ERR_WIN;
//get sender pointer
MPI_Win send_win = win->connected_wins[target_rank];
- void* send_addr = (void*)( ((char*)send_win->base) + target_disp * send_win->disp_unit);
+ void* send_addr = static_cast<void*>(static_cast<char*>(send_win->base) + target_disp * send_win->disp_unit);
XBT_DEBUG("Entering MPI_Get from %d", target_rank);
if(target_rank != smpi_comm_rank(win->comm)){
int smpi_mpi_accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win)
{
- if(!win->opened)//check that post/start has been done
+ if(win->opened==0)//check that post/start has been done
return MPI_ERR_WIN;
//FIXME: local version
//get receiver pointer
MPI_Win recv_win = win->connected_wins[target_rank];
- void* recv_addr = (void*)( ((char*)recv_win->base) + target_disp * recv_win->disp_unit);
+ void* recv_addr = static_cast<void*>(static_cast<char*>(recv_win->base) + target_disp * recv_win->disp_unit);
XBT_DEBUG("Entering MPI_Accumulate to %d", target_rank);
//prepare send_request
int size = smpi_group_size(group);
MPI_Request* reqs = xbt_new0(MPI_Request, size);
-// for(i=0;i<size;i++){
while(j!=size){
int src=smpi_group_index(group,j);
if(src!=smpi_process_index()){
int smpi_mpi_win_complete(MPI_Win win){
if(win->opened==0)
xbt_die("Complete called on already opened MPI_Win");
-// xbt_barrier_wait(win->bar);
- //MPI_Comm comm = smpi_comm_new(win->group, NULL);
- //mpi_coll_barrier_fun(comm);
- //smpi_comm_destroy(comm);
XBT_DEBUG("Entering MPI_Win_Complete");
int i=0,j=0;
MPI_Request req;
// start all requests that have been prepared by another process
xbt_dynar_foreach(reqqs, cpt, req){
- if (req->flags & PREPARED) smpi_mpi_start(req);
+ if (req->flags & PREPARED)
+ smpi_mpi_start(req);
}
MPI_Request* treqs = static_cast<MPI_Request*>(xbt_dynar_to_array(reqqs));
}
int smpi_mpi_win_wait(MPI_Win win){
-// xbt_barrier_wait(win->bar);
- //MPI_Comm comm = smpi_comm_new(win->group, NULL);
- //mpi_coll_barrier_fun(comm);
- //smpi_comm_destroy(comm);
//naive, blocking implementation.
XBT_DEBUG("Entering MPI_Win_Wait");
int i=0,j=0;
int size = smpi_group_size(win->group);
MPI_Request* reqs = xbt_new0(MPI_Request, size);
-// for(i=0;i<size;i++){
while(j!=size){
int src=smpi_group_index(win->group,j);
if(src!=smpi_process_index()){
MPI_Request req;
// start all requests that have been prepared by another process
xbt_dynar_foreach(reqqs, cpt, req){
- if (req->flags & PREPARED) smpi_mpi_start(req);
+ if (req->flags & PREPARED)
+ smpi_mpi_start(req);
}
MPI_Request* treqs = static_cast<MPI_Request*>(xbt_dynar_to_array(reqqs));
void smpi_cart_topo_destroy(MPIR_Cart_Topology cart) {
if (cart) {
if(cart->dims) {
- free(cart->dims);
+ xbt_free(cart->dims);
}
if(cart->periodic) {
- free(cart->periodic);
+ xbt_free(cart->periodic);
}
if(cart->position) {
- free(cart->position);
+ xbt_free(cart->position);
}
- free(cart);
+ xbt_free(cart);
}
}
newCart->topo.cart->nnodes = newSize;
- /* memcpy(newCart->topo.cart->dims, dims, ndims * sizeof(*newCart->topo.cart->dims)); */
- /* memcpy(newCart->topo.cart->periodic, periods, ndims * sizeof(*newCart->topo.cart->periodic)); */
-
// FIXME : code duplication... See smpi_mpi_cart_coords
nranks = newSize;
for (i=0; i<ndims; i++) {
}
newNDims = 0;
for (i = 0 ; i < oldNDims ; i++) {
- if (remain_dims[i]) newNDims++;
+ if (remain_dims[i])
+ newNDims++;
}
if (newNDims > 0) {
} else if (coord < 0) {
if(topo->topo.cart->periodic[i]) {
coord = coord % topo->topo.cart->dims[i];
- if (coord) coord = topo->topo.cart->dims[i] + coord;
+ if (coord)
+ coord = topo->topo.cart->dims[i] + coord;
} else {
*rank = -1;
return MPI_ERR_ARG;