Skip to content
Draft
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
16 changes: 16 additions & 0 deletions .github/actions/selalib_installation/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'SeLaLib installation'

runs:
using: "composite"
steps:
- uses: actions/checkout@v5
with:
repository: selalib/selalib
path: selalib
- name: Compile SeLaLib
shell: bash
run: |
cd selalib
cmake -B build .
cmake --build build -j 4 -t sll_splines

165 changes: 84 additions & 81 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
- 'mpi_tester.py'

pull_request:
branches: [ main ]
types:
- opened
- synchronize
Expand Down Expand Up @@ -40,6 +39,8 @@ jobs:
python-version: '3.10'
- name: Install dependencies
uses: ./.github/actions/linux_install
- name: Install SeLaLib
uses: ./.github/actions/selalib_installation
- name: Cache pip
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -84,6 +85,8 @@ jobs:
python-version: '3.10'
- name: Install dependencies
uses: ./.github/actions/linux_install
- name: Install SeLaLib
uses: ./.github/actions/selalib_installation
- name: Cache pip
uses: actions/cache@v3
env:
Expand All @@ -99,86 +102,86 @@ jobs:
- name: Unit tests
uses: ./.github/actions/pytest_run

Pyccel_C:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
uses: ./.github/actions/linux_install
- name: Cache pip
uses: actions/cache@v3
env:
cache-name: cache-pip
with:
path: ~/.local
key: ${{runner.os }}-build-${{ env.cache-name }}
- name: Install python dependencies
uses: ./.github/actions/pip_installation
- name: Make with pyccel
run: |
make LANGUAGE=c pycc
- name: Unit tests
uses: ./.github/actions/pytest_run

Numba:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
uses: ./.github/actions/linux_install
- name: Cache pip
uses: actions/cache@v3
env:
cache-name: cache-pip
with:
path: ~/.local
key: ${{runner.os }}-build-${{ env.cache-name }}
- name: Install python dependencies
uses: ./.github/actions/pip_installation
- name: Make with numba
run: |
make ACC=numba numba
- name: Unit tests
uses: ./.github/actions/pytest_run

Pythran:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
uses: ./.github/actions/linux_install
- name: Cache pip
uses: actions/cache@v3
env:
cache-name: cache-pip
with:
path: ~/.local
key: ${{runner.os }}-build-${{ env.cache-name }}
- name: Install python dependencies
uses: ./.github/actions/pip_installation
- name: Make with pyccel
run: |
make ACC=pythran pythran
- name: Unit tests
uses: ./.github/actions/pytest_run
#Pyccel_C:

# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v3
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Install dependencies
# uses: ./.github/actions/linux_install
# - name: Cache pip
# uses: actions/cache@v3
# env:
# cache-name: cache-pip
# with:
# path: ~/.local
# key: ${{runner.os }}-build-${{ env.cache-name }}
# - name: Install python dependencies
# uses: ./.github/actions/pip_installation
# - name: Make with pyccel
# run: |
# make LANGUAGE=c pycc
# - name: Unit tests
# uses: ./.github/actions/pytest_run

#Numba:

# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v3
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Install dependencies
# uses: ./.github/actions/linux_install
# - name: Cache pip
# uses: actions/cache@v3
# env:
# cache-name: cache-pip
# with:
# path: ~/.local
# key: ${{runner.os }}-build-${{ env.cache-name }}
# - name: Install python dependencies
# uses: ./.github/actions/pip_installation
# - name: Make with numba
# run: |
# make ACC=numba numba
# - name: Unit tests
# uses: ./.github/actions/pytest_run

#Pythran:

# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v3
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Install dependencies
# uses: ./.github/actions/linux_install
# - name: Cache pip
# uses: actions/cache@v3
# env:
# cache-name: cache-pip
# with:
# path: ~/.local
# key: ${{runner.os }}-build-${{ env.cache-name }}
# - name: Install python dependencies
# uses: ./.github/actions/pip_installation
# - name: Make with pyccel
# run: |
# make ACC=pythran pythran
# - name: Unit tests
# uses: ./.github/actions/pytest_run

Pep8:

Expand Down
12 changes: 11 additions & 1 deletion pygyro/splines/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Main targets
#----------------------------------------------------------

all: spline_eval_funcs$(SO_EXT) cubic_uniform_spline_eval_funcs$(SO_EXT) splines$(SO_EXT)
all: spline_eval_funcs$(SO_EXT) cubic_uniform_spline_eval_funcs$(SO_EXT) splines$(SO_EXT) accelerated_spline_interpolators$(SO_EXT) sll_m_spline_matrix_periodic_banded$(SO_EXT)

.ACC.$(ACC):
@rm -f .ACC.*
Expand All @@ -35,6 +35,16 @@ else
$(TOOL) $< $(TOOL_FLAGS) -o $@
endif

sll_m_spline_matrix_periodic_banded$(SO_EXT): sll_m_spline_matrix_periodic_banded.pyi
pyccel-wrap $< $(TOOL_FLAGS)

accelerated_spline_interpolators$(SO_EXT): $(NAME_PREFIX)accelerated_spline_interpolators.py .ACC.$(ACC) splines$(SO_EXT) sll_m_spline_matrix_periodic_banded$(SO_EXT)
ifneq ($(ACC), pythran)
$(TOOL) $< $(TOOL_FLAGS)
else
$(TOOL) $< $(TOOL_FLAGS) -o $@
endif


clean:
rm -f *.o *.so *.mod .ACC.pycc .lock_acquisition.lock
Expand Down
50 changes: 50 additions & 0 deletions pygyro/splines/accelerated_spline_interpolators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from typing import TypeVar, Final
import numpy as np
from pyccel.stdlib.internal.lapack import dgbtrs, zgbtrs
from .splines import Spline1D, BSplines

Check warning on line 4 in pygyro/splines/accelerated_spline_interpolators.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

pygyro/splines/accelerated_spline_interpolators.py#L4

Unused BSplines imported from splines
from .sll_m_spline_matrix_periodic_banded import PeriodicBandedMatrix

T = TypeVar('T', float, complex)


def solve_system_periodic(ug: 'Final[float[:]]', spl: Spline1D, offset: int, splu: Final[PeriodicBandedMatrix]):
"""
Compute the coefficients c of the spline which interpolates the points ug
for a periodic spline
"""

basis = spl.basis

n = basis.nbasis
p = basis.degree

c = spl.coeffs

c[offset:n+offset] = ug
splu.solve_inplace(c[offset:n+offset])
c[:offset] = c[n:n+offset]
c[n+offset:] = c[offset:p]

# ...


def solve_system_nonperiodic(ug: 'Final[T[:]]', c: 'T[:]', bmat: 'Final[T[:,:](order=F)]', l: np.int32, u: np.int32, ipiv: 'Final[int32[:]]'):
"""
Compute the coefficients c of the spline which interpolates the points ug
for a non-periodic spline
"""

assert ug.shape[0] == bmat.shape[1]
assert c.shape[0] == ug.shape[0]

sinfo: np.int32

c[:] = ug
if isinstance(c[0], np.float64):
dgbtrs('N', np.int32(bmat.shape[1]), l, u, np.int32(1), bmat, np.int32(
bmat.shape[0]), ipiv, c, np.int32(c.shape[0]), sinfo)

Check warning on line 45 in pygyro/splines/accelerated_spline_interpolators.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

pygyro/splines/accelerated_spline_interpolators.py#L45

Using variable 'sinfo' before assignment
else:
zgbtrs('N', np.int32(bmat.shape[1]), l, u, np.int32(1), bmat, np.int32(
bmat.shape[0]), ipiv, c, np.int32(c.shape[0]), sinfo)

return sinfo
27 changes: 27 additions & 0 deletions pygyro/splines/sll_m_spline_matrix_periodic_banded.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#$ header metavar includes="../../selalib/build/modules"
#$ header metavar libraries="sll_splines,pppack,sll_errors,sll_assert"
#$ header metavar libdirs="../../selalib/build/src/splines/splines_basic/,../../selalib/build/external/pppack/,../../selalib/build/src/low_level_utilities/errors/,../../selalib/build/src/low_level_utilities/assert/"
#$ header metavar no_target=True
import numpy as np

@low_level('sll_t_spline_matrix_periodic_banded')
class PeriodicBandedMatrix:
@low_level('init')
def __init__(self, n : np.int32, kl : np.int32, ku : np.int32):
...

@low_level('set_element')
def set_element(self, i : np.int32, j : np.int32, a_ij : float):
...

@low_level('factorize')
def factorize(self):
...

@low_level('solve_inplace')
def solve_inplace(self, bx : 'float[:]'):
...

@low_level('free')
def __del__(self):
...
Loading