我试图在内核中使用__shfl_xor,但是当我尝试对其进行编译时,出现错误“错误:标识符“__shfl_xor”未定义”。我知道您必须设置标记arch=compute_30,code=sm_30
才能使用它,但是我已经在CMakeLists.txt中添加了它
这是我的内核:
__global__ void dummy_kernel()
{
int x = 5;
int y = 10;
__shfl_xor(x, y);
}
这是编译器的输出:
/filepath/kernel_file.cu(13): error: identifier "__shfl_xor" is undefined
这是我的CMakeLists.txt的样子:
cmake_minimum_required(VERSION 3.1)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
find_package(CUDA REQUIRED)
cuda_add_executable(CasHashing3D
MatchPairGPU.cu
)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -gencode arch=compute_30,code=sm_30")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -gencode arch=compute_35,code=sm_35")
set_property(TARGET CasHashing3D PROPERTY CXX_STANDARD 11)
set_property(TARGET CasHashing3D PROPERTY CXX_STANDARD_REQUIRED ON)
configure_file(job.sh.in job.sh @ONLY)
CMake生成的makefile太大,无法粘贴到问题中,因此此处是a link。
最佳答案
不知何故,我将CMakeLists.txt更改为以下内容,并且有效,我不知道为什么。一旦弄清自己做错了什么,我将更新答案。
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -lpthread")
cmake_minimum_required(VERSION 3.2)
project(CasHashing3D)
find_package(CUDA REQUIRED)
# Pass options to NVCC
set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3 -gencode arch=compute_35,code=sm_35;
)
cuda_add_executable(CasHashing3D
Main.cc
)
set_property(TARGET CasHashing3D PROPERTY CXX_STANDARD 11)
set_property(TARGET CasHashing3D PROPERTY CXX_STANDARD_REQUIRED ON)
configure_file(job.sh.in job.sh @ONLY)
关于compiler-errors - 在我的CUDA内核中使用__shfl_xor,但在编译时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42000974/