From 75a66311fd11847a33869420dc42f0ec0be438f0 Mon Sep 17 00:00:00 2001 From: Erik Garrison Date: Tue, 4 Jun 2024 11:50:26 -0500 Subject: [PATCH 1/6] make building possible on TACC's stampede3 cluster --- CMakeLists.txt | 56 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9881cf6..13d90242 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,31 +63,77 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) add_subdirectory(src/common/wflign EXCLUDE_FROM_ALL) +include(ExternalProject) + +ExternalProject_Add(htslib + URL https://github.com/samtools/htslib/releases/download/1.20/htslib-1.20.tar.bz2 + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/htslib + CONFIGURE_COMMAND autoreconf -i && ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/htslib --disable-libcurl --disable-s3 + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + BUILD_IN_SOURCE 1 +) + +ExternalProject_Add(gsl + URL https://mirror.ibcp.fr/pub/gnu/gsl/gsl-2.8.tar.gz + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gsl + CONFIGURE_COMMAND ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/gsl + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + BUILD_IN_SOURCE 1 +) + +ExternalProject_Add(libdeflate + URL https://github.com/ebiggers/libdeflate/releases/download/v1.20/libdeflate-1.20.tar.gz + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libdeflate + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libdeflate + -DCMAKE_BUILD_TYPE=Release + BUILD_COMMAND cmake --build . --config Release + INSTALL_COMMAND cmake --install . --config Release + BUILD_IN_SOURCE 1 +) + +ExternalProject_Add(jemalloc + URL https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2 + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/jemalloc + CONFIGURE_COMMAND ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/jemalloc + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + BUILD_IN_SOURCE 1 +) + add_executable(wfmash src/common/utils.cpp src/interface/main.cpp) +add_dependencies(wfmash htslib gsl libdeflate jemalloc) + target_include_directories(wfmash PRIVATE src src/common src/common/wflign/deps src/common/wflign/deps/WFA2-lib + ${CMAKE_CURRENT_BINARY_DIR}/htslib/include + ${CMAKE_CURRENT_BINARY_DIR}/gsl/include + ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/include + ${CMAKE_CURRENT_BINARY_DIR}/jemalloc/include ) target_link_libraries(wfmash - gsl - gslcblas + ${CMAKE_CURRENT_BINARY_DIR}/gsl/lib/libgsl.a + ${CMAKE_CURRENT_BINARY_DIR}/gsl/lib/libgslcblas.a m pthread libwflign_static - hts + ${CMAKE_CURRENT_BINARY_DIR}/htslib/lib/libhts.a rt wfa2cpp_static - jemalloc + ${CMAKE_CURRENT_BINARY_DIR}/jemalloc/lib/libjemalloc.a lzma bz2 z - deflate + ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/lib64/libdeflate.a Threads::Threads ) From debeff72269d2104557870d10a12974e19ca8fa2 Mon Sep 17 00:00:00 2001 From: Erik Garrison Date: Tue, 4 Jun 2024 14:34:06 -0500 Subject: [PATCH 2/6] trying to debug on TACC which means getting ASAN bulit in --- CMakeLists.txt | 18 ++++++++++++++---- src/common/wflign/CMakeLists.txt | 4 ++-- src/common/wflign/src/wflign.cpp | 4 ++-- src/common/wflign/src/wflign_alignment.cpp | 2 +- src/common/wflign/src/wflign_patch.cpp | 13 ++++++++++--- src/common/wflign/src/wflign_patch.hpp | 6 +++--- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d90242..59239106 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,10 +37,10 @@ endif() message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") if (${CMAKE_BUILD_TYPE} MATCHES Release) - set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") - set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") + #set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") + # set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") if (NOT EXTRA_FLAGS) - set(EXTRA_FLAGS "-Ofast -march=x86-64-v3") + set(EXTRA_FLAGS "-Ofast -march=x86-64-v3 -g") endif() endif () @@ -103,11 +103,20 @@ ExternalProject_Add(jemalloc BUILD_IN_SOURCE 1 ) +ExternalProject_Add(gcc-13.2.0 + URL https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gcc-13.2.0 + CONFIGURE_COMMAND /configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/gcc-13.2.0 --enable-languages=c,c++ --disable-multilib --enable-libsanitizer=address + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + BUILD_IN_SOURCE 1 +) + add_executable(wfmash src/common/utils.cpp src/interface/main.cpp) -add_dependencies(wfmash htslib gsl libdeflate jemalloc) +add_dependencies(wfmash htslib gsl libdeflate jemalloc gcc-13.2.0) target_include_directories(wfmash PRIVATE src @@ -135,6 +144,7 @@ target_link_libraries(wfmash z ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/lib64/libdeflate.a Threads::Threads + ${CMAKE_CURRENT_BINARY_DIR}/gcc-13.2.0/lib64/libasan.a ) configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}) diff --git a/src/common/wflign/CMakeLists.txt b/src/common/wflign/CMakeLists.txt index 856cd3fc..aa089c1f 100644 --- a/src/common/wflign/CMakeLists.txt +++ b/src/common/wflign/CMakeLists.txt @@ -21,8 +21,8 @@ message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") if (${CMAKE_BUILD_TYPE} MATCHES Release) #set(EXTRA_FLAGS "-Ofast -march=x86-64-v3 -flto -fno-fat-lto-objects") - set(EXTRA_FLAGS "-Ofast -march=x86-64-v3") - set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") # reset CXX_FLAGS to replace -O3 with -Ofast + set(EXTRA_FLAGS "-Ofast -march=x86-64-v3 -g") + #set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") # reset CXX_FLAGS to replace -O3 with -Ofast endif () if (${CMAKE_BUILD_TYPE} MATCHES Debug) diff --git a/src/common/wflign/src/wflign.cpp b/src/common/wflign/src/wflign.cpp index 7cb1ee2f..a05e2152 100644 --- a/src/common/wflign/src/wflign.cpp +++ b/src/common/wflign/src/wflign.cpp @@ -183,8 +183,8 @@ int wflambda_extend_match( if (f != alignments.end()) { is_a_match = (alignments[k] != nullptr); } else { - const int query_begin = v * step_size; - const int target_begin = h * step_size; + const int64_t query_begin = v * step_size; + const int64_t target_begin = h * step_size; // The last fragment can be longer than segment_length_to_use (max 2*segment_length_to_use - 1) const uint16_t segment_length_to_use_q = diff --git a/src/common/wflign/src/wflign_alignment.cpp b/src/common/wflign/src/wflign_alignment.cpp index 394c44b7..2cef142e 100644 --- a/src/common/wflign/src/wflign_alignment.cpp +++ b/src/common/wflign/src/wflign_alignment.cpp @@ -642,4 +642,4 @@ bool hack_cigar(wfa::cigar_t &cigar, const char *query, const char *target, } } return ok; -}*/ \ No newline at end of file +}*/ diff --git a/src/common/wflign/src/wflign_patch.cpp b/src/common/wflign/src/wflign_patch.cpp index 53ec74a4..0754856f 100644 --- a/src/common/wflign/src/wflign_patch.cpp +++ b/src/common/wflign/src/wflign_patch.cpp @@ -28,18 +28,25 @@ bool do_wfa_segment_alignment( const char* query, std::vector*& query_sketch, const uint64_t& query_length, - const int& j, + const int64_t& j, const std::string& target_name, const char* target, std::vector*& target_sketch, const uint64_t& target_length, - const int& i, + const int64_t& i, const uint16_t& segment_length_q, const uint16_t& segment_length_t, const uint16_t& step_size, wflign_extend_data_t* extend_data, alignment_t& aln) { + // if our i or j index plus segment length in the query or target is too long we'll make a memory access error and weird stuff will happen + if (i + segment_length_t > target_length || j + segment_length_q > query_length) { + // display function parameters + std::cerr << "query_name: " << query_name << " query_length: " << query_length << " target_name: " << target_name << " target_length: " << target_length << std::endl; + std::cerr << "i: " << i << " j: " << j << " segment_length_t: " << segment_length_t << " segment_length_q: " << segment_length_q << std::endl; + } + // first make the sketches if we haven't yet if (query_sketch == nullptr) { query_sketch = new std::vector(); @@ -48,7 +55,7 @@ bool do_wfa_segment_alignment( ++extend_data->num_sketches_allocated; } if (target_sketch == nullptr) { - target_sketch = new std::vector(); + target_sketch = new std::vector(); *target_sketch = rkmh::hash_sequence( target + i, segment_length_t, extend_data->minhash_kmer_size, (uint64_t)((float)segment_length_t * extend_data->mash_sketch_rate)); ++extend_data->num_sketches_allocated; diff --git a/src/common/wflign/src/wflign_patch.hpp b/src/common/wflign/src/wflign_patch.hpp index e1416df9..d2d06a8d 100644 --- a/src/common/wflign/src/wflign_patch.hpp +++ b/src/common/wflign/src/wflign_patch.hpp @@ -34,12 +34,12 @@ namespace wflign { const char* query, std::vector*& query_sketch, const uint64_t& query_length, - const int& j, + const int64_t& j, const std::string& target_name, const char* target, std::vector*& target_sketch, const uint64_t& target_length, - const int& i, + const int64_t& i, const uint16_t& segment_length_q, const uint16_t& segment_length_t, const uint16_t& step_size, @@ -120,4 +120,4 @@ namespace wflign { void encodeOneStep(const char *filename, std::vector &image, unsigned width, unsigned height); } /* namespace wflign */ -#endif /* WFLIGN_PATCH_HPP_ */ \ No newline at end of file +#endif /* WFLIGN_PATCH_HPP_ */ From e6f18242f327859f0130cf8762a909b6ad431bfd Mon Sep 17 00:00:00 2001 From: Erik Garrison Date: Wed, 5 Jun 2024 09:47:24 -0500 Subject: [PATCH 3/6] rest on micromamba/anaconda --- CMakeLists.txt | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59239106..b6890988 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,29 +94,11 @@ ExternalProject_Add(libdeflate BUILD_IN_SOURCE 1 ) -ExternalProject_Add(jemalloc - URL https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2 - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/jemalloc - CONFIGURE_COMMAND ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/jemalloc - BUILD_COMMAND $(MAKE) - INSTALL_COMMAND $(MAKE) install - BUILD_IN_SOURCE 1 -) - -ExternalProject_Add(gcc-13.2.0 - URL https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gcc-13.2.0 - CONFIGURE_COMMAND /configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/gcc-13.2.0 --enable-languages=c,c++ --disable-multilib --enable-libsanitizer=address - BUILD_COMMAND $(MAKE) - INSTALL_COMMAND $(MAKE) install - BUILD_IN_SOURCE 1 -) - add_executable(wfmash src/common/utils.cpp src/interface/main.cpp) -add_dependencies(wfmash htslib gsl libdeflate jemalloc gcc-13.2.0) +add_dependencies(wfmash htslib gsl libdeflate) target_include_directories(wfmash PRIVATE src @@ -126,7 +108,6 @@ target_include_directories(wfmash PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/htslib/include ${CMAKE_CURRENT_BINARY_DIR}/gsl/include ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/include - ${CMAKE_CURRENT_BINARY_DIR}/jemalloc/include ) target_link_libraries(wfmash @@ -138,13 +119,12 @@ target_link_libraries(wfmash ${CMAKE_CURRENT_BINARY_DIR}/htslib/lib/libhts.a rt wfa2cpp_static - ${CMAKE_CURRENT_BINARY_DIR}/jemalloc/lib/libjemalloc.a + jemalloc lzma bz2 z ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/lib64/libdeflate.a Threads::Threads - ${CMAKE_CURRENT_BINARY_DIR}/gcc-13.2.0/lib64/libasan.a ) configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}) From 609082b76041964f1a888e4e5b861f81a391e9b1 Mon Sep 17 00:00:00 2001 From: Erik Garrison Date: Wed, 5 Jun 2024 11:00:16 -0500 Subject: [PATCH 4/6] build with clang and drop jemalloc --- CMakeLists.txt | 12 ++++++------ README.md | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6890988..94ef5e5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ find_package(ZLIB REQUIRED) find_package(BZip2 REQUIRED) find_package(LibLZMA REQUIRED) find_package(Threads REQUIRED) +find_package(OpenMP REQUIRED) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING @@ -37,11 +38,11 @@ endif() message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") if (${CMAKE_BUILD_TYPE} MATCHES Release) - #set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") - # set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") - if (NOT EXTRA_FLAGS) - set(EXTRA_FLAGS "-Ofast -march=x86-64-v3 -g") - endif() + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") + if (NOT EXTRA_FLAGS) + set(EXTRA_FLAGS "-Ofast -march=x86-64-v3") + endif() endif () if (${CMAKE_BUILD_TYPE} MATCHES Debug) @@ -119,7 +120,6 @@ target_link_libraries(wfmash ${CMAKE_CURRENT_BINARY_DIR}/htslib/lib/libhts.a rt wfa2cpp_static - jemalloc lzma bz2 z diff --git a/README.md b/README.md index e73580cc..096d2c76 100644 --- a/README.md +++ b/README.md @@ -122,10 +122,12 @@ gcc --version g++ --version ``` +You can also use recent versions of clang/LLVM. To switch compiler, use `export CC=$(which clang); export CXX=$(which clang++)` before running `cmake`. + It may be necessary to install several system-level libraries to build `wfmash`. On `Ubuntu 20.04`, these can be installed using `apt`: ``` -sudo apt install build-essential cmake libjemalloc-dev zlib1g-dev libgsl-dev libhts-dev +sudo apt install build-essential cmake zlib1g-dev libgsl-dev libhts-dev ``` After installing the required dependencies, clone the `wfmash` git repository and build with: From 18e33b0c4c70d181f3262fb74c9b06a63e04caf9 Mon Sep 17 00:00:00 2001 From: Erik Garrison Date: Wed, 12 Jun 2024 15:02:36 +0200 Subject: [PATCH 5/6] use typically correct path for libdeflate --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94ef5e5b..8a29d08a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,7 +123,7 @@ target_link_libraries(wfmash lzma bz2 z - ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/lib64/libdeflate.a + ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/lib/libdeflate.a Threads::Threads ) From d55cfe79b273a7807817fdd3a2541660a004c6a0 Mon Sep 17 00:00:00 2001 From: Erik Garrison Date: Wed, 12 Jun 2024 16:33:36 +0200 Subject: [PATCH 6/6] make the build configurable and document how --- CMakeLists.txt | 115 +++++++++++++++++++++++++++++-------------- README.md | 130 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 169 insertions(+), 76 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a29d08a..3aa60779 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,8 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Make sure no compiler-specific features are use set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) option(BUILD_STATIC "Build static binary" OFF) +option(BUILD_DEPS "Build external dependencies" OFF) +option(BUILD_RETARGETABLE "Build retargetable binary" OFF) if (BUILD_STATIC) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") @@ -41,7 +43,19 @@ if (${CMAKE_BUILD_TYPE} MATCHES Release) set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") if (NOT EXTRA_FLAGS) - set(EXTRA_FLAGS "-Ofast -march=x86-64-v3") + if (BUILD_RETARGETABLE) + set(EXTRA_FLAGS "-Ofast -march=x86-64-v3 -flto") + else() + set(EXTRA_FLAGS "-Ofast -march=native -flto") + endif() + endif() +endif () + +if (${CMAKE_BUILD_TYPE} MATCHES Generic) + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") + if (NOT EXTRA_FLAGS) + set(EXTRA_FLAGS "-Ofast -flto") endif() endif () @@ -66,64 +80,91 @@ add_subdirectory(src/common/wflign EXCLUDE_FROM_ALL) include(ExternalProject) -ExternalProject_Add(htslib - URL https://github.com/samtools/htslib/releases/download/1.20/htslib-1.20.tar.bz2 - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/htslib - CONFIGURE_COMMAND autoreconf -i && ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/htslib --disable-libcurl --disable-s3 - BUILD_COMMAND $(MAKE) - INSTALL_COMMAND $(MAKE) install - BUILD_IN_SOURCE 1 -) - -ExternalProject_Add(gsl - URL https://mirror.ibcp.fr/pub/gnu/gsl/gsl-2.8.tar.gz - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gsl - CONFIGURE_COMMAND ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/gsl - BUILD_COMMAND $(MAKE) - INSTALL_COMMAND $(MAKE) install - BUILD_IN_SOURCE 1 -) - -ExternalProject_Add(libdeflate - URL https://github.com/ebiggers/libdeflate/releases/download/v1.20/libdeflate-1.20.tar.gz - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libdeflate - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libdeflate - -DCMAKE_BUILD_TYPE=Release - BUILD_COMMAND cmake --build . --config Release - INSTALL_COMMAND cmake --install . --config Release - BUILD_IN_SOURCE 1 -) +if (BUILD_DEPS) + ExternalProject_Add(htslib + URL https://github.com/samtools/htslib/releases/download/1.20/htslib-1.20.tar.bz2 + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/htslib + CONFIGURE_COMMAND autoreconf -i && ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/htslib --disable-libcurl --disable-s3 + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + BUILD_IN_SOURCE 1 + ) + + ExternalProject_Add(gsl + URL https://mirror.ibcp.fr/pub/gnu/gsl/gsl-2.8.tar.gz + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gsl + CONFIGURE_COMMAND ./configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/gsl + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + BUILD_IN_SOURCE 1 + ) + + ExternalProject_Add(libdeflate + URL https://github.com/ebiggers/libdeflate/releases/download/v1.20/libdeflate-1.20.tar.gz + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libdeflate + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libdeflate + -DCMAKE_BUILD_TYPE=Release + BUILD_COMMAND cmake --build . --config Release + INSTALL_COMMAND cmake --install . --config Release + BUILD_IN_SOURCE 1 + ) + + add_dependencies(wfmash htslib gsl libdeflate) +endif() add_executable(wfmash src/common/utils.cpp src/interface/main.cpp) -add_dependencies(wfmash htslib gsl libdeflate) +if (BUILD_DEPS) + target_include_directories(wfmash PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/htslib/include + ${CMAKE_CURRENT_BINARY_DIR}/gsl/include + ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/include + ) + + target_link_libraries(wfmash + ${CMAKE_CURRENT_BINARY_DIR}/gsl/lib/libgsl.a + ${CMAKE_CURRENT_BINARY_DIR}/gsl/lib/libgslcblas.a + ${CMAKE_CURRENT_BINARY_DIR}/htslib/lib/libhts.a + ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/lib/libdeflate.a + ) +else() + #find_package(HTSLIB REQUIRED) + #find_package(GSL REQUIRED) + #find_package(LibDeflate REQUIRED) + + #target_include_directories(wfmash PRIVATE + # ${HTSLIB_INCLUDE_DIR} + # ${GSL_INCLUDE_DIR} + # ${LIBDEFLATE_INCLUDE_DIR} + #) + + target_link_libraries(wfmash + gsl + gslcblas + hts + deflate + ) +endif() target_include_directories(wfmash PRIVATE src src/common src/common/wflign/deps src/common/wflign/deps/WFA2-lib - ${CMAKE_CURRENT_BINARY_DIR}/htslib/include - ${CMAKE_CURRENT_BINARY_DIR}/gsl/include - ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/include ) target_link_libraries(wfmash - ${CMAKE_CURRENT_BINARY_DIR}/gsl/lib/libgsl.a - ${CMAKE_CURRENT_BINARY_DIR}/gsl/lib/libgslcblas.a m pthread libwflign_static - ${CMAKE_CURRENT_BINARY_DIR}/htslib/lib/libhts.a rt wfa2cpp_static lzma bz2 z - ${CMAKE_CURRENT_BINARY_DIR}/libdeflate/lib/libdeflate.a Threads::Threads ) diff --git a/README.md b/README.md index 096d2c76..6758c0bc 100644 --- a/README.md +++ b/README.md @@ -111,68 +111,130 @@ To prevent lags when starting a mapping process, users should apply `samtools in The `.fai` indexes are then used to quickly compute the sum of query lengths. -## installation +## Installation -### building from source +### Static binaries -The build is orchestrated with `cmake`. At least GCC version 9.3.0 is required for compilation. You can check your version via: +We provide [static builds of wfmash releases](https://github.com/waveygang/wfmash/releases) targeted at the `x86-64-v3` instruction set. + +### Bioconda + +`wfmash` recipes for Bioconda are available at https://anaconda.org/bioconda/wfmash. +To install the latest version using `Conda` execute: ``` bash -gcc --version -g++ --version +conda install -c bioconda wfmash ``` -You can also use recent versions of clang/LLVM. To switch compiler, use `export CC=$(which clang); export CXX=$(which clang++)` before running `cmake`. +## Building from Source -It may be necessary to install several system-level libraries to build `wfmash`. On `Ubuntu 20.04`, these can be installed using `apt`: +The build process for `wfmash` is managed using `CMake`, providing various options to customize the build. -``` -sudo apt install build-essential cmake zlib1g-dev libgsl-dev libhts-dev -``` +### Prerequisites -After installing the required dependencies, clone the `wfmash` git repository and build with: +Before building `wfmash`, you need the following dependencies installed on your system: +- GCC (version 9.3.0 or higher) or a recent version of Clang/LLVM +- CMake +- Zlib +- GSL +- HTSlib +- LibLZMA +- BZip2 +- Threads +- OpenMP + +On Ubuntu >20.04, these dependencies can be installed with the following command: + +```sh +sudo apt install build-essential cmake zlib1g-dev libgsl-dev libhts-dev liblzma-dev libbz2-dev ``` -git clone --recursive https://github.com/ekg/wfmash.git + +### Clone the Repository + +Clone the `wfmash` repository: + +```sh +git clone https://github.com/waveygang/wfmash.git cd wfmash -cmake -H. -Bbuild && cmake --build build -- -j 8 ``` -Of course, you can use as many cores as you like. +### Build Options -If your system has several versions of the `gcc`/`g++` compilers you might tell `cmake` which one to use with: +`wfmash` provides several CMake options to customize the build process: +- `BUILD_STATIC` (default: `OFF`): Build a static binary. +- `BUILD_DEPS` (default: `OFF`): Build external dependencies (htslib, gsl, libdeflate) from source. Use this if system libraries are not available or you want to use specific versions. HTSlib will be built without curl support, which removes a warning for static compilation related to `dlopen`. +- `BUILD_RETARGETABLE` (default: `OFF`): Build a retargetable binary. When this option is enabled, the binary will not include machine-specific optimizations (`-march=native`). + +These can be mixed and matched. + +### Building with System Libraries + +To build `wfmash` using system libraries: + +```sh +cmake -H. -Bbuild && cmake --build build -- -j 8 ``` -cmake -H. -Bbuild -DCMAKE_C_COMPILER='/usr/bin/gcc-10' -DCMAKE_CXX_COMPILER='/usr/bin/g++-10' -cmake --build build -- -j 8 -``` -The `wfmash` binary will be in `build/bin`. -#### Static compilation +This command will configure and build `wfmash` in the `build` directory, using as many cores as you specify with the `-j` option. -By default, we build `wfmash` in Release mode (with optimizations) and as a dynamically linked executable. -Alternatively we can build a static binary: +### Building with External Dependencies +If you need to build with external dependencies, use the `BUILD_DEPS` option: + +```sh +cmake -H. -Bbuild -DBUILD_DEPS=ON && cmake --build build -- -j 8 ``` + +This will download and build the necessary external dependencies. + +### Building a Static Binary + +To build a static binary, use the `BUILD_STATIC` option: + +```sh cmake -H. -Bbuild -DBUILD_STATIC=ON && cmake --build build -- -j 16 ``` -#### Notes for distribution +### Building a Retargetable Binary -If you need to avoid machine-specific optimizations, use the `CMAKE_BUILD_TYPE=Generic` build type: +To build a retargetable binary, use the `BUILD_RETARGETABLE` option: -```shell -cmake -H. -Bbuild -D CMAKE_BUILD_TYPE=Generic && cmake --build build -- -j 3 +```sh +cmake -H. -Bbuild -DBUILD_RETARGETABLE=ON && cmake --build build -- -j 8 ``` -#### Notes on dependencies +This will configure the build without `-march=native`, allowing the binary to be run on different types of machines. -On `Arch Linux`, the `jemalloc` dependency can be installed with: +### Installing +After building, you can install `wfmash` using: + +```sh +cmake --install build ``` -sudo pacman -S jemalloc # arch linux + +This will install the `wfmash` binary and any required libraries to the default installation directory (typically `/usr/local/bin` for binaries). + +#### Tests + +To build and run tests: + +```sh +cmake --build build --target test ``` +#### Notes for distribution + +If you need to avoid machine-specific optimizations, use the `CMAKE_BUILD_TYPE=Generic` build type: + +```shell +cmake -H. -Bbuild -D CMAKE_BUILD_TYPE=Generic && cmake --build build -- -j 8 +``` + +The resulting binary should be compatible with all x86 processors. + #### Notes for debugging/plotting To enable the functionality of emitting wavefront plots (in PNG format), tables (in TSV format), and timing information, add the `-DWFA_PNG_TSV_TIMING=ON` option: @@ -229,16 +291,6 @@ singularity run wfmash.sif $ARGS Where `$ARGS` are your typical command line arguments to `wfmash`. - -### Bioconda - -`wfmash` recipes for Bioconda are available at https://anaconda.org/bioconda/wfmash. -To install the latest version using `Conda` execute: - -``` bash -conda install -c bioconda wfmash -``` - ### Guix #### installing via the guix-genomics git repository