24{
25 int shm_comm_size;
26 MPI_Comm shm_comm = MPI_COMM_NULL;
28 int dev_count;
31 unsigned long uid;
33
35 MPI_CALL(MPI_Comm_split_type(comm, MPI_COMM_TYPE_SHARED,
36 rank, MPI_INFO_NULL, &shm_comm),
37 return _status);
38 MPI_CALL(MPI_Comm_size(shm_comm, &shm_comm_size),
return _status);
39 MPI_CALL(MPI_Comm_rank(shm_comm, &local_rank),
return _status);
40
43 for (
i = 0;
i < dev_count; ++
i) {
46
47 MPI_CALL(MPI_Alltoall(&
rank, 1, MPI_INT, ranks, 1, MPI_INT,
48 shm_comm),
49 return _status);
50 MPI_CALL(MPI_Alltoall(&uid, 1, MPI_UNSIGNED_LONG, uids, 1,
51 MPI_UNSIGNED_LONG, shm_comm),
52 return _status);
53
56 memcpy(sorted_uids, uids, sizeof(unsigned long) * shm_comm_size);
57 qsort(sorted_uids, shm_comm_size,
sizeof(
unsigned long),
cmp_fn);
58
59 if (local_rank == 0) {
60 int j, uniq_uids = 0;
61 unsigned long curr_uid = 0;
62 for (j = 0; j < shm_comm_size; ++j) {
63 if (sorted_uids[j] != curr_uid) {
64 curr_uid = sorted_uids[j];
65 uniq_sorted_uids[uniq_uids++] = curr_uid;
66 }
67 }
68
70 for (j = 0, l = 0; j < uniq_uids; ++j) {
71 for (k = 0; k < shm_comm_size; ++k) {
72 if (uids[k] == uniq_sorted_uids[j]) {
73 list[l++] = ranks[k];
74 }
75 }
76
77 printf( "GPU-%i Affinity : Name: %s, UID: %lu, Ranks: [ ",
78 i,
name, uniq_sorted_uids[j] );
79 for (k = 0; k < l; ++k) {
80 printf( "%d ", list[k] );
81 }
82 printf( "]\n" );
83 }
84 }
85 }
86
87 MPI_CALL(MPI_Comm_free(&shm_comm),
return _status);
88 return 0;
89}
returns device attributes
returns device type attributes
#define PAPI_DEV_ATTR__CUDA_ULONG_UID
#define PAPI_DEV_TYPE_ATTR__INT_COUNT
#define PAPI_DEV_ATTR__CUDA_CHAR_DEVICE_NAME
#define MPI_CALL(call, err_handle)
static int cmp_fn(const void *a, const void *b)