1
0
mirror of https://github.com/OpenMP/Examples.git synced 2025-04-07 15:12:11 +01:00
OpenMP-Examples/SIMD/sources/linear_modifier.2.cpp
2021-08-17 09:11:55 -07:00

45 lines
653 B
C++

/*
* @@name: linear_modifier.2cpp
* @@type: C++
* @@compilable: yes
* @@linkable: yes
* @@expect: success
* @@version: omp_4.5
*/
#include <stdio.h>
#define NN 1023
int a[NN];
#pragma omp declare simd linear(ref(p)) linear(uval(i))
void add_one2(int& p, const int& i)
{
p += i;
}
int main(void)
{
int i;
int* p = a;
for (i = 0; i < NN; i++) {
a[i] = i;
}
#pragma omp simd linear(p)
for (i = 0; i < NN; i++) {
int& k = *p;
add_one2(k, i);
p++;
}
for (i = 0; i < NN; i++) {
if (a[i] != i*2) {
printf("failed\n");
return 1;
}
}
printf("passed\n");
return 0;
}