From: degomme Date: Sun, 29 May 2016 20:59:10 +0000 (+0200) Subject: some more "fixes" for sonar X-Git-Tag: v3_14~1121 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9c3926e2c40bcec2394899543f06d2e1762b64e0 some more "fixes" for sonar --- diff --git a/src/smpi/private.h b/src/smpi/private.h index 323252218a..be67f01f17 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -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); -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); @@ -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; -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 diff --git a/src/smpi/smpi_base.cpp b/src/smpi/smpi_base.cpp index 3c01325d1f..4d36a02fea 100644 --- a/src/smpi/smpi_base.cpp +++ b/src/smpi/smpi_base.cpp @@ -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(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); } @@ -671,7 +671,7 @@ static void finish_wait(MPI_Request * request, MPI_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); @@ -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); diff --git a/src/smpi/smpi_bench.cpp b/src/smpi/smpi_bench.cpp index b321e241ec..1e9eaed4ed 100644 --- a/src/smpi/smpi_bench.cpp +++ b/src/smpi/smpi_bench.cpp @@ -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_privatize_global_variables; +bool smpi_privatize_global_variables; 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 - 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")); } @@ -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); - if(!calls) { + if(calls==0) { 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 - 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 @@ -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 - smpi_privatize_global_variables=0; + smpi_privatize_global_variables=false; return; } diff --git a/src/smpi/smpi_coll.cpp b/src/smpi/smpi_coll.cpp index 3d50a570b6..6d71088681 100644 --- a/src/smpi/smpi_coll.cpp +++ b/src/smpi/smpi_coll.cpp @@ -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[] = { - {"default", "gather default collective", (void*)smpi_mpi_gather}, + {"default", "gather default collective", reinterpret_cast(&smpi_mpi_gather)}, 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", - (void*)smpi_mpi_allgather}, + reinterpret_cast(&smpi_mpi_allgather)}, 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", - (void*)smpi_mpi_allgatherv}, + reinterpret_cast(&smpi_mpi_allgatherv)}, 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", - (void*)smpi_mpi_allreduce}, + reinterpret_cast(&smpi_mpi_allreduce)}, 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", - (void*)smpi_mpi_reduce_scatter}, + reinterpret_cast(&smpi_mpi_reduce_scatter)}, 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", - (void*)smpi_mpi_scatter}, + reinterpret_cast(&smpi_mpi_scatter)}, 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", - (void*)smpi_mpi_barrier}, + reinterpret_cast(&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", - (void*)smpi_coll_tuned_alltoall_ompi2}, + reinterpret_cast(&smpi_coll_tuned_alltoall_ompi2)}, COLL_ALLTOALLS(COLL_DESCRIPTION, COLL_COMMA), {"bruck", "Alltoall Bruck (SG) collective", - (void*)smpi_coll_tuned_alltoall_bruck}, + reinterpret_cast(&smpi_coll_tuned_alltoall_bruck)}, {"basic_linear", "Alltoall basic linear (SG) collective", - (void*)smpi_coll_tuned_alltoall_basic_linear}, + reinterpret_cast(&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", - (void*)smpi_coll_basic_alltoallv}, + reinterpret_cast(&smpi_coll_basic_alltoallv)}, 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 ", - (void*)smpi_mpi_bcast}, + reinterpret_cast(&smpi_mpi_bcast)}, 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", - (void*)smpi_mpi_reduce}, + reinterpret_cast(&smpi_mpi_reduce)}, 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 - name=(char*)xbt_cfg_get_string("smpi/coll-selector"); + name=static_cast(xbt_cfg_get_string("smpi/coll-selector")); 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 - name=(char*)"default"; + name=const_cast("default"); 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(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; @@ -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_copy((char *)sendbuf + rank * sendcount * sendext, + smpi_datatype_copy(static_cast(sendbuf) + rank * sendcount * sendext, sendcount, sendtype, - (char *)recvbuf + rank * recvcount * recvext, + static_cast(recvbuf) + rank * recvcount * recvext, 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) { - if (i == rank) { + if (i != rank) { + requests[count] = + smpi_irecv_init(static_cast(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); - 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) { - if (i == rank) { + if (i != rank) { + requests[count] = + smpi_isend_init(static_cast(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); - 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++) { - 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); } @@ -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 */ - err = smpi_datatype_copy((char *)sendbuf + rank * sendcount * sendext, + err = smpi_datatype_copy(static_cast(sendbuf) + rank * sendcount * sendext, sendcount, sendtype, - (char *)recvbuf + rank * recvcount * recvext, + static_cast(recvbuf) + rank * recvcount * recvext, 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] = - smpi_irecv_init((char *)recvbuf + i * recvcount * recvext, recvcount, + smpi_irecv_init(static_cast(recvbuf) + i * recvcount * recvext, recvcount, 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] = - smpi_isend_init((char *)sendbuf + i * sendcount * sendext, sendcount, + smpi_isend_init(static_cast(sendbuf) + i * sendcount * sendext, sendcount, 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++) { - 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); } @@ -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_copy((char *)sendbuf + senddisps[rank] * sendext, + smpi_datatype_copy(static_cast(sendbuf) + senddisps[rank] * sendext, sendcounts[rank], sendtype, - (char *)recvbuf + recvdisps[rank] * recvext, + static_cast(recvbuf) + recvdisps[rank] * recvext, 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) { - if (i == rank || recvcounts[i] == 0) { + if (i != rank && recvcounts[i] != 0) { + requests[count] = + smpi_irecv_init(static_cast(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]); - 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) { - if (i == rank || sendcounts[i] == 0) { + if (i != rank && sendcounts[i] != 0) { + requests[count] = + smpi_isend_init(static_cast(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]); - 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++) { - 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); } diff --git a/src/smpi/smpi_comm.cpp b/src/smpi/smpi_comm.cpp index ec94c1e1c7..3db4a9ab82 100644 --- a/src/smpi/smpi_comm.cpp +++ b/src/smpi/smpi_comm.cpp @@ -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(xbt_dict_get_or_null(smpi_comm_keyvals, reinterpret_cast(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); diff --git a/src/smpi/smpi_deployment.cpp b/src/smpi/smpi_deployment.cpp index b1b0575fcd..e910160f03 100644 --- a/src/smpi/smpi_deployment.cpp +++ b/src/smpi/smpi_deployment.cpp @@ -46,7 +46,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_ process_count+=num_processes; - if(!smpi_instances){ + if(smpi_instances==NULL){ 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){ - 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; diff --git a/src/smpi/smpi_f77.cpp b/src/smpi/smpi_f77.cpp index 8f174f8f95..72188356ee 100644 --- a/src/smpi/smpi_f77.cpp +++ b/src/smpi/smpi_f77.cpp @@ -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); - if(*flag==true){ + if(*flag!=0){ int replace=0; int i=0; for (i=0; i<*valuelen; i++){ diff --git a/src/smpi/smpi_group.cpp b/src/smpi/smpi_group.cpp index 36e94c0664..119b8bba68 100644 --- a/src/smpi/smpi_group.cpp +++ b/src/smpi/smpi_group.cpp @@ -113,7 +113,7 @@ int smpi_group_rank(MPI_Group group, int index) ptr_rank = static_cast(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; } diff --git a/src/smpi/smpi_mpi_dt.cpp b/src/smpi/smpi_mpi_dt.cpp index 25f4454d2e..607c1e6555 100644 --- a/src/smpi/smpi_mpi_dt.cpp +++ b/src/smpi/smpi_mpi_dt.cpp @@ -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(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(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); @@ -796,7 +796,7 @@ int smpi_datatype_indexed(int count, int* blocklens, int* indices, MPI_Datatype int i; int retval; int size = 0; - int contiguous=1; + bool contiguous=true; 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]) ) - contiguous=0; + contiguous=false; } 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, @@ -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 contiguous=1; + bool contiguous=true; 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(smpi_datatype_size(old_type))) != indices[i+1]) ) - contiguous=0; + contiguous=false; } 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, @@ -1101,7 +1101,7 @@ int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datat { int i; size_t size = 0; - int contiguous=1; + bool contiguous=true; 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]); } - 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) - contiguous=0; + contiguous=false; 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]; - forced_ub=1; + forced_ub=true; } if(!forced_lb && indices[i]+smpi_datatype_lb(old_types[i])(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); @@ -1154,7 +1154,7 @@ void smpi_datatype_commit(MPI_Datatype *datatype) 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) @@ -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); -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); @@ -1540,9 +1540,9 @@ MPI_Op smpi_op_new(MPI_User_function * function, int commute) 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) @@ -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(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&keyval), sizeof(int))); - if(!elem) + if(elem==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){ - 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(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&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); - 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; @@ -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){ - 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); @@ -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(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(keyval), sizeof(int))); - if(!elem){ + if(elem==0){ return MPI_ERR_ARG; } xbt_dict_remove_ext(smpi_type_keyvals, reinterpret_cast(keyval), sizeof(int)); diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index 83213f4b29..9fcc1226a6 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -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 { - *op = smpi_op_new(function, commute); + *op = smpi_op_new(function, (commute!=0)); retval = MPI_SUCCESS; } return retval;