1 // Tests cudaMemcpy and writes from kernel
2 // RUN: cat %s | clang-repl --cuda | FileCheck %s
4 extern "C" int printf(const char*, ...);
6 __global__ void test_func(int* value) { *value = 42; }
10 printf("cudaMalloc: %d\n", cudaMalloc((void **) &devptr, sizeof(int)));
11 // CHECK: cudaMalloc: 0
13 test_func<<<1,1>>>(devptr);
14 printf("CUDA Error: %d\n", cudaGetLastError());
15 // CHECK-NEXT: CUDA Error: 0
17 printf("cudaMemcpy: %d\n", cudaMemcpy(&var, devptr, sizeof(int), cudaMemcpyDeviceToHost));
18 // CHECK-NEXT: cudaMemcpy: 0
20 printf("Value: %d\n", var);
21 // CHECK-NEXT: Value: 42