Are CUDA .ptx files portable?

a 夏天 提交于 2019-12-12 11:35:44

问题


I'm studying the cudaDecodeD3D9 sample to learn how CUDA works, and at compilation it generates a .ptx file from a .cu file. This .ptx file is, as I understand it so far, an intermediate representation that will be compiled just-in-time for any specific GPU. The sample uses the class cudaModuleMgr to load this file via cuModuleLoadDataEx.

The .ptx file is in text format, and I can see that at the top of it is a bunch of hardcoded paths on my machine, including my user folder, i.e.:

    .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"

My question is then: since this file is created at compile-time, will it only work on my machine because of all these hardcoded paths? What should I do to ensure the program will run on any machine, even if the CUDA SDK isn't installed?


回答1:


The .file directive is only for debugging. It doesn't effect how the code will compile under normal circumstances. So I am pretty certain that you can strip or just completely ignore them and the code will portable, at least within architecture and feature limitations dictated by your compiler options (so target code version, architecture, and compile size).



来源:https://stackoverflow.com/questions/14653046/are-cuda-ptx-files-portable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!