Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Creating Objects and executing its functions in OpenCL Kernel

I'm trying to convert my current quad tree code into one that is parallel using OpenCL.

Here is my buildTree() function;

void QuadTree::buildTreeParallel()
{
    std::default_random_engine generator((int)std::chrono::system_clock::now().time_since_epoch().count());
    std::uniform_real_distribution<double> distribution(-1.0, 1.0);
    double x;
    double y;

    for (size_t i = 0; i != 10000; i++)
    {
        x = distribution(generator);
        y = distribution(generator);
        Particle* aParticle = new Particle(x, y);
        insertToNode(aParticle);
    }
}

This function in turn calls the insertToNode() function which is located in the QuadTree class. My question is, how would I port the objects and functions to OpenCL and execute this code? I tried the following:

__kernel void hello(__global QuadTree* aTree)
{
    //execute buildTreeParallel() and insertToNode() here
} 

Given that OpenCL is based on C99, I cannot use the random number generator, nor the vector class (in which I store particles) from the C++ libraries. How can I convert this code to OpenCL?

Comments