Results 1 to 3 of 3

Thread: Copying c++ classes for use in open CL

  1. #1
    Junior Member
    Join Date
    Dec 2012

    Copying c++ classes for use in open CL

    I'm just starting out with open CL, so there's a number of issues / questions that i have.

    My first question revolves around a list of 2-D points, for example in the following c++ class:
    Code :
    class Point2d
      double x, y;
      Point2d(double ax=0, double ay=0);  

    So let's say i have an array of Point2D. How do i pass this information to the GPU? Can i pass my Point2d array directly (which i'm assuming not), or do i have to manipulate my array another way? If so, how?

    I know you have to set up the platform, context, queues etc (not that i'm an expert on that, either).

    Say for example i wanted to take an array of Point2d, and have the GPU translate or rotate each of the points, in what form do i pass the information? (i know that getting the gpu to do this sort of task is overkill, but it's to help me get my head round it).

  2. #2

    Re: Copying c++ classes for use in open CL

    The OpenCL C programming language is based on C99, and therefore has no support for C++ features and types. In particular, this means you cannot pass C++ objects to OpenCL.

    For your specific example, you can just use the OpenCL built-in vector types, and they should do fine.

  3. #3
    Senior Member
    Join Date
    Oct 2012

    Re: Copying c++ classes for use in open CL

    You could also define a struct for your point. but i think it would be the same as using float2 datatype. If you really need double precision you have to keep in mind that you have to check for double precision compability and load the extension for it.

Similar Threads

  1. Barrier and Array copying
    By Gamingdrake in forum OpenCL
    Replies: 5
    Last Post: 06-28-2011, 01:00 PM
  2. can we use Classes?
    By qasim1981 in forum OpenGL ES
    Replies: 1
    Last Post: 11-11-2004, 08:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean