c++ - Can CUDA kernels be virtual functions? -


the question quite straighforward, let me give overview of framework. have abstract class abstractscheme representing type of computation (a kind of discretization equation, not important). each implementation has provide method return name of scheme , has implement protected function cuda kernel. base abstract class provides public method calls cuda kernel , returns how long took kernel completed.

class abstractscheme { public:     /**      * @return name of scheme returned      */     virtual std::string name() const =0;      /**      * copies input device,      * computes number of blocks , threads,      * launches kernel,      * copies output host,      * , measures time of this.      *      * @return number of milliseconds perform whole operation      *         returned      */     double docomputation(const float* input, float* output, int nelements)     {         // lot of things , calls this->kernel().     }  protected:     /**      * cuda kernel computation.      * must implemented.      */     virtual __global__ void kernel(const float*, float*, int) =0; }; 

i have couple of implementations of base class. when try compile nvcc 7.0, error message referring line define function kernel in abstractscheme (the last line in above listing):

myfile.cu(60): error: illegal combination of memory qualifiers 

i not find resource saying kernels cannot virtual functions, have feeling problem. can explain rationale behind this? i understand how , why __device__ functions cannot virtual functions (virtual functions pointers actual [host] functions stored in object, , cannot call such function within device code), i'm not sure __global__ functions.

edit: part of question striked out wrong. please @ comments understand why.

kernels can't members of classes in cuda object model, whether virtual or not. cause of compile error, if isn't particularly obvious error message emitted compiler.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -