111
|
1 // { dg-do compile }
|
|
2 // { dg-additional-options "-ffast-math -fopenmp-simd" }
|
|
3 // { dg-additional-options "-msse2" { target x86_64-*-* i?86-*-* } }
|
|
4
|
131
|
5 inline void* my_alloc (__SIZE_TYPE__ bytes) {void *ptr; __builtin_posix_memalign (&ptr, bytes, 128); return 0; }
|
111
|
6 inline void my_free (void* memory) {__builtin_free (memory);}
|
|
7
|
|
8 template <typename T>
|
|
9 class Vec
|
|
10 {
|
|
11 const int isize;
|
|
12 T* data;
|
|
13
|
|
14 public:
|
|
15
|
|
16 Vec (int n) : isize (n) {data = (T*)my_alloc (isize*sizeof (T));}
|
|
17 ~Vec () {my_free(data);}
|
|
18
|
|
19 Vec& operator = (const Vec& other)
|
|
20 {
|
|
21 if (this != &other)
|
|
22 __builtin_memcpy (data, other.data, isize*sizeof (T));
|
|
23 return *this;
|
|
24 }
|
|
25
|
|
26 T& operator [] (int i) {return data[i];}
|
|
27 const T& operator [] (int i) const {return data[i];}
|
|
28 T& at (int i) {return data[i];}
|
|
29 const T& at (int i) const {return data[i];}
|
|
30
|
|
31 operator T* () {return data;}
|
|
32 int size () const {return isize;}
|
|
33 };
|
|
34
|
|
35 template <typename T>
|
|
36 class Cl
|
|
37 {
|
|
38 public:
|
|
39
|
|
40 Cl (int n, int m);
|
|
41 const int N, M;
|
|
42 Vec<T> v_x, v_y;
|
|
43 Vec<int> v_i;
|
|
44 Vec<float> v_z;
|
|
45 };
|
|
46
|
|
47 struct Ss
|
|
48 {
|
|
49 const int S_n, S_m;
|
|
50 Cl<float> v1;
|
|
51 float* C1;
|
|
52 float* C2;
|
|
53 Ss (int n1, int n2): S_n(n1), S_m(n2), v1(n1, n2)
|
|
54 {
|
|
55 C1 = new float[n1 * 3];
|
|
56 C2 = new float[n2 * 4];
|
|
57 }
|
|
58
|
|
59 ~Ss () { delete C1; delete C2;}
|
|
60 void foo (float *in, float w);
|
|
61 };
|
|
62 void Ss::foo (float *in, float w)
|
|
63 {
|
|
64 #pragma omp simd
|
|
65 for (int i = 0; i < S_n; i++)
|
|
66 {
|
|
67 float w1 = C2[S_n + i] * w;
|
|
68 v1.v_i[i] += (int)w1;
|
|
69 C1[S_n + i] += w1;
|
|
70 }
|
|
71 }
|
|
72
|
131
|
73 // { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { xfail *-*-* } } }
|