X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c07b0d9b6750434a97220b7819c0f72bfc8d4e98..18be315df9e3c0639b33c60507addc5d21a89901:/src/smpi/include/smpi_file.hpp diff --git a/src/smpi/include/smpi_file.hpp b/src/smpi/include/smpi_file.hpp index 25b917112f..9abac40511 100644 --- a/src/smpi/include/smpi_file.hpp +++ b/src/smpi/include/smpi_file.hpp @@ -36,7 +36,7 @@ class File : public F2C{ File(MPI_Comm comm, const char *filename, int amode, MPI_Info info); File(const File&) = delete; File& operator=(const File&) = delete; - ~File(); + ~File() override; int size() const; int get_position(MPI_Offset* offset) const; int get_position_shared(MPI_Offset* offset) const; @@ -82,10 +82,10 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta MPI_Offset max_offset = min_offset + count * datatype->get_extent(); // cheating, as we don't care about exact data location, we can skip extent - MPI_Offset* min_offsets = new MPI_Offset[size]; - MPI_Offset* max_offsets = new MPI_Offset[size]; - simgrid::smpi::colls::allgather(&min_offset, 1, MPI_OFFSET, min_offsets, 1, MPI_OFFSET, comm_); - simgrid::smpi::colls::allgather(&max_offset, 1, MPI_OFFSET, max_offsets, 1, MPI_OFFSET, comm_); + std::vector min_offsets(size); + std::vector max_offsets(size); + simgrid::smpi::colls::allgather(&min_offset, 1, MPI_OFFSET, min_offsets.data(), 1, MPI_OFFSET, comm_); + simgrid::smpi::colls::allgather(&max_offset, 1, MPI_OFFSET, max_offsets.data(), 1, MPI_OFFSET, comm_); MPI_Offset min = min_offset; MPI_Offset max = max_offset; MPI_Offset tot = 0; @@ -103,15 +103,12 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta XBT_CDEBUG(smpi_pmpi, "my offsets to read : %lld:%lld, global min and max %lld:%lld", min_offset, max_offset, min, max); if (empty == 1) { - delete[] min_offsets; - delete[] max_offsets; - status->count = 0; + if (status != MPI_STATUS_IGNORE) + status->count = 0; return MPI_SUCCESS; } MPI_Offset total = max - min; if (total == tot && (datatype->flags() & DT_FLAG_CONTIGUOUS)) { - delete[] min_offsets; - delete[] max_offsets; // contiguous. Just have each proc perform its read if (status != MPI_STATUS_IGNORE) status->count = count * datatype->size(); @@ -122,10 +119,10 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta MPI_Offset my_chunk_start = (max - min + 1) / size * rank; MPI_Offset my_chunk_end = ((max - min + 1) / size * (rank + 1)); XBT_CDEBUG(smpi_pmpi, "my chunks to read : %lld:%lld", my_chunk_start, my_chunk_end); - int* send_sizes = new int[size]; - int* recv_sizes = new int[size]; - int* send_disps = new int[size]; - int* recv_disps = new int[size]; + std::vector send_sizes(size); + std::vector recv_sizes(size); + std::vector send_disps(size); + std::vector recv_disps(size); int total_sent = 0; for (int i = 0; i < size; i++) { send_sizes[i] = 0; @@ -144,7 +141,7 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta // merge the ranges of every process std::vector> ranges; for (int i = 0; i < size; ++i) - ranges.push_back(std::make_pair(min_offsets[i], max_offsets[i])); + ranges.emplace_back(min_offsets[i], max_offsets[i]); std::sort(ranges.begin(), ranges.end()); std::vector> chunks; chunks.push_back(ranges[0]); @@ -183,24 +180,18 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta seek(min_offset, MPI_SEEK_SET); T(this, sendbuf, totreads / datatype->size(), datatype, status); } - simgrid::smpi::colls::alltoall(send_sizes, 1, MPI_INT, recv_sizes, 1, MPI_INT, comm_); + simgrid::smpi::colls::alltoall(send_sizes.data(), 1, MPI_INT, recv_sizes.data(), 1, MPI_INT, comm_); int total_recv = 0; for (int i = 0; i < size; i++) { recv_disps[i] = total_recv; total_recv += recv_sizes[i]; } // Set buf value to avoid copying dumb data - simgrid::smpi::colls::alltoallv(sendbuf, send_sizes, send_disps, MPI_BYTE, buf, recv_sizes, recv_disps, MPI_BYTE, - comm_); + simgrid::smpi::colls::alltoallv(sendbuf, send_sizes.data(), send_disps.data(), MPI_BYTE, buf, recv_sizes.data(), + recv_disps.data(), MPI_BYTE, comm_); if (status != MPI_STATUS_IGNORE) status->count = count * datatype->size(); smpi_free_tmp_buffer(sendbuf); - delete[] send_sizes; - delete[] recv_sizes; - delete[] send_disps; - delete[] recv_disps; - delete[] min_offsets; - delete[] max_offsets; return MPI_SUCCESS; } }