dynamic_cast not supported by OpenACC

OpenACC and CUDA Fortran
Post Reply
Shine X.M. Zhai
Posts: 35
Joined: Apr 22 2019

dynamic_cast not supported by OpenACC

Post by Shine X.M. Zhai » Mon Oct 28, 2019 2:07 pm

Hello,

Could you confirm that dynamic_cast is not (yet?) supported by OpenACC?

Here is the small reproducer:

Code: Select all

#include <iostream>
#include "openacc.h"
#include "accel.h"

class base
{
public:
    base(){}
    virtual ~base(){}
    int base_int;
};

class derived : public base
{
public:
    derived(){}
    ~derived(){}
    int derived_int;
};

int main ()
{
    base basevar;

    #pragma acc serial
    {
        derived* derivedptr = dynamic_cast<derived*>(&basevar);
    }

    return 0;
}
With "pgc++ -acc test.C", the error message is:

Code: Select all

"test.C", line 27: warning: variable "derivedptr" was declared but never
          referenced
          derived* derivedptr = dynamic_cast<derived*>(&basevar);
                   ^
PGCC-S-0155-PGI support procedure called within a compute region: __dynamic_cast (test.C: 27)
PGCC-S-0155-Compiler failed to translate accelerator region (see -Minfo messages)  (test.C: 26)
PGCC/x86-64 Linux 19.4-0: compilation completed with severe errors
Thanks,
Shine

mkcolg
Posts: 8107
Joined: Jun 30 2004

Re: dynamic_cast not supported by OpenACC

Post by mkcolg » Tue Oct 29, 2019 7:41 am

Hi Shine,

No, sorry. Since CUDA doesn't support dynamic_cast, it's not something we can support when targeting NVIDIA devices. See: https://docs.nvidia.com/cuda/cuda-c-pro ... .html#rtti

Note, OpenACC doesn't specify specific language features that are supported. Rather it's up to the implementer to determine what features can or can't be supported on a particular target device.

-Mat

Shine X.M. Zhai
Posts: 35
Joined: Apr 22 2019

Re: dynamic_cast not supported by OpenACC

Post by Shine X.M. Zhai » Tue Oct 29, 2019 11:27 am

Hello Mat,

Thanks for the reference and your note. We will find alternatives to implement the feature.

Thanks,
Shine

Post Reply