[Openmp-dev] Mapping issue
Itaru Kitayama via Openmp-dev
openmp-dev at lists.llvm.org
Sun Oct 27 17:57:46 PDT 2019
Below C++ code does build with the appropriate offloading flags, but errors
at run time. I am wondering if the mapping is done correctly.
Tested with the trunk Clang on POWER8.
#include <iostream>
#include <vector>
class ConnectorBase {
public:
virtual int f() = 0;
//virtual void push_back() =0;
//virtual void copy_to_array() = 0;
//virtual void send() =0;
};
template<typename ConnectionT>
class Connector : public ConnectorBase {
private:
std::vector<ConnectionT> v_;
ConnectionT connArray[100];
public:
int f() { return 1; }
Connector<ConnectionT>& push_back(ConnectionT conn) {
v_.push_back(conn);
return *this;
}
void copy_to_array() {
std::copy(v_.begin(), v_.end(), connArray);
}
void send(int i, ConnectionT conn) {
int tmp=0;
while (true) {
ConnectionT conn_local = connArray[tmp];
//if (conn_local.is_disabled()) break;
if (tmp==10) break;
tmp++;
}
}
};
class SynIdDelay {
public:
bool is_disabled() const { return true; };
};
template <typename TargetT>
class Connection {
public:
int get_w() { return 1; }
bool is_disabled() const {
return syn_id_delay_.is_disabled();
}
protected:
SynIdDelay syn_id_delay_;
};
class Target {
};
int main()
{
int sum=0;
Connection<Target> connection;
ConnectorBase *connector = new Connector<Connection<Target>>();
Connector<Connection<Target>> *vc =
static_cast<Connector<Connection<Target>> *>(connector);
connector = &vc->push_back(connection);
vc->copy_to_array();
Connector<Connection<Target>> *c =
static_cast<Connector<Connection<Target> > *>(connector);
#pragma omp target parallel for reduction(+: sum) map(to: connection)
map(to: c)
for(int i=0; i<100; i++) {
c->send(i, connection); // works, accessing an element of an array.
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20191028/51697dc4/attachment.html>
More information about the Openmp-dev
mailing list