Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to please scan-build
authorAugustin Degomme <augustin.degomme@unibas.ch>
Sat, 2 Sep 2017 23:53:13 +0000 (01:53 +0200)
committerAugustin Degomme <augustin.degomme@unibas.ch>
Sat, 2 Sep 2017 23:53:13 +0000 (01:53 +0200)
examples/smpi/NAS/dt.c
examples/smpi/NAS/ep.c
examples/smpi/NAS/is.c
src/smpi/bindings/smpi_pmpi_win.cpp
src/smpi/colls/smpi_default_selector.cpp
teshsuite/smpi/coll-allgatherv/coll-allgatherv.c
teshsuite/smpi/coll-allreduce/coll-allreduce.c

index 45398c9..f1b63e0 100644 (file)
@@ -240,7 +240,6 @@ static DGraph *buildWH(const char cls){
     AttachNode(dg,nd);
   }
   totComparators=0;
     AttachNode(dg,nd);
   }
   totComparators=0;
-  numPrevLayerNodes=numLayerNodes;
   while(numLayerNodes>maxInDeg){
     numLayerNodes=numLayerNodes/maxInDeg;
     if(numLayerNodes*maxInDeg<numPrevLayerNodes)
   while(numLayerNodes>maxInDeg){
     numLayerNodes=numLayerNodes/maxInDeg;
     if(numLayerNodes*maxInDeg<numPrevLayerNodes)
@@ -452,7 +451,6 @@ static Arr* WindowFilter(Arr *a, Arr* b,int w){
     }
     if(rmsm1<rms0) k=-1;
     if(k==0){
     }
     if(rmsm1<rms0) k=-1;
     if(k==0){
-      j=i+fielddim;
       a->val[i]=weight*b->val[i];
       a->val[i+1]=weight*b->val[i+1];
       a->val[i+2]=weight*b->val[i+2];
       a->val[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(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");
     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");
index 24257dc..a7b8d50 100644 (file)
@@ -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);
   }
     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  */
 
   /* 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;
   }
   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 );
 
   /* 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)  {
     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 {
       }
       if (ik==0)
         stop = TRUE;
       else {
-        t3 = randlc(&t2, &t2);
+        randlc(&t2, &t2);
         kk = ik;
       }
     }
         kk = ik;
       }
     }
index 7314dee..b681965 100644 (file)
@@ -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 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;
   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 )
   for( i=1; i<=100; i++ ){
     ik = kk / 2;
     if( 2 * ik !=  kk )
-      t3 = randlc( &t1, &t2 );
+      randlc( &t1, &t2 );
     if( ik == 0 )
       break;
     if( ik == 0 )
       break;
-    t3 = randlc( &t2, &t2 );
+    randlc( &t2, &t2 );
     kk = ik;
   }
     kk = ik;
   }
-  an=t3;//added to silence paranoid compilers
 
   return t1;
 }
 
   return t1;
 }
index 983ed25..03b8438 100644 (file)
@@ -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 ((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();
     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 ((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;
     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 ((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();
     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 ((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;
     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 ((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;
     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 ((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;
     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;
              (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;
     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;
              (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;
     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;
     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();
     retval = MPI_ERR_TYPE;
   } else {
     int rank = smpi_process()->index();
index d3736cc..f218a4e 100644 (file)
@@ -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();
 
   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);
   //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);
index 1cbda3c..30734f1 100644 (file)
@@ -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));
 
   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);
   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("%d ", sb[i]);
+  }
   printf("]\n");
 
   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);
   status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD);
 
   printf("[%d] rcvbuf=[", rank);
index 45eeb9c..509aec9 100644 (file)
@@ -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)
   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));
 
   int* sb = (int *) xbt_malloc(size *maxlen * sizeof(int));
   int* rb = (int *) xbt_malloc(size *maxlen * sizeof(int));