I have a method which i want to run on several threads but each thread will return a different number of results. Is it possible to declare a private, thread specific, variable ie a list which i can then pass back to the Host and merge all the results?
Say i have an array as follows:
int[,] arr1 = new int[3,3] {{ 3, 4, 5 }, {4, 5, 6}, {1, 6, 4}};
int[] arr2 = new int[] { 3, 4, 1 };
Each thread will be give 3 values to analyze and records the difference between the value in arr2 and the values for a specific row in arr1.
[Cudafy]
public static void CountAbove(GThread thread, int[] a, int[,] b, list<int> c)
{
int tid = thread.blockIdx.x;
int threshold = a[tid];
for(int i = 0; i < b.GetLength(0); i++)
{
if (threshold < b[tid,i]) c.add(b[tid,i] - threshold);
}
}