cudaBindTexture

Host calls the compute function in every frame to execute ‘bind-call kernel-unbind’.

Inside the kernel function, I modify the content of the ‘mybuffer’.

I’m wondering which case is correct.

case1)

void compute(…)

{

cudaBindTexture(0, texref, mybuffer, desc, size );

//call kernel

K_compute<<numBlocks, numThreads>>( mybuffer );

cudaUnbindTexture( 0, texref );

}

case2)

cudaBindTexture(0, texref, mybuffer, desc, size ); // bind once at initialization

//call compute for several times

void compute(…)

{

 //call kernel

 K_compute<<numBlocks, numThreads>>( mybuffer );

}

cudaUnbindTexture( 0, texref ); // unbind at program termination

Does ‘bind’ mean sharing pointer(or reference) of certain memory?

It’s fine (and probably faster) to only bind once if the texture to buffer association isn’t changing.

It’s fine (and probably faster) to only bind once if the texture to buffer association isn’t changing.

Thanks a lot!

Thanks a lot!