Using textures in Cuda when kernel code is in PTX file and Host code also generates PTX file -
i having problem getting texture read work using cuda [4.2] on windows.
my programme reads ptx file containing kernel modules. in add-on compilation process spits out additional ptx file short routine of host code. here .cuh file , .cu file host code:
/////////////// "texturedefs.cuh" file /////////////////////////////////////////// #ifndef _texturedefs_cuh #define _texturedefs_cuh texture < float, cudatexturetype2d, cudareadmodeelementtype> texrefeachres_1; texture <float, cudatexturetype2d, cudareadmodeelementtype> texrefeachresprev; /////////////////////////////////////////////////////////////////////////////// /// mybind.cu ///////////////////////////////////////////////// #include "cuda.h" #include "texturedefs.cuh" extern cudapitchedptr gyallframesforeachres[me_num_res], gprevyforeachres[me_num_res]; // extern "c" cudaerror_t bindtextures(int resnum) { cudachannelformatdesc channeldesc = cudacreatechanneldesc(32, 0, 0, 0, cudachannelformatkindfloat); // x 32 bit float size_t offset; texrefeachresprev.addressmode[0] = cudaaddressmodeclamp; texrefeachresprev.addressmode[1] = cudaaddressmodeclamp; texrefeachresprev.filtermode = cudafiltermodelinear; texrefeachresprev.normalized = false; cudaerror_t err = cudabindtexture2d(&offset, &texrefeachresprev, (unsigned char *)gprevyforeachres[resnum].ptr, &channeldesc, gprevyforeachres[resnum].xsize, gprevyforeachres[resnum].ysize, gprevyforeachres[resnum].pitch); // jm bug 1/5 homecoming err; } every phone call tex2d in kernel code returns value 0 have checked , there valid info in array.
i wondering if need load mybind.ptx , if how , when , loaded? or not needed?
thanks help.
before cuda 5.0 references texture need within same compilation unit, otherwise dealing separate textures happen have same name live in different namespaces.
your options either include .ptx code single file before compilation, or upgrade cuda 5.0.
cuda textures gpu ptx
No comments:
Post a Comment