Debian Codegraph @

vendored-meson/meson/test cases/cuda/17 separate compilation linking/main.cu

raw
1 #include <stdio.h>
2
3 #include "b.h"
4
5 __global__ void foo(void)
6 {
7 __shared__ int a[N];
8 a[threadIdx.x] = threadIdx.x;
9
10 __syncthreads();
11
12 g[threadIdx.x] = a[blockDim.x - threadIdx.x - 1];
13
14 bar();
15 }
16
17 int main(void)
18 {
19 unsigned int i;
20 int *dg, hg[N];
21 int sum = 0;
22
23 foo<<<1, N>>>();
24
25 if (cudaGetSymbolAddress((void**)&dg, g)) {
26 printf("couldn't get the symbol addr\n");
27 return 1;
28 }
29 if (cudaMemcpy(hg, dg, N * sizeof(int), cudaMemcpyDeviceToHost)) {
30 printf("couldn't memcpy\n");
31 return 1;
32 }
33
34 for (i = 0; i < N; i++) {
35 sum += hg[i];
36 }
37 if (sum == 36) {
38 printf("PASSED\n");
39 } else {
40 printf("FAILED (%d)\n", sum);
41 }
42
43 return 0;
44 }