Passing the PTX program to the CUDA driver directly

后端 未结 2 472
傲寒
傲寒 2021-01-05 05:46

The CUDA driver API provides loading the file containing PTX code from the filesystem. One usually does the following:

CUmodule module;
CUfunction function;
         


        
相关标签:
2条回答
  • 2021-01-05 06:12

    Use the cuModuleLoadDataEx function to load PTX source from a NULL-terminated string.

    0 讨论(0)
  • 2021-01-05 06:27

    Taken from the ptxjit CUDA example:

    Define the PTX program as a C string as

    char myPtx32[] = "\n\
        .version 1.4\n\
        .target sm_10, map_f64_to_f32\n\
        .entry _Z8myKernelPi (\n\.param .u32 __cudaparm__Z8myKernelPi_data)\n\
        {\n\
        .reg .u16 %rh<4>;\n\
        .reg .u32 %r<8>;\n\
    
        // Other stuff
    
        .loc    28      18      0\n\
        exit;\n\
        }\n\
     ";
    

    then

     cuModuleLoadDataEx(phModule, myPtx32, 0, 0, 0);
    

    and finally

     cuModuleLoadDataEx(phModule, myPtx, 0, 0, 0);
    
    0 讨论(0)
提交回复
热议问题