Hello,

Situation:

I know the exact number of threads I will need. The problem is, I am having trouble figuring out how to map that number into Grid and Block dimensions.

Example:

The total combinations for a simulation will be: 133,784,560.

Let’s assume anything prefixed with ‘g’ is grid and ‘b’ is block

we basically have this equation: gDimx * gDimy * gDimz * bDimx * bDimy * bDimz = 133,784,560.

all we know about the variables are limitations given by the hardware. ie, gDimz = 1; bDimx*bDimy*bDimz < 512; gDimx || gDimy <= 65535

There are plenty of combinations that will suffice for example:

[indent] gDimx: 611

gDimy: 595

gDimz: 1

bDimx: 368

bDimy: 1

bDimz: 1[/indent]

Now, I’m not very proud of the way I am figuring that out at the moment as I am basically doing a brute force. I’m sure there is a much more elegant algebraic way to solve this getting a range for each of the variables since we have the hardware constraints. But, I am finding my algebra skills are far from good. Can anyone provide some insight?

Thanks!