Skip to content

Commit 97dd3d3

Browse files
authored
151 use pyccel 210 (#153)
**Solves the following issue(s):** Closes #151 Things that did not work for me with pyccel 2.1: - using `pyccel make ...` I get the [mysterious numpy error](https://struphy-hub.github.io/struphy/sections/install.html#compilation-problems). Using `pyccel compile ...` I don't get this error. - `pyccel make -d kernel_file.txt` did not behave like a make file, i.e. it recompiled everything on the second call. - `pyccel clean` did not remove the .so files; `pyccel clean -s` removed alos numpy and scipy stuff that I had to reinstall afterwards.
1 parent ce018a6 commit 97dd3d3

9 files changed

Lines changed: 110 additions & 17 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: PR - unit tests with MPI in Container
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- devel
7+
push:
8+
branches:
9+
- devel
10+
schedule:
11+
# run at 1 a.m. on Sunday
12+
- cron: "0 1 * * 0"
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
unit-tests-in-container-with-struphy:
28+
runs-on: ubuntu-latest
29+
30+
container:
31+
image: ghcr.io/struphy-hub/struphy/ubuntu-with-struphy:latest
32+
credentials:
33+
username: spossann
34+
password: ${{ secrets.GHCR_TOKEN }}
35+
36+
steps:
37+
- name: Check for dockerenv file
38+
run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)
39+
40+
- name: Checkout repo
41+
uses: actions/checkout@v4
42+
43+
- name: Check .testmondata 1
44+
run: |
45+
ls .testmon* || echo "No .testmondata"
46+
47+
- name: Setup cache for testmon
48+
uses: actions/cache@v4
49+
with:
50+
path: |
51+
.testmondata-unit-mpi
52+
key: testmon-unit-mpi-${{ github.ref_name }}-${{ github.event.number }}-${{ github.run_number }}
53+
restore-keys: |
54+
testmon-unit-mpi-${{ github.ref_name }}-${{ github.event.number }}-
55+
testmon-unit-mpi-${{ github.ref_name }}
56+
testmon-unit-mpi-devel
57+
testmon-unit-mpi-
58+
59+
- name: Check .testmondata 2
60+
run: |
61+
ls .testmon* || echo "No .testmondata"
62+
63+
- name: Install Struphy in Container
64+
uses: ./.github/actions/install/struphy_in_container
65+
66+
- name: Compile Struphy
67+
run: |
68+
source /struphy_c_/env_c_/bin/activate
69+
struphy compile
70+
71+
- name: Run unit tests with MPI
72+
shell: bash
73+
env:
74+
TESTMON_DATAFILE: ${{ github.workspace }}/.testmondata-unit-mpi
75+
# init .testmondata with non-MPI call
76+
run: |
77+
source /struphy_c_/env_c_/bin/activate
78+
struphy test Maxwell
79+
struphy test unit --mpi 2

.github/workflows/test-PR-unit.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR - unit tests in Container
1+
name: PR - unit tests serial in Container
22

33
on:
44
pull_request:
@@ -49,7 +49,6 @@ jobs:
4949
with:
5050
path: |
5151
.testmondata-unit
52-
.testmondata-unit-mpi
5352
key: testmon-unit-${{ github.ref_name }}-${{ github.event.number }}-${{ github.run_number }}
5453
restore-keys: |
5554
testmon-unit-${{ github.ref_name }}-${{ github.event.number }}-
@@ -78,15 +77,4 @@ jobs:
7877
struphy compile --status
7978
pip show mpi4py
8079
pip uninstall -y mpi4py
81-
struphy test unit
82-
83-
- name: Run unit tests with MPI
84-
shell: bash
85-
env:
86-
TESTMON_DATAFILE: ${{ github.workspace }}/.testmondata-unit-mpi
87-
# init .testmondata with non-MPI call
88-
run: |
89-
source /struphy_c_/env_c_/bin/activate
90-
struphy test Maxwell
91-
pip install -U mpi4py
92-
struphy test unit --mpi 2
80+
struphy test unit

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ classifiers = [
2525
dependencies = [
2626
'numpy',
2727
'cunumpy',
28-
'pyccel>=2.0',
28+
'pyccel>=2.1',
2929
'feectools',
3030
'scipy',
3131
'h5py',
File renamed without changes.

src/struphy/compile_struphy.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ all: $(OUTPUTS)
3535
@for dep in $^ ; do \
3636
echo $$dep ; \
3737
done
38-
pyccel $(FLAGS) $(FLAGS_openmp_pic) $(FLAGS_openmp_mhd) $<
38+
pyccel compile -v $(FLAGS) $(FLAGS_openmp_pic) $(FLAGS_openmp_mhd) $<
3939
@echo ""
4040

4141
#--------------------------------------

src/struphy/console/compile.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ def struphy_compile(
107107
if delete:
108108
# (change dir not to be in source path)
109109
print("\nDeleting .f90/.c and .so files ...")
110+
# TODO: for using pyccel clean in the future
111+
# cmd = [
112+
# "pyccel",
113+
# "clean",
114+
# ]
110115
cmd = [
111116
"make",
112117
"clean",
@@ -272,6 +277,15 @@ def struphy_compile(
272277

273278
# compilation
274279
print("\nCompiling Struphy kernels ...")
280+
kernel_file = os.path.join(libpath, "kernels.txt")
281+
# TODO: for using pyccel make in the future
282+
# cmd = [
283+
# "pyccel",
284+
# "make",
285+
# "-d",
286+
# kernel_file,
287+
# "-v",
288+
# ]
275289
cmd = [
276290
"make",
277291
"-f",

src/struphy/linear_algebra/tests/test_stencil_dot_kernels.py renamed to src/struphy/linear_algebra/tests/test_stencil_dot_kers.py

File renamed without changes.

src/struphy/linear_algebra/tests/test_stencil_transpose_kernels.py renamed to src/struphy/linear_algebra/tests/test_stencil_transpose_kers.py

File renamed without changes.

src/struphy/utils/utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@ def update_state(state):
5454

5555

5656
def save_state(state, libpath=STRUPHY_LIBPATH):
57-
"""Save the state to the state.yml file."""
57+
"""Save the state to state.yml and write the kernels to kernels.txt."""
5858
state_file = os.path.join(libpath, "state.yml")
5959
dict_to_yaml(state, state_file)
60+
if "kernels" in state:
61+
kernel_file = os.path.join(libpath, "kernels.txt")
62+
kernels_to_txt(state["kernels"], kernel_file)
6063

6164

6265
def print_all_attr(obj):
@@ -85,6 +88,15 @@ def dict_to_yaml(dictionary: dict, output: str):
8588
indent=4,
8689
line_break="\n",
8790
)
91+
# print(f"dict written to {output}.")
92+
93+
94+
def kernels_to_txt(kernels: list, output: str):
95+
"""Write state[kernels] to .txt file for pyccel make."""
96+
with open(output, "w") as file:
97+
for ker in kernels:
98+
file.write(f"{ker}\n")
99+
# print(f"kernels written to {output}.")
88100

89101

90102
class MyDumper(yaml.SafeDumper):

0 commit comments

Comments
 (0)