[Openmp-dev] virtual destructor prevents an object being created on the device

Itaru Kitayama via Openmp-dev openmp-dev at lists.llvm.org
Thu Mar 26 17:41:44 PDT 2020


Sorry Alexey, I meant this code:

[kitayama1 at 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 at 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 at juron1-adm pcp0151]$ c++filt _ZdlPv
operator delete(void*)

On Thu, Mar 26, 2020 at 10:17 PM Alexey.Bataev <a.bataev at outlook.com> wrote:

> You need to define operator() member function in Derived class to link it
> correctly.
>
> -------------
> Best regards,
> Alexey Bataev
>
> 25.03.2020 7:57 PM, Itaru Kitayama пишет:
>
> 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;
> }
>
> }
>
> On Wed, Mar 25, 2020 at 11:47 PM Alexey.Bataev <a.bataev at outlook.com>
> wrote:
>
>> What doy you see and what do you expect? Could you provide a reproducer?
>>
>> -------------
>> Best regards,
>> Alexey Bataev
>>
>> 25.03.2020 1:19 AM, Itaru Kitayama via Openmp-dev пишет:
>>
>> I would like to know why a class that has virtual destructor can not be
>> instantiated on the device while virtual methods are ok.
>>
>> _______________________________________________
>> Openmp-dev mailing listOpenmp-dev at lists.llvm.orghttps://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20200327/fdf22198/attachment.html>


More information about the Openmp-dev mailing list