Setup execution

Hi there,

I have a question :

How many times can I change the execution in one program ? I am using couple of kernels and each of them needs different sizes of threads and blocks

for instance : Can I do it like that ?
BLOCK_SIZE = 16, BLOCK_DIM = 32.

// FIRST setup execution parameters
dim3 threads(BLOCK_SIZE, BLOCK_SIZE);
dim3 grid(WC / threads.x, HC / threads.y);

// execute the FIRST  kernel
multiplication l<<< grid, threads >>>(d_C, d_A, d_X, WA, WX, HA, 0);

// SECOND setup execution parameters
dim3 threads(BLOCK_DIM, BLOCK_DIM, 1);
dim3 grid(size_x / BLOCK_DIM, size_y / BLOCK_DIM, 1);

// execute the SECOND kernel
transpose<<< grid, threads >>>(d_Xt, h_C, WXt, HXt);//half_data_size)

I am confused because in this case I muliply declaration of :
dim3 threads
dim3 grid

Thank you for your help :)

ttfn

Yunior,

As many times as you like. There is no limitation on this. Your problem is exactly what the error message says. You are declaring a variable more than once in a block which violates the C language rules.

1: You could create a second variable for the second kernel: dim3 threads2(BLOCK_DIM, BLOCK_DIM, 1); Though, that isn’t very pretty.

2: You could just change the existing threads variable: threads.x = threads.y = BLOCK_DIM;

3: You may even be able to do this: threads = dim3(BLOCK_DIM, BLOCK_DIM, 1); but that is a little more c++ than C and it’s always hard to tell what c++ nvcc can handle and what it cant.

And I’m sure there are a dozen more ways to do it.