mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
30 lines
543 B
C++
30 lines
543 B
C++
/*
|
|
* @@name: target-unstructured-data.1.cpp
|
|
* @@type: C++
|
|
* @@compilable: yes
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
class Matrix
|
|
{
|
|
|
|
Matrix(int n) {
|
|
len = n;
|
|
v = new double[len];
|
|
#pragma omp target enter data map(alloc:v[0:len])
|
|
}
|
|
|
|
~Matrix() {
|
|
// NOTE: delete map type should be used, since the corresponding
|
|
// host data will cease to exist after the deconstructor is called.
|
|
|
|
#pragma omp target exit data map(delete:v[0:len])
|
|
delete[] v;
|
|
}
|
|
|
|
private:
|
|
double* v;
|
|
int len;
|
|
|
|
};
|