Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Dec 26, 2024
2 parents 3927a34 + feba2ed commit 22220ea
Show file tree
Hide file tree
Showing 21 changed files with 117 additions and 280 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/phono3py-pytest-conda-mkl-phphmtblas.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pytest with mkl sing BLAS for phph-calc
name: Pytest with mkl using BLAS for phph-calc

on:
pull_request:
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install phono3py
run: |
conda activate test
PHPHCALC_USE_MTBLAS=ON pip install -e . -vvv
BUILD_WITHOUT_LAPACKE=OFF PHPHCALC_USE_MTBLAS=ON pip install -e . -vvv
- name: Run pytest
run: |
conda activate test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda-mkl-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install phono3py
run: |
conda activate test
pip install -e . -vvv
BUILD_WITHOUT_LAPACKE=OFF pip install -e . -vvv
- name: Run pytest
run: |
conda activate test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda-mkl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Run pytest
run: |
conda activate test
pytest -v --cov=./ --cov-report=xml test
BUILD_WITHOUT_LAPACKE=OFF pytest -v --cov=./ --cov-report=xml test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda-phphmtblas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install phono3py
run: |
conda activate test
PHPHCALC_USE_MTBLAS=ON pip install -e . -vvv
BUILD_WITHOUT_LAPACKE=OFF PHPHCALC_USE_MTBLAS=ON pip install -e . -vvv
- name: Run pytest
run: |
conda activate test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pytest without linking BLAS and LAPACK in C
name: Pytest with linking BLAS and LAPACK in C

on:
pull_request:
Expand All @@ -24,7 +24,7 @@ jobs:
run: |
conda activate test
conda install --yes python=${{ matrix.python-version }}
conda install --yes matplotlib-base pyyaml h5py scipy pytest spglib cmake c-compiler cxx-compiler
conda install --yes matplotlib-base pyyaml "libblas=*=*openblas" openblas h5py scipy pytest spglib cmake c-compiler cxx-compiler
- name: Install symfc develop branch
run: |
conda activate test
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Install phono3py
run: |
conda activate test
BUILD_WITHOUT_LAPACKE=ON pip install -e . -vvv
BUILD_WITHOUT_LAPACKE=OFF pip install -e . -vvv
- name: Run pytest
run: |
conda activate test
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/phono3py-pytest-conda.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pytest with openblas
name: Pytest without using LAPACKE

on:
pull_request:
Expand All @@ -25,13 +25,13 @@ jobs:
run: |
conda activate test
conda install --yes python=${{ matrix.python-version }}
conda install --yes matplotlib-base pyyaml "libblas=*=*openblas" openblas h5py "numpy>=2.1" scipy pytest spglib alm cmake c-compiler cxx-compiler pypolymlp
conda install --yes matplotlib-base pyyaml h5py "numpy>=2.1" scipy pytest spglib alm cmake c-compiler cxx-compiler pypolymlp
- name: Install dependent packages for python == 3.9
if: ${{ matrix.python-version == 3.9 }}
run: |
conda activate test
conda install --yes python=${{ matrix.python-version }}
conda install --yes matplotlib-base pyyaml "libblas=*=*openblas" openblas h5py scipy pytest spglib alm cmake c-compiler cxx-compiler
conda install --yes matplotlib-base pyyaml h5py scipy pytest spglib alm cmake c-compiler cxx-compiler
- name: Install symfc develop branch
run: |
conda activate test
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
exclude: ^example/AlN-LDA/

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.3
rev: v0.8.4
hooks:
- id: ruff
args: [ "--fix", "--show-fixes" ]
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_SYSTEM_PREFIX_PATH: ${CMAKE_SYSTEM_PREFIX_PATH}")

if(USE_CONDA_PATH AND DEFINED ENV{CONDA_PREFIX})
if((NOT BUILD_WITHOUT_LAPACKE)
AND USE_CONDA_PATH
AND DEFINED ENV{CONDA_PREFIX})
message(STATUS "$ENV{CONDA_PREFIX}")
set(CMAKE_MODULE_PATH $ENV{CONDA_PREFIX})
set(MY_INCLUDES $ENV{CONDA_PREFIX}/include ${PROJECT_SOURCE_DIR}/c)
Expand Down
162 changes: 0 additions & 162 deletions c/_phono3py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,168 +887,6 @@ void py_get_triplets_integration_weights_with_sigma(
num_triplets, frequencies, num_band, num_iw);
}

long py_get_grid_index_from_address(nb::ndarray<> py_address,
nb::ndarray<> py_D_diag) {
long *address;
long *D_diag;
long gp;

address = (long *)py_address.data();
D_diag = (long *)py_D_diag.data();

gp = ph3py_get_grid_index_from_address(address, D_diag);

return gp;
}

long py_get_ir_grid_map(nb::ndarray<> py_grid_mapping_table,
nb::ndarray<> py_D_diag, nb::ndarray<> py_is_shift,
nb::ndarray<> py_rotations) {
long *D_diag;
long *is_shift;
long(*rot)[3][3];
long num_rot;

long *grid_mapping_table;
long num_ir;

D_diag = (long *)py_D_diag.data();
is_shift = (long *)py_is_shift.data();
rot = (long(*)[3][3])py_rotations.data();
num_rot = (long)py_rotations.shape(0);
grid_mapping_table = (long *)py_grid_mapping_table.data();

num_ir = ph3py_get_ir_grid_map(grid_mapping_table, D_diag, is_shift, rot,
num_rot);
return num_ir;
}

void py_get_gr_grid_addresses(nb::ndarray<> py_gr_grid_addresses,
nb::ndarray<> py_D_diag) {
long(*gr_grid_addresses)[3];
long *D_diag;

gr_grid_addresses = (long(*)[3])py_gr_grid_addresses.data();
D_diag = (long *)py_D_diag.data();

ph3py_get_gr_grid_addresses(gr_grid_addresses, D_diag);
}

long py_get_reciprocal_rotations(nb::ndarray<> py_rec_rotations,
nb::ndarray<> py_rotations,
long is_time_reversal) {
long(*rec_rotations)[3][3];
long(*rotations)[3][3];
long num_rot, num_rec_rot;

rec_rotations = (long(*)[3][3])py_rec_rotations.data();
rotations = (long(*)[3][3])py_rotations.data();
num_rot = (long)py_rotations.shape(0);

num_rec_rot = ph3py_get_reciprocal_rotations(rec_rotations, rotations,
num_rot, is_time_reversal);

return num_rec_rot;
}

bool py_transform_rotations(nb::ndarray<> py_transformed_rotations,
nb::ndarray<> py_rotations, nb::ndarray<> py_D_diag,
nb::ndarray<> py_Q) {
long(*transformed_rotations)[3][3];
long(*rotations)[3][3];
long *D_diag;
long(*Q)[3];
long num_rot, succeeded;

transformed_rotations = (long(*)[3][3])py_transformed_rotations.data();
rotations = (long(*)[3][3])py_rotations.data();
D_diag = (long *)py_D_diag.data();
Q = (long(*)[3])py_Q.data();
num_rot = (long)py_transformed_rotations.shape(0);

succeeded = ph3py_transform_rotations(transformed_rotations, rotations,
num_rot, D_diag, Q);
if (succeeded) {
return true;
} else {
return false;
}
}

bool py_get_snf3x3(nb::ndarray<> py_D_diag, nb::ndarray<> py_P,
nb::ndarray<> py_Q, nb::ndarray<> py_A) {
long *D_diag;
long(*P)[3];
long(*Q)[3];
long(*A)[3];
long succeeded;

D_diag = (long *)py_D_diag.data();
P = (long(*)[3])py_P.data();
Q = (long(*)[3])py_Q.data();
A = (long(*)[3])py_A.data();

succeeded = ph3py_get_snf3x3(D_diag, P, Q, A);
if (succeeded) {
return true;
} else {
return false;
}
}

long py_get_bz_grid_addresses(nb::ndarray<> py_bz_grid_addresses,
nb::ndarray<> py_bz_map, nb::ndarray<> py_bzg2grg,
nb::ndarray<> py_D_diag, nb::ndarray<> py_Q,
nb::ndarray<> py_PS,
nb::ndarray<> py_reciprocal_lattice, long type) {
long(*bz_grid_addresses)[3];
long *bz_map;
long *bzg2grg;
long *D_diag;
long(*Q)[3];
long *PS;
double(*reciprocal_lattice)[3];
long num_total_gp;

bz_grid_addresses = (long(*)[3])py_bz_grid_addresses.data();
bz_map = (long *)py_bz_map.data();
bzg2grg = (long *)py_bzg2grg.data();
D_diag = (long *)py_D_diag.data();
Q = (long(*)[3])py_Q.data();
PS = (long *)py_PS.data();
reciprocal_lattice = (double(*)[3])py_reciprocal_lattice.data();

num_total_gp =
ph3py_get_bz_grid_addresses(bz_grid_addresses, bz_map, bzg2grg, D_diag,
Q, PS, reciprocal_lattice, type);

return num_total_gp;
}

long py_rotate_bz_grid_addresses(long bz_grid_index, nb::ndarray<> py_rotation,
nb::ndarray<> py_bz_grid_addresses,
nb::ndarray<> py_bz_map,
nb::ndarray<> py_D_diag, nb::ndarray<> py_PS,
long type) {
long(*bz_grid_addresses)[3];
long(*rotation)[3];
long *bz_map;
long *D_diag;
long *PS;
long ret_bz_gp;

bz_grid_addresses = (long(*)[3])py_bz_grid_addresses.data();
rotation = (long(*)[3])py_rotation.data();
bz_map = (long *)py_bz_map.data();
D_diag = (long *)py_D_diag.data();
PS = (long *)py_PS.data();

ret_bz_gp = ph3py_rotate_bz_grid_index(
bz_grid_index, rotation, bz_grid_addresses, bz_map, D_diag, PS, type);

return ret_bz_gp;
}

long py_get_default_colmat_solver() {
#if defined(MKL_BLAS) || defined(SCIPY_MKL_H) || !defined(NO_INCLUDE_LAPACKE)
return (long)1;
Expand Down
5 changes: 3 additions & 2 deletions c/lapack_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#define min(a, b) ((a) > (b) ? (b) : (a))

#if (defined(MKL_BLAS) || defined(SCIPY_MKL_H)) && !defined(NO_INCLUDE_LAPACKE)
#if defined(_MSC_VER) || defined(MKL_BLAS) || defined(SCIPY_MKL_H)
lapack_complex_double lapack_make_complex_double(double re, double im) {
lapack_complex_double z;
z.real = re;
Expand All @@ -47,7 +47,8 @@ lapack_complex_double lapack_make_complex_double(double re, double im) {
}
#endif

#if defined(MKL_BLAS) || defined(SCIPY_MKL_H) || defined(NO_INCLUDE_LAPACKE)
#if defined(_MSC_VER) || defined(MKL_BLAS) || defined(SCIPY_MKL_H) || \
defined(NO_INCLUDE_LAPACKE)
#ifndef LAPACKE_malloc
#define LAPACKE_malloc(size) malloc(size)
#endif
Expand Down
29 changes: 18 additions & 11 deletions c/lapack_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,21 @@
#ifndef __lapack_wrapper_H__
#define __lapack_wrapper_H__

#ifdef NO_INCLUDE_LAPACKE
#if defined(_MSC_VER) || defined(MKL_BLAS) || defined(SCIPY_MKL_H)
#if defined(_MSC_VER)
typedef struct {
double real;
double imag;
} lapack_complex_double;
#else
#include <mkl.h>
#define lapack_complex_double MKL_Complex16
#endif
lapack_complex_double lapack_make_complex_double(double re, double im);
#define lapack_complex_double_real(z) ((z).real)
#define lapack_complex_double_imag(z) ((z).imag)
#else
#if defined(NO_INCLUDE_LAPACKE)
#include <complex.h>
#define lapack_complex_double double _Complex
#ifdef CMPLX
Expand All @@ -45,18 +59,11 @@
#endif
#define lapack_complex_double_real(z) (creal(z))
#define lapack_complex_double_imag(z) (cimag(z))
#else
#if !defined(MKL_BLAS) && !defined(SCIPY_MKL_H)
#include <lapacke.h>
#endif

#if defined(MKL_BLAS) || defined(SCIPY_MKL_H)
#include <mkl.h>
#define lapack_complex_double MKL_Complex16
MKL_Complex16 lapack_make_complex_double(double re, double im);
#define lapack_complex_double_real(z) ((z).real)
#define lapack_complex_double_imag(z) ((z).imag)
#endif

#if !defined(MKL_BLAS) && !defined(SCIPY_MKL_H) && !defined(NO_INCLUDE_LAPACKE)
#include <lapacke.h>
#endif

lapack_complex_double phonoc_complex_prod(const lapack_complex_double a,
Expand Down
31 changes: 0 additions & 31 deletions c/phono3py.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,37 +176,6 @@ void ph3py_get_integration_weight_with_sigma(
const double *frequency_points, const long num_band0,
const long (*triplets)[3], const long num_triplets,
const double *frequencies, const long num_band, const long tp_type);
long ph3py_get_grid_index_from_address(const long address[3],
const long mesh[3]);
void ph3py_get_gr_grid_addresses(long gr_grid_addresses[][3],
const long D_diag[3]);
long ph3py_get_reciprocal_rotations(long rec_rotations[48][3][3],
const long (*rotations)[3][3],
const long num_rot,
const long is_time_reversal);
long ph3py_transform_rotations(long (*transformed_rots)[3][3],
const long (*rotations)[3][3],
const long num_rot, const long D_diag[3],
const long Q[3][3]);
long ph3py_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
const long A[3][3]);
long ph3py_transform_rotations(long (*transformed_rots)[3][3],
const long (*rotations)[3][3],
const long num_rot, const long D_diag[3],
const long Q[3][3]);
long ph3py_get_ir_grid_map(long *ir_grid_map, const long D_diag[3],
const long PS[3], const long (*grg_rotations)[3][3],
const long num_rot);
long ph3py_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map,
long *bzg2grg, const long D_diag[3],
const long Q[3][3], const long PS[3],
const double rec_lattice[3][3],
const long type);
long ph3py_rotate_bz_grid_index(const long bz_grid_index,
const long rotation[3][3],
const long (*bz_grid_addresses)[3],
const long *bz_map, const long D_diag[3],
const long PS[3], const long bz_grid_type);
void ph3py_symmetrize_collision_matrix(double *collision_matrix,
const long num_column,
const long num_temp,
Expand Down
4 changes: 4 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Change Log

## Dec-26-2024: Version 3.10.2

- `BUILD_WITHOUT_LAPACKE=ON` was made as the default compilation choice.

## Dec-23-2024: Version 3.10.1

- Replace `dtype="int_"` by `dtype="long"`.
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# The short X.Y version.
version = "3.10"
# The full version, including alpha/beta/rc tags.
release = "3.10.1"
release = "3.10.2"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
Loading

0 comments on commit 22220ea

Please sign in to comment.