X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d20f024dba9ff1e9c8822237caaf963b9e913889..39c935d6d5ee86d153f6f7e6a10d723ae7c57f6f:/src/smpi/colls/scatter/scatter-mvapich-two-level.cpp diff --git a/src/smpi/colls/scatter/scatter-mvapich-two-level.cpp b/src/smpi/colls/scatter/scatter-mvapich-two-level.cpp index 16f3781b78..80c8609512 100644 --- a/src/smpi/colls/scatter/scatter-mvapich-two-level.cpp +++ b/src/smpi/colls/scatter/scatter-mvapich-two-level.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. +/* Copyright (c) 2013-2021. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -36,37 +36,37 @@ */ #include "../colls_private.hpp" -#define MPIR_Scatter_MV2_Binomial Coll_scatter_ompi_binomial::scatter -#define MPIR_Scatter_MV2_Direct Coll_scatter_ompi_basic_linear::scatter +#define MPIR_Scatter_MV2_Binomial scatter__ompi_binomial +#define MPIR_Scatter_MV2_Direct scatter__ompi_basic_linear -extern int (*MV2_Scatter_intra_function) (void *sendbuf, int sendcount, MPI_Datatype sendtype, +extern int (*MV2_Scatter_intra_function) (const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm); namespace simgrid{ namespace smpi{ -int Coll_scatter_mvapich2_two_level_direct::scatter(void *sendbuf, - int sendcnt, - MPI_Datatype sendtype, - void *recvbuf, - int recvcnt, - MPI_Datatype recvtype, - int root, MPI_Comm comm) +int scatter__mvapich2_two_level_direct(const void *sendbuf, + int sendcnt, + MPI_Datatype sendtype, + void *recvbuf, + int recvcnt, + MPI_Datatype recvtype, + int root, MPI_Comm comm) { int comm_size, rank; int local_rank, local_size; int leader_comm_rank = -1, leader_comm_size = -1; int mpi_errno = MPI_SUCCESS; int recvtype_size, sendtype_size, nbytes; - void *tmp_buf = NULL; - void *leader_scatter_buf = NULL; + unsigned char* tmp_buf = nullptr; + unsigned char* leader_scatter_buf = nullptr; MPI_Status status; int leader_root, leader_of_root = -1; MPI_Comm shmem_comm, leader_comm; //if not set (use of the algo directly, without mvapich2 selector) - if(MV2_Scatter_intra_function==NULL) - MV2_Scatter_intra_function=Coll_scatter_mpich::scatter; + if (MV2_Scatter_intra_function == nullptr) + MV2_Scatter_intra_function = scatter__mpich; if(comm->get_leaders_comm()==MPI_COMM_NULL){ comm->init_smp(); @@ -142,16 +142,16 @@ int Coll_scatter_mvapich2_two_level_direct::scatter(void *sendbuf, if (leader_comm_size > 1 && local_rank == 0) { if (not comm->is_uniform()) { - int* displs = NULL; - int* sendcnts = NULL; + int* displs = nullptr; + int* sendcnts = nullptr; int* node_sizes; int i = 0; node_sizes = comm->get_non_uniform_map(); if (root != leader_of_root) { if (leader_comm_rank == leader_root) { - displs = static_cast(xbt_malloc(sizeof(int) * leader_comm_size)); - sendcnts = static_cast(xbt_malloc(sizeof(int) * leader_comm_size)); + displs = new int[leader_comm_size]; + sendcnts = new int[leader_comm_size]; sendcnts[0] = node_sizes[0] * nbytes; displs[0] = 0; @@ -160,12 +160,12 @@ int Coll_scatter_mvapich2_two_level_direct::scatter(void *sendbuf, sendcnts[i] = node_sizes[i] * nbytes; } } - Colls::scatterv(leader_scatter_buf, sendcnts, displs, MPI_BYTE, tmp_buf, nbytes * local_size, MPI_BYTE, + colls::scatterv(leader_scatter_buf, sendcnts, displs, MPI_BYTE, tmp_buf, nbytes * local_size, MPI_BYTE, leader_root, leader_comm); } else { if (leader_comm_rank == leader_root) { - displs = static_cast(xbt_malloc(sizeof(int) * leader_comm_size)); - sendcnts = static_cast(xbt_malloc(sizeof(int) * leader_comm_size)); + displs = new int[leader_comm_size]; + sendcnts = new int[leader_comm_size]; sendcnts[0] = node_sizes[0] * sendcnt; displs[0] = 0; @@ -174,12 +174,12 @@ int Coll_scatter_mvapich2_two_level_direct::scatter(void *sendbuf, sendcnts[i] = node_sizes[i] * sendcnt; } } - Colls::scatterv(sendbuf, sendcnts, displs, sendtype, tmp_buf, nbytes * local_size, MPI_BYTE, leader_root, + colls::scatterv(sendbuf, sendcnts, displs, sendtype, tmp_buf, nbytes * local_size, MPI_BYTE, leader_root, leader_comm); } if (leader_comm_rank == leader_root) { - xbt_free(displs); - xbt_free(sendcnts); + delete[] displs; + delete[] sendcnts; } } else { if (leader_of_root != root) { @@ -223,29 +223,29 @@ int Coll_scatter_mvapich2_two_level_direct::scatter(void *sendbuf, } -int Coll_scatter_mvapich2_two_level_binomial::scatter(void *sendbuf, - int sendcnt, - MPI_Datatype sendtype, - void *recvbuf, - int recvcnt, - MPI_Datatype recvtype, - int root, MPI_Comm comm) +int scatter__mvapich2_two_level_binomial(const void *sendbuf, + int sendcnt, + MPI_Datatype sendtype, + void *recvbuf, + int recvcnt, + MPI_Datatype recvtype, + int root, MPI_Comm comm) { int comm_size, rank; int local_rank, local_size; int leader_comm_rank = -1, leader_comm_size = -1; int mpi_errno = MPI_SUCCESS; int recvtype_size, sendtype_size, nbytes; - void *tmp_buf = NULL; - void *leader_scatter_buf = NULL; + unsigned char* tmp_buf = nullptr; + unsigned char* leader_scatter_buf = nullptr; MPI_Status status; int leader_root = -1, leader_of_root = -1; MPI_Comm shmem_comm, leader_comm; //if not set (use of the algo directly, without mvapich2 selector) - if(MV2_Scatter_intra_function==NULL) - MV2_Scatter_intra_function=Coll_scatter_mpich::scatter; + if (MV2_Scatter_intra_function == nullptr) + MV2_Scatter_intra_function = scatter__mpich; if(comm->get_leaders_comm()==MPI_COMM_NULL){ comm->init_smp(); @@ -318,16 +318,16 @@ int Coll_scatter_mvapich2_two_level_binomial::scatter(void *sendbuf, if (leader_comm_size > 1 && local_rank == 0) { if (not comm->is_uniform()) { - int* displs = NULL; - int* sendcnts = NULL; + int* displs = nullptr; + int* sendcnts = nullptr; int* node_sizes; int i = 0; node_sizes = comm->get_non_uniform_map(); if (root != leader_of_root) { if (leader_comm_rank == leader_root) { - displs = static_cast(xbt_malloc(sizeof(int) * leader_comm_size)); - sendcnts = static_cast(xbt_malloc(sizeof(int) * leader_comm_size)); + displs = new int[leader_comm_size]; + sendcnts = new int[leader_comm_size]; sendcnts[0] = node_sizes[0] * nbytes; displs[0] = 0; @@ -336,12 +336,12 @@ int Coll_scatter_mvapich2_two_level_binomial::scatter(void *sendbuf, sendcnts[i] = node_sizes[i] * nbytes; } } - Colls::scatterv(leader_scatter_buf, sendcnts, displs, MPI_BYTE, tmp_buf, nbytes * local_size, MPI_BYTE, + colls::scatterv(leader_scatter_buf, sendcnts, displs, MPI_BYTE, tmp_buf, nbytes * local_size, MPI_BYTE, leader_root, leader_comm); } else { if (leader_comm_rank == leader_root) { - displs = static_cast(xbt_malloc(sizeof(int) * leader_comm_size)); - sendcnts = static_cast(xbt_malloc(sizeof(int) * leader_comm_size)); + displs = new int[leader_comm_size]; + sendcnts = new int[leader_comm_size]; sendcnts[0] = node_sizes[0] * sendcnt; displs[0] = 0; @@ -350,12 +350,12 @@ int Coll_scatter_mvapich2_two_level_binomial::scatter(void *sendbuf, sendcnts[i] = node_sizes[i] * sendcnt; } } - Colls::scatterv(sendbuf, sendcnts, displs, sendtype, tmp_buf, nbytes * local_size, MPI_BYTE, leader_root, + colls::scatterv(sendbuf, sendcnts, displs, sendtype, tmp_buf, nbytes * local_size, MPI_BYTE, leader_root, leader_comm); } if (leader_comm_rank == leader_root) { - xbt_free(displs); - xbt_free(sendcnts); + delete[] displs; + delete[] sendcnts; } } else { if (leader_of_root != root) {