From 092d42ac325bf1852674dda343eba5a48eb67138 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 2 Nov 2022 11:02:51 +0200 Subject: [PATCH 1/2] Issue #104 - Use -march=haswell as default Make it possible to overwrite it with -DEXTRA_FLAGS="-march=armv8-a" Signed-off-by: Martin Tzvetanov Grigorov --- .github/workflows/build_and_test_on_push.yml | 4 ++-- CMakeLists.txt | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_test_on_push.yml b/.github/workflows/build_and_test_on_push.yml index 581b8c5..1bf6597 100644 --- a/.github/workflows/build_and_test_on_push.yml +++ b/.github/workflows/build_and_test_on_push.yml @@ -1,4 +1,4 @@ -on: [ push ] +on: [ push, pull_request ] name: build and test @@ -62,6 +62,6 @@ jobs: libjemalloc-dev run: | cd /seqwish - cmake -H. -DCMAKE_BUILD_TYPE=Release -Bbuild && cmake --build build -- -j 2 + cmake -H. -DCMAKE_BUILD_TYPE=Release -DEXTRA_FLAGS="-march=armv8-a" -Bbuild && cmake --build build -- -j 2 file bin/seqwish cd test && make test diff --git a/CMakeLists.txt b/CMakeLists.txt index bb26fe9..22927ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,11 +21,14 @@ endif() message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") +if(NOT DEFINED EXTRA_FLAGS) + set(EXTRA_FLAGS "-march=haswell" CACHE STRING + "Extra compilation flags for C and CXX." FORCE) +endif() + if (${CMAKE_BUILD_TYPE} MATCHES Release) - set(EXTRA_FLAGS "-Ofast -march=native") + set(EXTRA_FLAGS "-Ofast ${EXTRA_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") # reset CXX_FLAGS to replace -O3 with -Ofast -else() - set(EXTRA_FLAGS "-march=haswell") endif () if (${CMAKE_BUILD_TYPE} MATCHES Debug) From e0cd07aa3f38eff83b253b6ae0e23f2290de1ec5 Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 2 Nov 2022 21:34:50 +0200 Subject: [PATCH 2/2] Use "-march=native" as default Every user can set custom value by passing '-DEXTRA_FLAGS=-march=...' to cmake Signed-off-by: Martin Tzvetanov Grigorov --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22927ef..09eafb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") if(NOT DEFINED EXTRA_FLAGS) - set(EXTRA_FLAGS "-march=haswell" CACHE STRING + set(EXTRA_FLAGS "-march=native" CACHE STRING "Extra compilation flags for C and CXX." FORCE) endif()