用Cmake 编译cuda程序
2015-04-10 16:20
141 查看
运行系统及版本:
Jetson TK1cmake version 2.8.12.2
Cuda compilation tools, release 6.0, V6.0.1
直接上代码
CmakeLists.txt1 cmake_minimum_required(VERSION 2.8) 2 3 project(vectorAdd) 4 5 FIND_PACKAGE(CUDA REQUIRED) 6 7 # set source files 8 set(PROJECT_SRC vectorAdd.cu) 9 10 # build options 11 set(GENCODE -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute _35,code=compute_35) 12 set(GENCODE ${GENCODE} -gencode=arch=compute_20,code=sm_20) 13 #set(GENCODE ${GENCODE} -gencode=arch=compute_10,code=sm_10) 14 15 # debug options 16 set(CUDA_NVCC_FLAGS_DEBUG "-g -G") 17 set(CMAKE_CXX_FLAGS_DEBUG "-g") 18 19 # release options 20 set(CUDA_NVCC_FLAGS_RELEASE "-O2") 21 set(CMAKE_CXX_FLAGS_RELEASE "-O2") 22 #cuda_add_executable(vectorAdd vectorAdd.cu) 23 cuda_add_executable(vectorAdd ${PROJECT_SRC} OPTIONS ${GENCODE})
vectorAdd.cu 代码见: ~/NVIDIA_CUDA-6.0_Samples/0_Simple/vectorAdd/vectorAdd.cu
运行效果:
ubuntu@tegra-ubuntu:~/work/learn_cuda/vector_add/build$ cmake .. -- The C compiler identification is GNU 4.8.2 -- The CXX compiler identification is GNU 4.8.2 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Found CUDA: /usr/local/cuda (found version "6.0") -- Configuring done -- Generating done -- Build files have been written to: /home/ubuntu/work/learn_cuda/vector_add/build ubuntu@tegra-ubuntu:~/work/learn_cuda/vector_add/build$ make -- Configuring done -- Generating done -- Build files have been written to: /home/ubuntu/work/learn_cuda/vector_add/build make[2]: Warning: File `../vectorAdd.cu' has modification time 4.7e+08 s in the future [100%] Building NVCC (Device) object CMakeFiles/vectorAdd.dir//./vectorAdd_generated_vectorAdd.cu.o Scanning dependencies of target vectorAdd make[2]: warning: Clock skew detected. Your build may be incomplete. make[2]: Warning: File `../vectorAdd.cu' has modification time 4.7e+08 s in the future [100%] Building NVCC (Device) object CMakeFiles/vectorAdd.dir//./vectorAdd_generated_vectorAdd.cu.o Linking CXX executable vectorAdd make[2]: warning: Clock skew detected. Your build may be incomplete. [100%] Built target vectorAdd ubuntu@tegra-ubuntu:~/work/learn_cuda/vector_add/build$ ls CMakeCache.txt CMakeFiles cmake_install.cmake Makefile vectorAdd ubuntu@tegra-ubuntu:~/work/learn_cuda/vector_add/build$ ./vectorAdd [Vector addition of 50000 elements] Copy input data from the host memory to the CUDA device CUDA kernel launch with 196 blocks of 256 threads Copy output data from the CUDA device to the host memory Test PASSED Done ubuntu@tegra-ubuntu:~/work/learn_cuda/vector_add/build$
相关文章推荐
- 使用CMake编译QT程序的一个例子(没有使用Qt特殊class)
- VS下用CMake编译OpenCV程序
- cmake 编译OpenCV程序
- cmake编译dcmtk,并利用vs2010 进行开发mfc 程序
- 利用 CMake 和 NDK 交叉编译 Android 下的可执行程序
- 用cmake编译gtk程序:gssdp
- 在ubunt14.04(linux)下利用cmake编译运行opencv程序
- VS下用CMake编译OpenCV程序
- CUDA程序编译过程中产生警告的解决方法
- linux下用CMake、make工具手动编译程序的步骤、方法
- 在编译CUDA程序时出现 fatal error C1083: 无法打开包括文件:“cutil.h”: No such file or directory 的问题
- CMake(BEAN下)编译thrift程序
- CMake设置交叉编译程序
- visual studio 2013 编译第一个cuda 6.5程序
- cuda程序的编译运行
- VS下用CMake编译OpenCV程序
- cmake编译dcmtk,并利用vs2010 进行开发mfc 程序
- MPI+CUDA混合程序的编译命令
- 如何在QT中用cmake和qmake编译PCL程序
- [1] CMake On Linux - 编译链接可执行程序