aboutsummaryrefslogtreecommitdiffstats
path: root/ref_vldX.c
blob: ef7209efd09a55ed4e11e69d7cab93670cc133d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*

Copyright (c) 2009, 2010, 2011 STMicroelectronics
Written by Christophe Lyon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

*/

#ifdef __arm__
#include <arm_neon.h>
#else
#include "stm-arm-neon.h"
#endif

#include "stm-arm-neon-ref.h"

void exec_vldX (void)
{
  /* In this case, input variables are arrays of vectors */
#define DECL_VLDX(T1, W, N, X)						\
  VECT_ARRAY_TYPE(T1, W, N, X) VECT_ARRAY_VAR(vector, T1, W, N, X);	\
  VECT_VAR_DECL(result_bis_##X, T1, W, N)[X * N]

  /* We need to use a temporary result buffer (result_bis), because
     the one used for other tests is not large enough. A subset of the
     result data is moved from result_bis to result, and it is this
     subset which is used to check the actual behaviour. The next
     macro enables to move another chunk of data from result_bis to
     result.  */
#define TEST_VLDX(Q, T1, T2, W, N, X)					\
  VECT_ARRAY_VAR(vector, T1, W, N, X) =					\
    /* Use dedicated init buffer, of size X */				\
    vld##X##Q##_##T2##W(VECT_ARRAY_VAR(buffer_vld##X, T1, W, N, X));	\
  vst##X##Q##_##T2##W(VECT_VAR(result_bis_##X, T1, W, N),		\
		      VECT_ARRAY_VAR(vector, T1, W, N, X));		\
  memcpy(VECT_VAR(result, T1, W, N), VECT_VAR(result_bis_##X, T1, W, N), \
	 sizeof(VECT_VAR(result, T1, W, N)));

  /* Overwrite "result" with the contents of "result_bis"[Y] */
#define TEST_EXTRA_CHUNK(T1, W, N, X,Y)			\
  memcpy(VECT_VAR(result, T1, W, N),			\
	 &(VECT_VAR(result_bis_##X, T1, W, N)[Y*N]),	\
	 sizeof(VECT_VAR(result, T1, W, N)));

  /* With ARM RVCT, we need to declare variables before any executable
     statement */

  /* We need all variants in 64 bits, but there is no 64x2 variant */
#define DECL_ALL_VLDX(X)			\
  DECL_VLDX(int, 8, 8, X);			\
  DECL_VLDX(int, 16, 4, X);			\
  DECL_VLDX(int, 32, 2, X);			\
  DECL_VLDX(int, 64, 1, X);			\
  DECL_VLDX(uint, 8, 8, X);			\
  DECL_VLDX(uint, 16, 4, X);			\
  DECL_VLDX(uint, 32, 2, X);			\
  DECL_VLDX(uint, 64, 1, X);			\
  DECL_VLDX(float, 32, 2, X);			\
  DECL_VLDX(int, 8, 16, X);			\
  DECL_VLDX(int, 16, 8, X);			\
  DECL_VLDX(int, 32, 4, X);			\
  DECL_VLDX(uint, 8, 16, X);			\
  DECL_VLDX(uint, 16, 8, X);			\
  DECL_VLDX(uint, 32, 4, X);			\
  DECL_VLDX(float, 32, 4, X)

#define TEST_ALL_VLDX(X)			\
  TEST_VLDX(, int, s, 8, 8, X);			\
  TEST_VLDX(, int, s, 16, 4, X);		\
  TEST_VLDX(, int, s, 32, 2, X);		\
  TEST_VLDX(, int, s, 64, 1, X);		\
  TEST_VLDX(, uint, u, 8, 8, X);		\
  TEST_VLDX(, uint, u, 16, 4, X);		\
  TEST_VLDX(, uint, u, 32, 2, X);		\
  TEST_VLDX(, uint, u, 64, 1, X);		\
  TEST_VLDX(, float, f, 32, 2, X);		\
  TEST_VLDX(q, int, s, 8, 16, X);		\
  TEST_VLDX(q, int, s, 16, 8, X);		\
  TEST_VLDX(q, int, s, 32, 4, X);		\
  TEST_VLDX(q, uint, u, 8, 16, X);		\
  TEST_VLDX(q, uint, u, 16, 8, X);		\
  TEST_VLDX(q, uint, u, 32, 4, X);		\
  TEST_VLDX(q, float, f, 32, 4, X)

#define TEST_ALL_EXTRA_CHUNKS(X, Y)		\
  TEST_EXTRA_CHUNK(int, 8, 8, X, Y);		\
  TEST_EXTRA_CHUNK(int, 16, 4, X, Y);		\
  TEST_EXTRA_CHUNK(int, 32, 2, X, Y);		\
  TEST_EXTRA_CHUNK(int, 64, 1, X, Y);		\
  TEST_EXTRA_CHUNK(uint, 8, 8, X, Y);		\
  TEST_EXTRA_CHUNK(uint, 16, 4, X, Y);		\
  TEST_EXTRA_CHUNK(uint, 32, 2, X, Y);		\
  TEST_EXTRA_CHUNK(uint, 64, 1, X, Y);		\
  TEST_EXTRA_CHUNK(float, 32, 2, X, Y);		\
  TEST_EXTRA_CHUNK(int, 8, 16, X, Y);		\
  TEST_EXTRA_CHUNK(int, 16, 8, X, Y);		\
  TEST_EXTRA_CHUNK(int, 32, 4, X, Y);		\
  TEST_EXTRA_CHUNK(uint, 8, 16, X, Y);		\
  TEST_EXTRA_CHUNK(uint, 16, 8, X, Y);		\
  TEST_EXTRA_CHUNK(uint, 32, 4, X, Y);		\
  TEST_EXTRA_CHUNK(float, 32, 4, X, Y)

  DECL_ALL_VLDX(2);
  DECL_ALL_VLDX(3);
  DECL_ALL_VLDX(4);

  /* Check vld2/vld2q */
  clean_results ();
#define TEST_MSG "VLD2/VLD2Q"
  TEST_ALL_VLDX(2);
  dump_results_hex2 (TEST_MSG, " chunk 0");

  TEST_ALL_EXTRA_CHUNKS(2, 1);
  dump_results_hex2 (TEST_MSG, " chunk 1");

  /* Check vld3/vld3q */
  clean_results ();
#undef TEST_MSG
#define TEST_MSG "VLD3/VLD3Q"
  TEST_ALL_VLDX(3);
  dump_results_hex2 (TEST_MSG, " chunk 0");

  TEST_ALL_EXTRA_CHUNKS(3, 1);
  dump_results_hex2 (TEST_MSG, " chunk 1");
  TEST_ALL_EXTRA_CHUNKS(3, 2);
  dump_results_hex2 (TEST_MSG, " chunk 2");

  /* Check vld4/vld4q */
  clean_results ();
#undef TEST_MSG
#define TEST_MSG "VLD4/VLD4Q"
  TEST_ALL_VLDX(4);
  dump_results_hex2 (TEST_MSG, " chunk 0");

  TEST_ALL_EXTRA_CHUNKS(4, 1);
  dump_results_hex2 (TEST_MSG, " chunk 1");
  TEST_ALL_EXTRA_CHUNKS(4, 2);
  dump_results_hex2 (TEST_MSG, " chunk 2");
  TEST_ALL_EXTRA_CHUNKS(4, 3);
  dump_results_hex2 (TEST_MSG, " chunk 3");
}