-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathatomic_set.c
79 lines (66 loc) · 1.58 KB
/
atomic_set.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* atomic_set.c
*
* Copyright (c) 2016 U.S. Army Research Laboratory. All rights reserved.
* Copyright (c) 2019 Brown Deer Technology, LLC. All rights reserved.
*
* This file is part of the ARL OpenSHMEM Reference Implementation software
* package. For license information, see the LICENSE file in the top level
* directory of the distribution.
*
*/
/*
* Performance test for shmem_int_atomic_set
*/
#include <stdio.h>
#include <shmem.h>
#include "ctimer.h"
#define NLOOP 10000
int main (void)
{
int i, npe;
static int dest;
static unsigned int t, tsum;
static int pWrk[SHMEM_REDUCE_MIN_WRKDATA_SIZE];
static long pSync[SHMEM_REDUCE_SYNC_SIZE];
for (i = 0; i < SHMEM_REDUCE_SYNC_SIZE; i++) {
pSync[i] = SHMEM_SYNC_VALUE;
}
shmem_init();
int me = shmem_my_pe();
int npes = shmem_n_pes();
if (me == 0) {
printf("# SHMEM Atomic Set Performance for variable NPES\n"
"# NPES\tLatency (nanoseconds)\n");
}
for (npe = 2; npe <= npes; npe++)
{
int nxtpe = me + 1;
if (nxtpe >= npe) nxtpe -= npe;
dest = 0;
shmem_barrier_all();
ctimer_start();
if (me < npe) {
t = ctimer();
for (i = 0; i < NLOOP; i++) {
shmem_int_atomic_set(&dest, nxtpe, nxtpe);
}
t -= ctimer();
shmem_int_sum_to_all(&tsum, &t, 1, 0, 0, npe, pWrk, pSync);
}
if (me == 0) {
unsigned int nsec = ctimer_nsec(tsum / (npe * NLOOP));
printf("%5d %7u\n", npe, nsec);
}
if (me < npe) {
if (dest != me) {
printf("# %d: ERROR %d\n", me, dest);
}
} else {
if (dest != 0) {
printf("# %d: ERROR %d\n", me, dest);
}
}
}
shmem_finalize();
return 0;
}