[英]CUDA compilation and Linking
I have host files (say h_A.cpp, etc) which can be compiled by host compiler ( g++ ), device files (say d_A.cu, etc) to be compiled by device compiler ( nvcc ) and host-device files ie, host functions, kernel call, etc (say h_d_A.cu) to be compiled by device compiler ( nvcc ). 我有可由主机编译器( g ++ )编译的主机文件(例如h_A.cpp等),要由设备编译器( nvcc )编译的设备文件(例如d_A.cu等)和主机设备文件,即host函数,内核调用等(例如h_d_A.cu)将由设备编译器( nvcc )进行编译。
Device side compilation 设备端编译
nvcc -arch=sm_20 -dc d_A.cu -o d_A.o $(INCLUDES)
/* -dc since the file may call / have relocatable device functions */ / * -dc,因为该文件可以调用/具有可重定位的设备功能* /
Host side compilation 主机端编译
g++ -c h_A.cpp -o h_A.o $(INCLUDES, FLAGS)
Device Linkage as suggested here 所建议的设备链接在这里
nvcc -arch=sm_20 -dlink d_A.o -o link.o
/* Linkage due to relocatable device functions */ / *由于可重定位的设备功能而导致的链接* /
I am using Makefile for the project. 我正在为该项目使用Makefile。 Now, the query i have is, how do i form the final executable ? 现在,我所拥有的查询是,如何形成最终的可执行文件 ? I have tried, 我努力了,
1. g++ h_A.o link.o –L<path> -lcudart
Error: relocation 0 has invalid symbol index 10
2. g++ h_A.o link.o –lcudadevrt –L<path> –lcudart
Error: undefined reference to phase2(int*, int) //where phase2 is my __global__ kernel.
Sorry, Found out the problem i missed to include device objects while forming the final executable. 抱歉,发现我在形成最终可执行文件时错过了包含设备对象的问题。
corrected syntax. 更正的语法。
g++ h_A.o d_A.o link.o –L<path> -lcudart
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.