在我的CUDA内核中使用__shfl_xor但在编译时遇到错误

时间:2017-02-02 11:25:52

标签: compiler-errors cuda nvidia nvcc

我正在尝试在我的内核中使用__shfl_xor但是当我尝试编译它时,我收到错误“error:identifier”__shfl_xor“is undefined”。我知道您必须设置标志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

2 个答案:

答案 0 :(得分:2)

不知何故,我将我的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)

答案 1 :(得分:0)

您设置为CUDA架构35,它支持__shfl_xor() 费米GPU不支持该指令(即架构20和21)