Skip to content

Commit 24c5787

Browse files
authored
Merge branch 'fortran-lang:master' into matmul
2 parents a052599 + 3d0243e commit 24c5787

File tree

90 files changed

+3872
-535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+3872
-535
lines changed

.github/collab.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
echo "📦 GitHub Fork Collaboration Setup Script"
4+
5+
# Prompt for User's GitHub username
6+
7+
read -p "Enter the GitHub username of the fork owner (e.g., alice): " USER
8+
9+
# Prompt for the branch name
10+
11+
read -p "Enter the PR branch name (e.g., feature-branch): " BRANCH
12+
13+
# Add remotes
14+
15+
echo "🔗 Adding remotes..."
16+
17+
git remote add $USER https://github.com/$USER/stdlib.git
18+
19+
# Fetch and checkout the PR branch
20+
21+
echo "📥 Fetching branch '$BRANCH'..."
22+
23+
git fetch $USER
24+
25+
git checkout -b $BRANCH $USER/$BRANCH
26+
27+
# Done
28+
29+
echo "✅ Repo set up. You're now on '$BRANCH'."
30+
31+
echo "You can now make changes and push directly to $USER/stdlib:$BRANCH"

.github/workflows/CI.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,24 @@ jobs:
6161
compiler: ${{ matrix.toolchain.compiler }}
6262
version: ${{ matrix.toolchain.version }}
6363

64+
# Build and test with built-in BLAS and LAPACK
6465
- name: Configure with CMake
6566
if: ${{ contains(matrix.build, 'cmake') }}
6667
run: >-
6768
cmake -Wdev -G Ninja
6869
-DCMAKE_BUILD_TYPE=Release
6970
-DCMAKE_MAXIMUM_RANK:String=4
7071
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
72+
-DFIND_BLAS:STRING=FALSE
7173
-S . -B ${{ env.BUILD_DIR }}
7274
7375
- name: Build and compile
7476
if: ${{ contains(matrix.build, 'cmake') }}
7577
run: cmake --build ${{ env.BUILD_DIR }} --parallel
7678

7779
- name: catch build fail
78-
run: cmake --build ${{ env.BUILD_DIR }} --verbose --parallel 1
7980
if: ${{ failure() && contains(matrix.build, 'cmake') }}
81+
run: cmake --build ${{ env.BUILD_DIR }} --verbose --parallel 1
8082

8183
- name: test
8284
if: ${{ contains(matrix.build, 'cmake') }}

.github/workflows/ci_BLAS.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: CI_BLAS
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
CTEST_TIME_TIMEOUT: "5" # some failures hang forever
7+
CMAKE_GENERATOR: Ninja
8+
9+
jobs:
10+
msys2-build:
11+
runs-on: windows-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include: [{ msystem: UCRT64, arch: x86_64 }]
16+
defaults:
17+
run:
18+
shell: msys2 {0}
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Setup MinGW native environment
23+
uses: msys2/setup-msys2@v2
24+
with:
25+
msystem: ${{ matrix.msystem }}
26+
update: false
27+
install: >-
28+
git
29+
mingw-w64-ucrt-${{ matrix.arch }}-gcc
30+
mingw-w64-ucrt-${{ matrix.arch }}-gcc-fortran
31+
mingw-w64-ucrt-${{ matrix.arch }}-python
32+
mingw-w64-ucrt-${{ matrix.arch }}-python-fypp
33+
mingw-w64-ucrt-${{ matrix.arch }}-cmake
34+
mingw-w64-ucrt-${{ matrix.arch }}-ninja
35+
mingw-w64-ucrt-${{ matrix.arch }}-openblas
36+
37+
# Build and test with external BLAS and LAPACK (OpenBLAS on UCRT64)
38+
- name: Configure with CMake and OpenBLAS
39+
run: >-
40+
PATH=$PATH:/ucrt64/bin/ cmake
41+
-Wdev
42+
-B build
43+
-DCMAKE_BUILD_TYPE=Debug
44+
-DCMAKE_Fortran_FLAGS_DEBUG="-Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fbacktrace"
45+
-DCMAKE_MAXIMUM_RANK:String=4
46+
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
47+
-DFIND_BLAS:STRING=TRUE
48+
env:
49+
FC: gfortran
50+
CC: gcc
51+
CXX: g++
52+
53+
- name: CMake build with OpenBLAS
54+
run: PATH=$PATH:/ucrt64/bin/ cmake --build build --parallel
55+
56+
- name: catch build fail
57+
if: failure()
58+
run: PATH=$PATH:/ucrt64/bin/ cmake --build build --verbose --parallel 1
59+
60+
- name: CTest with OpenBLAS
61+
run: PATH=$PATH:/ucrt64/bin/ ctest --test-dir build --output-on-failure --parallel -V -LE quadruple_precision
62+
63+
- uses: actions/upload-artifact@v4
64+
if: failure()
65+
with:
66+
name: WindowsCMakeTestlog_openblas
67+
path: build/Testing/Temporary/LastTest.log
68+
69+
- name: Install project with OpenBLAS
70+
run: PATH=$PATH:/ucrt64/bin/ cmake --install build
71+
72+
Build:
73+
runs-on: ubuntu-latest
74+
strategy:
75+
fail-fast: false
76+
matrix:
77+
toolchain:
78+
- { compiler: intel, version: "2024.1" }
79+
build: [cmake]
80+
env:
81+
BUILD_DIR: ${{ matrix.build == 'cmake' && 'build' || '.' }}
82+
APT_PACKAGES: >-
83+
intel-oneapi-mkl
84+
intel-oneapi-mkl-devel
85+
steps:
86+
- name: Checkout code
87+
uses: actions/checkout@v4
88+
89+
- name: Set up Python 3.x
90+
uses: actions/setup-python@v5 # Use pip to install latest CMake, & FORD/Jin2For, etc.
91+
with:
92+
python-version: 3.x
93+
94+
- name: Install fypp
95+
run: pip install --upgrade fypp ninja
96+
97+
- name: Setup Fortran compiler
98+
uses: fortran-lang/[email protected]
99+
id: setup-fortran
100+
with:
101+
compiler: ${{ matrix.toolchain.compiler }}
102+
version: ${{ matrix.toolchain.version }}
103+
104+
- name: Install Intel oneAPI MKL
105+
run: |
106+
sudo apt-get install ${APT_PACKAGES}
107+
source /opt/intel/oneapi/mkl/latest/env/vars.sh
108+
printenv >> $GITHUB_ENV
109+
110+
# Build and test with external BLAS and LAPACK (MKL on Ubuntu with Intel compilers)
111+
- name: Configure with CMake and MKL
112+
run: >-
113+
cmake -Wdev -G Ninja
114+
-DCMAKE_BUILD_TYPE=Release
115+
-DCMAKE_MAXIMUM_RANK:String=4
116+
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
117+
-DFIND_BLAS:STRING=TRUE
118+
-S . -B ${{ env.BUILD_DIR }}
119+
120+
- name: Build and compile with MKL
121+
run: cmake --build ${{ env.BUILD_DIR }} --parallel
122+
123+
- name: catch build fail with MKL
124+
if: failure()
125+
run: cmake --build ${{ env.BUILD_DIR }} --verbose --parallel 1
126+
127+
- name: test with MKL
128+
run: >-
129+
ctest
130+
--test-dir ${{ env.BUILD_DIR }}
131+
--parallel
132+
--output-on-failure
133+
--no-tests=error
134+
135+
- name: Install project with MKL
136+
run: cmake --install ${{ env.BUILD_DIR }}

.github/workflows/ci_windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
-DCMAKE_Fortran_FLAGS_DEBUG="-Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fbacktrace"
4444
-DCMAKE_MAXIMUM_RANK:String=4
4545
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
46+
-DFIND_BLAS:STRING=FALSE
4647
env:
4748
FC: gfortran
4849
CC: gcc

CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,58 @@ if(NOT DEFINED CMAKE_MAXIMUM_RANK)
4242
set(CMAKE_MAXIMUM_RANK 4 CACHE STRING "Maximum array rank for generated procedures")
4343
endif()
4444

45+
option(FIND_BLAS "Find external BLAS and LAPACK" ON)
46+
47+
# --- find external BLAS and LAPACK
48+
if(FIND_BLAS)
49+
50+
message(STATUS "Searching for external BLAS/LAPACK")
51+
52+
# Common MKL setup
53+
if(DEFINED ENV{MKLROOT} OR "${BLA_VENDOR}" MATCHES "^(Intel|Intel10_64)")
54+
enable_language("C")
55+
message(STATUS "Detected Intel MKL environment")
56+
endif()
57+
58+
find_package(BLAS)
59+
find_package(LAPACK)
60+
61+
if(BLAS_FOUND AND LAPACK_FOUND)
62+
message(STATUS "Found external BLAS: ${BLAS_LIBRARIES}")
63+
message(STATUS "Found external LAPACK: ${LAPACK_LIBRARIES}")
64+
65+
# Detect ILP64 (common function)
66+
function(detect_ilp64 lib_name)
67+
set(${lib_name}_ILP64 False PARENT_SCOPE)
68+
# Prefer checking BLA_SIZEOF_INTEGER (available in CMake >= 3.22)
69+
if(DEFINED BLA_SIZEOF_INTEGER AND BLA_SIZEOF_INTEGER EQUAL 8)
70+
set(${lib_name}_ILP64 True PARENT_SCOPE)
71+
# Fallback: Check BLA_VENDOR manually for signs of ILP64
72+
elseif("${BLA_VENDOR}" MATCHES ".*(_ilp|ILP64).*")
73+
set(${lib_name}_ILP64 True PARENT_SCOPE)
74+
endif()
75+
endfunction()
76+
77+
detect_ilp64(BLAS)
78+
detect_ilp64(LAPACK)
79+
80+
# Set compile definitions
81+
if(BLAS_ILP64 OR LAPACK_ILP64)
82+
message(STATUS "Enabling 64-bit integer support (ILP64)")
83+
add_compile_definitions(STDLIB_EXTERNAL_BLAS_I64 STDLIB_EXTERNAL_LAPACK_I64)
84+
set(WITH_ILP64 True CACHE BOOL "Use 64-bit integer BLAS/LAPACK" FORCE)
85+
else()
86+
message(STATUS "Using standard 32-bit integer interface")
87+
add_compile_definitions(STDLIB_EXTERNAL_BLAS STDLIB_EXTERNAL_LAPACK)
88+
endif()
89+
90+
else()
91+
message(WARNING "External BLAS/LAPACK not found - "
92+
"Using built-in reference BLAS")
93+
endif()
94+
95+
endif()
96+
4597
# --- find preprocessor
4698
find_program(FYPP fypp)
4799
if(NOT FYPP)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Important options are
135135
- `-DBUILD_TESTING` set to `off` in case you want to disable the stdlib tests (default: `on`).
136136
- `-DCMAKE_VERBOSE_MAKEFILE` is by default set to `Off`, but if set to `On` will show commands used to compile the code.
137137
- `-DCMAKE_BUILD_TYPE` is by default set to `RelWithDebInfo`, which uses compiler flags suitable for code development (but with only `-O2` optimization). Beware the compiler flags set this way will override any compiler flags specified via `FFLAGS`. To prevent this, use `-DCMAKE_BUILD_TYPE=NoConfig` in conjunction with `FFLAGS`.
138+
- `-DFIND_BLAS` set to `off` in case you want to disable finding the external BLAS/LAPACK dependency (default: `on`).
138139

139140
For example, to configure a build using the Ninja backend while specifying compiler optimization via `FFLAGS`, generating procedures up to rank 7, installing to your home directory, using the `NoConfig` compiler flags, and printing the compiler commands, use
140141

WORKFLOW.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,42 @@ The project is usable as CMake subproject. Explicit references to
109109
break subproject builds.
110110
An example project is available [here](https://github.com/fortran-lang/stdlib-cmake-example)
111111
to test the CMake subproject integration.
112+
113+
## GitHub collaboration
114+
115+
Contributing can be daunting, we know! Even more for a big project with many contributors, and if you are not expert on the whole github workflow then even more, we have been there at some point.
116+
117+
In order to help lowering the barrier for collaborating on ongoing efforts (e.g. an open PR), we have crafted a simple script that might come in handy. To explain the process we'll use Alice (the person you want to help) and Bob (you):
118+
119+
┌────────────────────────────┐
120+
│ fortran-lang/stdlib │
121+
└────────────▲───────────────┘
122+
123+
│ [Pull Request]
124+
125+
┌───────┴────────┐
126+
│ alice/stdlib │ ←─────┐
127+
└──────▲─────────┘ │
128+
│ │
129+
[PR Branch] ←───┘ ┌──────┴──────┐
130+
feature-branch │ bob/stdlib │
131+
(hosted here) │ (fork) │
132+
└─────────────┘
133+
134+
135+
[Push access to Alice's repo]
136+
137+
After having forked from `fortran-lang/stdlib` and cloned your `stdlib` fork on your local machine; on an unix compatible terminal with access to the `git` CLI, being at the root folder:
138+
```sh
139+
./.github/collab.sh
140+
```
141+
You will be asked to enter the username and branch of the other person:
142+
```bash
143+
Enter the GitHub username of the fork owner (e.g., alice): alice
144+
Enter the PR branch name (e.g., feature-branch): feature-branch
145+
```
146+
This will fetch Alice's repository and switch your view to Alice's feature-branch. Now you can review, build, run, play around, propose your nice improvements.
147+
148+
Once you finish helping out, you can always `git checkout <your_own_branch>` and/or delet Alice's branch from your local view `git branch -d feature-branch`.
149+
150+
Remember, announce your willingness to help 😉

config/cmake/Findtest-drive.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ foreach(method ${${_pkg}_FIND_METHOD})
123123

124124
# We need the module directory in the subproject before we finish the configure stage
125125
if(NOT EXISTS "${${_pkg}_BINARY_DIR}/include")
126-
make_directory("${${_pkg}_BINARY_DIR}/include")
126+
file(MAKE_DIRECTORY "${${_pkg}_BINARY_DIR}/include")
127127
endif()
128128

129129
break()
@@ -147,7 +147,7 @@ foreach(method ${${_pkg}_FIND_METHOD})
147147
FetchContent_GetProperties("${_lib}" SOURCE_DIR "${_pkg}_SOURCE_DIR")
148148
FetchContent_GetProperties("${_lib}" BINARY_DIR "${_pkg}_BINARY_DIR")
149149
if(NOT EXISTS "${${_pkg}_BINARY_DIR}/include")
150-
make_directory("${${_pkg}_BINARY_DIR}/include")
150+
file(MAKE_DIRECTORY "${${_pkg}_BINARY_DIR}/include")
151151
endif()
152152

153153
break()

config/fypp_deployment.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,8 @@
66
C_PREPROCESSED = (
77
"stdlib_linalg_constants" ,
88
"stdlib_linalg_blas" ,
9-
"stdlib_linalg_blas_aux",
10-
"stdlib_linalg_blas_s",
11-
"stdlib_linalg_blas_d",
12-
"stdlib_linalg_blas_q",
13-
"stdlib_linalg_blas_c",
14-
"stdlib_linalg_blas_z",
15-
"stdlib_linalg_blas_w",
169
"stdlib_linalg_lapack",
17-
"stdlib_linalg_lapack_aux",
18-
"stdlib_linalg_lapack_s",
19-
"stdlib_linalg_lapack_d",
20-
"stdlib_linalg_lapack_q",
21-
"stdlib_linalg_lapack_c",
22-
"stdlib_linalg_lapack_z",
23-
"stdlib_linalg_lapack_w"
10+
"test_blas_lapack"
2411
)
2512

2613
def pre_process_fypp(args):
@@ -105,7 +92,7 @@ def recursive_copy(folder):
10592
for root, _, files in os.walk(folder):
10693
for file in files:
10794
if file not in prune:
108-
if file.endswith((".f90", ".F90", ".dat", ".npy", ".c")):
95+
if file.endswith((".f90", ".F90", ".dat", ".npy", ".c", ".h")):
10996
shutil.copy2(os.path.join(root, file), base_folder+os.sep+folder+os.sep+file)
11097
recursive_copy('src')
11198
recursive_copy('test')

0 commit comments

Comments
 (0)