Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | Copyright (c) 2009, 2010, 2011 STMicroelectronics |
| 4 | Written by Christophe Lyon |
| 5 | |
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | of this software and associated documentation files (the "Software"), to deal |
| 8 | in the Software without restriction, including without limitation the rights |
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | copies of the Software, and to permit persons to whom the Software is |
| 11 | furnished to do so, subject to the following conditions: |
| 12 | |
| 13 | The above copyright notice and this permission notice shall be included in |
| 14 | all copies or substantial portions of the Software. |
| 15 | |
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | THE SOFTWARE. |
| 23 | |
| 24 | */ |
| 25 | |
| 26 | #ifdef __arm__ |
| 27 | #include <arm_neon.h> |
| 28 | #else |
| 29 | #error Target not supported |
| 30 | #endif |
| 31 | |
| 32 | #include "stm-arm-neon-ref.h" |
| 33 | |
| 34 | #define TEST_MSG "VRSQRTS/VRSQRTSQ" |
| 35 | void exec_vrsqrts(void) |
| 36 | { |
| 37 | int i; |
| 38 | |
| 39 | /* Basic test: y=vrsqrts(x), then store the result. */ |
| 40 | #define TEST_VRSQRTS(Q, T1, T2, W, N) \ |
| 41 | VECT_VAR(vector_res, T1, W, N) = \ |
| 42 | vrsqrts##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \ |
| 43 | VECT_VAR(vector2, T1, W, N)); \ |
| 44 | vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ |
| 45 | VECT_VAR(vector_res, T1, W, N)) |
| 46 | |
| 47 | /* With ARM RVCT, we need to declare variables before any executable |
| 48 | statement */ |
| 49 | |
| 50 | /* No need for integer variants */ |
| 51 | DECL_VARIABLE(vector, float, 32, 2); |
| 52 | DECL_VARIABLE(vector, float, 32, 4); |
| 53 | |
| 54 | DECL_VARIABLE(vector2, float, 32, 2); |
| 55 | DECL_VARIABLE(vector2, float, 32, 4); |
| 56 | |
| 57 | DECL_VARIABLE(vector_res, float, 32, 2); |
| 58 | DECL_VARIABLE(vector_res, float, 32, 4); |
| 59 | |
| 60 | clean_results (); |
| 61 | |
| 62 | /* Choose init value arbitrarily */ |
Christophe Lyon | bd9ecf4 | 2011-07-19 16:30:50 +0200 | [diff] [blame^] | 63 | TEST_VDUP(vector, , float, f, 32, 2, 12.9f); |
| 64 | TEST_VDUP(vector, q, float, f, 32, 4, 9.1f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 65 | |
Christophe Lyon | bd9ecf4 | 2011-07-19 16:30:50 +0200 | [diff] [blame^] | 66 | TEST_VDUP(vector2, , float, f, 32, 2, 9.9f); |
| 67 | TEST_VDUP(vector2, q, float, f, 32, 4, 1.9f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 68 | |
| 69 | /* Apply the operator */ |
| 70 | TEST_VRSQRTS(, float, f, 32, 2); |
| 71 | TEST_VRSQRTS(q, float, f, 32, 4); |
| 72 | |
| 73 | fprintf (ref_file, "\n%s output:\n", TEST_MSG); |
| 74 | DUMP_FP(TEST_MSG, float, 32, 2, PRIx32); |
| 75 | DUMP_FP(TEST_MSG, float, 32, 4, PRIx32); |
| 76 | } |