Added SCE SIMD math library in Extras/simdmathlibrary
The upcoming vectormath that will used to speed up the SPU version of Extras/BulletMultiThreaded depends on this.
This commit is contained in:
131
Extras/simdmathlibrary/ppu/tests/Makefile
Normal file
131
Extras/simdmathlibrary/ppu/tests/Makefile
Normal file
@@ -0,0 +1,131 @@
|
||||
# Makefile for testsuite for the PPU SIMD math library
|
||||
# Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided that the
|
||||
# following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
# of its contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
TESTS = fabsf4 absi4 truncf4 sqrtf4 negatef4 \
|
||||
copysignf4 modff4 fminf4_fmaxf4 \
|
||||
floorf4 recipf4 ceilf4 divf4 divi4 \
|
||||
rsqrtf4 fmodf4 negatei4
|
||||
|
||||
STATIC_TESTS = $(TESTS)
|
||||
SHARED_TESTS = $(TESTS:=.shared)
|
||||
ALL_TESTS = $(STATIC_TESTS) $(SHARED_TESTS)
|
||||
|
||||
INCLUDES_PPU = -I../../
|
||||
|
||||
ARCH_PPU = 64
|
||||
CROSS_PPU = ppu-
|
||||
AR_PPU = $(CROSS_PPU)ar
|
||||
CC_PPU = $(CROSS_PPU)gcc
|
||||
CXX_PPU = $(CROSS_PPU)g++
|
||||
TEST_CMD_PPU =
|
||||
|
||||
ARCH_CFLAGS_PPU = -m$(ARCH_PPU) -maltivec -mabi=altivec
|
||||
CFLAGS_PPU = $(INCLUDES_PPU) -O2 -W -Wall $(ARCH_CFLAGS_PPU)
|
||||
STATIC_LDFLAGS_PPU = -static
|
||||
SHARED_LDFLAGS_PPU = -Wl,-rpath=..
|
||||
LDFLAGS_PPU = $(ARCH_CFLAGS_PPU) -L../ -l$(LIB_BASE) -lm
|
||||
|
||||
MAKE_DEFS = \
|
||||
LIB_BASE='$(LIB_BASE)' \
|
||||
LIB_NAME='$(LIB_NAME)' \
|
||||
STATIC_LIB='$(STATIC_LIB)' \
|
||||
SHARED_LIB='$(SHARED_LIB)' \
|
||||
ARCH_PPU='$(ARCH_PPU)' \
|
||||
ARCH_CFLAGS_PPU='$(ARCH_CFLAGS_PPU)' \
|
||||
CROSS_PPU='$(CROSS_PPU)' \
|
||||
AR_PPU='$(AR_PPU)' \
|
||||
CC_PPU='$(CC_PPU)' \
|
||||
CXX_PPU='$(CXX_PPU)' \
|
||||
TEST_CMD_PPU='$(TEST_CMD_PPU)'
|
||||
|
||||
LIB_BASE = simdmath
|
||||
LIB_NAME = lib$(LIB_BASE)
|
||||
STATIC_LIB = $(LIB_NAME).a
|
||||
SHARED_LIB = $(LIB_NAME).so
|
||||
|
||||
TEST_CMD = $(TEST_CMD_PPU)
|
||||
|
||||
COMMON_OBJS = testutils.o
|
||||
|
||||
|
||||
all: $(ALL_TESTS)
|
||||
|
||||
|
||||
$(STATIC_TESTS): %: %.o ../$(STATIC_LIB) $(COMMON_OBJS)
|
||||
$(CC_PPU) $*.o $(COMMON_OBJS) $(LDFLAGS_PPU) $(STATIC_LDFLAGS_PPU) -o $@
|
||||
|
||||
$(SHARED_TESTS): %.shared: %.o ../$(SHARED_LIB) $(COMMON_OBJS)
|
||||
$(CC_PPU) $*.o $(COMMON_OBJS) $(LDFLAGS_PPU) $(SHARED_LDFLAGS_PPU) -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f $(STATIC_TESTS) $(SHARED_TESTS)
|
||||
rm -f core*
|
||||
|
||||
check: $(ALL_TESTS)
|
||||
for test in $(ALL_TESTS); do \
|
||||
echo "TEST $${test}"; \
|
||||
if $(TEST_CMD) ./$${test}; then \
|
||||
pass="$$pass $$test"; \
|
||||
else \
|
||||
fail="$$fail $$test"; \
|
||||
fi \
|
||||
done; \
|
||||
echo; echo "PASS:$$pass"; echo "FAIL:$$fail"; \
|
||||
test -z "$$fail"
|
||||
|
||||
static_check:
|
||||
$(MAKE) $(MAKE_DEFS) ALL_TESTS="$(STATIC_TESTS)" check
|
||||
|
||||
shared_check:
|
||||
$(MAKE) $(MAKE_DEFS) ALL_TESTS="$(SHARED_TESTS)" check
|
||||
|
||||
../$(STATIC_LIB):
|
||||
cd ../;$(MAKE) $(MAKE_DEFS) $(STATIC_LIB)
|
||||
|
||||
../$(SHARED_LIB):
|
||||
cd ../;$(MAKE) $(MAKE_DEFS) $(SHARED_LIB)
|
||||
|
||||
%.o: %.c common-test.h testutils.h
|
||||
$(CC_PPU) $(CFLAGS_PPU) -c $<
|
||||
|
||||
#----------
|
||||
# C++
|
||||
#----------
|
||||
%.o: %.C
|
||||
$(CXX_PPU) $(CFLAGS_PPU) -c $<
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX_PPU) $(CFLAGS_PPU) -c $<
|
||||
|
||||
%.o: %.cc
|
||||
$(CXX_PPU) $(CFLAGS_PPU) -c $<
|
||||
|
||||
%.o: %.cxx
|
||||
$(CXX_PPU) $(CFLAGS_PPU) -c $<
|
||||
|
||||
73
Extras/simdmathlibrary/ppu/tests/absi4.c
Normal file
73
Extras/simdmathlibrary/ppu/tests/absi4.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/* Testcase for absi4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040908101807EJL","EJL", "abs");
|
||||
|
||||
int x0n = hide_int(0);
|
||||
int x0p = hide_int(0);
|
||||
int x1n = hide_int(-1);
|
||||
int x1p = hide_int(1);
|
||||
int x2n = hide_int(-83532);
|
||||
int x2p = hide_int(83532);
|
||||
|
||||
vec_int4 x0n_v = vec_splat_int(x0n);
|
||||
vec_int4 x0p_v = vec_splat_int(x0p);
|
||||
vec_int4 x1n_v = vec_splat_int(x1n);
|
||||
vec_int4 x1p_v = vec_splat_int(x1p);
|
||||
vec_int4 x2n_v = vec_splat_int(x2n);
|
||||
vec_int4 x2p_v = vec_splat_int(x2p);
|
||||
|
||||
vec_int4 res_v;
|
||||
|
||||
TEST_START("absi4");
|
||||
res_v = absi4(x0n_v);
|
||||
TEST_CHECK("20040908103824EJL", allequal_int4( res_v, x0p_v ), 0);
|
||||
res_v = absi4(x0p_v);
|
||||
TEST_CHECK("20040908103903EJL", allequal_int4( res_v, x0p_v ), 0);
|
||||
res_v = absi4(x1n_v);
|
||||
TEST_CHECK("20040908103905EJL", allequal_int4( res_v, x1p_v ), 0);
|
||||
res_v = absi4(x1p_v);
|
||||
TEST_CHECK("20040908114003EJL", allequal_int4( res_v, x1p_v ), 0);
|
||||
res_v = absi4(x2n_v);
|
||||
TEST_CHECK("20040908114714EJL", allequal_int4( res_v, x2p_v ), 0);
|
||||
res_v = absi4(x2p_v);
|
||||
TEST_CHECK("20040908114715EJL", allequal_int4( res_v, x2p_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
92
Extras/simdmathlibrary/ppu/tests/ceilf4.c
Normal file
92
Extras/simdmathlibrary/ppu/tests/ceilf4.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/* Testcase for ceilf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040916103300EJL","EJL", "ceilf");
|
||||
|
||||
unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value.
|
||||
unsigned int i3i = 0x4b000000;
|
||||
unsigned int i4 = 0x4b000000; // 2^23, no fractional part.
|
||||
unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value.
|
||||
|
||||
float x0 = hide_float(0.91825f);
|
||||
float x0i = hide_float(1.0f);
|
||||
float x1 = hide_float(-0.12958f);
|
||||
float x1i = hide_float(0.0f);
|
||||
float x2 = hide_float(-79615.1875f);
|
||||
float x2i = hide_float(-79615.0f);
|
||||
float x3 = hide_float(make_float(i3));
|
||||
float x3i = hide_float(make_float(i3i));
|
||||
float x4 = hide_float(make_float(i4));
|
||||
float x4i = hide_float(make_float(i4));
|
||||
float x5 = hide_float(make_float(i5));
|
||||
float x5i = hide_float(make_float(i5));
|
||||
|
||||
vec_float4 x0_v = vec_splat_float(x0);
|
||||
vec_float4 x0i_v = vec_splat_float(x0i);
|
||||
vec_float4 x1_v = vec_splat_float(x1);
|
||||
vec_float4 x1i_v = vec_splat_float(x1i);
|
||||
vec_float4 x2_v = vec_splat_float(x2);
|
||||
vec_float4 x2i_v = vec_splat_float(x2i);
|
||||
vec_float4 x3_v = vec_splat_float(x3);
|
||||
vec_float4 x3i_v = vec_splat_float(x3i);
|
||||
vec_float4 x4_v = vec_splat_float(x4);
|
||||
vec_float4 x4i_v = vec_splat_float(x4i);
|
||||
vec_float4 x5_v = vec_splat_float(x5);
|
||||
vec_float4 x5i_v = vec_splat_float(x5i);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("ceilf4");
|
||||
res_v = ceilf4(x0_v);
|
||||
TEST_CHECK("20040916103310EJL", allequal_float4( res_v, x0i_v ), 0);
|
||||
res_v = ceilf4(x1_v);
|
||||
TEST_CHECK("20040916103324EJL", allequal_float4( res_v, x1i_v ), 0);
|
||||
res_v = ceilf4(x2_v);
|
||||
TEST_CHECK("20040916103334EJL", allequal_float4( res_v, x2i_v ), 0);
|
||||
res_v = ceilf4(x3_v);
|
||||
TEST_CHECK("20040916103341EJL", allequal_float4( res_v, x3i_v ), 0);
|
||||
res_v = ceilf4(x4_v);
|
||||
TEST_CHECK("20040916103350EJL", allequal_float4( res_v, x4i_v ), 0);
|
||||
res_v = ceilf4(x5_v);
|
||||
TEST_CHECK("20040916103357EJL", allequal_float4( res_v, x5i_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
198
Extras/simdmathlibrary/ppu/tests/common-test.h
Normal file
198
Extras/simdmathlibrary/ppu/tests/common-test.h
Normal file
@@ -0,0 +1,198 @@
|
||||
/* Header file for common parts of the testsuite
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static inline unsigned long long clock()
|
||||
{
|
||||
unsigned long long ret;
|
||||
/* This need to be fixed for the hardware errata. */
|
||||
__asm __volatile__ ( "mftb %0\n"
|
||||
: "=r" (ret)
|
||||
:
|
||||
: "memory");
|
||||
return (ret);
|
||||
}
|
||||
// Test files begin with TEST_SET_START("your initials","test set description")
|
||||
// Individual tests begin with TEST_START("name of test")
|
||||
// and end with TEST_PASS(), TEST_FAIL("reason for failure") or TEST_CHECK(<test to evaluate>)
|
||||
// Or you can run a test encapsulated in a function with:
|
||||
// TEST_FUNCTION("name of test", function(), "reason for failure")
|
||||
//
|
||||
// The clock starts when you call TEST_START and stops with TEST_PASS, TEST_FAIL or TEST_CHECK
|
||||
// After a start there can be several PASS, FAIL or CHECK calls, each one counts as a test, time is measured from the prior call
|
||||
//
|
||||
char
|
||||
*__initials, // Test owner's initials
|
||||
*__description, // short descriptive name for this test set
|
||||
*__name, // name of the currently running test
|
||||
*__set_id; // id of the the test set
|
||||
int
|
||||
// __zip=0,
|
||||
__success=1, // set to 0 if any tests failed
|
||||
__count, // Total number of tests run
|
||||
__passed; // Total number of tests passed
|
||||
unsigned long long
|
||||
__ttemp,
|
||||
__time, // For timing tests (usually start time of last test)
|
||||
__ttime; // Cumulative test runtime NOT counting runtime of the TEST macros
|
||||
|
||||
// TEST_SET_START
|
||||
// Call at the start of a set of related tests to identify them
|
||||
// Prints a "start of set banner message"
|
||||
// set_id - unique test set identifyer a time in the format yyyymmddhhmmss followed by your initials ie: 20040716104615GAC
|
||||
// initials - your initials
|
||||
// description - brief descriptive name for this test set
|
||||
#define TEST_SET_START(set_id,initials,description) \
|
||||
do { \
|
||||
__set_id=set_id; \
|
||||
__initials=initials; \
|
||||
__description=description; \
|
||||
__count=0; \
|
||||
__passed=0; \
|
||||
__time=0; \
|
||||
__ttime=0; \
|
||||
printf("0\t%s\t%d\t%s\tSTART\tpassed\ttotal\ttime\t%s\tunique test id \t%s\n",__FILE__,__LINE__,__initials,__set_id, __description); \
|
||||
} while(0)
|
||||
|
||||
// TEST_START
|
||||
// Begins a test, and starts the clock
|
||||
// name - brief name for this test
|
||||
#define TEST_START(name) \
|
||||
do { \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__time) :: "memory"); \
|
||||
__name=name; \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__time) :: "memory"); \
|
||||
} while(0)
|
||||
|
||||
// TEST_PASS
|
||||
// Indicates the test passed
|
||||
// test_id - unique test ID number, same format as the set_id number
|
||||
// This should match the id provided to the matching TEST_FAIL call
|
||||
#define TEST_PASS(test_id) \
|
||||
do { \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__ttemp) :: "memory"); \
|
||||
__time=__ttemp-__time; \
|
||||
__ttime+=__time; \
|
||||
__count++; \
|
||||
__passed++; \
|
||||
printf("1\t%s\t%d\t%s\tPASS\t%d\t%d\t%lld\t%s\t%s\t%s\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name); \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__time) :: "memory"); \
|
||||
} while(0)
|
||||
|
||||
// TEST_FAIL
|
||||
// Indicates the test failed
|
||||
// test_id - unique test ID number, same format as the set_id number
|
||||
// This should match the id provided to the matching TEST_PASS call
|
||||
// why - brief description of why it failed
|
||||
#define TEST_FAIL(test_id,why,error_code) \
|
||||
do { \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__ttemp) :: "memory"); \
|
||||
__time=__ttemp-__time; \
|
||||
__ttime+=__time; \
|
||||
__count++; \
|
||||
__success=0; \
|
||||
printf("1\t%s\t%d\t%s\tFAIL\t%d\t%d\t%lld\t%s\t%s\t%s\tFAILED BECAUSE: %s\t%d\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name,why,error_code); \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__time) :: "memory"); \
|
||||
} while(0)
|
||||
|
||||
// TEST_CHECK
|
||||
// Passes or fails the test after evaluating the "test" argument (just like assert but without terminating the program)
|
||||
// The clock is immediately stopped so the time required to evaluate "test" will NOT be included in the reported time
|
||||
// If the test failed, the reason will be printed as FAILED BECAUSE: check (value of "test") failed
|
||||
// test_id - unique test ID number, same format as the set_id number
|
||||
// test - expression evaluating to true/false
|
||||
#define TEST_CHECK(test_id,test,error_code) \
|
||||
do { \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__ttemp) :: "memory"); \
|
||||
__time=__ttemp-__time; \
|
||||
__ttime+=__time; \
|
||||
__count++; \
|
||||
if(test) \
|
||||
{ \
|
||||
__passed++; \
|
||||
printf("1\t%s\t%d\t%s\tPASS\t%d\t%d\t%lld\t%s\t%s\t%s\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
__success=0; \
|
||||
printf("1\t%s\t%d\t%s\tFAIL\t%d\t%d\t%lld\t%s\t%s\t%s\tFAILED BECAUSE: check %s failed\t%d\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name,#test,error_code); \
|
||||
} \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__time) :: "memory"); \
|
||||
} while(0)
|
||||
|
||||
// TEST_FUNCTION
|
||||
// Runs a test encapsulated in a function that returns 0 if the test passed and an error number if it failed
|
||||
// The clock is started on calling the function and stopped as soon as it returns so the branching logic will not be included in the time
|
||||
// test_id - unique test ID number, same format as the set_id number
|
||||
// name - brief name for the test
|
||||
// func - function invocation (should include parenthesis, may have arguments)
|
||||
// why - brief description to print if the test fails
|
||||
#define TEST_FUNCTION(test_id,name,func,why) \
|
||||
do { \
|
||||
TEST_START(name); \
|
||||
int result=func; \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__ttemp) :: "memory"); \
|
||||
__time=__ttemp-__time; \
|
||||
__ttime+=__time; \
|
||||
__count++; \
|
||||
if(result==0) \
|
||||
{ \
|
||||
__passed++; \
|
||||
printf("1\t%s\t%d\t%s\tPASS\t%d\t%d\t%d\t%s\t%s\t%s\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
__success=0; \
|
||||
printf("1\t%s\t%d\t%s\tFAIL\t%d\t%d\t%d\t%s\t%s\t%s\tFAILED BECAUSE: %s\t%d\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name,why,result); \
|
||||
} \
|
||||
__asm __volatile__ ( "mftb %0 \n" : "=r" (__time) :: "memory"); \
|
||||
} while(0)
|
||||
|
||||
// TEST_SET_DONE
|
||||
// Ends a set of tests, prints out the closing banner (OK if all tests pass, PROBLEM if any fail)
|
||||
// Also prints count of tests passed, tests run and total time
|
||||
#define TEST_SET_DONE() \
|
||||
do { \
|
||||
printf("9\t%s\t%d\t%s\t%s\t%d\t%d\t%lld\t%s\tunique test id \t%s\n",__FILE__,__LINE__,__initials,(__count==__passed)?"OK":"PROBLEM",__passed,__count,__ttime,__set_id,__description); \
|
||||
} while(0)
|
||||
|
||||
// TEST_EXIT
|
||||
// Call this ONCE at the very end of the test program, it calls "exit" to return
|
||||
// EXIT_SUCCESS if all tests passed or EXIT_FAILURE if any tests failed.
|
||||
// This allows the makefile/shell script running the tests to know which ones failed
|
||||
#define TEST_EXIT() \
|
||||
do { \
|
||||
printf("FINISHED!\n"); \
|
||||
if(__success) \
|
||||
exit(0); \
|
||||
else \
|
||||
exit(-1); \
|
||||
} while (0)
|
||||
67
Extras/simdmathlibrary/ppu/tests/copysignf4.c
Normal file
67
Extras/simdmathlibrary/ppu/tests/copysignf4.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/* Testcase for copysignf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040917114054EJL", "EJL", "copysignf");
|
||||
|
||||
float x0m = hide_float(1989.0f);
|
||||
float x0s = hide_float(-319875.0f);
|
||||
float x0c = hide_float(-1989.0f);
|
||||
float x1m = hide_float(9013.0f);
|
||||
float x1s = hide_float(185.0f);
|
||||
float x1c = hide_float(9013.0f);
|
||||
|
||||
vec_float4 x0m_v = vec_splat_float(x0m);
|
||||
vec_float4 x0s_v = vec_splat_float(x0s);
|
||||
vec_float4 x0c_v = vec_splat_float(x0c);
|
||||
|
||||
vec_float4 x1m_v = vec_splat_float(x1m);
|
||||
vec_float4 x1s_v = vec_splat_float(x1s);
|
||||
vec_float4 x1c_v = vec_splat_float(x1c);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("copysignf4");
|
||||
res_v = copysignf4( x0m_v, x0s_v );
|
||||
TEST_CHECK("20040917114058EJL", allequal_float4( res_v, x0c_v ), 0);
|
||||
res_v = copysignf4( x1m_v, x1s_v );
|
||||
TEST_CHECK("20040917114100EJL", allequal_float4( res_v, x1c_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
128
Extras/simdmathlibrary/ppu/tests/divf4.c
Normal file
128
Extras/simdmathlibrary/ppu/tests/divf4.c
Normal file
@@ -0,0 +1,128 @@
|
||||
/* Testcase for divf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040928105926EJL","EJL", "divf4");
|
||||
|
||||
unsigned int i0n = 0x75013340;
|
||||
unsigned int i0d = 0x75e7753f;
|
||||
unsigned int i0r = 0x3e8ee64b;
|
||||
unsigned int i1n = 0x4c7fed5a;
|
||||
unsigned int i1d = 0x3a0731f0;
|
||||
unsigned int i1r = 0x51f24e86;
|
||||
unsigned int i2n = 0x5b08b303;
|
||||
unsigned int i2d = 0x562f5046;
|
||||
unsigned int i2r = 0x44479d24;
|
||||
unsigned int i3n = 0x748a9b87;
|
||||
unsigned int i3d = 0x6b014b46;
|
||||
unsigned int i3r = 0x49093864;
|
||||
unsigned int i4n = 0x35dcf9d8;
|
||||
unsigned int i4d = 0x6278d6e0;
|
||||
unsigned int i4r = 0x12e355b5;
|
||||
unsigned int i5n = 0x74d505fd;
|
||||
unsigned int i5d = 0x61ef565e;
|
||||
unsigned int i5r = 0x5263daa3;
|
||||
|
||||
float x0n = hide_float(make_float(i0n));
|
||||
float x0d = hide_float(make_float(i0d));
|
||||
float x0r = hide_float(make_float(i0r));
|
||||
|
||||
float x1n = hide_float(make_float(i1n));
|
||||
float x1d = hide_float(make_float(i1d));
|
||||
float x1r = hide_float(make_float(i1r));
|
||||
|
||||
float x2n = hide_float(make_float(i2n));
|
||||
float x2d = hide_float(make_float(i2d));
|
||||
float x2r = hide_float(make_float(i2r));
|
||||
|
||||
float x3n = hide_float(make_float(i3n));
|
||||
float x3d = hide_float(make_float(i3d));
|
||||
float x3r = hide_float(make_float(i3r));
|
||||
|
||||
float x4n = hide_float(make_float(i4n));
|
||||
float x4d = hide_float(make_float(i4d));
|
||||
float x4r = hide_float(make_float(i4r));
|
||||
|
||||
float x5n = hide_float(make_float(i5n));
|
||||
float x5d = hide_float(make_float(i5d));
|
||||
float x5r = hide_float(make_float(i5r));
|
||||
|
||||
vec_float4 x0n_v = vec_splat_float(x0n);
|
||||
vec_float4 x0d_v = vec_splat_float(x0d);
|
||||
vec_float4 x0r_v = vec_splat_float(x0r);
|
||||
|
||||
vec_float4 x1n_v = vec_splat_float(x1n);
|
||||
vec_float4 x1d_v = vec_splat_float(x1d);
|
||||
vec_float4 x1r_v = vec_splat_float(x1r);
|
||||
|
||||
vec_float4 x2n_v = vec_splat_float(x2n);
|
||||
vec_float4 x2d_v = vec_splat_float(x2d);
|
||||
vec_float4 x2r_v = vec_splat_float(x2r);
|
||||
|
||||
vec_float4 x3n_v = vec_splat_float(x3n);
|
||||
vec_float4 x3d_v = vec_splat_float(x3d);
|
||||
vec_float4 x3r_v = vec_splat_float(x3r);
|
||||
|
||||
vec_float4 x4n_v = vec_splat_float(x4n);
|
||||
vec_float4 x4d_v = vec_splat_float(x4d);
|
||||
vec_float4 x4r_v = vec_splat_float(x4r);
|
||||
|
||||
vec_float4 x5n_v = vec_splat_float(x5n);
|
||||
vec_float4 x5d_v = vec_splat_float(x5d);
|
||||
vec_float4 x5r_v = vec_splat_float(x5r);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("divf4");
|
||||
res_v = divf4(x0n_v, x0d_v);
|
||||
TEST_CHECK("20040928105932EJL", allequal_ulps_float4( res_v, x0r_v, 2 ), 0);
|
||||
res_v = divf4(x1n_v, x1d_v);
|
||||
TEST_CHECK("20040928105934EJL", allequal_ulps_float4( res_v, x1r_v, 2 ), 0);
|
||||
res_v = divf4(x2n_v, x2d_v);
|
||||
TEST_CHECK("20040928105936EJL", allequal_ulps_float4( res_v, x2r_v, 2 ), 0);
|
||||
res_v = divf4(x3n_v, x3d_v);
|
||||
TEST_CHECK("20040928105938EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0);
|
||||
res_v = divf4(x4n_v, x4d_v);
|
||||
TEST_CHECK("20040928105940EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0);
|
||||
res_v = divf4(x5n_v, x5d_v);
|
||||
TEST_CHECK("20040928105943EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
124
Extras/simdmathlibrary/ppu/tests/divi4.c
Normal file
124
Extras/simdmathlibrary/ppu/tests/divi4.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/* Testcase for divi4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040928161739EJL","EJL", "divi4");
|
||||
|
||||
int x0n = 0xffccb78d;
|
||||
int x0d = 0x0 ;
|
||||
int x0q = 0x0 ;
|
||||
int x0r = 0xffccb78d;
|
||||
int x1n = 0x0;
|
||||
int x1d = 0xff976bb6;
|
||||
int x1q = 0x0 ;
|
||||
int x1r = 0x0;
|
||||
int x2n = 0x0;
|
||||
int x2d = 0x0;
|
||||
int x2q = 0x0 ;
|
||||
int x2r = 0x0;
|
||||
int x3n = 0xf0e91618;
|
||||
int x3d = 0xfddff7ac;
|
||||
int x3q = 0x7 ;
|
||||
int x3r = 0xffc95064;
|
||||
|
||||
int x4n = 0xf2128d9d;
|
||||
int x4d = 0xe0f76 ;
|
||||
int x4q = 0xffffff03;
|
||||
int x4r = 0xfff7d53b;
|
||||
int x5n = 0xda1ba2ce;
|
||||
int x5d = 0x4c9 ;
|
||||
int x5q = 0xfff814d3;
|
||||
int x5r = 0xfffffd23;
|
||||
int x6n = 0xdd4426a6;
|
||||
int x6d = 0xf8d245cf;
|
||||
int x6q = 0x4 ;
|
||||
int x6r = 0xf9fb0f6a;
|
||||
int x7n = 0xd1d5ae9 ;
|
||||
int x7d = 0x333ab105;
|
||||
int x7q = 0x0 ;
|
||||
int x7r = 0xd1d5ae9 ;
|
||||
|
||||
int x8n = 0x3e0c6 ;
|
||||
int x8d = 0xfff24255;
|
||||
int x8q = 0x0 ;
|
||||
int x8r = 0x3e0c6 ;
|
||||
int x9n = 0xfd6fe27e;
|
||||
int x9d = 0xf32454 ;
|
||||
int x9q = 0xfffffffe;
|
||||
int x9r = 0xff562b26;
|
||||
int x10n =0xfb150f79;
|
||||
int x10d =0xf521 ;
|
||||
int x10q =0xfffffade;
|
||||
int x10r =0xffff42db;
|
||||
int x11n =0xfe88071f;
|
||||
int x11d =0xfff937c2;
|
||||
int x11q =0x37 ;
|
||||
int x11r =0xfffd0c71;
|
||||
|
||||
|
||||
vec_int4 x0n_v = (vec_int4){ x0n, x1n, x2n, x3n };
|
||||
vec_int4 x1n_v = (vec_int4){ x4n, x5n, x6n, x7n };
|
||||
vec_int4 x2n_v = (vec_int4){ x8n, x9n, x10n, x11n };
|
||||
|
||||
vec_int4 x0d_v = (vec_int4){ x0d, x1d, x2d, x3d };
|
||||
vec_int4 x1d_v = (vec_int4){ x4d, x5d, x6d, x7d };
|
||||
vec_int4 x2d_v = (vec_int4){ x8d, x9d, x10d, x11d };
|
||||
|
||||
vec_int4 x0q_v = (vec_int4){ x0q, x1q, x2q, x3q };
|
||||
vec_int4 x1q_v = (vec_int4){ x4q, x5q, x6q, x7q };
|
||||
vec_int4 x2q_v = (vec_int4){ x8q, x9q, x10q, x11q };
|
||||
|
||||
vec_int4 x0r_v = (vec_int4){ x0r, x1r, x2r, x3r };
|
||||
vec_int4 x1r_v = (vec_int4){ x4r, x5r, x6r, x7r };
|
||||
vec_int4 x2r_v = (vec_int4){ x8r, x9r, x10r, x11r };
|
||||
|
||||
divi4_t res;
|
||||
|
||||
TEST_START("divi4");
|
||||
res = divi4(x0n_v, x0d_v);
|
||||
TEST_CHECK("20040928161846EJL", allequal_int4( res.quot, x0q_v ) && allequal_int4( res.rem, x0r_v ), 0);
|
||||
res = divi4(x1n_v, x1d_v);
|
||||
TEST_CHECK("20040928161851EJL", allequal_int4( res.quot, x1q_v ) && allequal_int4( res.rem, x1r_v ), 0);
|
||||
res = divi4(x2n_v, x2d_v);
|
||||
TEST_CHECK("20040928161855EJL", allequal_int4( res.quot, x2q_v ) && allequal_int4( res.rem, x2r_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
85
Extras/simdmathlibrary/ppu/tests/fabsf4.c
Normal file
85
Extras/simdmathlibrary/ppu/tests/fabsf4.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/* Testcase for fabsf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040915032605EJL","EJL", "fabsf");
|
||||
|
||||
unsigned int i3n = 0xff000000;
|
||||
unsigned int i3p = 0x7f000000;
|
||||
|
||||
float x0n = hide_float(-0.0f);
|
||||
float x0p = hide_float(0.0f);
|
||||
float x1n = hide_float(-83532.96153153f);
|
||||
float x1p = hide_float(83532.96153153f);
|
||||
float x2n = hide_float(-0.0000000013152f);
|
||||
float x2p = hide_float(0.0000000013152f);
|
||||
float x3n = hide_float(make_float(i3n));
|
||||
float x3p = hide_float(make_float(i3p));
|
||||
|
||||
vec_float4 x0n_v = vec_splat_float(x0n);
|
||||
vec_float4 x0p_v = vec_splat_float(x0p);
|
||||
vec_float4 x1n_v = vec_splat_float(x1n);
|
||||
vec_float4 x1p_v = vec_splat_float(x1p);
|
||||
vec_float4 x2n_v = vec_splat_float(x2n);
|
||||
vec_float4 x2p_v = vec_splat_float(x2p);
|
||||
vec_float4 x3n_v = vec_splat_float(x3n);
|
||||
vec_float4 x3p_v = vec_splat_float(x3p);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("fabsf4");
|
||||
res_v = fabsf4(x0n_v);
|
||||
TEST_CHECK("20040915032618EJL", allequal_float4( res_v, x0p_v ), 0);
|
||||
res_v = fabsf4(x0p_v);
|
||||
TEST_CHECK("20040915032632EJL", allequal_float4( res_v, x0p_v ), 0);
|
||||
res_v = fabsf4(x1n_v);
|
||||
TEST_CHECK("20040915032643EJL", allequal_float4( res_v, x1p_v ), 0);
|
||||
res_v = fabsf4(x1p_v);
|
||||
TEST_CHECK("20040915032654EJL", allequal_float4( res_v, x1p_v ), 0);
|
||||
res_v = fabsf4(x2n_v);
|
||||
TEST_CHECK("20040915032704EJL", allequal_float4( res_v, x2p_v ), 0);
|
||||
res_v = fabsf4(x2p_v);
|
||||
TEST_CHECK("20040915032712EJL", allequal_float4( res_v, x2p_v ), 0);
|
||||
res_v = fabsf4(x3n_v);
|
||||
TEST_CHECK("20040915032719EJL", allequal_float4( res_v, x3p_v ), 0);
|
||||
res_v = fabsf4(x3p_v);
|
||||
TEST_CHECK("20040915032729EJL", allequal_float4( res_v, x3p_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
189
Extras/simdmathlibrary/ppu/tests/floatingpoint_tests.h
Normal file
189
Extras/simdmathlibrary/ppu/tests/floatingpoint_tests.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/* Header file for common parts of the testsuite
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FLOATINGPOINT_TESTS_H_
|
||||
#define _FLOATINGPOINT_TESTS_H_
|
||||
|
||||
#if defined(__PPC__)
|
||||
#include <altivec.h>
|
||||
#define vec_uchar16 vector unsigned char
|
||||
#define vec_char16 vector signed char
|
||||
#define vec_ushort8 vector unsigned short
|
||||
#define vec_short8 vector signed short
|
||||
#define vec_uint4 vector unsigned int
|
||||
#define vec_int4 vector signed int
|
||||
#define vec_ullong2 vector unsigned long long
|
||||
#define vec_llong2 vector signed long long
|
||||
#define vec_float4 vector float
|
||||
#define vec_double2 vector double
|
||||
#else
|
||||
#if __SPU__
|
||||
#include <spu_intrinsics.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// To avoid type punning warnings (for printing in hex notation, doing bit-diff etc)
|
||||
typedef union {
|
||||
double d;
|
||||
unsigned char uc[8];
|
||||
unsigned int ui[2];
|
||||
unsigned long long int ull;
|
||||
} sce_math_alt_double;
|
||||
|
||||
typedef union {
|
||||
float f;
|
||||
unsigned char uc[4];
|
||||
unsigned int ui;
|
||||
} sce_math_alt_float;
|
||||
|
||||
#if (__PPC__ || __SPU__)
|
||||
typedef union {
|
||||
vec_int4 vsi;
|
||||
int si[4];
|
||||
} sce_math_alt_vec_int4;
|
||||
|
||||
typedef union {
|
||||
vec_uint4 vui;
|
||||
int ui[4];
|
||||
} sce_math_alt_vec_uint4;
|
||||
|
||||
typedef union {
|
||||
vec_float4 vf;
|
||||
float sf[4];
|
||||
unsigned int ui[4];
|
||||
} sce_math_alt_vec_float4;
|
||||
#endif
|
||||
#if __SPU__
|
||||
typedef union {
|
||||
double sd[2];
|
||||
vec_double2 vd;
|
||||
unsigned long long int ui[2];
|
||||
} sce_math_alt_vec_double2;
|
||||
#endif
|
||||
|
||||
#if __PPC__
|
||||
inline vec_int4 bitdiff4(vec_float4 ref, vec_float4 vals) {
|
||||
vec_int4 refi = (vec_int4)ref;
|
||||
vec_int4 valsi = (vec_int4)vals;
|
||||
vec_int4 diff = vec_sub(refi, valsi);
|
||||
vec_int4 negdiff = vec_sub(((vec_int4){0,0,0,0}), diff);
|
||||
|
||||
return vec_sel(negdiff, diff, vec_cmpgt(diff, ((vec_int4){0,0,0,0}) ));
|
||||
}
|
||||
inline int bitdiff(float ref, float val) {
|
||||
sce_math_alt_float aref, aval;
|
||||
aref.f = ref;
|
||||
aval.f = val;
|
||||
int diff = aref.ui - aval.ui;
|
||||
return (diff>0)?diff:-diff;
|
||||
}
|
||||
inline vec_int4 bitmatch4(vec_float4 ref, vec_float4 vals) {
|
||||
vec_int4 refi = (vec_int4)ref;
|
||||
vec_int4 valsi = (vec_int4)vals;
|
||||
vec_int4 diff = vec_sub(refi, valsi);
|
||||
vec_int4 negdiff = vec_sub(((vec_int4){0,0,0,0}), diff);
|
||||
|
||||
diff = vec_sel(negdiff, diff, vec_cmpgt(diff, ((vec_int4){0,0,0,0}) ));
|
||||
vec_float4 logdiff = vec_loge(vec_ctf(diff,0));
|
||||
return vec_sub(((vec_int4){32,32,32,32}), vec_cts(vec_ceil(logdiff),0));
|
||||
}
|
||||
inline int bitmatch(float ref, float val) {
|
||||
sce_math_alt_vec_float4 aref, aval;
|
||||
sce_math_alt_vec_int4 adiff;
|
||||
aref.sf[0] = ref;
|
||||
aval.sf[0] = val;
|
||||
adiff.vsi = bitmatch4(aref.vf, aval.vf);
|
||||
return adiff.si[0];
|
||||
}
|
||||
inline float extractFloat(vec_float4 vf, int index)
|
||||
{
|
||||
sce_math_alt_vec_float4 vec;
|
||||
vec.vf = vf;
|
||||
return vec.sf[index];
|
||||
}
|
||||
inline int extractInt(vec_int4 vi, int index)
|
||||
{
|
||||
sce_math_alt_vec_int4 vec;
|
||||
vec.vsi = vi;
|
||||
return vec.si[index];
|
||||
}
|
||||
inline int extractUInt(vec_uint4 vi, int index)
|
||||
{
|
||||
sce_math_alt_vec_uint4 vec;
|
||||
vec.vui = vi;
|
||||
return vec.ui[index];
|
||||
}
|
||||
#else
|
||||
#if __SPU__
|
||||
inline vec_int4 bitdiff4(vec_float4 ref, vec_float4 vals) {
|
||||
vec_int4 refi = (vec_int4)ref;
|
||||
vec_int4 valsi = (vec_int4)vals;
|
||||
vec_int4 diff = spu_sub(refi, valsi);
|
||||
vec_int4 negdiff = spu_sub(spu_splats((int)0), diff);
|
||||
|
||||
return spu_sel(negdiff, diff, (vec_uchar16)spu_cmpgt(diff, 0));
|
||||
}
|
||||
inline int bitdiff(float ref, float val) {
|
||||
return spu_extract(bitdiff4(spu_promote(ref,0), spu_promote(val,0)), 0);
|
||||
}
|
||||
inline vec_int4 bitmatch4(vec_float4 ref, vec_float4 vals) {
|
||||
vec_int4 refi = (vec_int4)ref;
|
||||
vec_int4 valsi = (vec_int4)vals;
|
||||
vec_int4 diff = spu_sub(refi, valsi);
|
||||
vec_int4 negdiff = spu_sub(spu_splats((int)0), diff);
|
||||
|
||||
return (vec_int4)spu_cntlz(spu_sel(negdiff, diff, (vec_uchar16)spu_cmpgt(diff, 0)));
|
||||
}
|
||||
inline int bitmatch(float ref, float val) {
|
||||
return spu_extract(bitmatch4(spu_promote(ref,0), spu_promote(val,0)), 0);
|
||||
}
|
||||
|
||||
#else
|
||||
inline int bitdiff(sce_math_alt_float ref, sce_math_alt_float val) {
|
||||
int diff = ref.ui - val.ui;
|
||||
return((diff>0)?diff:-diff);
|
||||
}
|
||||
inline int bitmatch(sce_math_alt_float ref, sce_math_alt_float val) {
|
||||
int diff, i;
|
||||
unsigned int udiff;
|
||||
diff = ref.ui - val.ui;
|
||||
udiff = (diff>0) ? diff : -diff;
|
||||
i = 32;
|
||||
while(udiff != 0) {
|
||||
i = i-1;
|
||||
udiff = udiff >> 1;
|
||||
}
|
||||
return udiff;
|
||||
}
|
||||
#endif // __SPU__
|
||||
#endif // __PPC__
|
||||
|
||||
|
||||
#endif // _FLOATINGPOINT_TESTS_H_
|
||||
92
Extras/simdmathlibrary/ppu/tests/floorf4.c
Normal file
92
Extras/simdmathlibrary/ppu/tests/floorf4.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/* Testcase for floorf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040916145017EJL","EJL", "floorf");
|
||||
|
||||
unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value.
|
||||
unsigned int i3i = 0x4afffffe;
|
||||
unsigned int i4 = 0x4b000000; // 2^23, no fractional part.
|
||||
unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value.
|
||||
|
||||
float x0 = hide_float(0.91825f);
|
||||
float x0i = hide_float(0.0f);
|
||||
float x1 = hide_float(-0.12958f);
|
||||
float x1i = hide_float(-1.0f);
|
||||
float x2 = hide_float(-79615.1875f);
|
||||
float x2i = hide_float(-79616.0f);
|
||||
float x3 = hide_float(make_float(i3));
|
||||
float x3i = hide_float(make_float(i3i));
|
||||
float x4 = hide_float(make_float(i4));
|
||||
float x4i = hide_float(make_float(i4));
|
||||
float x5 = hide_float(make_float(i5));
|
||||
float x5i = hide_float(make_float(i5));
|
||||
|
||||
vec_float4 x0_v = vec_splat_float(x0);
|
||||
vec_float4 x0i_v = vec_splat_float(x0i);
|
||||
vec_float4 x1_v = vec_splat_float(x1);
|
||||
vec_float4 x1i_v = vec_splat_float(x1i);
|
||||
vec_float4 x2_v = vec_splat_float(x2);
|
||||
vec_float4 x2i_v = vec_splat_float(x2i);
|
||||
vec_float4 x3_v = vec_splat_float(x3);
|
||||
vec_float4 x3i_v = vec_splat_float(x3i);
|
||||
vec_float4 x4_v = vec_splat_float(x4);
|
||||
vec_float4 x4i_v = vec_splat_float(x4i);
|
||||
vec_float4 x5_v = vec_splat_float(x5);
|
||||
vec_float4 x5i_v = vec_splat_float(x5i);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("floorf4");
|
||||
res_v = floorf4(x0_v);
|
||||
TEST_CHECK("20040916145022EJL", allequal_float4( res_v, x0i_v ), 0);
|
||||
res_v = floorf4(x1_v);
|
||||
TEST_CHECK("20040916145024EJL", allequal_float4( res_v, x1i_v ), 0);
|
||||
res_v = floorf4(x2_v);
|
||||
TEST_CHECK("20040916145027EJL", allequal_float4( res_v, x2i_v ), 0);
|
||||
res_v = floorf4(x3_v);
|
||||
TEST_CHECK("20040916145029EJL", allequal_float4( res_v, x3i_v ), 0);
|
||||
res_v = floorf4(x4_v);
|
||||
TEST_CHECK("20040916145032EJL", allequal_float4( res_v, x4i_v ), 0);
|
||||
res_v = floorf4(x5_v);
|
||||
TEST_CHECK("20040916145034EJL", allequal_float4( res_v, x5i_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
91
Extras/simdmathlibrary/ppu/tests/fminf4_fmaxf4.c
Normal file
91
Extras/simdmathlibrary/ppu/tests/fminf4_fmaxf4.c
Normal file
@@ -0,0 +1,91 @@
|
||||
/* Testcase for fminf4 and fmaxf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040928184342EJL","EJL", "fminf4_fmaxf4");
|
||||
|
||||
float x0min = hide_float(1760.135f);
|
||||
float x0max = hide_float(19355.03f);
|
||||
|
||||
float x1min = hide_float(-12351.9f);
|
||||
float x1max = hide_float(-139.035f);
|
||||
|
||||
float x2min = hide_float(-1.0);
|
||||
float x2max = hide_float(0.0);
|
||||
|
||||
vec_float4 x0min_v = vec_splat_float(x0min);
|
||||
vec_float4 x0max_v = vec_splat_float(x0max);
|
||||
|
||||
vec_float4 x1min_v = vec_splat_float(x1min);
|
||||
vec_float4 x1max_v = vec_splat_float(x1max);
|
||||
|
||||
vec_float4 x2min_v = vec_splat_float(x2min);
|
||||
vec_float4 x2max_v = vec_splat_float(x2max);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("fminf4");
|
||||
res_v = fminf4(x0min_v, x0max_v);
|
||||
TEST_CHECK("20040928184345EJL", allequal_float4( res_v, x0min_v ), 0);
|
||||
res_v = fminf4(x0max_v, x0min_v);
|
||||
TEST_CHECK("20040928184349EJL", allequal_float4( res_v, x0min_v ), 0);
|
||||
res_v = fminf4(x1min_v, x1max_v);
|
||||
TEST_CHECK("20040928184351EJL", allequal_float4( res_v, x1min_v ), 0);
|
||||
res_v = fminf4(x1max_v, x1min_v);
|
||||
TEST_CHECK("20040928184353EJL", allequal_float4( res_v, x1min_v ), 0);
|
||||
res_v = fminf4(x2min_v, x2max_v);
|
||||
TEST_CHECK("20040928184354EJL", allequal_float4( res_v, x2min_v ), 0);
|
||||
res_v = fminf4(x2max_v, x2min_v);
|
||||
TEST_CHECK("20040928184356EJL", allequal_float4( res_v, x2min_v ), 0);
|
||||
|
||||
TEST_START("fmaxf4");
|
||||
res_v = fmaxf4(x0min_v, x0max_v);
|
||||
TEST_CHECK("20040928184411EJL", allequal_float4( res_v, x0max_v ), 0);
|
||||
res_v = fmaxf4(x0max_v, x0min_v);
|
||||
TEST_CHECK("20040928184413EJL", allequal_float4( res_v, x0max_v ), 0);
|
||||
res_v = fmaxf4(x1min_v, x1max_v);
|
||||
TEST_CHECK("20040928184415EJL", allequal_float4( res_v, x1max_v ), 0);
|
||||
res_v = fmaxf4(x1max_v, x1min_v);
|
||||
TEST_CHECK("20040928184416EJL", allequal_float4( res_v, x1max_v ), 0);
|
||||
res_v = fmaxf4(x2min_v, x2max_v);
|
||||
TEST_CHECK("20040928184417EJL", allequal_float4( res_v, x2max_v ), 0);
|
||||
res_v = fmaxf4(x2max_v, x2min_v);
|
||||
TEST_CHECK("20040928184419EJL", allequal_float4( res_v, x2max_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
129
Extras/simdmathlibrary/ppu/tests/fmodf4.c
Normal file
129
Extras/simdmathlibrary/ppu/tests/fmodf4.c
Normal file
@@ -0,0 +1,129 @@
|
||||
/* Testcase for fmodf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040928191240EJL","EJL", "fmodf4");
|
||||
|
||||
unsigned int i0n = 0x449edbc6;
|
||||
unsigned int i0d = 0x40cf799d;
|
||||
unsigned int i0r = 0x3daa7300;
|
||||
unsigned int i1n = 0x6bca107a;
|
||||
unsigned int i1d = 0x6c4a107a;
|
||||
unsigned int i1r = 0x6bca107a;
|
||||
unsigned int i2n = 0x1c123605;
|
||||
unsigned int i2d = 0x1c923602;
|
||||
unsigned int i2r = 0x1c123605;
|
||||
unsigned int i3n = 0x2b4c50fa;
|
||||
unsigned int i3d = 0x253a3ae3;
|
||||
unsigned int i3r = 0x25141df9;
|
||||
unsigned int i4n = 0x73addffc;
|
||||
unsigned int i4d = 0x742ddffc;
|
||||
unsigned int i4r = 0x73addffc;
|
||||
unsigned int i5n = 0x29d4d97c;
|
||||
unsigned int i5d = 0x2a546e77;
|
||||
unsigned int i5r = 0x29d4d97c;
|
||||
|
||||
float x0n = hide_float(make_float(i0n));
|
||||
float x0d = hide_float(make_float(i0d));
|
||||
float x0r = hide_float(make_float(i0r));
|
||||
|
||||
float x1n = hide_float(make_float(i1n));
|
||||
float x1d = hide_float(make_float(i1d));
|
||||
float x1r = hide_float(make_float(i1r));
|
||||
|
||||
float x2n = hide_float(make_float(i2n));
|
||||
float x2d = hide_float(make_float(i2d));
|
||||
float x2r = hide_float(make_float(i2r));
|
||||
|
||||
float x3n = hide_float(make_float(i3n));
|
||||
float x3d = hide_float(make_float(i3d));
|
||||
float x3r = hide_float(make_float(i3r));
|
||||
|
||||
float x4n = hide_float(make_float(i4n));
|
||||
float x4d = hide_float(make_float(i4d));
|
||||
float x4r = hide_float(make_float(i4r));
|
||||
|
||||
float x5n = hide_float(make_float(i5n));
|
||||
float x5d = hide_float(make_float(i5d));
|
||||
float x5r = hide_float(make_float(i5r));
|
||||
|
||||
vec_float4 x0n_v = vec_splat_float(x0n);
|
||||
vec_float4 x0d_v = vec_splat_float(x0d);
|
||||
vec_float4 x0r_v = vec_splat_float(x0r);
|
||||
|
||||
vec_float4 x1n_v = vec_splat_float(x1n);
|
||||
vec_float4 x1d_v = vec_splat_float(x1d);
|
||||
vec_float4 x1r_v = vec_splat_float(x1r);
|
||||
|
||||
vec_float4 x2n_v = vec_splat_float(x2n);
|
||||
vec_float4 x2d_v = vec_splat_float(x2d);
|
||||
vec_float4 x2r_v = vec_splat_float(x2r);
|
||||
|
||||
vec_float4 x3n_v = vec_splat_float(x3n);
|
||||
vec_float4 x3d_v = vec_splat_float(x3d);
|
||||
vec_float4 x3r_v = vec_splat_float(x3r);
|
||||
|
||||
vec_float4 x4n_v = vec_splat_float(x4n);
|
||||
vec_float4 x4d_v = vec_splat_float(x4d);
|
||||
vec_float4 x4r_v = vec_splat_float(x4r);
|
||||
|
||||
vec_float4 x5n_v = vec_splat_float(x5n);
|
||||
vec_float4 x5d_v = vec_splat_float(x5d);
|
||||
vec_float4 x5r_v = vec_splat_float(x5r);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("fmodf4");
|
||||
res_v = fmodf4(x0n_v, x0d_v);
|
||||
TEST_CHECK("20040928191245EJL", allequal_ulps_float4( res_v, x0r_v, 1 ), 0);
|
||||
res_v = fmodf4(x1n_v, x1d_v);
|
||||
TEST_CHECK("20040928191247EJL", allequal_ulps_float4( res_v, x1r_v, 1 ), 0);
|
||||
res_v = fmodf4(x2n_v, x2d_v);
|
||||
TEST_CHECK("20040928191249EJL", allequal_ulps_float4( res_v, x2r_v, 1 ), 0);
|
||||
res_v = fmodf4(x3n_v, x3d_v);
|
||||
TEST_CHECK("20040928191251EJL", allequal_ulps_float4( res_v, x3r_v, 1 ), 0);
|
||||
res_v = fmodf4(x4n_v, x4d_v);
|
||||
TEST_CHECK("20040928191253EJL", allequal_ulps_float4( res_v, x4r_v, 1 ), 0);
|
||||
res_v = fmodf4(x5n_v, x5d_v);
|
||||
TEST_CHECK("20040928191255EJL", allequal_ulps_float4( res_v, x5r_v, 1 ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
108
Extras/simdmathlibrary/ppu/tests/modff4.c
Normal file
108
Extras/simdmathlibrary/ppu/tests/modff4.c
Normal file
@@ -0,0 +1,108 @@
|
||||
/* Testcase for modff4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040916170642EJL", "EJL", "modff");
|
||||
|
||||
unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value.
|
||||
unsigned int i3i = 0x4afffffe;
|
||||
unsigned int i4 = 0x4b000000; // 2^23, no fractional part.
|
||||
unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value.
|
||||
|
||||
float x0 = hide_float(0.91825f);
|
||||
float x0i = hide_float(0.0f);
|
||||
float x0f = hide_float(0.91825f);
|
||||
|
||||
float x1 = hide_float(-0.12958f);
|
||||
float x1i = hide_float(0.0f);
|
||||
float x1f = hide_float(-0.12958f);
|
||||
|
||||
float x2 = hide_float(-79615.1875f);
|
||||
float x2i = hide_float(-79615.0f);
|
||||
float x2f = hide_float(-0.1875f);
|
||||
|
||||
float x3 = hide_float(make_float(i3));
|
||||
float x3i = hide_float(make_float(i3i));
|
||||
float x3f = hide_float(0.5f);
|
||||
|
||||
float x4 = hide_float(make_float(i4));
|
||||
float x4i = hide_float(make_float(i4));
|
||||
float x4f = hide_float(0.0f);
|
||||
|
||||
float x5 = hide_float(make_float(i5));
|
||||
float x5i = hide_float(make_float(i5));
|
||||
float x5f = hide_float(0.0f);
|
||||
|
||||
vec_float4 x0_v = vec_splat_float(x0);
|
||||
vec_float4 x0i_v = vec_splat_float(x0i);
|
||||
vec_float4 x0f_v = vec_splat_float(x0f);
|
||||
vec_float4 x1_v = vec_splat_float(x1);
|
||||
vec_float4 x1i_v = vec_splat_float(x1i);
|
||||
vec_float4 x1f_v = vec_splat_float(x1f);
|
||||
vec_float4 x2_v = vec_splat_float(x2);
|
||||
vec_float4 x2i_v = vec_splat_float(x2i);
|
||||
vec_float4 x2f_v = vec_splat_float(x2f);
|
||||
vec_float4 x3_v = vec_splat_float(x3);
|
||||
vec_float4 x3i_v = vec_splat_float(x3i);
|
||||
vec_float4 x3f_v = vec_splat_float(x3f);
|
||||
vec_float4 x4_v = vec_splat_float(x4);
|
||||
vec_float4 x4i_v = vec_splat_float(x4i);
|
||||
vec_float4 x4f_v = vec_splat_float(x4f);
|
||||
vec_float4 x5_v = vec_splat_float(x5);
|
||||
vec_float4 x5i_v = vec_splat_float(x5i);
|
||||
vec_float4 x5f_v = vec_splat_float(x5f);
|
||||
|
||||
vec_float4 integer_v, fraction_v;
|
||||
|
||||
TEST_START("modff4");
|
||||
fraction_v = modff4(x0_v, &integer_v);
|
||||
TEST_CHECK("20040916170647EJL", allequal_float4( integer_v, x0i_v ) && allequal_float4( fraction_v, x0f_v ), 0);
|
||||
fraction_v = modff4(x1_v, &integer_v);
|
||||
TEST_CHECK("20040916170650EJL", allequal_float4( integer_v, x1i_v ) && allequal_float4( fraction_v, x1f_v ), 0);
|
||||
fraction_v = modff4(x2_v, &integer_v);
|
||||
TEST_CHECK("20040916170653EJL", allequal_float4( integer_v, x2i_v ) && allequal_float4( fraction_v, x2f_v ), 0);
|
||||
fraction_v = modff4(x3_v, &integer_v);
|
||||
TEST_CHECK("20040916170656EJL", allequal_float4( integer_v, x3i_v ) && allequal_float4( fraction_v, x3f_v ), 0);
|
||||
fraction_v = modff4(x4_v, &integer_v);
|
||||
TEST_CHECK("20040916170658EJL", allequal_float4( integer_v, x4i_v ) && allequal_float4( fraction_v, x4f_v ), 0);
|
||||
fraction_v = modff4(x5_v, &integer_v);
|
||||
TEST_CHECK("20040916170701EJL", allequal_float4( integer_v, x5i_v ) && allequal_float4( fraction_v, x5f_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
86
Extras/simdmathlibrary/ppu/tests/negatef4.c
Normal file
86
Extras/simdmathlibrary/ppu/tests/negatef4.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/* Testcase for negatef4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040930102649EJL","EJL", "negatef4");
|
||||
|
||||
unsigned int i3n = 0xff000000;
|
||||
unsigned int i3p = 0x7f000000;
|
||||
|
||||
float x0n = hide_float(-0.0f);
|
||||
float x0p = hide_float(0.0f);
|
||||
float x1n = hide_float(-83532.96153153f);
|
||||
float x1p = hide_float(83532.96153153f);
|
||||
float x2n = hide_float(-0.0000000013152f);
|
||||
float x2p = hide_float(0.0000000013152f);
|
||||
float x3n = hide_float(make_float(i3n));
|
||||
float x3p = hide_float(make_float(i3p));
|
||||
|
||||
vec_float4 x0n_v = vec_splat_float(x0n);
|
||||
vec_float4 x0p_v = vec_splat_float(x0p);
|
||||
vec_float4 x1n_v = vec_splat_float(x1n);
|
||||
vec_float4 x1p_v = vec_splat_float(x1p);
|
||||
vec_float4 x2n_v = vec_splat_float(x2n);
|
||||
vec_float4 x2p_v = vec_splat_float(x2p);
|
||||
vec_float4 x3n_v = vec_splat_float(x3n);
|
||||
vec_float4 x3p_v = vec_splat_float(x3p);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("negatef4");
|
||||
res_v = negatef4(x0n_v);
|
||||
TEST_CHECK("20040930102652EJL", allequal_float4( res_v, x0p_v ), 0);
|
||||
res_v = negatef4(x0p_v);
|
||||
TEST_CHECK("20040930102653EJL", allequal_float4( res_v, x0n_v ), 0);
|
||||
res_v = negatef4(x1n_v);
|
||||
TEST_CHECK("20040930102655EJL", allequal_float4( res_v, x1p_v ), 0);
|
||||
res_v = negatef4(x1p_v);
|
||||
TEST_CHECK("20040930102657EJL", allequal_float4( res_v, x1n_v ), 0);
|
||||
res_v = negatef4(x2n_v);
|
||||
TEST_CHECK("20040930102659EJL", allequal_float4( res_v, x2p_v ), 0);
|
||||
res_v = negatef4(x2p_v);
|
||||
TEST_CHECK("20040930102701EJL", allequal_float4( res_v, x2n_v ), 0);
|
||||
res_v = negatef4(x3n_v);
|
||||
TEST_CHECK("20040930102703EJL", allequal_float4( res_v, x3p_v ), 0);
|
||||
res_v = negatef4(x3p_v);
|
||||
TEST_CHECK("20040930102705EJL", allequal_float4( res_v, x3n_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
83
Extras/simdmathlibrary/ppu/tests/negatei4.c
Normal file
83
Extras/simdmathlibrary/ppu/tests/negatei4.c
Normal file
@@ -0,0 +1,83 @@
|
||||
/* Testcase for negatei4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040930102649EJL","EJL", "negatei4");
|
||||
|
||||
int x0n = hide_int(0);
|
||||
int x0p = hide_int(0);
|
||||
int x1n = hide_int(-83532);
|
||||
int x1p = hide_int(83532);
|
||||
int x2n = hide_int(-13152);
|
||||
int x2p = hide_int(13152);
|
||||
int x3n = hide_int(-1);
|
||||
int x3p = hide_int(1);
|
||||
|
||||
vec_int4 x0n_v = vec_splat_int(x0n);
|
||||
vec_int4 x0p_v = vec_splat_int(x0p);
|
||||
vec_int4 x1n_v = vec_splat_int(x1n);
|
||||
vec_int4 x1p_v = vec_splat_int(x1p);
|
||||
vec_int4 x2n_v = vec_splat_int(x2n);
|
||||
vec_int4 x2p_v = vec_splat_int(x2p);
|
||||
vec_int4 x3n_v = vec_splat_int(x3n);
|
||||
vec_int4 x3p_v = vec_splat_int(x3p);
|
||||
|
||||
vec_int4 res_v;
|
||||
|
||||
TEST_START("negatei4");
|
||||
res_v = negatei4(x0n_v);
|
||||
TEST_CHECK("20040930102652EJL", allequal_int4( res_v, x0p_v ), 0);
|
||||
res_v = negatei4(x0p_v);
|
||||
TEST_CHECK("20040930102653EJL", allequal_int4( res_v, x0n_v ), 0);
|
||||
res_v = negatei4(x1n_v);
|
||||
TEST_CHECK("20040930102655EJL", allequal_int4( res_v, x1p_v ), 0);
|
||||
res_v = negatei4(x1p_v);
|
||||
TEST_CHECK("20040930102657EJL", allequal_int4( res_v, x1n_v ), 0);
|
||||
res_v = negatei4(x2n_v);
|
||||
TEST_CHECK("20040930102659EJL", allequal_int4( res_v, x2p_v ), 0);
|
||||
res_v = negatei4(x2p_v);
|
||||
TEST_CHECK("20040930102701EJL", allequal_int4( res_v, x2n_v ), 0);
|
||||
res_v = negatei4(x3n_v);
|
||||
TEST_CHECK("20040930102703EJL", allequal_int4( res_v, x3p_v ), 0);
|
||||
res_v = negatei4(x3p_v);
|
||||
TEST_CHECK("20040930102705EJL", allequal_int4( res_v, x3n_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
108
Extras/simdmathlibrary/ppu/tests/recipf4.c
Normal file
108
Extras/simdmathlibrary/ppu/tests/recipf4.c
Normal file
@@ -0,0 +1,108 @@
|
||||
/* Testcase for recipf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040920142553EJL","EJL", "recipf4");
|
||||
|
||||
unsigned int i1 = 0xff000000; // -2^127
|
||||
unsigned int i2 = 0xfe7fffff; // -2^126 - 1 ulp
|
||||
unsigned int i2r = 0x80800001;
|
||||
unsigned int i3 = 0x75013340; // random values
|
||||
unsigned int i3r = 0x09fd9f35;
|
||||
unsigned int i4 = 0x75e7753f;
|
||||
unsigned int i4r = 0x090d9277;
|
||||
unsigned int i5 = 0x4c7fed5a;
|
||||
unsigned int i5r = 0x32800954;
|
||||
unsigned int i6 = 0x3a0731f0;
|
||||
unsigned int i6r = 0x44f2602e;
|
||||
unsigned int i7 = 0x69784a07;
|
||||
unsigned int i7r = 0x1583f9a3;
|
||||
|
||||
float x1 = hide_float(make_float(i1));
|
||||
float x1r = hide_float(0.0f);
|
||||
float x2 = hide_float(make_float(i2));
|
||||
float x2r = hide_float(make_float(i2r));
|
||||
float x3 = hide_float(make_float(i3));
|
||||
float x3r = hide_float(make_float(i3r));
|
||||
float x4 = hide_float(make_float(i4));
|
||||
float x4r = hide_float(make_float(i4r));
|
||||
float x5 = hide_float(make_float(i5));
|
||||
float x5r = hide_float(make_float(i5r));
|
||||
float x6 = hide_float(make_float(i6));
|
||||
float x6r = hide_float(make_float(i6r));
|
||||
float x7 = hide_float(make_float(i7));
|
||||
float x7r = hide_float(make_float(i7r));
|
||||
|
||||
vec_float4 x1_v = vec_splat_float(x1);
|
||||
vec_float4 x1r_v = vec_splat_float(x1r);
|
||||
vec_float4 x2_v = vec_splat_float(x2);
|
||||
vec_float4 x2r_v = vec_splat_float(x2r);
|
||||
vec_float4 x3_v = vec_splat_float(x3);
|
||||
vec_float4 x3r_v = vec_splat_float(x3r);
|
||||
vec_float4 x4_v = vec_splat_float(x4);
|
||||
vec_float4 x4r_v = vec_splat_float(x4r);
|
||||
vec_float4 x5_v = vec_splat_float(x5);
|
||||
vec_float4 x5r_v = vec_splat_float(x5r);
|
||||
vec_float4 x6_v = vec_splat_float(x6);
|
||||
vec_float4 x6r_v = vec_splat_float(x6r);
|
||||
vec_float4 x7_v = vec_splat_float(x7);
|
||||
vec_float4 x7r_v = vec_splat_float(x7r);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("recipf4");
|
||||
res_v = recipf4(x1_v);
|
||||
TEST_CHECK("20040920142600EJL", allequal_float4( res_v, x1r_v), 0);
|
||||
res_v = recipf4(x2_v);
|
||||
TEST_CHECK("20040920142602EJL", allequal_ulps_float4( res_v, x2r_v, 2 ), 0);
|
||||
res_v = recipf4(x3_v);
|
||||
TEST_CHECK("20040920142604EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0);
|
||||
res_v = recipf4(x4_v);
|
||||
TEST_CHECK("20040920142606EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0);
|
||||
res_v = recipf4(x5_v);
|
||||
TEST_CHECK("20040920142608EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0);
|
||||
res_v = recipf4(x6_v);
|
||||
TEST_CHECK("20040920142609EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0);
|
||||
res_v = recipf4(x7_v);
|
||||
TEST_CHECK("20040920142611EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
95
Extras/simdmathlibrary/ppu/tests/rsqrtf4.c
Normal file
95
Extras/simdmathlibrary/ppu/tests/rsqrtf4.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/* Testcase for rsqrtf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040928182349EJL","EJL", "rsqrtf4");
|
||||
|
||||
unsigned int i3 = 0x742c4455;
|
||||
unsigned int i3r = 0x251c099a;
|
||||
unsigned int i4 = 0x75e7753f;
|
||||
unsigned int i4r = 0x243e5fe2;
|
||||
unsigned int i5 = 0x4baa9e3c;
|
||||
unsigned int i5r = 0x395dbbeb;
|
||||
unsigned int i6 = 0x39344296;
|
||||
unsigned int i6r = 0x429889eb;
|
||||
unsigned int i7 = 0x68a586b0;
|
||||
unsigned int i7r = 0x2ae11e67;
|
||||
|
||||
float x3 = hide_float(make_float(i3));
|
||||
float x3r = hide_float(make_float(i3r));
|
||||
float x4 = hide_float(make_float(i4));
|
||||
float x4r = hide_float(make_float(i4r));
|
||||
float x5 = hide_float(make_float(i5));
|
||||
float x5r = hide_float(make_float(i5r));
|
||||
float x6 = hide_float(make_float(i6));
|
||||
float x6r = hide_float(make_float(i6r));
|
||||
float x7 = hide_float(make_float(i7));
|
||||
float x7r = hide_float(make_float(i7r));
|
||||
|
||||
vec_float4 x3_v = vec_splat_float(x3);
|
||||
vec_float4 x3r_v = vec_splat_float(x3r);
|
||||
vec_float4 x4_v = vec_splat_float(x4);
|
||||
vec_float4 x4r_v = vec_splat_float(x4r);
|
||||
vec_float4 x5_v = vec_splat_float(x5);
|
||||
vec_float4 x5r_v = vec_splat_float(x5r);
|
||||
vec_float4 x6_v = vec_splat_float(x6);
|
||||
vec_float4 x6r_v = vec_splat_float(x6r);
|
||||
vec_float4 x7_v = vec_splat_float(x7);
|
||||
vec_float4 x7r_v = vec_splat_float(x7r);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("rsqrtf4");
|
||||
res_v = rsqrtf4(x3_v);
|
||||
TEST_CHECK("20040928182352EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0);
|
||||
res_v = rsqrtf4(x4_v);
|
||||
TEST_CHECK("20040928182355EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0);
|
||||
res_v = rsqrtf4(x5_v);
|
||||
TEST_CHECK("20040928182357EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0);
|
||||
res_v = rsqrtf4(x6_v);
|
||||
TEST_CHECK("20040928182358EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0);
|
||||
res_v = rsqrtf4(x7_v);
|
||||
TEST_CHECK("20040928182401EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
100
Extras/simdmathlibrary/ppu/tests/sqrtf4.c
Normal file
100
Extras/simdmathlibrary/ppu/tests/sqrtf4.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/* Testcase for sqrtf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040928182549EJL","EJL", "sqrtf4");
|
||||
|
||||
unsigned int i3 = 0x742c4455;
|
||||
unsigned int i3r = 0x59d20034;
|
||||
unsigned int i4 = 0x75e7753f;
|
||||
unsigned int i4r = 0x5aac1fb5;
|
||||
unsigned int i5 = 0x4baa9e3c;
|
||||
unsigned int i5r = 0x4593c7d8;
|
||||
unsigned int i6 = 0x39344296;
|
||||
unsigned int i6r = 0x3c56d14c;
|
||||
unsigned int i7 = 0x68a586b0;
|
||||
unsigned int i7r = 0x54118f09;
|
||||
|
||||
float x0 = hide_float(0.0f);
|
||||
float x0r = hide_float(0.0f);
|
||||
|
||||
float x3 = hide_float(make_float(i3));
|
||||
float x3r = hide_float(make_float(i3r));
|
||||
float x4 = hide_float(make_float(i4));
|
||||
float x4r = hide_float(make_float(i4r));
|
||||
float x5 = hide_float(make_float(i5));
|
||||
float x5r = hide_float(make_float(i5r));
|
||||
float x6 = hide_float(make_float(i6));
|
||||
float x6r = hide_float(make_float(i6r));
|
||||
float x7 = hide_float(make_float(i7));
|
||||
float x7r = hide_float(make_float(i7r));
|
||||
|
||||
vec_float4 x0_v = vec_splat_float(x0);
|
||||
vec_float4 x0r_v = vec_splat_float(x0r);
|
||||
|
||||
vec_float4 x3_v = vec_splat_float(x3);
|
||||
vec_float4 x3r_v = vec_splat_float(x3r);
|
||||
vec_float4 x4_v = vec_splat_float(x4);
|
||||
vec_float4 x4r_v = vec_splat_float(x4r);
|
||||
vec_float4 x5_v = vec_splat_float(x5);
|
||||
vec_float4 x5r_v = vec_splat_float(x5r);
|
||||
vec_float4 x6_v = vec_splat_float(x6);
|
||||
vec_float4 x6r_v = vec_splat_float(x6r);
|
||||
vec_float4 x7_v = vec_splat_float(x7);
|
||||
vec_float4 x7r_v = vec_splat_float(x7r);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("sqrtf4");
|
||||
res_v = sqrtf4(x0_v);
|
||||
TEST_CHECK("20040928182551EJL", allequal_float4( res_v, x0r_v ), 0);
|
||||
res_v = sqrtf4(x3_v);
|
||||
TEST_CHECK("20040928182552EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0);
|
||||
res_v = sqrtf4(x4_v);
|
||||
TEST_CHECK("20040928182554EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0);
|
||||
res_v = sqrtf4(x5_v);
|
||||
TEST_CHECK("20040928182556EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0);
|
||||
res_v = sqrtf4(x6_v);
|
||||
TEST_CHECK("20040928182557EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0);
|
||||
res_v = sqrtf4(x7_v);
|
||||
TEST_CHECK("20040928182559EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
67
Extras/simdmathlibrary/ppu/tests/testutils.c
Normal file
67
Extras/simdmathlibrary/ppu/tests/testutils.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/* Common part of the testsuite
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
hide_uint( unsigned int x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
hide_int( int x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
float
|
||||
hide_float( float x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
double
|
||||
hide_double( double x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
float
|
||||
make_float( unsigned int x )
|
||||
{
|
||||
|
||||
union
|
||||
{
|
||||
unsigned int i;
|
||||
float f;
|
||||
}fi;
|
||||
fi.i = x;
|
||||
return fi.f;
|
||||
}
|
||||
|
||||
|
||||
100
Extras/simdmathlibrary/ppu/tests/testutils.h
Normal file
100
Extras/simdmathlibrary/ppu/tests/testutils.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/* Header file for common parts of the testsuite
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/* FIXME: Don't use altivec style initializers. */
|
||||
|
||||
#ifndef _TESTUTILS_H_
|
||||
|
||||
#include "floatingpoint_tests.h"
|
||||
|
||||
extern unsigned int hide_uint( unsigned int x );
|
||||
extern int hide_int( int x );
|
||||
extern float hide_float( float x );
|
||||
extern float make_float( unsigned int x );
|
||||
|
||||
inline vec_int4 vec_splat_int( int x )
|
||||
{
|
||||
return (vec_int4){x, x, x, x};
|
||||
}
|
||||
|
||||
inline vec_float4 vec_splat_float( float x )
|
||||
{
|
||||
return (vec_float4){x, x, x, x};
|
||||
}
|
||||
|
||||
inline vec_uint4 bitDiff_f4(vec_float4 ref, vec_float4 vals) {
|
||||
vec_int4 refi = (vec_int4)ref;
|
||||
vec_int4 valsi = (vec_int4)vals;
|
||||
vec_int4 diff = vec_sub( refi, valsi );
|
||||
vec_int4 negdiff = vec_sub( vec_splat_int(0), diff );
|
||||
vec_uint4 lz;
|
||||
|
||||
diff = vec_sel( negdiff, diff, vec_cmpgt( diff, vec_splat_int(0) ) );
|
||||
|
||||
lz = vec_sub( (vec_uint4)vec_splat_int(158), vec_sr( (vec_uint4)vec_ctf( diff, 0 ), (vec_uint4)vec_splat_int(23) ) );
|
||||
lz = vec_sel( lz, (vec_uint4)vec_splat_int(32), vec_cmpeq( diff, vec_splat_int(0) ) );
|
||||
|
||||
return vec_sub( (vec_uint4)vec_splat_int(32), lz );
|
||||
}
|
||||
|
||||
inline vec_uint4 ulpDiff_f4(vec_float4 ref, vec_float4 vals) {
|
||||
vec_int4 refi = (vec_int4)ref;
|
||||
vec_int4 valsi = (vec_int4)vals;
|
||||
vec_int4 diff = vec_sub( refi, valsi );
|
||||
vec_int4 negdiff = vec_sub( vec_splat_int(0), diff );
|
||||
|
||||
return (vec_uint4)( vec_sel( negdiff, diff, vec_cmpgt( diff, vec_splat_int(0) ) ) );
|
||||
}
|
||||
|
||||
inline int allequal_int4( vec_int4 x, vec_int4 y )
|
||||
{
|
||||
return ( vec_all_eq( x, y ) );
|
||||
}
|
||||
|
||||
inline int allequal_float4( vec_float4 x, vec_float4 y )
|
||||
{
|
||||
return ( vec_all_eq( x, y ) );
|
||||
}
|
||||
|
||||
inline int allequal_ulps_float4( vec_float4 x, vec_float4 y, int tolerance )
|
||||
{
|
||||
vec_uint4 vtol = (vec_uint4)vec_splat_int( tolerance );
|
||||
vec_uint4 ulps = ulpDiff_f4( x, y );
|
||||
return vec_all_le( ulps, vtol );
|
||||
}
|
||||
|
||||
inline int allequal_bits_float4( vec_float4 x, vec_float4 y, int tolerance )
|
||||
{
|
||||
vec_uint4 vtol = (vec_uint4)vec_splat_int( tolerance );
|
||||
vec_uint4 bits = bitDiff_f4( x, y );
|
||||
return vec_all_le( bits, vtol );
|
||||
}
|
||||
|
||||
#endif
|
||||
93
Extras/simdmathlibrary/ppu/tests/truncf4.c
Normal file
93
Extras/simdmathlibrary/ppu/tests/truncf4.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/* Testcase for truncf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "common-test.h"
|
||||
#include "testutils.h"
|
||||
#include "simdmath.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SET_START("20040916100012EJL","EJL", "truncf");
|
||||
|
||||
unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value.
|
||||
unsigned int i3i = 0x4afffffe;
|
||||
unsigned int i4 = 0x4b000000; // 2^23, no fractional part.
|
||||
unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value.
|
||||
|
||||
float x0 = hide_float(0.91825f);
|
||||
float x0i = hide_float(0.0f);
|
||||
float x1 = hide_float(-0.12958f);
|
||||
float x1i = hide_float(0.0f);
|
||||
float x2 = hide_float(-79615.1875f);
|
||||
float x2i = hide_float(-79615.0f);
|
||||
float x3 = hide_float(make_float(i3));
|
||||
float x3i = hide_float(make_float(i3i));
|
||||
float x4 = hide_float(make_float(i4));
|
||||
float x4i = hide_float(make_float(i4));
|
||||
float x5 = hide_float(make_float(i5));
|
||||
float x5i = hide_float(make_float(i5));
|
||||
|
||||
vec_float4 x0_v = vec_splat_float(x0);
|
||||
vec_float4 x0i_v = vec_splat_float(x0i);
|
||||
vec_float4 x1_v = vec_splat_float(x1);
|
||||
vec_float4 x1i_v = vec_splat_float(x1i);
|
||||
vec_float4 x2_v = vec_splat_float(x2);
|
||||
vec_float4 x2i_v = vec_splat_float(x2i);
|
||||
vec_float4 x3_v = vec_splat_float(x3);
|
||||
vec_float4 x3i_v = vec_splat_float(x3i);
|
||||
vec_float4 x4_v = vec_splat_float(x4);
|
||||
vec_float4 x4i_v = vec_splat_float(x4i);
|
||||
vec_float4 x5_v = vec_splat_float(x5);
|
||||
vec_float4 x5i_v = vec_splat_float(x5i);
|
||||
|
||||
vec_float4 res_v;
|
||||
|
||||
TEST_START("truncf4");
|
||||
res_v = truncf4(x0_v);
|
||||
TEST_CHECK("20040916100023EJL", allequal_float4( res_v, x0i_v ), 0);
|
||||
res_v = truncf4(x1_v);
|
||||
TEST_CHECK("20040916100034EJL", allequal_float4( res_v, x1i_v ), 0);
|
||||
res_v = truncf4(x2_v);
|
||||
TEST_CHECK("20040916100043EJL", allequal_float4( res_v, x2i_v ), 0);
|
||||
res_v = truncf4(x3_v);
|
||||
TEST_CHECK("20040916100054EJL", allequal_float4( res_v, x3i_v ), 0);
|
||||
res_v = truncf4(x4_v);
|
||||
TEST_CHECK("20040916100103EJL", allequal_float4( res_v, x4i_v ), 0);
|
||||
res_v = truncf4(x5_v);
|
||||
TEST_CHECK("20040916100111EJL", allequal_float4( res_v, x5i_v ), 0);
|
||||
|
||||
TEST_SET_DONE();
|
||||
|
||||
TEST_EXIT();
|
||||
}
|
||||
Reference in New Issue
Block a user