creating, binding texRef

Hi everyone,

I wanted to create texture reference and an array on device(maybe in global or constant memory) and set it to the

texRef as below.

In the kernel, the texRef is defined:

texture<uchar, 2, cudaReadModeNormalizedFloat> texRef;

the `cuModule’ load the texRef, kernels without bug.

What happened is that the routines for texRef creation show 700 as CUresult (LAUNCH_FAILED)

Where can I find the bug?

Is memcopyHtoD right? (I cannot help choose this because this only use CUarray as an argument).

If I moved (3)(4)(5)(6) before(2), then they show CUDA_SUCCEED but (7) should be after (2) and it says 700 error too.

Thank you.



//Creating array


cu_desc.Width = imageWidth;

cu_desc.Height = imageHeight;

cu_desc.Format = CU_AD_FORMAT_UNSIGNED_INT32;

cu_desc.NumChannels = 1;

CUarray d_imageArray;

CU_SAFE_CALL(cuArrayCreate(&d_imageArray, &cu_desc));                               //(1)

CU_SAFE_CALL(cuMemcpyHtoA(d_imageArray, 0, h_data, size));                       //(2)


// creating tex ref.

CUtexref cuTexRef;


CU_SAFE_CALL(cuModuleGetTexRef(&cuTexRef, cuModule, "texRef"));                                //(3)

CU_SAFE_CALL(cuTexRefSetFilterMode(cuTexRef, CU_TR_FILTER_MODE_LINEAR));                //(4)

CU_SAFE_CALL(cuTexRefSetFlags(cuTexRef, CU_TRSF_NORMALIZED_COORDINATES));          //(5)

CU_SAFE_CALL(cuTexRefSetFormat(cuTexRef, CU_AD_FORMAT_UNSIGNED_INT32, 1));          //(6)

// setArray to cuTexRef.

CU_SAFE_CALL(cuTexRefSetArray(cuTexRef, d_imageArray, CU_TRSA_OVERRIDE_FORMAT)); //(7)