Hi –
I am currently working on a program in jCUDA and can’t seem to get it to agree with me (for the most part, however, jCUDA is working great!). Since there is very little documentation, I wanted to write to see if you might be able to help me figure out what’s going wrong.
I’ve got a program in C+CUDA that I’m trying to translate to Java+jCUDA for my research. The program has the following lines that I’m trying to replicate:
[codebox]static texture<float4, 2, cudaReadModeElementType> tex;
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc();
cudaArray * bind(float4 *d_src, int width, int height, texture<float4, 2, cudaReadModeElementType> &t) {
cudaArray *d_imageArray = 0;
CUDA_SAFE_CALL( cudaMallocArray(&d_imageArray, &channelDesc, width, height) );
CUDA_SAFE_CALL( cudaUnbindTexture(t) );
uint size = width * height * sizeof(float4);
CUDA_SAFE_CALL( cudaMemcpyToArray(d_imageArray, 0, 0, d_src, size, cudaMemcpyDeviceToDevice));
t.filterMode = cudaFilterModeLinear;
t.normalized = false;
CUDA_SAFE_CALL( cudaBindTextureToArray(t, d_imageArray, channelDesc) );
return d_imageArray;
}
[/codebox]
I’ve got a few questions:
-
Does jCUDA have an equivalent to cudaUnbindTexture?
-
To have access to “tex” within my Java code, I just use the following line, right: CUtexref tex = cuda.getModuleTexRef(“tex”);
-
Is the following an accurate translation of the call to cudaMemcpyToArray (it doesn’t seem to do anything!):
[codebox] CUDA_MEMCPY2D copyData = new CUDA_MEMCPY2D();
copyData.dstArray = result.getValue();
copyData.dstXInBytes = 0;
copyData.dstY = 0;
copyData.dstMemoryType = CUmemorytype.CU_MEMORYTYPE_ARRAY;
copyData.srcDevice = src.getValue();
copyData.srcMemoryType = CUmemorytype.CU_MEMORYTYPE_DEVICE;
copyData.srcXInBytes = 0;
copyData.srcY = 0;
copyData.WidthInBytes = width*SizeOf.FLOAT4;
copyData.Height = height;
cuda.copy2D(copyData);[/codebox]
- How do I turn of normalization?
Thanks for your help –