A virtual function in the third target region fails on the device, am I doing something wrong in the
below code? Clang is built daily from the main.
#include <memory_resource>
#include
#include
#include <omp.h>
#include
#include <boost/core/demangle.hpp>
#include
extern “C” {
void* llvm_omp_target_alloc_shared(size_t, int);
}
class Base {
public:
virtual void send() = 0;
};
class Derived : public Base {
public:
void send() { printf(“executing send() on device\n”); };
};
int main() {
#pragma omp target
{
Base *p = new Derived();
p->send(); // ok as new is called in the target region
}
auto p1 = (uintptr_t)llvm_omp_target_alloc_shared(sizeof(Derived), 0);
#pragma omp target
new (reinterpret_cast<Derived*>(p1)) Derived();
#pragma omp target
{
reinterpret_cast<Derived*>(p1)->send(); // ok through p1 Derived::send() is called on device
}
auto p2 = (Derived*)llvm_omp_target_alloc_shared(sizeof(Derived), 0);
#pragma omp target
new (p2) Derived();
#pragma omp target is_device_ptr(p2)
{
p2->send(); // not working
}
return 0;
}