Skip to content

Commit fbf4318

Browse files
authored
Merge pull request ZimmermanGroup#46 from ZimmermanGroup/44-github-actions
Add GitHub Actions CI workflow
2 parents 4efef9f + baa5ebd commit fbf4318

File tree

7 files changed

+256
-39
lines changed

7 files changed

+256
-39
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
schedule:
9+
# Run monthly on the 1st at midnight UTC to test with latest pixi
10+
- cron: '0 0 1 * *'
11+
12+
jobs:
13+
build:
14+
strategy:
15+
matrix:
16+
include:
17+
- os: ubuntu-latest
18+
platform: linux-64
19+
- os: macos-latest
20+
platform: osx-arm64
21+
22+
runs-on: ${{ matrix.os }}
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Extract minimum pixi version from pixi.toml
29+
id: pixi-version
30+
run: |
31+
# Extract version from requires-pixi = ">=X.Y.Z"
32+
VERSION=$(grep 'requires-pixi' pixi.toml | sed 's/.*>=\([0-9.]*\).*/\1/')
33+
echo "version=$VERSION" >> $GITHUB_OUTPUT
34+
echo "Using minimum pixi version: $VERSION"
35+
36+
- name: Set up Pixi (minimum version)
37+
if: github.event_name != 'schedule'
38+
uses: prefix-dev/setup-pixi@v0.9.1
39+
with:
40+
pixi-version: v${{ steps.pixi-version.outputs.version }}
41+
log-level: v
42+
cache: true
43+
44+
- name: Set up Pixi (latest version for scheduled builds)
45+
if: github.event_name == 'schedule'
46+
uses: prefix-dev/setup-pixi@v0.9.1
47+
with:
48+
log-level: v
49+
cache: true
50+
51+
- name: Run test
52+
run: pixi run test

GSM/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ message("${BLAS_LIBRARIES} ${BLAS_LINKER_FLAGS}")
7575

7676
find_package(BLAS REQUIRED)
7777
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}")
78-
target_include_directories(gsm PUBLIC "$ENV{MKLROOT}/include")
78+
79+
# MKL include path (Linux only)
80+
if(DEFINED ENV{MKLROOT})
81+
target_include_directories(gsm PUBLIC "$ENV{MKLROOT}/include")
82+
endif()
7983

8084
FIND_PACKAGE( OpenMP REQUIRED)
8185
if(OPENMP_FOUND)

GSM/blas_compat.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// BLAS/LAPACK compatibility header for cross-platform support
2+
// Abstracts differences between MKL (Linux) and OpenBLAS (macOS)
3+
4+
#ifndef BLAS_COMPAT_H
5+
#define BLAS_COMPAT_H
6+
7+
#ifdef __APPLE__
8+
// macOS with OpenBLAS/Accelerate
9+
#include <cblas.h>
10+
11+
// Define MKL_INT as int for compatibility with existing code
12+
typedef int MKL_INT;
13+
14+
// Declare LAPACK functions (Fortran interface)
15+
extern "C" {
16+
void dgesvd_(char*, char*, int*, int*, double*, int*, double*, double*, int*,
17+
double*, int*, double*, int*, int*);
18+
void dgetrf_(int*, int*, double*, int*, int*, int*);
19+
void dgetri_(int*, double*, int*, int*, double*, int*, int*);
20+
void dsyevx_(char*, char*, char*, int*, double*, int*, double*, double*,
21+
int*, int*, double*, int*, double*, double*, int*, double*,
22+
int*, int*, int*, int*);
23+
void dsyevd_(char*, char*, int*, double*, int*, double*, double*, int*,
24+
int*, int*, int*);
25+
}
26+
27+
#else
28+
// Linux with MKL
29+
#include <mkl.h>
30+
#endif
31+
32+
#endif // BLAS_COMPAT_H

GSM/bmat.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "icoord.h"
22
#include "utils.h"
3-
#include <mkl.h>
4-
//#include "/export/apps/Intel/Compiler/11.1/075/mkl/include/mkl.h"
5-
//#include "/opt/acml5.3.1/gfortran64/include/acml.h"
3+
#include "blas_compat.h"
64

75
using namespace std;
86

GSM/utils.cpp

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@
33
#include "omp.h"
44
//#include <Accelerate/Accelerate.h>
55
//#include <vecLib/clapack.h>
6-
#include <mkl.h>
7-
//#include "/export/apps/Intel/Compiler/11.1/075/mkl/include/mkl.h"
8-
//#include "/export/apps/Intel/Compiler/11.1/075/mkl/include/mkl_lapack.h"
9-
//#include "/opt/acml5.3.1/gfortran64/include/acml.h"
10-
11-
#define USE_ACML 0
12-
13-
// extern "C" void dgesvd_(char*,char*,int*,int*,double*,int*,double*,double*,int*,double*,int*,double*,int*,int*);
14-
// extern "C" void dgetrf_(int*,int*,double*,int*,int*,int*);
15-
// extern "C" void dgetri_(int*,double*,int*,int*,double*,int*,int*);
16-
// extern "C" void dsyevx_(char*,char*,char*,int*,double*,int*,double*,double*,int*,int*,double*,int*,double*,double*,int*,double*,int*,int*,int*,int*);
6+
#include "blas_compat.h"
177

188
using namespace std;
199

@@ -418,12 +408,6 @@ int SVD(double* A, double* V, double* eigen, int m, int n){
418408
MKL_INT mkl_m = (MKL_INT) m;
419409
MKL_INT mkl_n = (MKL_INT) n;
420410

421-
#if USE_ACML
422-
//disabled this function
423-
printf(" SVD not set up for ACML \n");
424-
return -1;
425-
#endif
426-
427411
#if 0
428412
for (int i=0;i<m;i++)
429413
for (int j=0;j<n;j++)
@@ -461,12 +445,10 @@ int SVD(double* A, double* V, double* eigen, int m, int n){
461445
char JOBU='A';
462446
char JOBVT='A';
463447

464-
#if !USE_ACML
465448
dgesvd_(&JOBU, &JOBVT, &mkl_m, &mkl_n, B, &LDA, S, U, &mkl_m, Vt, &mkl_n, Work, &LenWork, &Info);
466449

467450
//vs dgesdd (divide and conquer version)
468451
// dgesdd_((char*)"A", &m, &n, A, &LDA, S, U, &m, Vt, &n, Work0, &LenWork, IWork, &Info);
469-
#endif
470452

471453
if (Info!=0)
472454
printf(" after SVD, Info error is: %i \n",Info);
@@ -610,18 +592,12 @@ int Diagonalize(double* A, double* eigen, int size){
610592

611593
MKL_INT Info = 0;
612594

613-
#if USE_ACML
614-
dsyevx(JobZ, Range, UpLo, N, A, LDA, VL,
615-
VU, IL, IU, AbsTol, &NEValFound, EVal, EVec, LDA,
616-
IFail, &Info);
617-
#else
618595
#if DSYEVX
619596
dsyevx_(&JobZ, &Range, &UpLo, &N, A, &LDA, &VL, &VU, &IL, &IU, &AbsTol,
620597
&NEValFound, EVal, EVec, &LDA, Work, &LenWork, IWork, IFail, &Info);
621598
#else
622599
dsyevd_(&JobZ, &UpLo, &N, A, &LDA, EVal, Work, &LenWork, IWork, &LenIWork, &Info);
623600
#endif
624-
#endif
625601

626602
#if 0
627603
if (Info != 0 && KillJob) {
@@ -686,14 +662,8 @@ int Diagonalize(double* A, double* eigenvecs, double* eigen, int size){
686662

687663
MKL_INT Info = 0;
688664

689-
#if USE_ACML
690-
dsyevx(JobZ, Range, UpLo, N, A, LDA, VL,
691-
VU, IL, IU, AbsTol, &NEValFound, EVal, EVec, LDA,
692-
IFail, &Info);
693-
#else
694665
dsyevx_(&JobZ, &Range, &UpLo, &N, A, &LDA, &VL, &VU, &IL, &IU, &AbsTol,
695666
&NEValFound, EVal, EVec, &LDA, Work, &LenWork, IWork, IFail, &Info);
696-
#endif
697667

698668
#if 0
699669
if (Info != 0 && KillJob) {

0 commit comments

Comments
 (0)