CUDA .ptx文件是否可移植?

时间:2013-02-01 18:48:21

标签: c++ cuda gpgpu gpu-programming

我正在研究cudaDecodeD3D9 sample以了解CUDA的工作原理,并在编译时从.cu文件生成.ptx文件。据我所知,这个.ptx文件是一个中间表示,可以为任何特定的GPU及时编译。该示例使用类cudaModuleMgr通过cuModuleLoadDataEx加载此文件。

.ptx文件是文本格式,我可以看到它顶部是我的机器上的一堆硬编码路径,包括我的用户文件夹,即:

    .file   1   "C:/Users/******/AppData/Local/Temp/tmpxft_00002abc_00000000-7_NV12ToARGB_drvapi.cudafe2.gpu"
    .file   2   "c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h"
    .file   3   "C:/Program Files (x86)/NVIDIA GPU Computing Toolkit/CUDA/v5.0/include\crt/device_runtime.h"
    .file   4   "C:/Program Files (x86)/NVIDIA GPU Computing Toolkit/CUDA/v5.0/include\host_defines.h"
    .file   5   "C:/Program Files (x86)/NVIDIA GPU Computing Toolkit/CUDA/v5.0/include\builtin_types.h"
    .file   6   "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\device_types.h"
    .file   7   "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\host_defines.h"
    .file   8   "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\driver_types.h"
    .file   9   "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\surface_types.h"
    .file   10  "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\texture_types.h"
    .file   11  "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\vector_types.h"
    .file   12  "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\builtin_types.h"
    .file   13  "C:/Program Files (x86)/NVIDIA GPU Computing Toolkit/CUDA/v5.0/include\device_launch_parameters.h"
    .file   14  "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\crt\storage_class.h"
    .file   15  "c:\users\******\desktop\cudadecodesample\3_imaging\cudadecoded3d9\cudaProcessFrame.h"
    .file   16  "c:\program files (x86)\nvidia gpu computing toolkit\cuda\v5.0\include\math_functions.h"
    .file   17  "C:/Users/******/Desktop/CudaDecodeSample/3_Imaging/cudaDecodeD3D9/NV12ToARGB_drvapi.cu"
    .file   18  "C:/Program Files (x86)/NVIDIA GPU Computing Toolkit/CUDA/v5.0/include\common_functions.h"

我的问题是:由于这个文件是在编译时创建的,它是否只能在我的机器上工作,因为所有这些硬编码路径?即使未安装CUDA SDK,我该怎么做才能确保程序在任何机器上运行?

1 个答案:

答案 0 :(得分:5)

.file指令仅用于调试。它不会影响代码在正常情况下的编译方式。所以我很确定你可以剥离或者完全忽略它们,代码将是可移植的,至少在你的编译器选项所规定的架构和功能限制内(所以目标代码版本,体系结构和编译大小)。