Click here to Skip to main content
15,885,899 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
C#
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 15-Sep-20 22:36pm
v3

1 solution

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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900