X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6d3a6943f1232a8ab01f0f6e2def45ad1b98aed8..35a644bdf9d0c5603c9483f03f913e4a649638d6:/teshsuite/smpi/replay-ti-colls/replay-ti-colls.c diff --git a/teshsuite/smpi/replay-ti-colls/replay-ti-colls.c b/teshsuite/smpi/replay-ti-colls/replay-ti-colls.c index 4e0cb638d6..c14b802d10 100644 --- a/teshsuite/smpi/replay-ti-colls/replay-ti-colls.c +++ b/teshsuite/smpi/replay-ti-colls/replay-ti-colls.c @@ -1,6 +1,3 @@ -//exclude from clang static analysis, as there is an intentional uninitialized value passed to MPI calls. -#ifndef __clang_analyzer__ - #include "mpi.h" #include #include @@ -10,13 +7,13 @@ static void setup_recvbuf(int nprocs, int** recvbuf, int** displs, int** counts, int** rcounts) { - *recvbuf = malloc(BUFSIZE * nprocs * sizeof(int)); + *recvbuf = xbt_malloc(BUFSIZE * nprocs * sizeof(int)); for (int i = 0; i < BUFSIZE * nprocs; i++) (*recvbuf)[i] = i; - *displs = malloc(nprocs * sizeof(int)); - *counts = malloc(nprocs * sizeof(int)); - *rcounts = malloc(nprocs * sizeof(int)); + *displs = xbt_malloc(nprocs * sizeof(int)); + *counts = xbt_malloc(nprocs * sizeof(int)); + *rcounts = xbt_malloc(nprocs * sizeof(int)); for (int i = 0; i < nprocs; i++) { (*displs)[i] = i * BUFSIZE; (*counts)[i] = BOUNDED(i); @@ -34,18 +31,20 @@ int main(int argc, char** argv) MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &rank); - int* sendbuf = malloc(BUFSIZE * nprocs * sizeof(int)); + int* sendbuf = xbt_malloc(BUFSIZE * nprocs * sizeof(int)); for (int i = 0; i < BUFSIZE * nprocs; i++) sendbuf[i] = rank; - int* alltoallvcounts = malloc(nprocs * sizeof(int)); + int* alltoallvcounts = xbt_malloc(nprocs * sizeof(int)); for (int i = 0; i < nprocs; i++) alltoallvcounts[i] = BOUNDED(i + rank); - int* recvbuf; - int* displs; - int* counts; - int* rcounts; + int* dummy_buffer = xbt_malloc(sizeof(int)); + // initialize buffers with an invalid value (we want to trigger a valgrind error if they are used) + int* recvbuf = dummy_buffer + 1; + int* displs = dummy_buffer + 1; + int* counts = dummy_buffer + 1; + int* rcounts = dummy_buffer + 1; if (rank == 0) setup_recvbuf(nprocs, &recvbuf, &displs, &counts, &rcounts); @@ -58,6 +57,7 @@ int main(int argc, char** argv) MPI_Scatterv(recvbuf, counts, displs, MPI_INT, sendbuf, BOUNDED(rank), MPI_INT, 0, MPI_COMM_WORLD); MPI_Reduce(sendbuf, recvbuf, BUFSIZE, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD); + xbt_free(dummy_buffer); if (rank != 0) setup_recvbuf(nprocs, &recvbuf, &displs, &counts, &rcounts); @@ -78,15 +78,13 @@ int main(int argc, char** argv) MPI_Exscan(sendbuf, recvbuf, BUFSIZE, MPI_INT, MPI_MAX, MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); - free(alltoallvcounts); - free(sendbuf); - free(recvbuf); - free(displs); - free(counts); - free(rcounts); + xbt_free(alltoallvcounts); + xbt_free(sendbuf); + xbt_free(recvbuf); + xbt_free(displs); + xbt_free(counts); + xbt_free(rcounts); MPI_Finalize(); return 0; } - -#endif