-
Notifications
You must be signed in to change notification settings - Fork 7
/
mpi_tag_ub.c
45 lines (37 loc) · 1.27 KB
/
mpi_tag_ub.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright (C) 2019, Northwestern University
* See COPYRIGHT notice in top-level directory.
*
* This program shows how to obtain the value of MPI_TAG_UB, which is an
* attribute of an MPI communicator.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#define CHECK_ERR(func) { \
if (err != MPI_SUCCESS) { \
int errorStringLen; \
char errorString[MPI_MAX_ERROR_STRING]; \
MPI_Error_string(err, errorString, &errorStringLen); \
printf("Error at line %d: calling %s (%s)\n",__LINE__, #func, errorString); \
} \
}
int main(int argc, char **argv)
{
void *value;
int err, rank, tag_ub, isSet;
MPI_Init(&argc,&argv);
err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
CHECK_ERR(MPI_Comm_rank);
err = MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &value, &isSet);
CHECK_ERR(MPI_Comm_get_attr);
tag_ub = *(int *) value;
if (isSet)
printf("rank %d: attribute MPI_TAG_UB for MPI_COMM_WORLD is %d\n",rank, tag_ub);
else
printf("rank %d: attribute MPI_TAG_UB for MPI_COMM_WORLD is NOT set\n",rank);
MPI_Finalize();
return 0;
}