blob: abe80453e6808f60eaee75792c751a8c087f3742 [file] [log] [blame]
Christophe Lyon073831a2011-01-24 17:37:40 +01001/*
2
3Copyright (c) 2009, 2010, 2011 STMicroelectronics
4Written by Christophe Lyon
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22THE SOFTWARE.
23
24*/
25
Christophe Lyon1775be02014-07-10 13:46:54 +020026#if defined(__arm__) || defined(__aarch64__)
Christophe Lyon073831a2011-01-24 17:37:40 +010027#include <arm_neon.h>
28#else
Christophe Lyon0dab5f72011-07-19 17:14:09 +020029#include "stm-arm-neon.h"
Christophe Lyon073831a2011-01-24 17:37:40 +010030#endif
31
32#include "stm-arm-neon-ref.h"
Christophe Lyonae97a862011-09-23 11:24:43 +020033#include <math.h>
Christophe Lyon073831a2011-01-24 17:37:40 +010034
35#define TEST_MSG "VRSQRTS/VRSQRTSQ"
36void exec_vrsqrts(void)
37{
38 int i;
39
40 /* Basic test: y=vrsqrts(x), then store the result. */
41#define TEST_VRSQRTS(Q, T1, T2, W, N) \
42 VECT_VAR(vector_res, T1, W, N) = \
43 vrsqrts##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \
44 VECT_VAR(vector2, T1, W, N)); \
45 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
46 VECT_VAR(vector_res, T1, W, N))
47
48 /* With ARM RVCT, we need to declare variables before any executable
49 statement */
50
51 /* No need for integer variants */
52 DECL_VARIABLE(vector, float, 32, 2);
53 DECL_VARIABLE(vector, float, 32, 4);
54
55 DECL_VARIABLE(vector2, float, 32, 2);
56 DECL_VARIABLE(vector2, float, 32, 4);
57
58 DECL_VARIABLE(vector_res, float, 32, 2);
59 DECL_VARIABLE(vector_res, float, 32, 4);
60
61 clean_results ();
62
63 /* Choose init value arbitrarily */
Christophe Lyonbd9ecf42011-07-19 16:30:50 +020064 TEST_VDUP(vector, , float, f, 32, 2, 12.9f);
65 TEST_VDUP(vector, q, float, f, 32, 4, 9.1f);
Christophe Lyon073831a2011-01-24 17:37:40 +010066
Christophe Lyonbd9ecf42011-07-19 16:30:50 +020067 TEST_VDUP(vector2, , float, f, 32, 2, 9.9f);
68 TEST_VDUP(vector2, q, float, f, 32, 4, 1.9f);
Christophe Lyon073831a2011-01-24 17:37:40 +010069
70 /* Apply the operator */
71 TEST_VRSQRTS(, float, f, 32, 2);
72 TEST_VRSQRTS(q, float, f, 32, 4);
73
74 fprintf (ref_file, "\n%s output:\n", TEST_MSG);
75 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
76 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
Christophe Lyonae97a862011-09-23 11:24:43 +020077
78
79 /* Test FP variants with special input values (NaN) */
80 TEST_VDUP(vector, , float, f, 32, 2, NAN);
81 TEST_VDUP(vector2, q, float, f, 32, 4, NAN);
82
83 /* Apply the operator */
84 TEST_VRSQRTS(, float, f, 32, 2);
85 TEST_VRSQRTS(q, float, f, 32, 4);
86
87 fprintf (ref_file, "\n%s output:\n", TEST_MSG " FP special (NAN) and normal values");
88 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
89 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
90
91
92 /* Test FP variants with special input values (infinity, 0) */
93 TEST_VDUP(vector, , float, f, 32, 2, HUGE_VALF);
94 TEST_VDUP(vector, q, float, f, 32, 4, 0.0f);
95 TEST_VDUP(vector2, q, float, f, 32, 4, 3.2f); /* Restore a normal value */
96
97 /* Apply the operator */
98 TEST_VRSQRTS(, float, f, 32, 2);
99 TEST_VRSQRTS(q, float, f, 32, 4);
100
101 fprintf (ref_file, "\n%s output:\n", TEST_MSG " FP special (infinity, 0) and normal values");
102 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
103 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
104
105
106 /* Test FP variants with only special input values (infinity, 0) */
107 TEST_VDUP(vector, , float, f, 32, 2, HUGE_VALF);
108 TEST_VDUP(vector, q, float, f, 32, 4, 0.0f);
Christophe Lyonc8aa0f62011-09-26 18:00:27 +0200109 TEST_VDUP(vector2, , float, f, 32, 2, -0.0f);
Christophe Lyonae97a862011-09-23 11:24:43 +0200110 TEST_VDUP(vector2, q, float, f, 32, 4, HUGE_VALF);
111
112 /* Apply the operator */
113 TEST_VRSQRTS(, float, f, 32, 2);
114 TEST_VRSQRTS(q, float, f, 32, 4);
115
116 fprintf (ref_file, "\n%s output:\n", TEST_MSG " FP special (infinity, 0)");
117 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
118 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
Christophe Lyon073831a2011-01-24 17:37:40 +0100119}