1
0
mirror of https://github.com/OpenMP/Examples.git synced 2025-04-10 16:32:11 +01:00
2015-01-13 11:38:24 -08:00

23 lines
580 B
C

/*
* @@name: teams.2c
* @@type: C
* @@compilable: yes
* @@linkable: no
* @@expect: success
*/
float dotprod(float B[], float C[], int N, int block_size,
int num_teams, int block_threads)
{
float sum = 0;
int i, i0;
#pragma omp target map(to: B[0:N], C[0:N])
#pragma omp teams num_teams(num_teams) thread_limit(block_threads) \
reduction(+:sum)
#pragma omp distribute
for (i0=0; i0<N; i0 += block_size)
#pragma omp parallel for reduction(+:sum)
for (i=i0; i< min(i0+block_size,N); i++)
sum += B[i] * C[i];
return sum;
}