From d302816d682e544d2ec520f5844cfd271137296a Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Sun, 3 Sep 2017 01:53:13 +0200 Subject: [PATCH] try to please scan-build --- examples/smpi/NAS/dt.c | 4 +-- examples/smpi/NAS/ep.c | 6 ++-- examples/smpi/NAS/is.c | 7 ++--- src/smpi/bindings/smpi_pmpi_win.cpp | 28 +++++++++++-------- src/smpi/colls/smpi_default_selector.cpp | 2 ++ .../smpi/coll-allgatherv/coll-allgatherv.c | 12 ++++---- .../smpi/coll-allreduce/coll-allreduce.c | 2 +- 7 files changed, 32 insertions(+), 29 deletions(-) diff --git a/examples/smpi/NAS/dt.c b/examples/smpi/NAS/dt.c index 45398c9a87..f1b63e054f 100644 --- a/examples/smpi/NAS/dt.c +++ b/examples/smpi/NAS/dt.c @@ -240,7 +240,6 @@ static DGraph *buildWH(const char cls){ AttachNode(dg,nd); } totComparators=0; - numPrevLayerNodes=numLayerNodes; while(numLayerNodes>maxInDeg){ numLayerNodes=numLayerNodes/maxInDeg; if(numLayerNodes*maxInDegval[i]=weight*b->val[i]; a->val[i+1]=weight*b->val[i+1]; a->val[i+2]=weight*b->val[i+2]; @@ -677,7 +675,7 @@ int main(int argc,char **argv ){ if(my_rank==0) fprintf(stderr,"Not enough timers. Node timeing is off. \n"); } - if(dg->numNodes>comm_size){ + if(dg->numNodes && dg->numNodes>comm_size){ if(my_rank==0){ fprintf(stderr,"** The number of MPI processes should not be less than \n"); fprintf(stderr,"** the number of nodes in the graph\n"); diff --git a/examples/smpi/NAS/ep.c b/examples/smpi/NAS/ep.c index 24257dc1b2..a7b8d50fae 100644 --- a/examples/smpi/NAS/ep.c +++ b/examples/smpi/NAS/ep.c @@ -73,7 +73,6 @@ int main(int argc, char **argv) { fprintf(stdout," Number of random numbers generated: %s\n",size); fprintf(stdout," Number of active processes: %d\n",no_nodes); } - verified = FALSE; /* Compute the number of "batches" of random number pairs generated per processor. Adjust if the number of processors * does not evenly divide the total number */ @@ -99,7 +98,6 @@ int main(int argc, char **argv) { for (i=0;i<2*nk;i++) { x[i] = -1e99; } - Mops = log(sqrt(abs(1))); /* Synchronize before placing time stamp */ MPI_Barrier( MPI_COMM_WORLD ); @@ -147,12 +145,12 @@ int main(int argc, char **argv) { for (i=1;i<=100 && !stop;i++) { ik = kk / 2; if (2 * ik != kk) { - t3 = randlc(&t1, &t2); + randlc(&t1, &t2); } if (ik==0) stop = TRUE; else { - t3 = randlc(&t2, &t2); + randlc(&t2, &t2); kk = ik; } } diff --git a/examples/smpi/NAS/is.c b/examples/smpi/NAS/is.c index 7314dee222..b68196515a 100644 --- a/examples/smpi/NAS/is.c +++ b/examples/smpi/NAS/is.c @@ -124,7 +124,7 @@ static double find_my_seed( int kn, /* my processor rank, 0<=kn<=num pro double a ) /* Ran num gen mult, try 1220703125.00 */ { long i; - double t1,t2,t3,an; + double t1,t2,an; long mq,nq,kk,ik; nq = nn / np; @@ -145,13 +145,12 @@ static double find_my_seed( int kn, /* my processor rank, 0<=kn<=num pro for( i=1; i<=100; i++ ){ ik = kk / 2; if( 2 * ik != kk ) - t3 = randlc( &t1, &t2 ); + randlc( &t1, &t2 ); if( ik == 0 ) break; - t3 = randlc( &t2, &t2 ); + randlc( &t2, &t2 ); kk = ik; } - an=t3;//added to silence paranoid compilers return t1; } diff --git a/src/smpi/bindings/smpi_pmpi_win.cpp b/src/smpi/bindings/smpi_pmpi_win.cpp index 983ed259e2..03b8438e66 100644 --- a/src/smpi/bindings/smpi_pmpi_win.cpp +++ b/src/smpi/bindings/smpi_pmpi_win.cpp @@ -190,7 +190,8 @@ int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else { int rank = smpi_process()->index(); @@ -224,7 +225,8 @@ int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if(request == nullptr){ retval = MPI_ERR_REQUEST; @@ -259,7 +261,8 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else { int rank = smpi_process()->index(); @@ -295,7 +298,8 @@ int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if(request == nullptr){ retval = MPI_ERR_REQUEST; @@ -332,7 +336,8 @@ int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -367,7 +372,8 @@ int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_d } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -406,8 +412,8 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){ (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) || (result_addr==nullptr && result_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((origin_datatype != MPI_DATATYPE_NULL && not origin_datatype->is_valid()) || - (not target_datatype->is_valid()) || (not result_datatype->is_valid())) { + } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) || + (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -447,8 +453,8 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){ (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) || (result_addr==nullptr && result_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((origin_datatype != MPI_DATATYPE_NULL && not origin_datatype->is_valid()) || - (not target_datatype->is_valid()) || (not result_datatype->is_valid())) { + } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) || + (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -490,7 +496,7 @@ int PMPI_Compare_and_swap(void *origin_addr, void *compare_addr, retval = MPI_ERR_ARG; } else if (origin_addr==nullptr || result_addr==nullptr || compare_addr==nullptr){ retval = MPI_ERR_COUNT; - } else if (not datatype->is_valid()) { + } else if ((datatype == MPI_DATATYPE_NULL) || (not datatype->is_valid())) { retval = MPI_ERR_TYPE; } else { int rank = smpi_process()->index(); diff --git a/src/smpi/colls/smpi_default_selector.cpp b/src/smpi/colls/smpi_default_selector.cpp index d3736cc81b..f218a4efcb 100644 --- a/src/smpi/colls/smpi_default_selector.cpp +++ b/src/smpi/colls/smpi_default_selector.cpp @@ -213,6 +213,8 @@ int Coll_reduce_default::reduce(void *sendbuf, void *recvbuf, int count, MPI_Dat int rank = comm->rank(); int size = comm->size(); + if(size==0) + return MPI_ERR_COMM; //non commutative case, use a working algo from openmpi if (op != MPI_OP_NULL && not op->is_commutative()) { return Coll_reduce_ompi_basic_linear::reduce(sendtmpbuf, recvbuf, count, datatype, op, root, comm); diff --git a/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c b/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c index 1cbda3cc01..30734f17d5 100644 --- a/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c +++ b/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c @@ -39,16 +39,16 @@ int main(int argc, char *argv[]) int* sb = (int *) xbt_malloc(recv_counts[rank] * sizeof(int)); int* rb = (int *) xbt_malloc(recv_sb_size * sizeof(int)); - for (i = 0; i < recv_counts[rank]; ++i) - sb[i] = recv_disps[rank] + i; - for (i = 0; i < recv_sb_size; ++i) - rb[i] = -1; - printf("[%d] sndbuf=[", rank); - for (i = 0; i < recv_counts[rank]; i++) + for (i = 0; i < recv_counts[rank]; i++){ + sb[i] = recv_disps[rank] + i; printf("%d ", sb[i]); + } printf("]\n"); + for (i = 0; i < recv_sb_size; i++) + rb[i] = -1; + status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD); printf("[%d] rcvbuf=[", rank); diff --git a/teshsuite/smpi/coll-allreduce/coll-allreduce.c b/teshsuite/smpi/coll-allreduce/coll-allreduce.c index 45eeb9c8e5..509aec9883 100644 --- a/teshsuite/smpi/coll-allreduce/coll-allreduce.c +++ b/teshsuite/smpi/coll-allreduce/coll-allreduce.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); if (maxlen > 1) - mult = size; + mult = maxlen > size ? size : maxlen; int* sb = (int *) xbt_malloc(size *maxlen * sizeof(int)); int* rb = (int *) xbt_malloc(size *maxlen * sizeof(int)); -- 2.20.1