Click here to Skip to main content
14,635,454 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello, I have been reviewing OpenCL Library in C# for what will use in my project.

But I don't know how to get calculated data from OpenCL Library.
public static void RunGPU()
{
    try
    {
        EasyCL cl = new EasyCL()
        {
            Accelerator = AcceleratorDevice.GPU
        };

        int[] WorkSet1 = new int[100];
        int[] WorkSet2 = new int[100];
        int[] WorkSet3 = new int[100];

        for (int i = 0; i < 100; i++)
        {
            WorkSet1[i] = i;
            WorkSet2[i] = i + 1;
            WorkSet3[i] = i + 2;
        }

        cl.LoadKernel(IsPrime);
        cl.Invoke("dd", 0, 1, WorkSet1, WorkSet2, WorkSet3);    //OpenCL uses a Cache. Real speed after that

        int a = 0;
        a++;
    }
    catch (Exception ex)
    {

        Console.WriteLine(ex.ToString());
    }

}

static string IsPrime
{
    get
    {
        return @"
        kernel void dd(global int* message1, global int* message2, global int* message3) 
        {
            for(int i = 0; i<100; i++)
            {
                *(message1 + i) = message2[i] + message3[i];
                printf(""%d %d %d\n"", message1[i], message2[i], message3[i]);
            }
        }
        ";
    }
}

in this code, RunGPU Method call the IsPrime.

then message2 and message3 are added, and save in message1

and show message1's values in the Console text box.

but IsPrime method can't effect WorkSet1 in RunGPU

I hope to take a result value(added) to Workset1 in RunGPU.

But I don't know how to do it.

message1 couldn't save in Workset1.

How can message1 be saved in Workset1?

What I have tried:

I have been trying to get it. and make test program from to get result value from OpenCL
Posted
Updated 4 days ago
v3

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You will most likely get a quicker response at OpenCL Overview - The Khronos Group Inc[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100