Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
some more "fixes" for sonar
authordegomme <augustin.degomme@unibas.ch>
Sun, 29 May 2016 20:59:10 +0000 (22:59 +0200)
committerdegomme <augustin.degomme@unibas.ch>
Sun, 29 May 2016 20:59:15 +0000 (22:59 +0200)
src/smpi/private.h
src/smpi/smpi_base.cpp
src/smpi/smpi_bench.cpp
src/smpi/smpi_coll.cpp
src/smpi/smpi_comm.cpp
src/smpi/smpi_deployment.cpp
src/smpi/smpi_f77.cpp
src/smpi/smpi_group.cpp
src/smpi/smpi_mpi_dt.cpp
src/smpi/smpi_pmpi.cpp

index 3232522..be67f01 100644 (file)
@@ -234,8 +234,8 @@ XBT_PRIVATE int smpi_mpi_pack(void* inbuf, int incount, MPI_Datatype type, void*
                        MPI_Comm comm);
 
 XBT_PRIVATE void smpi_empty_status(MPI_Status * status);
                        MPI_Comm comm);
 
 XBT_PRIVATE void smpi_empty_status(MPI_Status * status);
-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 MPI_Op smpi_op_new(MPI_User_function * function, bool commute);
+XBT_PRIVATE bool 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, const void *invec, void *inoutvec, int *len, MPI_Datatype * datatype);
 
 XBT_PRIVATE void smpi_op_destroy(MPI_Op op);
 XBT_PRIVATE void smpi_op_apply(MPI_Op op, const void *invec, void *inoutvec, int *len, MPI_Datatype * datatype);
 
@@ -399,7 +399,7 @@ XBT_PRIVATE int smpi_type_keyval_free(int* keyval);
 // utilities
 extern XBT_PRIVATE double smpi_cpu_threshold;
 extern XBT_PRIVATE double smpi_running_power;
 // utilities
 extern XBT_PRIVATE double smpi_cpu_threshold;
 extern XBT_PRIVATE double smpi_running_power;
-extern XBT_PRIVATE int smpi_privatize_global_variables;
+extern XBT_PRIVATE bool smpi_privatize_global_variables;
 extern XBT_PRIVATE char* smpi_start_data_exe; //start of the data+bss segment of the executable
 extern XBT_PRIVATE int smpi_size_data_exe; //size of the data+bss segment of the executable
 
 extern XBT_PRIVATE char* smpi_start_data_exe; //start of the data+bss segment of the executable
 extern XBT_PRIVATE int smpi_size_data_exe; //size of the data+bss segment of the executable
 
index 3c01325..4d36a02 100644 (file)
@@ -415,7 +415,7 @@ void smpi_mpi_start(MPI_Request request)
 
     //if we are giving back the control to the user without waiting for completion, we have to inject timings
     double sleeptime = 0.0;
 
     //if we are giving back the control to the user without waiting for completion, we have to inject timings
     double sleeptime = 0.0;
-    if(request->detached != 0 || (request->flags & (ISEND|SSEND))){// issend should be treated as isend
+    if(request->detached != 0 || ((request->flags & (ISEND|SSEND)) != 0)){// issend should be treated as isend
       //isend and send timings may be different
       sleeptime = ((request->flags & ISEND) != 0)? smpi_ois(request->size) : smpi_os(request->size);
     }
       //isend and send timings may be different
       sleeptime = ((request->flags & ISEND) != 0)? smpi_ois(request->size) : smpi_os(request->size);
     }
@@ -671,7 +671,7 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
   MPI_Request req = *request;
   smpi_empty_status(status);
 
   MPI_Request req = *request;
   smpi_empty_status(status);
 
-  if(!((req->detached != 0) && req->flags & SEND) && ((req->flags & PREPARED) == 0)){
+  if(!((req->detached != 0) && ((req->flags & SEND) != 0)) && ((req->flags & PREPARED) == 0)){
     if(status != MPI_STATUS_IGNORE) {
       int src = req->src == MPI_ANY_SOURCE ? req->real_src : req->src;
       status->MPI_SOURCE = smpi_group_rank(smpi_comm_group(req->comm), src);
     if(status != MPI_STATUS_IGNORE) {
       int src = req->src == MPI_ANY_SOURCE ? req->real_src : req->src;
       status->MPI_SOURCE = smpi_group_rank(smpi_comm_group(req->comm), src);
@@ -708,7 +708,7 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
     }
   }
 
     }
   }
 
-  if (TRACE_smpi_view_internals() && req->flags & RECV){
+  if (TRACE_smpi_view_internals() && ((req->flags & RECV) != 0)){
     int rank = smpi_process_index();
     int src_traced = (req->src == MPI_ANY_SOURCE ? req->real_src : req->src);
     TRACE_smpi_recv(rank, src_traced, rank);
     int rank = smpi_process_index();
     int src_traced = (req->src == MPI_ANY_SOURCE ? req->real_src : req->src);
     TRACE_smpi_recv(rank, src_traced, rank);
index b321e24..1e9eaed 100644 (file)
@@ -80,7 +80,7 @@ double smpi_running_power;
 int smpi_loaded_page = -1;
 char* smpi_start_data_exe = NULL;
 int smpi_size_data_exe = 0;
 int smpi_loaded_page = -1;
 char* smpi_start_data_exe = NULL;
 int smpi_size_data_exe = 0;
-int smpi_privatize_global_variables;
+bool smpi_privatize_global_variables;
 double smpi_total_benched_time = 0;
 smpi_privatisation_region_t smpi_privatisation_regions;
 
 double smpi_total_benched_time = 0;
 smpi_privatisation_region_t smpi_privatisation_regions;
 
@@ -414,7 +414,7 @@ void smpi_sample_1(int global, const char *file, int line, int iters, double thr
 
     // if we already have some data, check whether sample_2 should get one more bench or whether it should emulate
     // the computation instead
 
     // if we already have some data, check whether sample_2 should get one more bench or whether it should emulate
     // the computation instead
-    data->benching = !sample_enough_benchs(data);
+    data->benching = (sample_enough_benchs(data) == 0);
     XBT_DEBUG("XXXX Re-entering the benched nest %s. %s",loc,
              (data->benching?"more benching needed":"we have enough data, skip computes"));
   }
     XBT_DEBUG("XXXX Re-entering the benched nest %s. %s",loc,
              (data->benching?"more benching needed":"we have enough data, skip computes"));
   }
@@ -597,7 +597,7 @@ void* smpi_shared_get_call(const char* func, const char* input) {
 void* smpi_shared_set_call(const char* func, const char* input, void* data) {
    char* loc = bprintf("%s:%s", func, input);
 
 void* smpi_shared_set_call(const char* func, const char* input, void* data) {
    char* loc = bprintf("%s:%s", func, input);
 
-   if(!calls) {
+   if(calls==0) {
       calls = xbt_dict_new_homogeneous(NULL);
    }
    xbt_dict_set(calls, loc, data, NULL);
       calls = xbt_dict_new_homogeneous(NULL);
    }
    xbt_dict_set(calls, loc, data, NULL);
@@ -651,7 +651,7 @@ int smpi_is_privatisation_file(char* file)
 void smpi_initialize_global_memory_segments(){
 
 #if !HAVE_PRIVATIZATION
 void smpi_initialize_global_memory_segments(){
 
 #if !HAVE_PRIVATIZATION
-  smpi_privatize_global_variables=0;
+  smpi_privatize_global_variables=false;
   xbt_die("You are trying to use privatization on a system that does not support it. Don't.");
   return;
 #else
   xbt_die("You are trying to use privatization on a system that does not support it. Don't.");
   return;
 #else
@@ -661,7 +661,7 @@ void smpi_initialize_global_memory_segments(){
   XBT_DEBUG ("bss+data segment found : size %d starting at %p", smpi_size_data_exe, smpi_start_data_exe );
 
   if (smpi_size_data_exe == 0){//no need to switch
   XBT_DEBUG ("bss+data segment found : size %d starting at %p", smpi_size_data_exe, smpi_start_data_exe );
 
   if (smpi_size_data_exe == 0){//no need to switch
-    smpi_privatize_global_variables=0;
+    smpi_privatize_global_variables=false;
     return;
   }
 
     return;
   }
 
index 3d50a57..6d71088 100644 (file)
@@ -17,7 +17,7 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI (coll)");
 
 s_mpi_coll_description_t mpi_coll_gather_description[] = {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI (coll)");
 
 s_mpi_coll_description_t mpi_coll_gather_description[] = {
-  {"default", "gather default collective", (void*)smpi_mpi_gather},
+  {"default", "gather default collective", reinterpret_cast<void*>(&smpi_mpi_gather)},
    COLL_GATHERS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 
    COLL_GATHERS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 
@@ -25,7 +25,7 @@ s_mpi_coll_description_t mpi_coll_gather_description[] = {
 s_mpi_coll_description_t mpi_coll_allgather_description[] = {
   {"default",
    "allgather default collective",
 s_mpi_coll_description_t mpi_coll_allgather_description[] = {
   {"default",
    "allgather default collective",
-   (void*)smpi_mpi_allgather},
+   reinterpret_cast<void*>(&smpi_mpi_allgather)},
 COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
@@ -33,7 +33,7 @@ COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA),
 s_mpi_coll_description_t mpi_coll_allgatherv_description[] = {
   {"default",
    "allgatherv default collective",
 s_mpi_coll_description_t mpi_coll_allgatherv_description[] = {
   {"default",
    "allgatherv default collective",
-   (void*)smpi_mpi_allgatherv},
+   reinterpret_cast<void*>(&smpi_mpi_allgatherv)},
 COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
@@ -41,7 +41,7 @@ COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA),
 s_mpi_coll_description_t mpi_coll_allreduce_description[] = {
   {"default",
    "allreduce default collective",
 s_mpi_coll_description_t mpi_coll_allreduce_description[] = {
   {"default",
    "allreduce default collective",
-   (void*)smpi_mpi_allreduce},
+   reinterpret_cast<void*>(&smpi_mpi_allreduce)},
 COLL_ALLREDUCES(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 COLL_ALLREDUCES(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
@@ -49,7 +49,7 @@ COLL_ALLREDUCES(COLL_DESCRIPTION, COLL_COMMA),
 s_mpi_coll_description_t mpi_coll_reduce_scatter_description[] = {
   {"default",
    "reduce_scatter default collective",
 s_mpi_coll_description_t mpi_coll_reduce_scatter_description[] = {
   {"default",
    "reduce_scatter default collective",
-   (void*)smpi_mpi_reduce_scatter},
+   reinterpret_cast<void*>(&smpi_mpi_reduce_scatter)},
 COLL_REDUCE_SCATTERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 COLL_REDUCE_SCATTERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
@@ -57,7 +57,7 @@ COLL_REDUCE_SCATTERS(COLL_DESCRIPTION, COLL_COMMA),
 s_mpi_coll_description_t mpi_coll_scatter_description[] = {
   {"default",
    "scatter default collective",
 s_mpi_coll_description_t mpi_coll_scatter_description[] = {
   {"default",
    "scatter default collective",
-   (void*)smpi_mpi_scatter},
+   reinterpret_cast<void*>(&smpi_mpi_scatter)},
 COLL_SCATTERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 COLL_SCATTERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
@@ -65,28 +65,28 @@ COLL_SCATTERS(COLL_DESCRIPTION, COLL_COMMA),
 s_mpi_coll_description_t mpi_coll_barrier_description[] = {
   {"default",
    "barrier default collective",
 s_mpi_coll_description_t mpi_coll_barrier_description[] = {
   {"default",
    "barrier default collective",
-   (void*)smpi_mpi_barrier},
+   reinterpret_cast<void*>(&smpi_mpi_barrier)},
 COLL_BARRIERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 s_mpi_coll_description_t mpi_coll_alltoall_description[] = {
   {"default",
    "Ompi alltoall default collective",
 COLL_BARRIERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 s_mpi_coll_description_t mpi_coll_alltoall_description[] = {
   {"default",
    "Ompi alltoall default collective",
-   (void*)smpi_coll_tuned_alltoall_ompi2},
+   reinterpret_cast<void*>(&smpi_coll_tuned_alltoall_ompi2)},
 COLL_ALLTOALLS(COLL_DESCRIPTION, COLL_COMMA),
   {"bruck",
    "Alltoall Bruck (SG) collective",
 COLL_ALLTOALLS(COLL_DESCRIPTION, COLL_COMMA),
   {"bruck",
    "Alltoall Bruck (SG) collective",
-   (void*)smpi_coll_tuned_alltoall_bruck},
+   reinterpret_cast<void*>(&smpi_coll_tuned_alltoall_bruck)},
   {"basic_linear",
    "Alltoall basic linear (SG) collective",
   {"basic_linear",
    "Alltoall basic linear (SG) collective",
-   (void*)smpi_coll_tuned_alltoall_basic_linear},
+   reinterpret_cast<void*>(&smpi_coll_tuned_alltoall_basic_linear)},
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 
 s_mpi_coll_description_t mpi_coll_alltoallv_description[] = {
   {"default",
    "Ompi alltoallv default collective",
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 
 s_mpi_coll_description_t mpi_coll_alltoallv_description[] = {
   {"default",
    "Ompi alltoallv default collective",
-   (void*)smpi_coll_basic_alltoallv},
+   reinterpret_cast<void*>(&smpi_coll_basic_alltoallv)},
 COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
@@ -94,7 +94,7 @@ COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA),
 s_mpi_coll_description_t mpi_coll_bcast_description[] = {
   {"default",
    "bcast default collective ",
 s_mpi_coll_description_t mpi_coll_bcast_description[] = {
   {"default",
    "bcast default collective ",
-   (void*)smpi_mpi_bcast},
+   reinterpret_cast<void*>(&smpi_mpi_bcast)},
 COLL_BCASTS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 COLL_BCASTS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
@@ -102,7 +102,7 @@ COLL_BCASTS(COLL_DESCRIPTION, COLL_COMMA),
 s_mpi_coll_description_t mpi_coll_reduce_description[] = {
   {"default",
    "reduce default collective",
 s_mpi_coll_description_t mpi_coll_reduce_description[] = {
   {"default",
    "reduce default collective",
-   (void*)smpi_mpi_reduce},
+   reinterpret_cast<void*>(&smpi_mpi_reduce)},
 COLL_REDUCES(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 COLL_REDUCES(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
@@ -126,7 +126,7 @@ int find_coll_description(s_mpi_coll_description_t * table,
   int selector_on=0;
   if (name==NULL || name[0] == '\0') {
     //no argument provided, use active selector's algorithm
   int selector_on=0;
   if (name==NULL || name[0] == '\0') {
     //no argument provided, use active selector's algorithm
-    name=(char*)xbt_cfg_get_string("smpi/coll-selector");
+    name=static_cast<char*>(xbt_cfg_get_string("smpi/coll-selector"));
     selector_on=1;
   }
   for (int i = 0; table[i].name; i++)
     selector_on=1;
   }
   for (int i = 0; table[i].name; i++)
@@ -138,7 +138,7 @@ int find_coll_description(s_mpi_coll_description_t * table,
 
   if(selector_on){
     // collective seems not handled by the active selector, try with default one
 
   if(selector_on){
     // collective seems not handled by the active selector, try with default one
-    name=(char*)"default";
+    name=const_cast<char*>("default");
     for (int i = 0; table[i].name; i++)
       if (!strcmp(name, table[i].name)) {
         return i;
     for (int i = 0; table[i].name; i++)
       if (!strcmp(name, table[i].name)) {
         return i;
@@ -150,8 +150,8 @@ int find_coll_description(s_mpi_coll_description_t * table,
   for (int i = 1; table[i].name; i++) {
     name_list = static_cast<char*>(xbt_realloc(name_list,
                     strlen(name_list) + strlen(table[i].name) + 3));
   for (int i = 1; table[i].name; i++) {
     name_list = static_cast<char*>(xbt_realloc(name_list,
                     strlen(name_list) + strlen(table[i].name) + 3));
-    strcat(name_list, ", ");
-    strcat(name_list, table[i].name);
+    strncat(name_list, ", ",2);
+    strncat(name_list, table[i].name, strlen(table[i].name));
   }
   xbt_die("Collective '%s' is invalid! Valid collectives are: %s.", name, name_list);
   return -1;
   }
   xbt_die("Collective '%s' is invalid! Valid collectives are: %s.", name, name_list);
   return -1;
@@ -224,9 +224,9 @@ int smpi_coll_tuned_alltoall_bruck(void *sendbuf, int sendcount,
   smpi_datatype_extent(recvtype, &lb, &recvext);
   /* Local copy from self */
   err =
   smpi_datatype_extent(recvtype, &lb, &recvext);
   /* Local copy from self */
   err =
-      smpi_datatype_copy((char *)sendbuf + rank * sendcount * sendext, 
+      smpi_datatype_copy(static_cast<char *>(sendbuf) + rank * sendcount * sendext, 
                          sendcount, sendtype, 
                          sendcount, sendtype, 
-                         (char *)recvbuf + rank * recvcount * recvext,
+                         static_cast<char *>(recvbuf) + rank * recvcount * recvext,
                          recvcount, recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
                          recvcount, recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
@@ -234,34 +234,35 @@ int smpi_coll_tuned_alltoall_bruck(void *sendbuf, int sendcount,
     count = 0;
     /* Create all receives that will be posted first */
     for (i = 0; i < size; ++i) {
     count = 0;
     /* Create all receives that will be posted first */
     for (i = 0; i < size; ++i) {
-      if (i == rank) {
+      if (i != rank) {
+        requests[count] =
+          smpi_irecv_init(static_cast<char *>(recvbuf) + i * recvcount * recvext, recvcount,
+                          recvtype, i, system_tag, comm);
+      count++;
+      }else{
         XBT_DEBUG("<%d> skip request creation [src = %d, recvcount = %d]",
                rank, i, recvcount);
         XBT_DEBUG("<%d> skip request creation [src = %d, recvcount = %d]",
                rank, i, recvcount);
-        continue;
       }
       }
-      requests[count] =
-          smpi_irecv_init((char *)recvbuf + i * recvcount * recvext, recvcount,
-                          recvtype, i, system_tag, comm);
-      count++;
     }
     /* Now create all sends  */
     for (i = 0; i < size; ++i) {
     }
     /* Now create all sends  */
     for (i = 0; i < size; ++i) {
-      if (i == rank) {
+      if (i != rank) {
+        requests[count] =
+          smpi_isend_init(static_cast<char *>(sendbuf) + i * sendcount * sendext, sendcount,
+                          sendtype, i, system_tag, comm);
+      count++;
+      }else{
         XBT_DEBUG("<%d> skip request creation [dst = %d, sendcount = %d]",
                rank, i, sendcount);
         XBT_DEBUG("<%d> skip request creation [dst = %d, sendcount = %d]",
                rank, i, sendcount);
-        continue;
       }
       }
-      requests[count] =
-          smpi_isend_init((char *)sendbuf + i * sendcount * sendext, sendcount,
-                          sendtype, i, system_tag, comm);
-      count++;
     }
     /* Wait for them all. */
     smpi_mpi_startall(count, requests);
     XBT_DEBUG("<%d> wait for %d requests", rank, count);
     smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
     for(i = 0; i < count; i++) {
     }
     /* Wait for them all. */
     smpi_mpi_startall(count, requests);
     XBT_DEBUG("<%d> wait for %d requests", rank, count);
     smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
     for(i = 0; i < count; i++) {
-      if(requests[i]!=MPI_REQUEST_NULL) smpi_mpi_request_free(&requests[i]);
+      if(requests[i]!=MPI_REQUEST_NULL)
+        smpi_mpi_request_free(&requests[i]);
     }
     xbt_free(requests);
   }
     }
     xbt_free(requests);
   }
@@ -289,9 +290,9 @@ int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
   smpi_datatype_extent(sendtype, &lb, &sendext);
   smpi_datatype_extent(recvtype, &lb, &recvext);
   /* simple optimization */
   smpi_datatype_extent(sendtype, &lb, &sendext);
   smpi_datatype_extent(recvtype, &lb, &recvext);
   /* simple optimization */
-  err = smpi_datatype_copy((char *)sendbuf + rank * sendcount * sendext, 
+  err = smpi_datatype_copy(static_cast<char *>(sendbuf) + rank * sendcount * sendext, 
                            sendcount, sendtype, 
                            sendcount, sendtype, 
-                           (char *)recvbuf + rank * recvcount * recvext, 
+                           static_cast<char *>(recvbuf) + rank * recvcount * recvext, 
                            recvcount, recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
                            recvcount, recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
@@ -300,7 +301,7 @@ int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
     count = 0;
     for (i = (rank + 1) % size; i != rank; i = (i + 1) % size) {
       requests[count] =
     count = 0;
     for (i = (rank + 1) % size; i != rank; i = (i + 1) % size) {
       requests[count] =
-          smpi_irecv_init((char *)recvbuf + i * recvcount * recvext, recvcount, 
+          smpi_irecv_init(static_cast<char *>(recvbuf) + i * recvcount * recvext, recvcount, 
                           recvtype, i, system_tag, comm);
       count++;
     }
                           recvtype, i, system_tag, comm);
       count++;
     }
@@ -311,7 +312,7 @@ int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
      */
     for (i = (rank + size - 1) % size; i != rank; i = (i + size - 1) % size) {
       requests[count] =
      */
     for (i = (rank + size - 1) % size; i != rank; i = (i + size - 1) % size) {
       requests[count] =
-          smpi_isend_init((char *)sendbuf + i * sendcount * sendext, sendcount,
+          smpi_isend_init(static_cast<char *>(sendbuf) + i * sendcount * sendext, sendcount,
                           sendtype, i, system_tag, comm);
       count++;
     }
                           sendtype, i, system_tag, comm);
       count++;
     }
@@ -320,7 +321,8 @@ int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
     XBT_DEBUG("<%d> wait for %d requests", rank, count);
     smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
     for(i = 0; i < count; i++) {
     XBT_DEBUG("<%d> wait for %d requests", rank, count);
     smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
     for(i = 0; i < count; i++) {
-      if(requests[i]!=MPI_REQUEST_NULL) smpi_mpi_request_free(&requests[i]);
+      if(requests[i]!=MPI_REQUEST_NULL)
+        smpi_mpi_request_free(&requests[i]);
     }
     xbt_free(requests);
   }
     }
     xbt_free(requests);
   }
@@ -346,9 +348,9 @@ int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
   smpi_datatype_extent(recvtype, &lb, &recvext);
   /* Local copy from self */
   err =
   smpi_datatype_extent(recvtype, &lb, &recvext);
   /* Local copy from self */
   err =
-      smpi_datatype_copy((char *)sendbuf + senddisps[rank] * sendext, 
+      smpi_datatype_copy(static_cast<char *>(sendbuf) + senddisps[rank] * sendext, 
                          sendcounts[rank], sendtype,
                          sendcounts[rank], sendtype,
-                         (char *)recvbuf + recvdisps[rank] * recvext, 
+                         static_cast<char *>(recvbuf) + recvdisps[rank] * recvext, 
                          recvcounts[rank], recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
                          recvcounts[rank], recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
@@ -356,36 +358,37 @@ int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
     count = 0;
     /* Create all receives that will be posted first */
     for (i = 0; i < size; ++i) {
     count = 0;
     /* Create all receives that will be posted first */
     for (i = 0; i < size; ++i) {
-      if (i == rank || recvcounts[i] == 0) {
+      if (i != rank && recvcounts[i] != 0) {
+        requests[count] =
+          smpi_irecv_init(static_cast<char *>(recvbuf) + recvdisps[i] * recvext, 
+                          recvcounts[i], recvtype, i, system_tag, comm);
+        count++;
+      }else{
         XBT_DEBUG
             ("<%d> skip request creation [src = %d, recvcounts[src] = %d]",
              rank, i, recvcounts[i]);
         XBT_DEBUG
             ("<%d> skip request creation [src = %d, recvcounts[src] = %d]",
              rank, i, recvcounts[i]);
-        continue;
       }
       }
-      requests[count] =
-          smpi_irecv_init((char *)recvbuf + recvdisps[i] * recvext, 
-                          recvcounts[i], recvtype, i, system_tag, comm);
-      count++;
     }
     /* Now create all sends  */
     for (i = 0; i < size; ++i) {
     }
     /* Now create all sends  */
     for (i = 0; i < size; ++i) {
-      if (i == rank || sendcounts[i] == 0) {
+      if (i != rank && sendcounts[i] != 0) {
+      requests[count] =
+          smpi_isend_init(static_cast<char *>(sendbuf) + senddisps[i] * sendext, 
+                          sendcounts[i], sendtype, i, system_tag, comm);
+      count++;
+      }else{
         XBT_DEBUG
             ("<%d> skip request creation [dst = %d, sendcounts[dst] = %d]",
              rank, i, sendcounts[i]);
         XBT_DEBUG
             ("<%d> skip request creation [dst = %d, sendcounts[dst] = %d]",
              rank, i, sendcounts[i]);
-        continue;
       }
       }
-      requests[count] =
-          smpi_isend_init((char *)sendbuf + senddisps[i] * sendext, 
-                          sendcounts[i], sendtype, i, system_tag, comm);
-      count++;
     }
     /* Wait for them all. */
     smpi_mpi_startall(count, requests);
     XBT_DEBUG("<%d> wait for %d requests", rank, count);
     smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
     for(i = 0; i < count; i++) {
     }
     /* Wait for them all. */
     smpi_mpi_startall(count, requests);
     XBT_DEBUG("<%d> wait for %d requests", rank, count);
     smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
     for(i = 0; i < count; i++) {
-      if(requests[i]!=MPI_REQUEST_NULL) smpi_mpi_request_free(&requests[i]);
+      if(requests[i]!=MPI_REQUEST_NULL) 
+        smpi_mpi_request_free(&requests[i]);
     }
     xbt_free(requests);
   }
     }
     xbt_free(requests);
   }
index ec94c1e..3db4a9a 100644 (file)
@@ -305,7 +305,7 @@ void smpi_comm_cleanup_attributes(MPI_Comm comm){
     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, reinterpret_cast<const char*>(key)));
     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, reinterpret_cast<const char*>(key)));
-      if(elem!=NULL &&  elem->delete_fn)
+      if(elem!=NULL &&  elem->delete_fn!=NULL)
         elem->delete_fn(comm, *key, value, &flag);
     }
     xbt_dict_free(&comm->attributes);
         elem->delete_fn(comm, *key, value, &flag);
     }
     xbt_dict_free(&comm->attributes);
index b1b0575..e910160 100644 (file)
@@ -46,7 +46,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_
 
   process_count+=num_processes;
 
 
   process_count+=num_processes;
 
-  if(!smpi_instances){
+  if(smpi_instances==NULL){
     smpi_instances = xbt_dict_new_homogeneous(xbt_free_f);
   }
 
     smpi_instances = xbt_dict_new_homogeneous(xbt_free_f);
   }
 
@@ -57,7 +57,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_
 //get the index of the process in the process_data array
 void smpi_deployment_register_process(const char* instance_id, int rank, int index,MPI_Comm** comm, xbt_bar_t* bar){
 
 //get the index of the process in the process_data array
 void smpi_deployment_register_process(const char* instance_id, int rank, int index,MPI_Comm** comm, xbt_bar_t* bar){
 
-  if(!smpi_instances){//no instance registered, we probably used smpirun.
+  if(smpi_instances==NULL){//no instance registered, we probably used smpirun.
     index_to_process_data[index]=index;
     *bar = NULL;
     *comm = NULL;
     index_to_process_data[index]=index;
     *bar = NULL;
     *comm = NULL;
index 8f174f8..7218835 100644 (file)
@@ -796,7 +796,7 @@ void mpi_info_get_ (int* info,char *key,int* valuelen, char *value, int *flag, i
   tkey[keylen]='\0';
   *ierr = MPI_Info_get(smpi_info_f2c(*info),tkey,*valuelen, value, flag);
   xbt_free(tkey);
   tkey[keylen]='\0';
   *ierr = MPI_Info_get(smpi_info_f2c(*info),tkey,*valuelen, value, flag);
   xbt_free(tkey);
-  if(*flag==true){
+  if(*flag!=0){
     int replace=0;
     int i=0;
     for (i=0; i<*valuelen; i++){
     int replace=0;
     int i=0;
     for (i=0; i<*valuelen; i++){
index 36e94c0..119b8bb 100644 (file)
@@ -113,7 +113,7 @@ int smpi_group_rank(MPI_Group group, int index)
   ptr_rank = static_cast<int*>(xbt_dict_get_or_null(group->index_to_rank_map, key));
   xbt_free(key);
 
   ptr_rank = static_cast<int*>(xbt_dict_get_or_null(group->index_to_rank_map, key));
   xbt_free(key);
 
-  if (!ptr_rank)
+  if (ptr_rank==NULL)
     return MPI_UNDEFINED;
   return *ptr_rank;
 }
     return MPI_UNDEFINED;
   return *ptr_rank;
 }
index 25f4454..607c1e6 100644 (file)
@@ -406,7 +406,7 @@ void smpi_datatype_free(MPI_Datatype* type){
     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, reinterpret_cast<const char*>(key), sizeof(int)));
     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, reinterpret_cast<const char*>(key), sizeof(int)));
-      if(elem!=NULL &&  elem->delete_fn)
+      if(elem!=NULL && elem->delete_fn!=NULL)
         elem->delete_fn(*type,*key, value, &flag);
     }
     xbt_dict_free(&(*type)->attributes);
         elem->delete_fn(*type,*key, value, &flag);
     }
     xbt_dict_free(&(*type)->attributes);
@@ -796,7 +796,7 @@ int smpi_datatype_indexed(int count, int* blocklens, int* indices, MPI_Datatype
   int i;
   int retval;
   int size = 0;
   int i;
   int retval;
   int size = 0;
-  int contiguous=1;
+  bool contiguous=true;
   MPI_Aint lb = 0;
   MPI_Aint ub = 0;
   if(count>0){
   MPI_Aint lb = 0;
   MPI_Aint ub = 0;
   if(count>0){
@@ -815,10 +815,10 @@ int smpi_datatype_indexed(int count, int* blocklens, int* indices, MPI_Datatype
       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]) )
       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;
+      contiguous=false;
   }
   if (old_type->sizeof_substruct != 0)
   }
   if (old_type->sizeof_substruct != 0)
-    contiguous=0;
+    contiguous=false;
 
   if(!contiguous){
     s_smpi_mpi_indexed_t* subtype = smpi_datatype_indexed_create( blocklens, indices, count, old_type,
 
   if(!contiguous){
     s_smpi_mpi_indexed_t* subtype = smpi_datatype_indexed_create( blocklens, indices, count, old_type,
@@ -946,7 +946,7 @@ int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Dat
   int i;
   int retval;
   int size = 0;
   int i;
   int retval;
   int size = 0;
-  int contiguous=1;
+  bool contiguous=true;
   MPI_Aint lb = 0;
   MPI_Aint ub = 0;
   if(count>0){
   MPI_Aint lb = 0;
   MPI_Aint ub = 0;
   if(count>0){
@@ -964,10 +964,10 @@ int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Dat
       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]) )
       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]) )
-      contiguous=0;
+      contiguous=false;
   }
   if (old_type->sizeof_substruct != 0 || lb!=0)
   }
   if (old_type->sizeof_substruct != 0 || lb!=0)
-    contiguous=0;
+    contiguous=false;
 
   if(!contiguous){
     s_smpi_mpi_hindexed_t* subtype = smpi_datatype_hindexed_create( blocklens, indices, count, old_type,
 
   if(!contiguous){
     s_smpi_mpi_hindexed_t* subtype = smpi_datatype_hindexed_create( blocklens, indices, count, old_type,
@@ -1101,7 +1101,7 @@ int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datat
 {
   int i;
   size_t size = 0;
 {
   int i;
   size_t size = 0;
-  int contiguous=1;
+  bool contiguous=true;
   size = 0;
   MPI_Aint lb = 0;
   MPI_Aint ub = 0;
   size = 0;
   MPI_Aint lb = 0;
   MPI_Aint ub = 0;
@@ -1109,22 +1109,22 @@ int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datat
     lb=indices[0] + smpi_datatype_lb(old_types[0]);
     ub=indices[0] + blocklens[0]*smpi_datatype_ub(old_types[0]);
   }
     lb=indices[0] + smpi_datatype_lb(old_types[0]);
     ub=indices[0] + blocklens[0]*smpi_datatype_ub(old_types[0]);
   }
-  int forced_lb=0;
-  int forced_ub=0;
+  bool forced_lb=false;
+  bool forced_ub=false;
   for(i=0; i< count; i++){
     if (blocklens[i]<0)
       return MPI_ERR_ARG;
     if (old_types[i]->sizeof_substruct != 0)
   for(i=0; i< count; i++){
     if (blocklens[i]<0)
       return MPI_ERR_ARG;
     if (old_types[i]->sizeof_substruct != 0)
-      contiguous=0;
+      contiguous=false;
 
     size += blocklens[i]*smpi_datatype_size(old_types[i]);
     if (old_types[i]==MPI_LB){
       lb=indices[i];
 
     size += blocklens[i]*smpi_datatype_size(old_types[i]);
     if (old_types[i]==MPI_LB){
       lb=indices[i];
-      forced_lb=1;
+      forced_lb=true;
     }
     if (old_types[i]==MPI_UB){
       ub=indices[i];
     }
     if (old_types[i]==MPI_UB){
       ub=indices[i];
-      forced_ub=1;
+      forced_ub=true;
     }
 
     if(!forced_lb && indices[i]+smpi_datatype_lb(old_types[i])<lb) 
     }
 
     if(!forced_lb && indices[i]+smpi_datatype_lb(old_types[i])<lb) 
@@ -1133,10 +1133,10 @@ int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datat
       ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_types[i]);
 
     if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast<int>(smpi_datatype_size(old_types[i])) != indices[i+1]) )
       ub = indices[i]+blocklens[i]*smpi_datatype_ub(old_types[i]);
 
     if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast<int>(smpi_datatype_size(old_types[i])) != indices[i+1]) )
-      contiguous=0;
+      contiguous=false;
   }
 
   }
 
-  if(contiguous==0){
+  if(!contiguous){
     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);
     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);
@@ -1154,7 +1154,7 @@ void smpi_datatype_commit(MPI_Datatype *datatype)
 
 typedef struct s_smpi_mpi_op {
   MPI_User_function *func;
 
 typedef struct s_smpi_mpi_op {
   MPI_User_function *func;
-  int is_commute;
+  bool is_commute;
 } s_smpi_mpi_op_t;
 
 #define MAX_OP(a, b)  (b) = (a) < (b) ? (b) : (a)
 } s_smpi_mpi_op_t;
 
 #define MAX_OP(a, b)  (b) = (a) < (b) ? (b) : (a)
@@ -1531,7 +1531,7 @@ CREATE_MPI_OP(MPI_MAXLOC, maxloc_func);
 CREATE_MPI_OP(MPI_MINLOC, minloc_func);
 CREATE_MPI_OP(MPI_REPLACE, replace_func);
 
 CREATE_MPI_OP(MPI_MINLOC, minloc_func);
 CREATE_MPI_OP(MPI_REPLACE, replace_func);
 
-MPI_Op smpi_op_new(MPI_User_function * function, int commute)
+MPI_Op smpi_op_new(MPI_User_function * function, bool commute)
 {
   MPI_Op op;
   op = xbt_new(s_smpi_mpi_op_t, 1);
 {
   MPI_Op op;
   op = xbt_new(s_smpi_mpi_op_t, 1);
@@ -1540,9 +1540,9 @@ MPI_Op smpi_op_new(MPI_User_function * function, int commute)
   return op;
 }
 
   return op;
 }
 
-int smpi_op_is_commute(MPI_Op op)
+bool smpi_op_is_commute(MPI_Op op)
 {
 {
-  return (op==MPI_OP_NULL) ? 1 : op-> is_commute;
+  return (op==MPI_OP_NULL) ? true : op-> is_commute;
 }
 
 void smpi_op_destroy(MPI_Op op)
 }
 
 void smpi_op_destroy(MPI_Op op)
@@ -1588,7 +1588,7 @@ int smpi_type_attr_delete(MPI_Datatype type, int keyval){
 int smpi_type_attr_get(MPI_Datatype type, int keyval, void* attr_value, int* flag){
   smpi_type_key_elem elem =
     static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
 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, reinterpret_cast<const char*>(&keyval), sizeof(int)));
-  if(!elem)
+  if(elem==NULL)
     return MPI_ERR_ARG;
   xbt_ex_t ex;
   if(type->attributes==NULL){
     return MPI_ERR_ARG;
   xbt_ex_t ex;
   if(type->attributes==NULL){
@@ -1607,8 +1607,8 @@ int smpi_type_attr_get(MPI_Datatype type, int keyval, void* attr_value, int* fla
 }
 
 int smpi_type_attr_put(MPI_Datatype type, int keyval, void* attr_value){
 }
 
 int smpi_type_attr_put(MPI_Datatype type, int keyval, void* attr_value){
-  if(!smpi_type_keyvals)
-  smpi_type_keyvals = xbt_dict_new();
+  if(smpi_type_keyvals==NULL)
+    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, reinterpret_cast<const char*>(&keyval), sizeof(int)));
   if(elem==NULL)
   smpi_type_key_elem 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)
@@ -1616,7 +1616,7 @@ int smpi_type_attr_put(MPI_Datatype type, int keyval, void* attr_value){
   int flag;
   void* value;
   smpi_type_attr_get(type, keyval, &value, &flag);
   int flag;
   void* value;
   smpi_type_attr_get(type, 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(type, keyval, value, &flag);
     if(ret!=MPI_SUCCESS) 
       return ret;
     int ret = elem->delete_fn(type, keyval, value, &flag);
     if(ret!=MPI_SUCCESS) 
       return ret;
@@ -1630,8 +1630,8 @@ int smpi_type_attr_put(MPI_Datatype type, int keyval, void* attr_value){
 
 int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
                             void* extra_state){
 
 int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
                             void* extra_state){
-  if(!smpi_type_keyvals)
-  smpi_type_keyvals = xbt_dict_new();
+  if(smpi_type_keyvals==NULL)
+    smpi_type_keyvals = xbt_dict_new();
 
   smpi_type_key_elem value = (smpi_type_key_elem) xbt_new0(s_smpi_mpi_type_key_elem_t,1);
 
 
   smpi_type_key_elem value = (smpi_type_key_elem) xbt_new0(s_smpi_mpi_type_key_elem_t,1);
 
@@ -1647,7 +1647,7 @@ int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delet
 int smpi_type_keyval_free(int* keyval){
   smpi_type_key_elem elem =
     static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int)));
 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, reinterpret_cast<const char*>(keyval), sizeof(int)));
-  if(!elem){
+  if(elem==0){
     return MPI_ERR_ARG;
   }
   xbt_dict_remove_ext(smpi_type_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int));
     return MPI_ERR_ARG;
   }
   xbt_dict_remove_ext(smpi_type_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int));
index 83213f4..9fcc122 100644 (file)
@@ -262,7 +262,7 @@ int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
   if (function == NULL || op == NULL) {
     retval = MPI_ERR_ARG;
   } else {
   if (function == NULL || op == NULL) {
     retval = MPI_ERR_ARG;
   } else {
-    *op = smpi_op_new(function, commute);
+    *op = smpi_op_new(function, (commute!=0));
     retval = MPI_SUCCESS;
   }
   return retval;
     retval = MPI_SUCCESS;
   }
   return retval;