From a9972e71dad58420cc93947509ace0cb02e04a4c Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Wed, 19 Apr 2017 08:19:58 -0500 Subject: [PATCH 1/2] Test both with and without SSE --- .travis.yml | 2 ++ test/HandmadeMath_NoSSE.c | 5 +++++ test/HandmadeMath_NoSSE.cpp | 6 ++++++ test/Makefile | 9 ++++++++- test/hmm_test.c | 2 +- 5 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/HandmadeMath_NoSSE.c create mode 100644 test/HandmadeMath_NoSSE.cpp diff --git a/.travis.yml b/.travis.yml index 484d561..365f684 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,6 @@ install: - make script: - ./hmm_test_c + - ./hmm_test_c_no_sse - ./hmm_test_cpp + - ./hmm_test_cpp_no_sse diff --git a/test/HandmadeMath_NoSSE.c b/test/HandmadeMath_NoSSE.c new file mode 100644 index 0000000..64e88c6 --- /dev/null +++ b/test/HandmadeMath_NoSSE.c @@ -0,0 +1,5 @@ + +#define HANDMADE_MATH_IMPLEMENTATION +#define HANDMADE_MATH_NO_SSE +#define HANDMADE_MATH_NO_INLINE +#include "../HandmadeMath.h" diff --git a/test/HandmadeMath_NoSSE.cpp b/test/HandmadeMath_NoSSE.cpp new file mode 100644 index 0000000..1ee7f09 --- /dev/null +++ b/test/HandmadeMath_NoSSE.cpp @@ -0,0 +1,6 @@ + +#define HANDMADE_MATH_IMPLEMENTATION +#define HANDMADE_MATH_CPP_MODE +#define HANDMADE_MATH_NO_SSE +#define HANDMADE_MATH_NO_INLINE +#include "../HandmadeMath.h" diff --git a/test/Makefile b/test/Makefile index 91a9028..972ebcd 100644 --- a/test/Makefile +++ b/test/Makefile @@ -2,7 +2,7 @@ ROOT_DIR = .. CXXFLAGS += -g -Wall -Wextra -pthread -Wno-missing-braces -Wno-missing-field-initializers -all: c cpp +all: c c_no_sse cpp cpp_no_sse clean: rm -f hmm_test_c hmm_test_cpp *.o @@ -11,7 +11,14 @@ c: $(ROOT_DIR)/test/HandmadeMath.c test_impl $(CC) $(CPPFLAGS) $(CXXFLAGS) -std=c99 -c $(ROOT_DIR)/test/HandmadeMath.c $(ROOT_DIR)/test/hmm_test.c -lm $(CC) -ohmm_test_c HandmadeMath.o hmm_test.o -lm +c_no_sse: $(ROOT_DIR)/test/HandmadeMath_NoSSE.c test_impl + $(CC) $(CPPFLAGS) $(CXXFLAGS) -std=c99 -c $(ROOT_DIR)/test/HandmadeMath_NoSSE.c $(ROOT_DIR)/test/hmm_test.c -lm + $(CC) -ohmm_test_c_no_sse HandmadeMath_NoSSE.o hmm_test.o -lm + cpp: $(ROOT_DIR)/test/HandmadeMath.cpp test_impl $(CXX) $(CPPFLAGS) $(CXXFLAGS) -ohmm_test_cpp $(ROOT_DIR)/test/HandmadeMath.cpp $(ROOT_DIR)/test/hmm_test.cpp +cpp_no_sse: $(ROOT_DIR)/test/HandmadeMath_NoSSE.cpp test_impl + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -ohmm_test_cpp_no_sse $(ROOT_DIR)/test/HandmadeMath_NoSSE.cpp $(ROOT_DIR)/test/hmm_test.cpp + test_impl: $(ROOT_DIR)/test/hmm_test.cpp $(ROOT_DIR)/test/hmm_test.c diff --git a/test/hmm_test.c b/test/hmm_test.c index d608c8d..a0034dd 100644 --- a/test/hmm_test.c +++ b/test/hmm_test.c @@ -70,7 +70,7 @@ int run_tests() TEST_BEGIN(RSquareRootF) { - EXPECT_FLOAT_EQ(HMM_RSquareRootF(10.0f), 0.31616211f); + EXPECT_NEAR(HMM_RSquareRootF(10.0f), 0.31616211f, 0.0001f); } TEST_END() From 364569abe9cb4fa7e07a5761fc1349bc1f2b256d Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Fri, 9 Jun 2017 10:43:11 -0500 Subject: [PATCH 2/2] Fix wrong name for square root function --- HandmadeMath.h | 2 +- test/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HandmadeMath.h b/HandmadeMath.h index 78d2d92..a966f9f 100644 --- a/HandmadeMath.h +++ b/HandmadeMath.h @@ -774,7 +774,7 @@ HMM_RSquareRootF(float Value) float Result = 0.0f; #ifdef HANDMADE_MATH_NO_SSE - Result = 1.0f/HMM_SqrtF(Value); + Result = 1.0f/HMM_SquareRootF(Value); #else __m128 In = _mm_set_ss(Value); __m128 Out = _mm_rsqrt_ss(In); diff --git a/test/Makefile b/test/Makefile index 972ebcd..70353ee 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,7 +5,7 @@ CXXFLAGS += -g -Wall -Wextra -pthread -Wno-missing-braces -Wno-missing-field-ini all: c c_no_sse cpp cpp_no_sse clean: - rm -f hmm_test_c hmm_test_cpp *.o + rm -f hmm_test_c hmm_test_cpp hmm_test_c_no_sse hmm_test_cpp_no_sse *.o c: $(ROOT_DIR)/test/HandmadeMath.c test_impl $(CC) $(CPPFLAGS) $(CXXFLAGS) -std=c99 -c $(ROOT_DIR)/test/HandmadeMath.c $(ROOT_DIR)/test/hmm_test.c -lm