Skip to content

Commit

Permalink
Merge pull request #93 from ekg/cmake_tweaks
Browse files Browse the repository at this point in the history
`cmake` tweaks and `atomic_queue` update for future portability
  • Loading branch information
AndreaGuarracino authored Apr 1, 2022
2 parents 5a159f5 + f2d56d0 commit a2d85fb
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Init and update submodules
run: git submodule update --init --recursive
- name: Build seqwish
run: sed -i 's/CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -mcx16 -g/CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O -mcx16 -g -fsanitize=address/g' CMakeLists.txt && sed -i 's/CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mcx16 -g/CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O -mcx16 -g -fsanitize=address/g' CMakeLists.txt && cmake -H. -Bbuild && cmake --build build -- -j 2
run: cmake -H. -DCMAKE_BUILD_TYPE=Debug -Bbuild && cmake --build build -- -j 2
- name: Execute tests
run: cd test && ASAN_OPTIONS=detect_leaks=1:symbolize=1 LSAN_OPTIONS=verbosity=0:log_threads=1 make test

31 changes: 25 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,30 @@ set(CMAKE_CXX_STANDARD 14)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

# Use all standard-compliant optimizations
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -mcx16 -g")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mcx16 -g")
#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O -mcx16 -g -fsanitize=address")
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O -mcx16 -g -fsanitize=address")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Release Debug Generic." FORCE)
endif()

# set(CMAKE_BUILD_TYPE Debug) -- don't uncomment this, instead run
# cmake -DCMAKE_BUILD_TYPE=Debug ..

message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

if (${CMAKE_BUILD_TYPE} MATCHES Release)
set(EXTRA_FLAGS "-Ofast -march=native")
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") # reset CXX_FLAGS to replace -O3 with -Ofast
endif ()

if (${CMAKE_BUILD_TYPE} MATCHES Debug)
# Debug use the defaults
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O -mcx16 -g -fsanitize=address")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O -mcx16 -g -fsanitize=address")
else()
# Use all standard-compliant optimizations - always add these:
set (CMAKE_C_FLAGS "${OpenMP_C_FLAGS} ${PIC_FLAG} ${EXTRA_FLAGS} -mcx16")
set (CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${PIC_FLAG} ${EXTRA_FLAGS} -mcx16")
endif ()

# Set the output folder where your program will be created
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
Expand Down Expand Up @@ -114,7 +133,7 @@ ExternalProject_Add(atomicqueue
BUILD_COMMAND ""
CONFIGURE_COMMAND "")
ExternalProject_Get_property(atomicqueue SOURCE_DIR)
set(atomicqueue_INCLUDE "${SOURCE_DIR}")
set(atomicqueue_INCLUDE "${SOURCE_DIR}/include/atomic_queue")

# ska
ExternalProject_Add(ska
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ cmake -DBUILD_STATIC=1 -H. -Bbuild && cmake --build build -- -j 3
You'll need to set this flag to 0 or remove and rebuild your build directory if you want to unset this behavior.
Static builds are unlikely to be supported on OSX, and require appropriate static libraries on linux.

#### Notes for distribution

If you need to avoid machine-specific optimizations, use the `CMAKE_BUILD_TYPE=Generic` build type:

```shell
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Generic && cmake --build build -- -j 3
```

### Docker

Expand Down
2 changes: 1 addition & 1 deletion deps/atomic_queue
5 changes: 0 additions & 5 deletions src/dset64-gccAtomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@
*
*/

// Sanity check that we are compiling on x86_64.
#if !__x86_64__
#error "seqwish can only be built on an x86_64 machine (64-bit Intel/AMD)"
#endif

namespace seqwish {

class DisjointSets {
Expand Down
5 changes: 0 additions & 5 deletions src/dset64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@
*
*/

// Sanity check that we are compiling on x86_64.
#if !__x86_64__
#error "seqwish can only be built on an x86_64 machine (64-bit Intel/AMD)"
#endif

namespace seqwish {

class DisjointSets {
Expand Down

0 comments on commit a2d85fb

Please sign in to comment.