X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2807fde4fd1f59c230d69a934634c5dfb77905f2..ea74f5d95928a521a588737e81f1de94eef25d19:/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp?ds=sidebyside diff --git a/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp b/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp index df78b16451..0c41344d63 100644 --- a/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp +++ b/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2011-2022. 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. */ @@ -72,7 +72,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. */ @@ -102,8 +102,7 @@ static int scatter_for_bcast( } -int -Coll_bcast_scatter_rdb_allgather::bcast ( +int bcast__scatter_rdb_allgather( void *buffer, int count, MPI_Datatype datatype, @@ -115,7 +114,8 @@ Coll_bcast_scatter_rdb_allgather::bcast ( int relative_rank, mask; int mpi_errno = MPI_SUCCESS; int scatter_size, curr_size, recv_size = 0; - int j, k, i, tmp_mask, is_contig, is_homogeneous; + int j, k, i, tmp_mask; + bool is_contig, is_homogeneous; MPI_Aint type_size = 0, nbytes = 0; int relative_dst, dst_tree_root, my_tree_root, send_offset; int recv_offset, tree_root, nprocs_completed, offset; @@ -131,13 +131,9 @@ Coll_bcast_scatter_rdb_allgather::bcast ( if (comm_size == 1) goto fn_exit; //if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN) - if(datatype->flags() & DT_FLAG_CONTIGUOUS) - is_contig = 1; - else { - is_contig = 0; - } + is_contig = ((datatype->flags() & DT_FLAG_CONTIGUOUS) != 0); - is_homogeneous = 1; + is_homogeneous = true; /* MPI_Type_size() might not give the accurate size of the packed * datatype for heterogeneous systems (because of padding, encoding, @@ -162,15 +158,14 @@ Coll_bcast_scatter_rdb_allgather::bcast ( } else { - tmp_buf=(void*)xbt_malloc(nbytes); - - /* TODO: Pipeline the packing and communication */ - 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); - } + tmp_buf = new unsigned char[nbytes]; + + /* TODO: Pipeline the packing and communication */ + position = 0; + if (rank == root) { + mpi_errno = datatype->pack(buffer, count, tmp_buf, nbytes, &position, comm); + xbt_assert(mpi_errno == 0, "crash while packing %d", mpi_errno); + } } @@ -178,9 +173,7 @@ Coll_bcast_scatter_rdb_allgather::bcast ( 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) */ @@ -320,22 +313,19 @@ Coll_bcast_scatter_rdb_allgather::bcast ( /* 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); } } fn_exit: -/* xbt_free(tmp_buf);*/ - return mpi_errno; + /* delete[] static_cast(tmp_buf); */ + return mpi_errno; } }