mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
26 lines
622 B
C
26 lines
622 B
C
/*
|
|
* @@name: target_data.3c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
#include <math.h>
|
|
void gramSchmidt(restrict float Q[][COLS], const int rows, const int cols)
|
|
{
|
|
#pragma omp target data map(Q[0:rows][0:cols])
|
|
for(int k=0; k < cols; k++)
|
|
{
|
|
double tmp = 0.0;
|
|
#pragma omp target
|
|
#pragma omp parallel for reduction(+:tmp)
|
|
for(int i=0; i < rows; i++)
|
|
tmp += (Q[i][k] * Q[i][k]);
|
|
tmp = 1/sqrt(tmp);
|
|
#pragma omp target
|
|
#pragma omp parallel for
|
|
for(int i=0; i < rows; i++)
|
|
Q[i][k] *= tmp;
|
|
}
|
|
}
|