-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathhello.cpp
More file actions
32 lines (24 loc) · 795 Bytes
/
Copy pathhello.cpp
File metadata and controls
32 lines (24 loc) · 795 Bytes
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
/*
* Copyright (c) 2020, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <unistd.h>
#include "nvshmem.h"
int main(int argc, char **argv) {
char hostname[256];
int ret = gethostname(hostname, 256);
if (ret < 0) {
printf("Failed to get hostname\n");
return 1;
}
printf("[%s][%ld] Starting up...\n", hostname, (long)getpid());
nvshmem_init();
int mype_node = nvshmem_team_my_pe(NVSHMEMX_TEAM_NODE);
cudaSetDevice(mype_node);
void *ptr = nvshmem_malloc(1); // initialize NVSHMEM after device is set
printf("[%s][%ld] Hello from PE %d of %d\n", hostname, (long)getpid(), nvshmem_my_pe(),
nvshmem_n_pes());
nvshmem_finalize();
return 0;
}