cuda原子性操作代码编译问题 error: identifier "atomicAdd" is undefined
来源:互联网 发布:ubuntu vim使用 编辑:程序博客网 时间:2024/04/30 02:22
这次遇到的问题是,编译原子性代码出错。
代码是《GPU高性能编程cuda实践》第9章的hist_gpu_gmem_atomics.cu和hist_gpu_shmem_atomics.cu。
这次还是用原有sdk带有makefile修改来编译。
出现
"/usr/local/cuda-5.5"/bin/nvcc-ccbin g++ -I../../../common/inc -m32-gencodearch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20-gencode arch=compute_30,code=sm_30 -gencodearch=compute_35,code=\"sm_35,compute_35\" -o exe.o -chist_gpu_shmem_atomics.cu
error:identifier "atomicAdd" is undefined
分析:书中提到,原子性操作在低端的计算能力GPU是不支持的,
1.1以上的计算能力才支持全局内存的原子操作,
1.2以上的计算能力才支持共享内存的原子操作。
我观察到了makefile的nvvc的编译命令有-gencodearch=compute_10,code=sm_10,
感觉不靠谱,于是改了一下。
把
GENCODE_FLAGS := $(GENCODE_SM10) $(GENCODE_SM20) $(GENCODE_SM30)
改为
GENCODE_FLAGS := $(GENCODE_SM20) $(GENCODE_SM30)
#$(GENCODE_SM10)
就是把(GENCODE_SM10)选项去掉
再次编译,貌似没事。
运行,出问题了。输出不正常阿。
搞了很久,猜测一下,把GENCODE_SM10改为GENCODE_SM12就可以了。
makefile的主要修改如下
#CUDA code generation flags
ifneq($(OS_ARCH),armv7l)
GENCODE_SM12 := -gencode arch=compute_12,code=sm_12
endif
GENCODE_SM20 := -gencode arch=compute_20,code=sm_20
GENCODE_SM30 := -gencode arch=compute_30,code=sm_30 -gencodearch=compute_35,code=\"sm_35,compute_35\"
GENCODE_FLAGS := $(GENCODE_SM12) $(GENCODE_SM20) $(GENCODE_SM30)
我知道我机器GPU的Computecapability: 1.2,
所以这样改。但具体原因不知道。
目前只能这样理解:编译参数如果跟机器属性不符,有可能会出错。
不过还好,再次对cuda的编译有了更深入的理解。
- cuda原子性操作代码编译问题 error: identifier "atomicAdd" is undefined
- error : identifier “atomicAdd” is undefined
- 在VS2012下的CUDA程序中出现错误error : identifier “atomicAdd” is undefined
- 在VS2010下的CUDA程序中出现错误error : identifier “atomicAdd” is undefined
- 在VS2010下的CUDA程序中出现异常error : identifier “atomicAdd” is undefined
- error: identifier "XXXXX" is undefined
- STM32 HAL库 error: #20: identifier "HAL_StatusTypeDef" is undefined问题
- cuda中atomicAdd效率问题
- error: #20: identifier "EXTI0_IRQChannel" is undefined
- error: #20: identifier "FILE" is undefined
- error: #20: identifier "stm32f10x_xxxx.h" is undefined
- stm32编译出错: identifier "DMA_Channel_TypeDef" is undefined
- 编译cuda源程序时出错 error: function “atomicAdd(double *, double)” has already been defined
- 关于CUDA操作中的原子问题
- identifier "EXTI_InitTypeDef" is undefined
- stm32 usb error : identifier "bool" is undefined
- mod.cu(299): error: identifier ''callkernel_node_……'' is undefined
- IAR Error[Pe020]: identifier 'FILE' is undefined 解决方法
- Win7时间日期格式YYYY/MM/DD改为YYYY-MM-DD
- VPATH
- 新浪云SAE使用WordPress搭建个人博客
- puppet 安装配置
- UITableView中的部分设置
- cuda原子性操作代码编译问题 error: identifier "atomicAdd" is undefined
- controller传参数到页面的方法有三种:
- 16_反射
- 文字纵向滚动
- java keytool导入和删除证书
- android中的path类
- java数组
- poj1760 Disk Tree
- iBatis的简单增删改查(CRUD)操作二