Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2023.
[simgrid.git] / src / smpi / colls / bcast / bcast-scatter-rdb-allgather.cpp
index 85cb981..6fa290e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2011-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -6,8 +6,7 @@
 #include "../colls_private.hpp"
 #include "smpi_status.hpp"
 
-namespace simgrid{
-namespace smpi{
+namespace simgrid::smpi {
 
 static int scatter_for_bcast(
     int root,
@@ -72,7 +71,7 @@ static int scatter_for_bcast(
     }
 
     /* This process is responsible for all processes that have bits
-       set from the LSB upto (but not including) mask.  Because of
+       set from the LSB up to (but not including) mask.  Because of
        the "not including", we start by shifting mask back down
        one. */
 
@@ -164,8 +163,7 @@ int bcast__scatter_rdb_allgather(
       position = 0;
       if (rank == root) {
         mpi_errno = datatype->pack(buffer, count, tmp_buf, nbytes, &position, comm);
-        if (mpi_errno)
-          xbt_die("crash while packing %d", mpi_errno);
+        xbt_assert(mpi_errno == 0, "crash while packing %d", mpi_errno);
       }
     }
 
@@ -174,9 +172,7 @@ int bcast__scatter_rdb_allgather(
 
     mpi_errno = scatter_for_bcast(root, comm,
                                   nbytes, tmp_buf);
-    if (mpi_errno) {
-      xbt_die("crash while scattering %d", mpi_errno);
-    }
+    xbt_assert(mpi_errno == 0, "crash while scattering %d", mpi_errno);
 
     /* curr_size is the amount of data that this process now has stored in
      * buffer at byte offset (relative_rank*scatter_size) */
@@ -316,16 +312,13 @@ int bcast__scatter_rdb_allgather(
 
     /* check that we received as much as we expected */
     /* recvd_size may not be accurate for packed heterogeneous data */
-    if (is_homogeneous && curr_size != nbytes) {
-      xbt_die("we didn't receive enough !");
-    }
+    xbt_assert(not is_homogeneous || curr_size == nbytes, "we didn't receive enough !");
 
     if (not is_contig || not is_homogeneous) {
       if (rank != root) {
         position  = 0;
         mpi_errno = MPI_Unpack(tmp_buf, nbytes, &position, buffer, count, datatype, comm);
-        if (mpi_errno)
-          xbt_die("error when unpacking %d", mpi_errno);
+        xbt_assert(mpi_errno == 0, "error when unpacking %d", mpi_errno);
       }
     }
 
@@ -334,5 +327,4 @@ fn_exit:
   return mpi_errno;
 }
 
-}
-}
+} // namespace simgrid::smpi