Skip to content

Commit

Permalink
Merge pull request #25 from ssciwr/fix_17_openmp
Browse files Browse the repository at this point in the history
enable OpenMP on linux
  • Loading branch information
lkeegan authored Jul 19, 2021
2 parents adb4aa9 + 7a25544 commit 8922d74
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ on: [push, pull_request]

env:
BUILD_TYPE: Release
AVX2: OFF
AVX512: OFF
HAMMING_WITH_AVX2: OFF
HAMMING_WITH_AVX512: OFF
HAMMING_WITH_OPENMP: OFF

jobs:
build-and-test:
Expand All @@ -17,18 +18,21 @@ jobs:
os: [ubuntu-18.04, macos-10.15, windows-2019]

steps:
# clone the repo & any submodules
- uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: enable openmp on linux
run: echo "HAMMING_WITH_OPENMP=ON" >> $GITHUB_ENV
if: runner.os == 'Linux'

- name: make build directory
run: cmake -E make_directory ${{runner.workspace}}/build

- name: configure cmake
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=ON -DHAMMING_BUILD_BENCHMARKS=ON -DHAMMING_WITH_SSE2=ON -DHAMMING_WITH_AVX2=$AVX2 -DHAMMING_WITH_AVX512=$AVX512 -DHAMMING_BUILD_PYTHON=ON
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=ON -DHAMMING_BUILD_BENCHMARKS=ON -DHAMMING_WITH_SSE2=ON -DHAMMING_WITH_AVX2=$HAMMING_WITH_AVX2 -DHAMMING_WITH_AVX512=$HAMMING_WITH_AVX512 -DHAMMING_BUILD_PYTHON=ON -DHAMMING_WITH_OPENMP=$HAMMING_WITH_OPENMP

- name: build
shell: bash
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ jobs:
env:
CIBW_TEST_REQUIRES: 'pytest numpy'
CIBW_TEST_COMMAND: 'pytest {project}/python/tests'
CIBW_TEST_SKIP: "pp*"
CIBW_TEST_SKIP: 'pp*'
CIBW_SKIP: "*-manylinux_i686"
CIBW_BUILD_VERBOSITY: 3

strategy:
matrix:
Expand All @@ -20,6 +22,10 @@ jobs:
with:
submodules: 'recursive'

- name: enable openmp on linux
run: echo 'CIBW_ENVIRONMENT=HAMMING_WITH_OPENMP=ON' >> $GITHUB_ENV
if: runner.os == 'Linux'

- uses: pypa/[email protected]

- uses: actions/upload-artifact@v2
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ data.dump_sequence_indices("indices.txt")
data = hammingdist.from_stringlist(["ACGTACGT", "ACGTAGGT", "ATTTACGT"])
```

The Python package is currently built without OpenMP support, but this can
be changed upon request.
## OpenMP on linux

The latest version of hammingdist on linux is now built with OpenMP (multithreading) support.
If this causes any issues, you can install the previous version of hammingdist without OpenMP support:
```bash
pip install hammingdist==0.11.0
```
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def build_extension(self, ext):
'-DHAMMING_BUILD_PYTHON=ON',
'-DBUILD_TESTING=OFF',
'-DHAMMING_BUILD_BENCHMARKS=OFF',
'-DHAMMING_WITH_OPENMP=OFF',
'-DHAMMING_WITH_OPENMP=' + os.environ.get('HAMMING_WITH_OPENMP', 'OFF')
]

cfg = 'Debug' if self.debug else 'Release'
Expand Down Expand Up @@ -77,7 +77,7 @@ def build_extension(self, ext):

setup(
name='hammingdist',
version='0.11.0',
version='0.12.0',
author='Dominic Kempf, Liam Keegan',
author_email='[email protected]',
description='A fast tool to calculate Hamming distances',
Expand Down
4 changes: 4 additions & 0 deletions src/hamming_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ TEST_CASE("from_csv reproduces correct data", "[hamming]") {
std::remove(tmp_file_name);
}


// skip this test of openmp is enabled: affects exception handling
#ifndef HAMMING_WITH_OPENMP
TEST_CASE("throws on distance integer overflow", "[hamming]") {
auto n = std::numeric_limits<DistIntType>::max() + 1;
std::mt19937 gen(12345);
Expand All @@ -243,6 +246,7 @@ TEST_CASE("throws on distance integer overflow", "[hamming]") {
std::string msg{"Error: Distance is too large for chosen integer type"};
REQUIRE_THROWS_WITH(DataSet(data), msg);
}
#endif

TEST_CASE("from_lower_triangular reproduces correct data", "[hamming]") {
std::mt19937 gen(12345);
Expand Down

0 comments on commit 8922d74

Please sign in to comment.