The target construct offloads the area of ββcode from the host to the target device. The variables p, v1, v2is clearly displayed on the target device using the proposals map. target data also do the same
Then what is meant:
- "The design creates variables that will be preserved throughout the entire target data area."
- "Creating a new device data environment"
in relation to the design of the "target data",
I mean, what differences exist in the unloading mechanism between these codes:
void vec_mult1(float *p, float *v1, float *v2, int N)
{
int i;
init(v1, v2, N);
#pragma omp target map(to: v1[0:N], v2[:N]) map(from: p[0:N])
#pragma omp parallel for
for (i=0; i<N; i++)
p[i] = v1[i] * v2[i];
output(p, N);
}
void vec_mult2(float *p, float *v1, float *v2, int N)
{
int i;
init(v1, v2, N);
#pragma omp target device(mic0) data map(to: v1[0:N], v2[:N]) map(from: p[0:N])
{
#pragma omp target
#pragma omp parallel for
for (i=0; i<N; i++)
p[i] = v1[i] * v2[i];
}
output(p, N);
}
void vec_mult3(float *p, float *v1, float *v2, int N)
{
int i;
init(v1, v2, N);
#pragma omp target data map(to: v1[0:N], v2[:N]) map(from: p[0:N])
{
#pragma omp parallel for
for (i=0; i<N; i++)
p[i] = v1[i] * v2[i];
}
output(p, N);
}
I tried to execute them, but I can not notice the significant differences between them.