samedi 25 avril 2015

C++ class dll with CUDA member?


I have a C++ class-based dll. I'd like to convert some of the class members to CUDA based operation.

I am using VS2012, WINDOWS 7, CUDA6.5, sm_20;

Say the original SuperProjector.h file is like:

class __declspec(dllexport) SuperProjector 
{
public:
    SuperProjector(){}; 
    ~SuperProjector(){};
    void sumVectors(float* c, float* a, float* b, int N);
};

and the original sumVector() function in SuperProjector.cpp

void SuperProjector::sumVectors(float* c, float* a, float* b, int N)
{
    for (int n = 1; n < N; b++)
        c[n] = a[n] + b[n];
}

I am stuck on how I should convert sumVector() to CUDA. Specifically:

  1. I read some posts saying add __global__ __device__ keywords in front of class members will work, but so I need to change the suffix of the cpp file to cu?
  2. I also tried to create a cuda project from the beginning, but it seems VS2012 does not give me the option of creating a dll once I chose to create a CUDA project.

I am very confused what is the best way to convert some of the members of tthis C++ class based dll into some CUDA kernel functions. I appreciate anyone can offer some ideas, or better with some very simple examples.


Aucun commentaire:

Enregistrer un commentaire