| 1 |
/* |
| 2 |
* This file is part of MUSIC. |
| 3 |
* Copyright (C) 2022 Mikael Djurfeldt |
| 4 |
* |
| 5 |
* MUSIC is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* MUSIC is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "music/mpi_utils.hh" |
| 20 |
|
| 21 |
namespace MUSIC { |
| 22 |
|
| 23 |
bool |
| 24 |
mpi_is_initialized () |
| 25 |
{ |
| 26 |
int isInitialized; |
| 27 |
MPI_Initialized (&isInitialized); |
| 28 |
return isInitialized; |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
mpi_get_rank (MPI_Comm comm) |
| 33 |
{ |
| 34 |
int rank; |
| 35 |
MPI_Comm_rank (comm, &rank); |
| 36 |
return rank; |
| 37 |
} |
| 38 |
|
| 39 |
int |
| 40 |
mpi_get_comm_size (MPI_Comm comm) |
| 41 |
{ |
| 42 |
int size; |
| 43 |
MPI_Comm_size (comm, &size); |
| 44 |
return size; |
| 45 |
} |
| 46 |
|
| 47 |
int |
| 48 |
mpi_get_group_size (MPI_Group group) |
| 49 |
{ |
| 50 |
int size; |
| 51 |
MPI_Group_size (group, &size); |
| 52 |
return size; |
| 53 |
} |
| 54 |
|
| 55 |
int |
| 56 |
mpi_get_type_size (MPI_Datatype type) |
| 57 |
{ |
| 58 |
int size; |
| 59 |
MPI_Type_size (type, &size); |
| 60 |
return size; |
| 61 |
} |
| 62 |
|
| 63 |
MPI_Group |
| 64 |
mpi_get_group (MPI_Comm comm) |
| 65 |
{ |
| 66 |
MPI_Group group; |
| 67 |
MPI_Comm_group (comm, &group); |
| 68 |
return group; |
| 69 |
} |
| 70 |
|
| 71 |
} |