0

I am newbie using Cuda. When run a example about atomicAdd_system but it did not run. My GPU is Quadro RTX 6000 with Compute capability: 7.5 (I search Compute capability on the internet) and this is my code:

__global__ void mykernel(int *addr) {
  atomicAdd_system(addr, 10);       
}

void foo() {
  int *addr;
  cudaMallocManaged(&addr, 4);
  *addr = 0;

   mykernel<<<10,10>>>(addr);
   __sync_fetch_and_add(addr, 10);
}

Thank you!

nghia le
  • 1
  • 1
  • 2
    you need to compile for the correct compute capability. add `-arch=sm_75` to your compile command line, and watch that error disappear. according to the [documentation](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#atomic-functions), the `_system` atomics are only available on compute capability 6.0 and higher. (7.2 and higher on Tegra) – Robert Crovella Jul 17 '20 at 09:05
  • Thanks for supporting. "add -arch=sm_75 to your compile command line, and watch that error disappear" where is my compile command line? for example: I compile the project something like this: "nvcc main.cu -o main". Where need I add -arch=sm_75? – nghia le Jul 17 '20 at 09:12
  • `nvcc main.cu -o main -arch=sm_75` or `nvcc -arch=sm_75 main.cu -o main` or `nvcc main.cu -arch=sm_75 -o main` Those are all the permutations I can think of. – Robert Crovella Jul 17 '20 at 09:15
  • All reported /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrtl.o: Infunction `_start':(.text+0x20): undefined reference to 'main' – nghia le Jul 17 '20 at 09:24
  • That is a different issue, it is because the code you have shown has no `main` function in it, so it is not a complete program. change `void foo()` to `int main()`, or ask a new question. This new issue/question now has nothing to do with CUDA. – Robert Crovella Jul 17 '20 at 09:26
  • https://stackoverflow.com/questions/7965437/undefined-reference-to-main-collect2-ld-returned-1-exit-status – Robert Crovella Jul 17 '20 at 09:33

0 Answers0