我需要将传递给函数的数组声明为易失性,Cudafy.NET支持这一点吗?
例如(在C#中):
[Cudafy]
private static void doStuffOnGPU(GThread thread, volatile int[] output)
{
//do a whole bunch of stuff
}发布于 2016-11-26 22:25:00
答案是否定的,截至2016年11月26日,Cudafy.NET不支持易失性关键字。然而,在某些情况下,您可以让Cudafy.NET允许它。
例如:
//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
}此代码将在连续运行进行测试时使用全局声明,并将在GPU上使用易失性声明。
https://stackoverflow.com/questions/39824464
复制相似问题