I would like to know why a class that has virtual destructor can not be
instantiated on the device while virtual methods are ok.
Below code can’t be built with OpenMP offloading flags enabled:
class Base {
public:
virtual void operator()() = 0;
};
class Derived : Base {
public:
void operator()();
};
int main() {
#pragma omp target parallel for
for (int i =0;i<100;i++) {
Derived d;
}
}
Sorry Alexey, I meant this code:
[kitayama1@juron1-adm pcp0151]$ cat tmp.cpp
class Base {
public:
virtual ~Base() {
}
virtual void operator()() = 0;
};
class Derived : public Base {
public:
virtual void operator()();
};
void Derived::operator()() {
// int x=0;
}
int main() {
#pragma omp target parallel for
for (int i =0;i<100;i++) {
Derived d;
}
}
[kitayama1@juron1-adm pcp0151]$ clang++ -fopenmp -fopenmp-targets=nvptx64 tmp.cpp
nvlink error : Undefined reference to ‘_ZdlPv’ in ‘/tmp/tmp-f87ae4.cubin’
clang-11: error: nvlink command failed with exit code 255 (use -v to see invocation)
[kitayama1@juron1-adm pcp0151]$ c++filt _ZdlPv
operator delete(void*)