Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
protect (hopefully) collective communication algorithms from abuse.
authorAugustin Degomme <degomme@idpann.imag.fr>
Wed, 22 Jan 2014 16:46:13 +0000 (17:46 +0100)
committerAugustin Degomme <degomme@idpann.imag.fr>
Wed, 22 Jan 2014 16:46:13 +0000 (17:46 +0100)
Prevent their use with a number of node they don't like
Allows the automatic selector to ignore those failing using exception mechanism

23 files changed:
src/smpi/colls/allgather-2dmesh.c
src/smpi/colls/allgather-3dmesh.c
src/smpi/colls/allgather-SMP-NTS.c
src/smpi/colls/allgather-loosely-lr.c
src/smpi/colls/allgather-pair.c
src/smpi/colls/allgather-rhv.c
src/smpi/colls/allgather-smp-simple.c
src/smpi/colls/allgatherv-pair.c
src/smpi/colls/allreduce-rab1.c
src/smpi/colls/allreduce-smp-rsag-rab.c
src/smpi/colls/alltoall-pair-light-barrier.c
src/smpi/colls/alltoall-pair-mpi-barrier.c
src/smpi/colls/alltoall-pair-one-barrier.c
src/smpi/colls/alltoall-pair.c
src/smpi/colls/alltoallv-pair-light-barrier.c
src/smpi/colls/alltoallv-pair-mpi-barrier.c
src/smpi/colls/alltoallv-pair-one-barrier.c
src/smpi/colls/alltoallv-pair.c
src/smpi/colls/bcast-SMP-binary.c
src/smpi/colls/bcast-SMP-binomial.c
src/smpi/colls/bcast-SMP-linear.c
src/smpi/colls/colls.h
src/smpi/colls/smpi_automatic_selector.c

index 602d540..8ebc848 100644 (file)
@@ -120,7 +120,7 @@ smpi_coll_tuned_allgather_2dmesh(void *send_buff, int send_count, MPI_Datatype
   block_size = extent * send_count;
 
   if (!is_2dmesh(num_procs, &X, &Y))
-    return MPI_ERR_COMM;
+    THROWF(arg_error,0, "allgather_2dmesh algorithm can't be used with this number of processes! ");
 
   my_row_base = (rank / Y) * Y;
   my_col_base = rank % Y;
index 5a22437..c83fdc6 100644 (file)
@@ -103,7 +103,9 @@ int smpi_coll_tuned_allgather_3dmesh(void *send_buff, int send_count,
   num_procs = smpi_comm_size(comm);
   extent = smpi_datatype_get_extent(send_type);
 
-  is_3dmesh(num_procs, &X, &Y, &Z);
+  if (!is_3dmesh(num_procs, &X, &Y, &Z))
+    THROWF(arg_error,0, "allgather_3dmesh algorithm can't be used with this number of processes! ");
+
 
   num_reqs = X;
 
index 3bbad64..7ad059a 100644 (file)
@@ -23,6 +23,9 @@ int smpi_coll_tuned_allgather_SMP_NTS(void *sbuf, int scount,
   int inter_comm_size = (comm_size + NUM_CORE - 1) / NUM_CORE;
   int num_core_in_current_smp = NUM_CORE;
 
+  if(comm_size%NUM_CORE)
+    THROWF(arg_error,0, "allgather SMP NTS algorithm can't be used with non multiple of NUM_CORE=%d number of processes ! ", NUM_CORE);
+
   /* for too small number of processes, use default implementation */
   if (comm_size <= NUM_CORE) {
     XBT_WARN("MPI_allgather_SMP_NTS use default MPI_allgather.");        
index 04c7faf..7abe6e0 100644 (file)
@@ -16,6 +16,10 @@ int smpi_coll_tuned_allgather_loosely_lr(void *sbuf, int scount,
   int inter_dst, inter_src;
 
   comm_size = smpi_comm_size(comm);
+
+  if(comm_size%4)
+    THROWF(arg_error,0, "allgather loosely lr algorithm can't be used with non multiple of NUM_CORE=4 number of processes ! ");
+
   rank = smpi_comm_rank(comm);
   MPI_Aint rextent, sextent;
   rextent = smpi_datatype_get_extent(rtype);
index 6075723..50f75aa 100644 (file)
@@ -75,6 +75,10 @@ smpi_coll_tuned_allgather_pair(void *send_buff, int send_count,
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "allgather pair algorithm can't be used with non power of two number of processes ! ");
+
   extent = smpi_datatype_get_extent(send_type);
 
   // local send/recv
index aceb283..8179aff 100644 (file)
@@ -21,6 +21,10 @@ smpi_coll_tuned_allgather_rhv(void *sbuf, int send_count,
 
   // get size of the communicator, followed by rank 
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "allgather rhv algorithm can't be used with non power of two number of processes ! ");
+
   rank = smpi_comm_rank(comm);
 
   // get size of single element's type for send buffer and recv buffer
index 1438870..f1c25d0 100644 (file)
@@ -10,6 +10,10 @@ int smpi_coll_tuned_allgather_smp_simple(void *send_buf, int scount,
 {
   int src, dst, comm_size, rank;
   comm_size = smpi_comm_size(comm);
+
+  if(comm_size%NUM_CORE)
+     THROWF(arg_error,0, "allgather SMP simple algorithm can't be used with non multiple of NUM_CORE=%d number of processes ! ", NUM_CORE);
+
   rank = smpi_comm_rank(comm);
   MPI_Aint rextent, sextent;
   rextent = smpi_datatype_get_extent(rtype);
index c73366e..e31fb62 100644 (file)
@@ -75,6 +75,10 @@ smpi_coll_tuned_allgatherv_pair(void *send_buff, int send_count,
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "allgatherv pair algorithm can't be used with non power of two number of processes ! ");
+
   extent = smpi_datatype_get_extent(send_type);
 
   // local send/recv
index 66862da..e863339 100644 (file)
@@ -16,6 +16,9 @@ int smpi_coll_tuned_allreduce_rab1(void *sbuff, void *rbuff,
   rank = smpi_comm_rank(comm);
   nprocs = smpi_comm_size(comm);
 
+  if((nprocs&(nprocs-1)))
+    THROWF(arg_error,0, "allreduce rab1 algorithm can't be used with non power of two number of processes ! ");
+
   extent = smpi_datatype_get_extent(dtype);
 
   pof2 = 1;
index cec7521..ced01ab 100644 (file)
@@ -29,6 +29,10 @@ int smpi_coll_tuned_allreduce_smp_rsag_rab(void *sbuf, void *rbuf, int count,
   int num_core = NUM_CORE;
 
   comm_size = smpi_comm_size(comm);
+
+  if((comm_size&(comm_size-1)))
+    THROWF(arg_error,0, "allreduce smp rsag rab algorithm can't be used with non power of two number of processes ! ");
+
   rank = smpi_comm_rank(comm);
   MPI_Aint extent;
   extent = smpi_datatype_get_extent(dtype);
index 65ae5f8..9c6a6de 100644 (file)
@@ -39,6 +39,10 @@ smpi_coll_tuned_alltoall_pair_light_barrier(void *send_buff, int send_count,
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "alltoall pair algorithm can't be used with non power of two number of processes ! ");
+
   send_chunk = smpi_datatype_get_extent(send_type);
   recv_chunk = smpi_datatype_get_extent(recv_type);
 
index 20dd573..1816cff 100644 (file)
@@ -36,6 +36,10 @@ smpi_coll_tuned_alltoall_pair_mpi_barrier(void *send_buff, int send_count,
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "alltoall pair algorithm can't be used with non power of two number of processes ! ");
+
   send_chunk = smpi_datatype_get_extent(send_type);
   recv_chunk = smpi_datatype_get_extent(recv_type);
 
index 209fa81..b230402 100644 (file)
@@ -37,6 +37,10 @@ smpi_coll_tuned_alltoall_pair_one_barrier(void *send_buff, int send_count,
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "alltoall pair algorithm can't be used with non power of two number of processes ! ");
+
   send_chunk = smpi_datatype_get_extent(send_type);
   recv_chunk = smpi_datatype_get_extent(recv_type);
 
index 66c4767..bac1909 100644 (file)
@@ -74,6 +74,10 @@ int smpi_coll_tuned_alltoall_pair(void *send_buff, int send_count,
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "alltoall pair algorithm can't be used with non power of two number of processes ! ");
+
   send_chunk = smpi_datatype_get_extent(send_type);
   recv_chunk = smpi_datatype_get_extent(recv_type);
 
index 60e2647..7843d91 100644 (file)
@@ -39,6 +39,10 @@ smpi_coll_tuned_alltoallv_pair_light_barrier(void *send_buff, int *send_counts,
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "alltoallv pair algorithm can't be used with non power of two number of processes ! ");
+
   send_chunk = smpi_datatype_get_extent(send_type);
   recv_chunk = smpi_datatype_get_extent(recv_type);
 
index 62b0d71..aba8f25 100644 (file)
@@ -36,6 +36,10 @@ smpi_coll_tuned_alltoallv_pair_mpi_barrier(void *send_buff, int *send_counts, in
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "alltoallv pair algorithm can't be used with non power of two number of processes ! ");
+
   send_chunk = smpi_datatype_get_extent(send_type);
   recv_chunk = smpi_datatype_get_extent(recv_type);
 
index 7bea7e7..7227df8 100644 (file)
@@ -36,6 +36,10 @@ smpi_coll_tuned_alltoallv_pair_one_barrier(void *send_buff, int *send_counts, in
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "alltoallv pair algorithm can't be used with non power of two number of processes ! ");
+
   send_chunk = smpi_datatype_get_extent(send_type);
   recv_chunk = smpi_datatype_get_extent(recv_type);
 
index 6692eeb..afce437 100644 (file)
@@ -36,6 +36,10 @@ int smpi_coll_tuned_alltoallv_pair(void *send_buff, int *send_counts, int *send_
 
   rank = smpi_comm_rank(comm);
   num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "alltoallv pair algorithm can't be used with non power of two number of processes ! ");
+
   send_chunk = smpi_datatype_get_extent(send_type);
   recv_chunk = smpi_datatype_get_extent(recv_type);
 
index 1645e71..c09d703 100644 (file)
@@ -22,6 +22,9 @@ int smpi_coll_tuned_bcast_SMP_binary(void *buf, int count,
   rank = smpi_comm_rank(comm);
   size = smpi_comm_size(comm);
 
+  if(size%NUM_CORE)
+    THROWF(arg_error,0, "bcast SMP binary can't be used with non multiple of NUM_CORE=%d number of processes ! ",NUM_CORE);
+
   int segment = bcast_SMP_binary_segment_byte / extent;
   int pipe_length = count / segment;
   int remainder = count % segment;
index c2b24a4..2239960 100644 (file)
@@ -16,6 +16,9 @@ int smpi_coll_tuned_bcast_SMP_binomial(void *buf, int count,
   size = smpi_comm_size(comm);
   rank = smpi_comm_rank(comm);
 
+  if(size%NUM_CORE)
+    THROWF(arg_error,0, "bcast SMP binomial can't be used with non multiple of NUM_CORE=%d number of processes ! ",NUM_CORE);
+
   int to_intra, to_inter;
   int from_intra, from_inter;
   int inter_rank = rank / NUM_CORE;
index b999b39..092ab26 100644 (file)
@@ -22,6 +22,9 @@ int smpi_coll_tuned_bcast_SMP_linear(void *buf, int count,
   rank = smpi_comm_rank(comm);
   size = smpi_comm_size(comm);
 
+  if(size%NUM_CORE)
+    THROWF(arg_error,0, "bcast SMP linear can't be used with non multiple of NUM_CORE=%d number of processes ! ",NUM_CORE);
+
   int segment = bcast_SMP_linear_segment_byte / extent;
   int pipe_length = count / segment;
   int remainder = count % segment;
index b70a313..9a2cd45 100644 (file)
@@ -4,6 +4,7 @@
 #include <math.h>
 #include "smpi/mpi.h"
 #include "smpi/private.h"
+#include "xbt/ex.h"
 #include "xbt.h"
 
 #define COLL_DESCRIPTION(cat, ret, args, name) \
index ded62ec..95a7ce4 100644 (file)
@@ -26,6 +26,7 @@
   double time1, time2, time_min=DBL_MAX;\
   int min_coll=-1, global_coll=-1;\
   int i;\
+  xbt_ex_t ex;\
   double buf_in, buf_out, max_min=DBL_MAX;\
   for (i = 0; mpi_coll_##cat##_description[i].name; i++){\
       if(!strcmp(mpi_coll_##cat##_description[i].name, "automatic"))continue;\
       smpi_mpi_barrier(comm);\
       TRACE_AUTO_COLL(cat)\
       time1 = SIMIX_get_clock();\
+      TRY{\
       ((int (*) args)\
           mpi_coll_##cat##_description[i].coll) args2 ;\
+      }\
+      CATCH(ex) {\
+        continue;\
+      }\
       time2 = SIMIX_get_clock();\
       buf_out=time2-time1;\
       smpi_mpi_reduce((void*)&buf_out,(void*)&buf_in, 1, MPI_DOUBLE, MPI_MAX, 0,comm );\