diff --git a/externals/coda-oss/.github/workflows/build_unittest.yml b/externals/coda-oss/.github/workflows/build_unittest.yml index 5f8044cb52..8b6a5dd226 100644 --- a/externals/coda-oss/.github/workflows/build_unittest.yml +++ b/externals/coda-oss/.github/workflows/build_unittest.yml @@ -58,7 +58,8 @@ jobs: os: [windows-latest] platform: [x64] configuration: [Debug] # Debug turns on more compiler warnings - name: ${{ matrix.os }}-msbuild + avx: [AVX2, AVX512F] + name: ${{ matrix.os }}-${{ matrix.avx }}-msbuild runs-on: ${{ matrix.os }} steps: @@ -68,7 +69,7 @@ jobs: ls env: mkdir out cd out - cmake .. -DCMAKE_INSTALL_PREFIX=install\${{ matrix.platform }}-${{ matrix.configuration }} -DENABLE_PYTHON=OFF + cmake .. -DCMAKE_INSTALL_PREFIX=install\${{ matrix.platform }}-${{ matrix.configuration }} -DENABLE_PYTHON=OFF -DENABLE_${{ matrix.avx }}=ON - name: build run: | cd out @@ -131,14 +132,15 @@ jobs: matrix: os: [ubuntu-latest] configuration: [Debug, Release] - name: ${{ matrix.os }}-${{ matrix.configuration }}-CMake + avx: [AVX2, AVX512F] + name: ${{ matrix.os }}-${{ matrix.configuration }}-${{ matrix.avx }}-CMake runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - name: configure run: | mkdir out && cd out - cmake .. -DENABLE_PYTHON=OFF -DENABLE_ASAN=ON + cmake .. -DENABLE_PYTHON=OFF -DENABLE_ASAN=ON -DENABLE_${{ matrix.avx }}=ON - name: build run: | cd out diff --git a/externals/coda-oss/CMakeLists.txt b/externals/coda-oss/CMakeLists.txt index 4b1bc2c645..f512d520a8 100644 --- a/externals/coda-oss/CMakeLists.txt +++ b/externals/coda-oss/CMakeLists.txt @@ -24,19 +24,8 @@ if (${CMAKE_PROJECT_NAME} STREQUAL coda-oss) if (MSVC) add_compile_options(/WX) # warnings as errors add_compile_options(/MP) # multi-processor compile - - if (ENABLE_ASAN) - # https://docs.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-160 - add_compile_options(/fsanitize=address) - endif() elseif (UNIX) add_compile_options(-Werror) # warnings as errors - - if (ENABLE_ASAN) - # https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html - add_compile_options(-fsanitize=address) - add_link_options(-fsanitize=address) - endif() endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/externals/coda-oss/cmake/CodaBuild.cmake b/externals/coda-oss/cmake/CodaBuild.cmake index 69a143c1b2..1427737888 100644 --- a/externals/coda-oss/cmake/CodaBuild.cmake +++ b/externals/coda-oss/cmake/CodaBuild.cmake @@ -165,6 +165,22 @@ macro(coda_initialize_build) # This should probably be replaced by GenerateExportHeader #set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD TRUE) + + if (ENABLE_ASAN) + # https://docs.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-160 + add_compile_options(/fsanitize=address) + endif() + + # Note SSE2 is implicitly enabled for x64 builds. + if (ENABLE_AVX2 AND (NOT ENABLE_AVX512F)) + # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x86?view=msvc-170 + add_compile_options(/arch:AVX2) + endif() + if (ENABLE_AVX512F) + # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x86?view=msvc-170 + add_compile_options(/arch:AVX512) + endif() + endif() # Unix/Linux specific options @@ -173,6 +189,27 @@ macro(coda_initialize_build) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ) + + if (ENABLE_ASAN) + # https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) + endif() + + # Note SSE2 is implicitly enabled for x64 builds. + if (ENABLE_AVX2 AND (NOT ENABLE_AVX512F)) + # https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html + # It doesn't look like GCC has a specific option for AVX2; + # other projects use "haswell" + add_compile_options(-march=haswell) + endif() + if (ENABLE_AVX512F) + # https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html + # It doesn't look like GCC has a specific option for AVX512F; + # other projects use "native" which isn't quite correct.' + add_compile_options(-march=native) + endif() + endif() # all targets should be installed using this export set diff --git a/externals/coda-oss/modules/c++/avx/unittests/test_m256.cpp b/externals/coda-oss/modules/c++/avx/unittests/test_m256.cpp index 8c6cdc47b9..920a0f9f8d 100644 --- a/externals/coda-oss/modules/c++/avx/unittests/test_m256.cpp +++ b/externals/coda-oss/modules/c++/avx/unittests/test_m256.cpp @@ -25,7 +25,9 @@ #include #include +#include #include +#include TEST_CASE(extractf) { @@ -49,8 +51,50 @@ TEST_CASE(extractf) */ TEST_SUCCESS; } + +TEST_CASE(test_getSIMDInstructionSet) +{ + // This is the reverse of getSIMDInstructionSet(): it uses the macros to generate a value. + constexpr auto simdInstructionSet = sys::getSIMDInstructionSet(); + #if __AVX512F__ + static_assert(simdInstructionSet == sys::SIMDInstructionSet::AVX512F, "getSIMDInstructionSet()"); + #elif __AVX2__ + static_assert(simdInstructionSet == sys::SIMDInstructionSet::AVX2, "getSIMDInstructionSet()"); + #else + static_assert(simdInstructionSet == sys::SIMDInstructionSet::SSE2, "getSIMDInstructionSet()"); + #endif + CODA_OSS_disable_warning_push + #if _MSC_VER + #pragma warning(disable: 4127) // conditional expression is constant + #endif + + switch (sys::getSIMDInstructionSet()) // run-time value + { + case sys::SIMDInstructionSet::SSE2: + { + TEST_ASSERT(simdInstructionSet == sys::SIMDInstructionSet::SSE2); + break; + } + case sys::SIMDInstructionSet::AVX2: + { + TEST_ASSERT(simdInstructionSet == sys::SIMDInstructionSet::AVX2); + break; + } + case sys::SIMDInstructionSet::AVX512F: + { + TEST_ASSERT(simdInstructionSet == sys::SIMDInstructionSet::AVX512F); + break; + } + default: + { + TEST_FAIL; + } + } + CODA_OSS_disable_warning_pop +} TEST_MAIN( TEST_CHECK(extractf); + TEST_CHECK(test_getSIMDInstructionSet); ) diff --git a/externals/nitro/modules/c/nrt/unittests/test_buffer_adapter.c b/externals/nitro/modules/c/nrt/unittests/test_buffer_adapter.c index 8c6e5dce8e..186b86aff4 100644 --- a/externals/nitro/modules/c/nrt/unittests/test_buffer_adapter.c +++ b/externals/nitro/modules/c/nrt/unittests/test_buffer_adapter.c @@ -44,6 +44,8 @@ TEST_CASE(testReadInBounds) { TEST_ASSERT(output[ii] == (char)1); } + + nrt_IOInterface_destruct(&reader); } TEST_CASE(testReadPastEnd) @@ -63,6 +65,8 @@ TEST_CASE(testReadPastEnd) nrt_IOInterface_seek(reader, 8, NRT_SEEK_SET, &error); success = nrt_IOInterface_read(reader, output, sizeof(output), &error); TEST_ASSERT(!success); + + nrt_IOInterface_destruct(&reader); } TEST_CASE(testReadOutOfBounds) @@ -82,6 +86,8 @@ TEST_CASE(testReadOutOfBounds) TEST_ASSERT(success != 0); success = nrt_IOInterface_read(reader, output, sizeof(output), &error); TEST_ASSERT(!success); + + nrt_IOInterface_destruct(&reader); } TEST_CASE(testWriteOutOfBounds) @@ -99,11 +105,11 @@ TEST_CASE(testWriteOutOfBounds) TEST_ASSERT(success != 0); success = nrt_IOInterface_write(writer, input, 4, &error); TEST_ASSERT(!success); + + nrt_IOInterface_destruct(&writer); } TEST_MAIN( - (void) argc; - (void) argv; CHECK(testReadInBounds); CHECK(testReadPastEnd); CHECK(testReadOutOfBounds);