GADGET-4
allreduce_debugcheck.cc
Go to the documentation of this file.
1/*******************************************************************************
2 * \copyright This file is part of the GADGET4 N-body/SPH code developed
3 * \copyright by Volker Springel. Copyright (C) 2014-2020 by Volker Springel
4 * \copyright (vspringel@mpa-garching.mpg.de) and all contributing authors.
5 *******************************************************************************/
6
12#include "gadgetconfig.h"
13
14#include <math.h>
15#include <mpi.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19
20#include "../data/allvars.h"
21#include "../data/dtypes.h"
22#include "../mpi_utils/mpi_utils.h"
23
24int myMPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
25{
26 int mi, ma;
27
28 MPI_Allreduce(&count, &mi, 1, MPI_INT, MPI_MIN, comm);
29 MPI_Allreduce(&count, &ma, 1, MPI_INT, MPI_MAX, comm);
30
31 if(mi != ma)
32 {
33 int thistask, ntask;
34 MPI_Comm_rank(comm, &thistask);
35 MPI_Comm_size(comm, &ntask);
36
37 printf("Error in MPI_Allreduce: task=%d out of %d has size = %d\n", thistask, ntask, count);
38 fflush(stdout);
39 MPI_Barrier(comm);
40
41 Terminate("mi=%d ma=%d\n", mi, ma);
42 }
43
44 return MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm);
45}
int myMPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
#define Terminate(...)
Definition: macros.h:15