#ifndef HEADER
#define HEADER
#pragma omp declare simd linear(d: 8)
#pragma omp declare simd inbranch simdlen(32)
#pragma omp declare simd notinbranch
void add_1(float *d) __attribute__((cold));
#pragma omp declare simd aligned(hp, hp2:V)
#pragma omp declare simd aligned(hp, hp2:V)
template <class C, int V> void h(C *hp, C *hp2, C *hq, C *lin) {
}
#pragma omp declare simd aligned(hp, hp2)
template <class C> void h(C *hp, C *hp2, C *hq, C *lin) {
}
#pragma omp declare simd aligned(hp, hp2)
template <>
void h(int *hp, int *hp2, int *hq, int *lin)
{
h((float*) hp, (float*) hp2, (float*) hq, (float*) lin);
}
class VV {
#pragma omp declare simd uniform(this, a) linear(val(b): a)
int add(int a, int b) __attribute__((cold)) { return a + b; }
#pragma omp declare simd aligned (b: 4) aligned(a) linear(ref(b): 4) linear(this, a)
float taddpf(float *a, float *&b) { return *a + *b; }
#pragma omp declare simd linear(uval(c): 8)
#pragma omp declare simd aligned(b : 8)
int tadd(int (&b)[], int &c) { return x[b[0]] + b[0]; }
private:
int x[10];
};
template <int X, typename T>
class TVV {
public:
#pragma omp declare simd simdlen(X)
int tadd(int a, int b) { return a + b; }
#pragma omp declare simd aligned(a : X * 2) aligned(b) linear(ref(b): X)
float taddpf(float *a, T *&b) { return *a + *b; }
#pragma omp declare simd
#pragma omp declare simd uniform(this, b)
int tadd(int b) { return x[b] + b; }
private:
int x[X];
};
#pragma omp declare simd simdlen(N) aligned(b : N * 2) linear(uval(c): N)
template <int N>
void foo(int (&b)[N], float *&c);
TVV<16, float> t16;
void f() {
float a = 1.0f, b = 2.0f;
float *p = &b;
float r = t16.taddpf(&a, p);
int res = t16.tadd(b);
int c[64];
foo(c, p);
}
#endif