CUDA build error

Hello In cmake build I have error that was not present in case when I had compiled it as visual studio project

atomicAdd_block is undefined

I had found in stack overflow that one should set CMAKE_CUDA_ARCHITECTURES to at least 70 to avoid this problem, but in my case it still do not work

my includes

#include <cuda.h>
#include <cuda_runtime.h>
#include <cstdint>
#include <cooperative_groups.h>
#include <vector>
#include <cooperative_groups/reduce.h>
#include <cooperative_groups/memcpy_async.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <cstdint>
#include <assert.h>
#include "device_launch_parameters.h"

code causing problem (was working as visual studio project)

count = atomicAdd_block(&fpFnLocCounter[0], count);


cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(hello LANGUAGES CXX CUDA)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -lineinfo -lcudadevrt")
add_executable(hello  )
target_link_libraries(${PROJECT_NAME} ${CUDA_LIBRARIES})

full repository for reference

thanks for help !

Cc: @robert.maynard

1 Like

Your CMakeLists.txt is correct, you just need to ensure you are using CMake 3.18 or newer to have support for this variable.

I see no such issue with your repo when using CUDA 11.6 and CMake 3.23

1 Like

Thank you !!!