Forcing predicate Would this guarantee it?

Hi

Is there a way to guarantee that the CUDA compiler will use prediction rather than serialisation? i.e. would the following always be done with prediction;

if(condition) variableA = variableTemp;

I don’t know how to test this so I’m having to ask.

Cheers. :D

What prediction you are talking about? CUDA is not superscalar.

Search ‘predicate’ in the user manual.

It says there is a threshold on the number of instructions allowed for prediction, but I don’t see how to test to make sure prediction is being used rather than serialisation.

I see…

I would compare performance of the following pieces of code (predicate is always true but it should not be optimized):

for(int i=0;i<1000000;i++)

{

  if(predicate)

  {

   a+=b;

   b^=c;

   c-=a;

  }

   a+=b;

   b^=c;

   c-=a;

}
for(int i=0;i<1000000;i++)

{

  if(predicate)

  {

   a+=b;

   b^=c;

  }

   c-=a;

   a+=b;

   b^=c;

   c-=a;

}
for(int i=0;i<1000000;i++)

{

  if(predicate)

  {

   a+=b;

  }

   b^=c;

   c-=a;

   a+=b;

   b^=c;

   c-=a;

}

and return a to the host to avoid optimization.

I don’t think there is a way to force predication. Maybe you can do so in ptx. I believe there is some mention in the Programming Guide about predication, that seems to indicate predication is use when the code path is not too long. Otherwise it is serialized.

So the question is how long “not so long” :-)

Well, decuda should be a quite sure way to find out, though I guess this is likely to depend on the architecture version (i.e. change with future graphic cards).

The decuda output uses the “@$pn.cond” prefix for this I think (where pn is the predicate register and cond is the condition on which the instruction behind this is executed).

I do not see any way to influence/see this in ptx, though that is no surprise since IMO the limit is likely to depend on the specific GPU (at least in the future),and the GPU-specific stuff is done in ptxas.

And please take care not to write “prediction” when you mean “predication”, while I am not sure if the later is really a valid word, the former already has a meaning, and a very different one.