mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-10 16:32:11 +01:00
26 lines
683 B
C
26 lines
683 B
C
/*
|
|
* @@name: teams.4
|
|
* @@type: C
|
|
* @@operation: compile
|
|
* @@expect: success
|
|
* @@version: omp_4.0
|
|
*/
|
|
#define N 1024*1024
|
|
float dotprod(float B[], float C[])
|
|
{
|
|
float sum = 0.0;
|
|
int i;
|
|
#pragma omp target map(to: B[0:N], C[0:N]) map(tofrom: sum)
|
|
#pragma omp teams num_teams(8) thread_limit(16) reduction(+:sum)
|
|
#pragma omp distribute parallel for reduction(+:sum) \
|
|
dist_schedule(static, 1024) schedule(static, 64)
|
|
for (i=0; i<N; i++)
|
|
sum += B[i] * C[i];
|
|
return sum;
|
|
}
|
|
|
|
/* Note: The variable sum is now mapped with tofrom, for correct
|
|
execution with 4.5 (and pre-4.5) compliant compilers.
|
|
See Devices Intro.
|
|
*/
|