-
-
Notifications
You must be signed in to change notification settings - Fork 45
Add numba backend
#801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add numba backend
#801
Changes from 107 commits
Commits
Show all changes
112 commits
Select commit
Hold shift + click to select a range
77b3f02
Updates to 'language' support
chrisrichardson 620321a
Fixes for ruff
chrisrichardson c8ac53a
Add numba
chrisrichardson 4b3d85c
Add suffix support
chrisrichardson c29a1f9
Merge branch 'main' into chris/languages-3
chrisrichardson 0d4d4b4
updates
chrisrichardson f316110
Formatting fixes
chrisrichardson 018bc9e
Merge branch 'main' into chris/languages-3
chrisrichardson 584d648
Merge branch 'main' into chris/languages-3
chrisrichardson 7052541
fixes
chrisrichardson aacc715
Remove wrapper
chrisrichardson 2134b36
Merge branch 'main' into schnellerhase/copy-chris/languages-3
schnellerhase 9c2ad9d
Fix
schnellerhase 2f3c3d5
[tmp] no mypy
schnellerhase a41f7d7
[tmp] no ruff
schnellerhase 8b73bc3
Start with numba
schnellerhase 218ce8d
drop cpp/
schnellerhase 1c3e77d
ruff
schnellerhase 6bacc68
Merge branch 'main' into schnellerhase/copy-chris/languages-3
schnellerhase a2079c3
add __all__
schnellerhase d651099
Test numba standalone
schnellerhase 5b3c7ad
Get CI up
schnellerhase 3363324
dependency numba
schnellerhase b98b945
Explicit
schnellerhase 4724e1a
install numba module
schnellerhase 1543c5e
parallel test execution
schnellerhase 1420eb1
Fix complex
schnellerhase 96eafee
Make optional
schnellerhase c4aeb22
Skip real only demos
schnellerhase bd1d933
Reactivate ruff
schnellerhase f85afda
Start on unit testing (almost passing)
schnellerhase 655d92d
Commit ufl, not kernel
schnellerhase f7d308b
Add custom_data input
schnellerhase 09a0576
Fix n_const computation
schnellerhase 5b9253a
Add array creation by (full) scalar value
schnellerhase be5f6b5
n_coeff computation
schnellerhase e02c4af
Linear form + coefficient kernel
schnellerhase 6233d19
Introduce number_coordinate_dofs to CommonExpressionIR
schnellerhase 67c1522
Fix remaining shape computations
schnellerhase e0fc385
Fix no coordinate element case
schnellerhase 9ed41a1
Parametrize over scalar type
schnellerhase 0761b70
remove in pwd
schnellerhase b146cfa
Fix expressions template
schnellerhase 8576e6b
Add expression tensor size computations
schnellerhase d3e1d35
Add expression test
schnellerhase b4f01de
Merge branch 'main' into schnellerhase/copy-chris/languages-3
schnellerhase dd0f073
Start fine tuning
schnellerhase e6333eb
modernize cmdline test
schnellerhase 8730fa5
Merge with poisson test
schnellerhase 1bfe332
Licensing headers
schnellerhase 453d15f
Resolve path
schnellerhase 70552cf
Fix files system mess
schnellerhase 4e3b2bd
Language agnostic formatter name: c_format -> format
schnellerhase 098328d
Language agnostic formatter name: c_impl -> impl
schnellerhase 1fc4944
Language agnostic naming: c/numba_implementation -> implementation
schnellerhase 2774e7c
Language agnostic naming: c/numbaFormatter -> Formatter
schnellerhase ec1f538
One more visualise fix
schnellerhase 77280a8
Prepare alignment of expressions to C
schnellerhase 77ac932
Integrals alost completely aligned
schnellerhase 0bff1fc
Finalise cleanup
schnellerhase 07a7e14
checked
schnellerhase f6be02b
Reactivate mypy
schnellerhase 664bb1f
Fix mypy
schnellerhase 161ad40
Fix: tensor size
schnellerhase ffdd3c6
Activate redundant check, drop uneccessary args
schnellerhase cab8da1
Add coordinate_element_hash to expression
schnellerhase 48bd21f
Extend keys check and tidy of integrals
schnellerhase 021a603
Tidy up test_demos and allow for further extensions
schnellerhase 5249124
Add key checking to form
schnellerhase ca6a9e8
Try with Path
schnellerhase a45b464
Add choices
schnellerhase 8546437
only import basix.ufl
schnellerhase d234b84
type hints
schnellerhase 4dc78af
fixes
schnellerhase fa45531
no self
schnellerhase ff6498c
derived
schnellerhase 3eeb26d
more
schnellerhase fcb5636
.
schnellerhase 43c46d2
+1
schnellerhase 2b2fab4
format
schnellerhase 32e5f66
race condition on windows?
schnellerhase e196d86
No subprocess for FFCx call - should result in accurate coverage reports
schnellerhase c808bfd
ruff
schnellerhase 880c448
Revert for demos, cwd more important than coverage
schnellerhase ef0e3a2
Update test/poisson.py
schnellerhase a6b4113
Drop user defined import
schnellerhase e676680
Move --language option to options.py
schnellerhase d8f317a
Fix: size of tensor, extend test to tensor valued expression
schnellerhase 9ce56a1
off by one
schnellerhase 80b53d6
int
schnellerhase c2c6da4
mypy
schnellerhase 6b71383
Get type info from formatter - use _dtype_to_name logic
schnellerhase 1251d16
mypy
schnellerhase 7916b2d
ignore
schnellerhase 8c5d7cd
format
schnellerhase 611ebb9
Apply suggestions from code review
schnellerhase a5df6ab
Add docstrings and types to integrals
schnellerhase 3faefbd
String/comment formatting
schnellerhase d662931
mypy
schnellerhase 3ccd079
Raise bessel
schnellerhase eefeb6c
Introduce _format_comment_str
schnellerhase fe3b1de
docstring
schnellerhase 5476288
Docstring
schnellerhase ec82f17
We do need bessel :)
schnellerhase 2921d32
Remove API breaking chane with suffixes
schnellerhase d6a5996
Tidy
schnellerhase bdf95cc
last one?
schnellerhase 6061a88
Apply suggestions from code review
schnellerhase 28a47a6
Consistent factory_name with C
schnellerhase 38edf48
Template of form was unallgined with C, rewrite
schnellerhase d46d49f
NULL -> None
schnellerhase af5078d
Add warning to file template
schnellerhase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,60 +1,87 @@ | ||
| """Test demos.""" | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| demo_dir = os.path.dirname(os.path.realpath(__file__)) | ||
| demo_dir = Path(__file__).parent | ||
|
|
||
| ufl_files = [] | ||
| for file in os.listdir(demo_dir): | ||
| if file.endswith(".py") and not file == "test_demos.py": | ||
| ufl_files.append(file[:-3]) | ||
| ufl_files = [ | ||
| f | ||
| for f in demo_dir.iterdir() | ||
| if f.suffix == ".py" and not f.stem.endswith("_numba") and f != Path(__file__) | ||
| ] | ||
|
|
||
| skip_complex = ["BiharmonicHHJ", "BiharmonicRegge", "StabilisedStokes"] | ||
|
|
||
|
|
||
| def skip_unsupported(test): | ||
| """Dcecorate test case to skip unsupported cases.""" | ||
schnellerhase marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def check_skip(file, scalar_type): | ||
| """Skip scalar_type file combinations not supported.""" | ||
| if "complex" in scalar_type and file.stem in skip_complex: | ||
| pytest.skip(reason="Not implemented for complex types") | ||
| elif "Complex" in file.stem and scalar_type in ["float64", "float32"]: | ||
| pytest.skip(reason="Not implemented for real types") | ||
|
|
||
| return test(file, scalar_type) | ||
|
|
||
| return check_skip | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("file", ufl_files) | ||
| @pytest.mark.parametrize("scalar_type", ["float64", "float32", "complex128", "complex64"]) | ||
| def test_demo(file, scalar_type): | ||
| @skip_unsupported | ||
| def test_C(file, scalar_type): | ||
| """Test a demo.""" | ||
| if sys.platform.startswith("win32") and "complex" in scalar_type: | ||
| # Skip complex demos on win32 | ||
| pytest.skip(reason="_Complex not supported on Windows") | ||
|
|
||
| if "complex" in scalar_type and file in [ | ||
| "BiharmonicHHJ", | ||
| "BiharmonicRegge", | ||
| "StabilisedStokes", | ||
| ]: | ||
| # Skip demos that are not implemented for complex scalars | ||
| pytest.skip(reason="Not implemented for complex types") | ||
| elif "Complex" in file and scalar_type in ["float64", "float32"]: | ||
| # Skip demos that are only implemented for complex scalars | ||
| pytest.skip(reason="Not implemented for real types") | ||
| subprocess.run(["ffcx", "--scalar_type", scalar_type, file], cwd=demo_dir, check=True) | ||
|
|
||
| if sys.platform.startswith("win32"): | ||
| opts = f"--scalar_type {scalar_type}" | ||
| extra_flags = "/std:c17" | ||
| assert os.system(f"cd {demo_dir} && ffcx {opts} {file}.py") == 0 | ||
| assert ( | ||
| os.system( | ||
| f'cd {demo_dir} && cl.exe /I "../ffcx/codegeneration" {extra_flags} /c {file}.c' | ||
| for compiler in ["cl.exe", "clang-cl.exe"]: | ||
| subprocess.run( | ||
| [ | ||
| compiler, | ||
| "/I", | ||
| f"{demo_dir.parent / 'ffcx/codegeneration'}", | ||
| *extra_flags.split(" "), | ||
| "/c", | ||
| file.with_suffix(".c"), | ||
| ], | ||
| cwd=demo_dir, | ||
| check=True, | ||
| ) | ||
| ) == 0 | ||
| assert ( | ||
| os.system( | ||
| f"cd {demo_dir} && " | ||
| f'clang-cl.exe /I "../ffcx/codegeneration" {extra_flags} /c {file}.c' | ||
| ) | ||
| ) == 0 | ||
| else: | ||
| cc = os.environ.get("CC", "cc") | ||
| opts = f"--scalar_type {scalar_type}" | ||
| extra_flags = ( | ||
| "-std=c17 -Wunused-variable -Werror -fPIC -Wno-error=implicit-function-declaration" | ||
| ) | ||
| assert os.system(f"cd {demo_dir} && ffcx {opts} {file}.py") == 0 | ||
| assert ( | ||
| os.system(f"cd {demo_dir} && {cc} -I../ffcx/codegeneration {extra_flags} -c {file}.c") | ||
| == 0 | ||
| subprocess.run( | ||
| [ | ||
| cc, | ||
| f"-I{demo_dir.parent / 'ffcx/codegeneration'}", | ||
| *extra_flags.split(" "), | ||
| "-c", | ||
| file.with_suffix(".c"), | ||
| ], | ||
| cwd=demo_dir, | ||
| check=True, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("file", ufl_files) | ||
| @pytest.mark.parametrize("scalar_type", ["float64", "float32", "complex128", "complex64"]) | ||
| @skip_unsupported | ||
| def test_numba(file, scalar_type): | ||
| """Test numba generation.""" | ||
| opts = f"--language numba --scalar_type {scalar_type}" | ||
| subprocess.run(["ffcx", *opts.split(" "), file], cwd=demo_dir, check=True) | ||
| subprocess.run(["python", file], cwd=demo_dir, check=True) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| """Generation of C code.""" | ||
|
|
||
| from ffcx.codegeneration.C import expressions, file, form, integrals | ||
|
|
||
| __all__ = ["expressions", "file", "form", "integrals", "suffixes"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.