Is it possible to use the volatile keyword with Cudafy.NET?

59 views Asked by At

I need to declare an array passed to a function as volatile, does Cudafy.NET support this?

For example (in C#):

[Cudafy]
private static void doStuffOnGPU(GThread thread, volatile int[] output)
{
  //do a whole bunch of stuff
}
1

There are 1 answers

0
jpreed00 On BEST ANSWER

The answer is no, as of November 26, 2016, Cudafy.NET does not support the volatile keyword. However, you can tricksify Cudafy.NET into allowing it in certain circumstances.

Ex:

//declare a dummy in global scope
public static int[] volatileArray = new int[256];
[Cudafy]
private static void doStuffOnGPU(GThread thread, int[] output)
{
  //use the GThread.InsertCode() function to declare in CUDA
  GThread.InsertCode("__shared__ volatile int volatileArray[256];");
  //do a whole bunch of stuff
}

This code will use the global declaration when run serially for testing and will use the volatile declaration on the GPU.