File: test1.96.prog.c

package info (click to toggle)
slurm-wlm 22.05.8-4%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 48,492 kB
  • sloc: ansic: 475,246; exp: 69,020; sh: 8,862; javascript: 6,528; python: 6,444; makefile: 4,185; perl: 4,069; pascal: 131
file content (43 lines) | stat: -rw-r--r-- 1,060 bytes parent folder | download | duplicates (12)
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
/*****************************************************************************\
 *  test1.96.prog.upc - Basic SHMEM test via srun.
 *****************************************************************************
 *  Based upon "Code Example" in "SHMEM Tutorial"
 *  By Hung-Hsun Su, UPC Group, HSC Lab, Spring 2010
\*****************************************************************************/

#include <stdio.h>
#include <shmem.h>

int me, npes, i;
int src[8], dest[8];

int main(int argc, char * argv[])
{
	/* Get PE information */
	shmem_init();
	me = _my_pe();
	npes = _num_pes();

	/* Initialize and send on PE 0 */
	if (me == 0) {
		for (i = 0; i < 8; i++)
			src[i] = i + 1;
		/* Put source date at PE 0 to dest at PE 1+ */
		for (i = 1; i < npes; i++)
			shmem_put64(dest, src, 8 * sizeof(int) / 8, i);
	}

	/* Make sure the transfer is complete */
	shmem_barrier_all();

	/* Print from PE 1+ */
	if (me > 0) {
		printf("PE %d: %d", me, dest[0]);
		for (i = 1; i < 8; i++)
			printf(",%d", dest[i]);
		printf("\n");
	}
	shmem_finalize();

	return 0;
}