Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ env:
ninja
cmake
gcovr

jobs:
gcc-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
Expand All @@ -43,6 +43,11 @@ jobs:
sanitizer: none
buildtype: release

runs-on: ${{ matrix.os }}

permissions:
contents: read

env:
FC: gfortran
CC: gcc
Expand All @@ -52,7 +57,9 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -62,23 +69,29 @@ jobs:
- name: Install GCC ${{ matrix.GCC_V }} (OSX)
if: contains(matrix.os, 'macos')
run: |
ln -s /usr/local/bin/gfortran-${{ env.GCC_V }} /usr/local/bin/gfortran
ln -s /usr/local/bin/gcc-${{ env.GCC_V }} /usr/local/bin/gcc
ln -s /usr/local/bin/g++-${{ env.GCC_V }} /usr/local/bin/g++
ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
ln -s /usr/local/bin/gcc-${GCC_V} /usr/local/bin/gcc
ln -s /usr/local/bin/g++-${GCC_V} /usr/local/bin/g++
env:
GCC_V: ${{ env.GCC_V }}

- name: Install GCC (Linux)
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-${{ env.GCC_V }} g++-${{ env.GCC_V }} gfortran-${{ env.GCC_V }}
sudo apt-get install gcc-${GCC_V} g++-${GCC_V} gfortran-${GCC_V}
env:
GCC_V: ${{ env.GCC_V }}

- name: Set GCC Version (Linux)
if: contains(matrix.os, 'ubuntu')
run: >-
sudo update-alternatives
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }}
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }}
--install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V}
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
env:
GCC_V: ${{ env.GCC_V }}

- name: Install CBLAS and LAPACKE
if: contains(matrix.os, 'ubuntu')
Expand All @@ -95,7 +108,7 @@ jobs:
--libdir=lib
--warnlevel=0
-Dsanitizer=${{ matrix.sanitizer }}
-Db_coverage=${{ env.COVERAGE }}
-Db_coverage=${COVERAGE}
env:
COVERAGE: ${{ contains(matrix.os, 'ubuntu') && 'true' || 'false' }}

Expand All @@ -107,7 +120,7 @@ jobs:
meson test -C ${{ env.M_BUILD_DIR }} --print-errorlogs --no-rebuild --num-processes 2 -t 2

- name: Create coverage report
if: matrix.os == 'ubuntu-latest' && matrix.GCC_V == '11'
if: matrix.os == 'ubuntu-latest' && matrix.GCC_V == '12'
run: |
ninja -C ${{ env.M_BUILD_DIR }} coverage

Expand All @@ -117,7 +130,8 @@ jobs:
echo "DFTD4_PREFIX=$PWD/_dist" >> $GITHUB_ENV

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest' && matrix.GCC_V == '11'
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # 5.1.1
if: matrix.os == 'ubuntu-latest' && matrix.GCC_V == '12'
with:
files: ./coverage.xml # optional
verbose: true # optional (default = false)
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-yaml
- id: check-added-large-files
args: ["--maxkb=20000"]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v21.1.7
hooks:
- id: clang-format
types_or: [c++, c, cuda]

- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.18.0
hooks:
- id: zizmor
5 changes: 3 additions & 2 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void help() {

<file> is a valid xmol file (coordinates in Ångström).
(Turbomole coordinate file (coordinates in Bohr) not yet supported!)


Options:

Expand Down Expand Up @@ -146,7 +146,8 @@ int main(int argc, char **argv) {
} else if (args.getflag("-f")) {
func = args.getopt("-f");
} else {
printf("WARNING: No functional given (via '--func'). Defaulting to PBE.\n\n"
printf(
"WARNING: No functional given (via '--func'). Defaulting to PBE.\n\n"
);
func = "pbe";
}
Expand Down
42 changes: 23 additions & 19 deletions include/dftd_cblas.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/*
* This file contains code adapted from the ORCA quantum chemistry program.
* ORCA is developed by the group of Prof. Frank Neese at the Max-Planck-Institut für Kohlenforschung,
* Mülheim an der Ruhr and FAccTs GmbH. ORCA is licensed by the Max-Planck-Institut für Kohlenforschung and FAccTs GmbH.
* ORCA is developed by the group of Prof. Frank Neese at the
* Max-Planck-Institut für Kohlenforschung, Mülheim an der Ruhr and FAccTs GmbH.
* ORCA is licensed by the Max-Planck-Institut für Kohlenforschung and FAccTs
* GmbH.
*
* The inclusion of ORCA code in this file has been done with the explicit permission
* of the ORCA developers.
* The inclusion of ORCA code in this file has been done with the explicit
* permission of the ORCA developers.
*
* For reuse or licensing of this code, please contact the ORCA team at the Max-Planck-Institut
* für Kohlenforschung (https://orcaforum.kofo.mpg.de/) or FAccTs GmbH (https://www.faccts.de/).
* For reuse or licensing of this code, please contact the ORCA team at the
* Max-Planck-Institut für Kohlenforschung (https://orcaforum.kofo.mpg.de/) or
* FAccTs GmbH (https://www.faccts.de/).
*/
#pragma once

Expand Down Expand Up @@ -35,8 +38,8 @@ inline int BLAS_Add_Mat_x_Vec(
bool Transpose,
double alpha
) {
if (Transpose) {
if (A.cols == C.N && A.rows == V.N) {
if (Transpose) {
if (A.cols == C.N && A.rows == V.N) {
cblas_dgemv(
CblasRowMajor,
CblasTrans,
Expand All @@ -54,7 +57,7 @@ inline int BLAS_Add_Mat_x_Vec(
return EXIT_SUCCESS;
};
} else {
if (A.rows == C.N && A.cols == V.N) {
if (A.rows == C.N && A.cols == V.N) {
cblas_dgemv(
CblasRowMajor,
CblasNoTrans,
Expand Down Expand Up @@ -98,7 +101,7 @@ inline int BLAS_Add_Mat_x_Mat(
// check for size 0 matrices
if (A.cols == 0 || A.rows == 0 || B.cols == 0 || B.rows == 0 || C.cols == 0 ||
C.rows == 0) {
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
};

// check for transpositions
Expand Down Expand Up @@ -221,9 +224,9 @@ inline int BLAS_InvertMatrix(TMatrix<double> &a) {
(lapack_int)a.cols,
ipiv
);
if (info != 0) {
if (info != 0) {
delete[] ipiv;
return EXIT_FAILURE;
return EXIT_FAILURE;
}

// Inverse of an LU-factored general matrix
Expand All @@ -240,19 +243,19 @@ inline int BLAS_InvertMatrix(TMatrix<double> &a) {
/**
* @brief Solve a symmetric linear system A * X = B for X.
*
* This routine factorizes a symmetric matrix A using Bunch-Kaufman factorization
* and solves for the right-hand side vector B. The matrix A is overwritten
* by its factorization. The solution overwrites B.
* This routine factorizes a symmetric matrix A using Bunch-Kaufman
* factorization and solves for the right-hand side vector B. The matrix A is
* overwritten by its factorization. The solution overwrites B.
*
* @param A Symmetric matrix of size (m x m). Overwritten by the factorization.
* @param B Right-hand side vector of size m. Overwritten by the solution.
* @return int Returns EXIT_SUCCESS (0) on success, EXIT_FAILURE (1) on error.
*/
inline int BLAS_SolveSymmetric(
TMatrix<double> &A, // symmetric matrix
TVector<double> &B // RHS vector (becomes solution)
TMatrix<double> &A, // symmetric matrix
TVector<double> &B // RHS vector (becomes solution)
) {
const lapack_int m = A.rows;
const lapack_int m = A.rows;
const lapack_int nrhs = 1;

if (A.cols != m || B.N != m) {
Expand All @@ -272,7 +275,8 @@ inline int BLAS_SolveSymmetric(
}

// Solve for all RHS columns
info = LAPACKE_dsytrs(LAPACK_ROW_MAJOR, 'L', m, nrhs, A.p, m, ipiv, B.p, nrhs);
info =
LAPACKE_dsytrs(LAPACK_ROW_MAJOR, 'L', m, nrhs, A.p, m, ipiv, B.p, nrhs);
delete[] ipiv;

if (info != 0) {
Expand Down
Loading