Skip to content

Commit

Permalink
Macro setting in cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Aug 30, 2022
1 parent cd679b2 commit b89f321
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/phono3py-pytest-conda-mkl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Python Package using Conda

on:
push:
branches-ignore:
- master
- rc

jobs:
build-linux:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
# Use conda-incubator/setup-miniconda for precise control of conda infrastructure
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
channels: conda-forge
channel-priority: strict
python-version: ${{ matrix.python-version }}
- name: Install dependent packages
run: |
conda activate test
conda install --yes python=${{ matrix.python-version }}
#conda install --yes matplotlib-base pyyaml "libblas=*=*openblas" openblas h5py scipy pytest codecov pytest-cov spglib alm cmake c-compiler
conda install --yes matplotlib-base pyyaml "libblas=*=*mkl" mkl-include h5py scipy pytest codecov pytest-cov spglib alm cmake c-compiler
- name: Install phonopy
run: |
conda activate test
git clone --depth 1 https://github.com/phonopy/phonopy.git
cd phonopy
pip install -e . -vvv
cd ..
- name: Install phono3py
run: |
conda activate test
pip install -e . -vvv
- name: Run pytest
run: |
pytest --cov=./ --cov-report=xml test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
verbose: true
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,17 @@ endif()

if (PHONO3PY OR PHONONMOD)
if (BLAS_LIBRARIES MATCHES "libmkl")
message(STATUS "MKL library detected")
add_compile_definitions(MKL_LAPACKE) # phono3py macro
message(STATUS "MKL detected: Set C-macros MKL_LAPACKE MULTITHREADED_BLAS")
add_compile_definitions(MKL_LAPACKE)
add_compile_definitions(MULTITHREADED_BLAS) # phono3py macro
add_compile_definitions(NPY_NO_DEPRECATED_API=0) # phono3py macro
add_compile_definitions(THM_EPSILON=1e-10) # phono3py macro
endif()
if (BLAS_LIBRARIES MATCHES "libopenblas")
message(STATUS "OpenBLAS detected: Set C-macro MULTITHREADED_BLAS")
add_compile_definitions(MULTITHREADED_BLAS) # phono3py macro
add_compile_definitions(NPY_NO_DEPRECATED_API=0) # phono3py macro
add_compile_definitions(THM_EPSILON=1e-10) # phono3py macro
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions c/phonon.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ static void get_undone_phonons(
}

/* To avoid multithreaded BLAS in OpenMP loop */
#ifdef _OPENMP
#ifndef MULTITHREADED_BLAS
#ifdef _OPENMP
#pragma omp parallel for private(j, gp, freqs_tmp, info)
#endif
#endif
Expand Down Expand Up @@ -274,8 +274,8 @@ static void get_gonze_undone_phonons(
}

/* To avoid multithreaded BLAS in OpenMP loop */
#ifdef _OPENMP
#ifndef MULTITHREADED_BLAS
#ifdef _OPENMP
#pragma omp parallel for private(j, gp, freqs_tmp, info)
#endif
#endif
Expand Down

0 comments on commit b89f321

Please sign in to comment.