Tizen 2.1 base
[platform/upstream/libbullet.git] / Extras / simdmathlibrary / spu / tests / fpclassifyf4.c
1 /* Test fpclassifyf4 for SPU
2    Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
3    All rights reserved.
4
5    Redistribution and use in source and binary forms,
6    with or without modification, are permitted provided that the
7    following conditions are met:
8     * Redistributions of source code must retain the above copyright
9       notice, this list of conditions and the following disclaimer.
10     * Redistributions in binary form must reproduce the above copyright
11       notice, this list of conditions and the following disclaimer in the
12       documentation and/or other materials provided with the distribution.
13     * Neither the name of the Sony Computer Entertainment Inc nor the names
14       of its contributors may be used to endorse or promote products derived
15       from this software without specific prior written permission.
16
17    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27    POSSIBILITY OF SUCH DAMAGE.
28  */
29
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <math.h>
34 #include "simdmath.h"
35 #include "common-test.h"
36 #include "testutils.h"
37
38 int main()
39 {
40    TEST_SET_START("20060828000000AAN","AAN", "fpclassifyf4");
41
42    // -Nan
43    float x0 = hide_float(-NANF);
44    int r0 = FP_NORMAL;
45    
46    // -Inf
47    float x1 = hide_float(-HUGE_VALF);
48    int r1 = FP_NORMAL;
49    
50    // -Smax
51    float x2 = hide_float(make_float(0xFFFFFFFF));
52    int r2 = FP_NORMAL;
53
54    // -Norm
55    float x3 = hide_float(-824842.58421394f);
56    int r3 = FP_NORMAL;
57    
58    // -Smin
59    float x4 = hide_float(make_float(0x80800000));
60    int r4 = FP_NORMAL;
61    
62    // -Denorm
63    float x5 = hide_float(make_float(0x803AAAAA));
64    int r5 = FP_SUBNORMAL;
65    
66    // -Unf
67    float x6 = hide_float(-1.0e-999);
68    int r6 = FP_ZERO;
69    
70    // -0
71    float x7 = hide_float(-0.0f);
72    int r7 = FP_ZERO;
73
74    // 0
75    float x8 = hide_float( 0.0f);
76    int r8 = FP_ZERO;
77    
78    // +Unf
79    float x9 = hide_float( 1.0e-999);
80    int r9 = FP_ZERO;
81
82    // +Denorm
83    float x10 = hide_float(make_float(0x003AAAAA));
84    int r10 = FP_SUBNORMAL;
85    
86    // +Smin
87    float x11 = hide_float(make_float(0x00800000));
88    int r11 = FP_NORMAL;
89    
90    // +Norm
91    float x12 = hide_float(3.14152634f);
92    int r12 = FP_NORMAL;
93    
94    // +Smax
95    float x13 = hide_float(make_float(0x7FFFFFFF));
96    int r13 = FP_NORMAL;
97    
98    // +Inf
99    float x14 = hide_float(HUGE_VALF);
100    int r14 = FP_NORMAL;
101    
102    //+Nan
103    float x15 = hide_float(NANF);
104    int r15 = FP_NORMAL;
105    
106    // Compound
107    vec_float4 x16_v = (vec_float4) {make_float(0x003AAAAA), -1.0e-999, 345.27533, make_float(0x803AAAAA)};
108    vec_int4 r16_v = (vec_int4) {FP_SUBNORMAL, FP_ZERO, FP_NORMAL, FP_SUBNORMAL};
109
110    vec_float4 x0_v = spu_splats(x0);
111    vec_int4  r0_v = spu_splats(r0);
112
113    vec_float4 x1_v = spu_splats(x1);
114    vec_int4  r1_v = spu_splats(r1);
115
116    vec_float4 x2_v = spu_splats(x2);
117    vec_int4  r2_v = spu_splats(r2);
118
119    vec_float4 x3_v = spu_splats(x3);
120    vec_int4  r3_v = spu_splats(r3);
121
122    vec_float4 x4_v = spu_splats(x4);
123    vec_int4  r4_v = spu_splats(r4);
124
125    vec_float4 x5_v = spu_splats(x5);
126    vec_int4  r5_v = spu_splats(r5);
127
128    vec_float4 x6_v = spu_splats(x6);
129    vec_int4  r6_v = spu_splats(r6);
130
131    vec_float4 x7_v = spu_splats(x7);
132    vec_int4  r7_v = spu_splats(r7);
133
134    vec_float4 x8_v = spu_splats(x8);
135    vec_int4  r8_v = spu_splats(r8);
136
137    vec_float4 x9_v = spu_splats(x9);
138    vec_int4  r9_v = spu_splats(r9);
139
140    vec_float4 x10_v = spu_splats(x10);
141    vec_int4  r10_v = spu_splats(r10);
142
143    vec_float4 x11_v = spu_splats(x11);
144    vec_int4  r11_v = spu_splats(r11);
145
146    vec_float4 x12_v = spu_splats(x12);
147    vec_int4  r12_v = spu_splats(r12);
148
149    vec_float4 x13_v = spu_splats(x13);
150    vec_int4  r13_v = spu_splats(r13);
151
152    vec_float4 x14_v = spu_splats(x14);
153    vec_int4  r14_v = spu_splats(r14);
154
155    vec_float4 x15_v = spu_splats(x15);
156    vec_int4  r15_v = spu_splats(r15);
157    
158    vec_int4 res_v;
159
160    TEST_START("fpclassifyf4");
161
162    res_v = (vec_int4)fpclassifyf4(x0_v);
163    TEST_CHECK("20060828000000AAN", allequal_int4( res_v, r0_v ), 0);
164    res_v = (vec_int4)fpclassifyf4(x1_v);
165    TEST_CHECK("20060828000001AAN", allequal_int4( res_v, r1_v ), 0);
166    res_v = (vec_int4)fpclassifyf4(x2_v);
167    TEST_CHECK("20060828000002AAN", allequal_int4( res_v, r2_v ), 0);
168    res_v = (vec_int4)fpclassifyf4(x3_v);
169    TEST_CHECK("20060828000003AAN", allequal_int4( res_v, r3_v ), 0);
170    res_v = (vec_int4)fpclassifyf4(x4_v);
171    TEST_CHECK("20060828000004AAN", allequal_int4( res_v, r4_v ), 0);
172    res_v = (vec_int4)fpclassifyf4(x5_v);
173    TEST_CHECK("20060828000005AAN", allequal_int4( res_v, r5_v ), 0);
174    res_v = (vec_int4)fpclassifyf4(x6_v);
175    TEST_CHECK("20060828000006AAN", allequal_int4( res_v, r6_v ), 0);
176    res_v = (vec_int4)fpclassifyf4(x7_v);
177    TEST_CHECK("20060828000007AAN", allequal_int4( res_v, r7_v ), 0);
178    res_v = (vec_int4)fpclassifyf4(x8_v);
179    TEST_CHECK("20060828000008AAN", allequal_int4( res_v, r8_v ), 0);
180    res_v = (vec_int4)fpclassifyf4(x9_v);
181    TEST_CHECK("20060828000009AAN", allequal_int4( res_v, r9_v ), 0);
182    res_v = (vec_int4)fpclassifyf4(x10_v);
183    TEST_CHECK("20060828000010AAN", allequal_int4( res_v, r10_v ), 0);
184    res_v = (vec_int4)fpclassifyf4(x11_v);
185    TEST_CHECK("20060828000011AAN", allequal_int4( res_v, r11_v ), 0);
186    res_v = (vec_int4)fpclassifyf4(x12_v);
187    TEST_CHECK("20060828000012AAN", allequal_int4( res_v, r12_v ), 0);
188    res_v = (vec_int4)fpclassifyf4(x13_v);
189    TEST_CHECK("20060828000013AAN", allequal_int4( res_v, r13_v ), 0);
190    res_v = (vec_int4)fpclassifyf4(x14_v);
191    TEST_CHECK("20060828000014AAN", allequal_int4( res_v, r14_v ), 0);
192    res_v = (vec_int4)fpclassifyf4(x15_v);
193    TEST_CHECK("20060828000015AAN", allequal_int4( res_v, r15_v ), 0);
194    res_v = (vec_int4)fpclassifyf4(x16_v);
195    TEST_CHECK("20060828000016AAN", allequal_int4( res_v, r16_v ), 0);
196    
197    TEST_SET_DONE();
198    
199    TEST_EXIT();
200 }