From c856a862afc69570031741d3875f937e0116ca06 Mon Sep 17 00:00:00 2001 From: Ayan Shafqat Date: Fri, 1 Jan 2021 14:06:47 -0500 Subject: [PATCH] Add unit test for FMA extension routine --- libs/ardour/test/fpu_test.cc | 28 ++++++++++++++++++++++++++++ libs/ardour/test/fpu_test.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/libs/ardour/test/fpu_test.cc b/libs/ardour/test/fpu_test.cc index 23f224cbc3..b0b89621ee 100644 --- a/libs/ardour/test/fpu_test.cc +++ b/libs/ardour/test/fpu_test.cc @@ -98,6 +98,34 @@ FPUTest::compare (std::string msg, size_t cnt) } #if defined(ARCH_X86) && defined(BUILD_SSE_OPTIMIZATIONS) + +void +FPUTest::avxFmaTest () +{ + PBD::FPU* fpu = PBD::FPU::instance (); + if (!(fpu->has_avx () && fpu->has_fma ())) { + printf ("AVX and FMA is not available at run-time\n"); + return; + } + +#if ( defined(__x86_64__) || defined(_M_X64) ) + size_t align_max = 64; +#else + size_t align_max = 16; +#endif + CPPUNIT_ASSERT_MESSAGE ("Aligned Malloc", (((intptr_t)_test1) % align_max) == 0); + CPPUNIT_ASSERT_MESSAGE ("Aligned Malloc", (((intptr_t)_test2) % align_max) == 0); + + compute_peak = x86_sse_avx_compute_peak; + find_peaks = x86_sse_avx_find_peaks; + apply_gain_to_buffer = x86_sse_avx_apply_gain_to_buffer; + mix_buffers_with_gain = x86_fma_mix_buffers_with_gain; + mix_buffers_no_gain = x86_sse_avx_mix_buffers_no_gain; + copy_vector = x86_sse_avx_copy_vector; + + run (align_max); +} + void FPUTest::avxTest () { diff --git a/libs/ardour/test/fpu_test.h b/libs/ardour/test/fpu_test.h index 37afeff5f7..d66673322e 100644 --- a/libs/ardour/test/fpu_test.h +++ b/libs/ardour/test/fpu_test.h @@ -9,6 +9,7 @@ class FPUTest : public CppUnit::TestFixture #if defined(ARCH_X86) && defined(BUILD_SSE_OPTIMIZATIONS) CPPUNIT_TEST (sseTest); CPPUNIT_TEST (avxTest); + CPPUNIT_TEST (avxFmaTest); #elif defined ARM_NEON_SUPPORT CPPUNIT_TEST (neonTest); #elif defined(__APPLE__) && defined(BUILD_VECLIB_OPTIMIZATIONS) @@ -23,6 +24,7 @@ public: void tearDown (); #if defined(ARCH_X86) && defined(BUILD_SSE_OPTIMIZATIONS) + void avxFmaTest (); void avxTest (); void sseTest (); #elif defined ARM_NEON_SUPPORT