-
Notifications
You must be signed in to change notification settings - Fork 15
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
JIT invocation from python for benchmarks #832
Conversation
- Created CodegenDriver class to factor out ast preparation - Created pybind wrappers for Jit and Codegen configuration options - misc small changes to simplify code
Logfiles from GitLab pipeline #43947 (:no_entry:) have been uploaded here! Status and direct links: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. I just skimmed through the PR and left some comments/suggestions on its current state since it's still draft
- Updated benchmark runner to return runtime stats - Updated python module to reflect this change and return results to python - Addressed @iomaganaris' comments.
Logfiles from GitLab pipeline #47934 (:no_entry:) have been uploaded here! Status and direct links: |
Logfiles from GitLab pipeline #48066 (:no_entry:) have been uploaded here! Status and direct links: |
Logfiles from GitLab pipeline #48065 (:no_entry:) have been uploaded here! Status and direct links: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor suggestions and comments.
Overall LGTM. I would just like to add an integration test that runs a small python example.
Also the python jit needs to have -DNMODL_PYTHON_BINDINGS_ENABLED
to work but when I enable it with clang 13.0.0
I get issues like the following:
/usr/bin/ld: ../codegen/libcodegen.a(codegen_driver.cpp.o): relocation R_X86_64_32S against hidden symbol `_ZTVN5nmodl7visitor10AstVisitorE' can not be used when making a shared object
/usr/bin/ld: ../codegen/libcodegen.a(codegen_compatibility_visitor.cpp.o): relocation R_X86_64_32 against hidden symbol `_ZTIN5nmodl3ast3AstE' can not be used when making a shared object
/usr/bin/ld: ../../test/benchmark/libllvm_benchmark.a(llvm_benchmark.cpp.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../test/benchmark/libllvm_benchmark.a(jit_driver.cpp.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../test/unit/libbenchmark_data.a(codegen_data_helper.cpp.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
Compiling NMODL
with -DCMAKE_CXX_FLAGS="-fPIC"
fixes the compilation but then I get the following error when I run the example provided:
➜ build_pyjit git:(ohm314/pyjit) python test_pyjit.py
['/home/magkanar/bbp_repos/nmodl/build_pyjit', '/home/magkanar/bbp_repos/nmodl/build_pyjit/install/lib/python', '/home/magkanar/bbp_repos/nmodl/build_pyjit/install/lib#', '/home/magkanar/bbp_repos/nmodl/build_pyjit/install/lib', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/magkanar/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']
[NMODL] [warning] :: Python bindings are not available
Traceback (most recent call last):
File "test_pyjit.py", line 5, in <module>
import nmodl.dsl as nmodl
File "/home/magkanar/bbp_repos/nmodl/build_pyjit/install/lib/nmodl/dsl.py", line 4, in <module>
from ._nmodl import *
ImportError: /home/magkanar/bbp_repos/nmodl/build_pyjit/install/lib/nmodl/_nmodl.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZTVN5nmodl7codegen20CodegenHelperVisitorE
Am I missing something? How did you build/test this?
Logfiles from GitLab pipeline #48181 (:no_entry:) have been uploaded here! Status and direct links: |
- Move fmt::literals namespace using into the nmodl namespace (where it should be). - Remove also logger.hpp header inclusion from places where it is unnecessary.
Logfiles from GitLab pipeline #49638 (:no_entry:) have been uploaded here! Status and direct links: |
Passing the dereferenced node and constructing new shared_ptrs when needed causes all kinds of grief.
Logfiles from GitLab pipeline #49989 (:no_entry:) have been uploaded here! Status and direct links: |
Logfiles from GitLab pipeline #50460 (:white_check_mark:) have been uploaded here! Status and direct links: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really nice! was able to run this locally!
$ PYTHONPATH=`pwd`/lib/ python3 test.py
...
[NMODL] [info] :: Created LLVM IR module from NMODL AST in 1.9729e-05 sec
[NMODL] [info] :: CPU: icelake-client
[NMODL] [info] :: Benchmarking kernel 'nrn_state_hh' with 2.708770751953125 MBs dataset
[NMODL] [info] :: Average compute time = 0.000038
[NMODL] [info] :: Compute time standard deviation = 0.000000
[NMODL] [info] :: Minimum compute time = 0.000025
[NMODL] [info] :: Maximum compute time = 0.003346
{'nrn_state_hh': (3.821874700000001e-05, 1.229097320882649e-07, 2.4908e-05, 0.003346102)}
All looks good to me! If you ask me, I would have two questions/wishes:
- as python bindings are required for running all meaningful tests, I wonder if we should turn ON bindings now (we turned off in the llvm branch during initial development):
option(NMODL_ENABLE_PYTHON_BINDINGS "Enable pybind11 based python bindings" OFF)
- to avoid this getting broken, it will be helpful to add a minimal test (like the one shown in the description) here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from the existing comments.
Regarding enabling NMODL_ENABLE_PYTHON_BINDINGS
I think we can still keep it off by default to accelerate local development when the python bindings are not needed however we can enable them on the CI.
I'm also in favour of adding a test that uses the python JIT.
In https://github.com/BlueBrain/nmodl/pull/829/files#diff-037ea159eb0a7cb0ac23b851e66bee30fb838ee8d0d99fa331a1ba65283d37f7R93 I've added tests for running the JIT on the gitlab ci in allocations on BB5 so we can use the same configuration here to run the tests
I will add a test. @iomaganaris already suggested it too and you are absolutely right. |
Logfiles from GitLab pipeline #51014 (:white_check_mark:) have been uploaded here! Status and direct links: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
- Created CodegenDriver class to factor out ast preparation - Created pybind wrappers for Jit and Codegen configuration options - Updated benchmark runner to return runtime stats - Return benchmark results to python - Addressed @iomaganaris' comments. - Add a PyJIT integration test * Re-enable python bindings by default
- Created CodegenDriver class to factor out ast preparation - Created pybind wrappers for Jit and Codegen configuration options - Updated benchmark runner to return runtime stats - Return benchmark results to python - Addressed @iomaganaris' comments. - Add a PyJIT integration test * Re-enable python bindings by default
- Created CodegenDriver class to factor out ast preparation - Created pybind wrappers for Jit and Codegen configuration options - Updated benchmark runner to return runtime stats - Return benchmark results to python - Addressed @iomaganaris' comments. - Add a PyJIT integration test * Re-enable python bindings by default
- Created CodegenDriver class to factor out ast preparation - Created pybind wrappers for Jit and Codegen configuration options - Updated benchmark runner to return runtime stats - Return benchmark results to python - Addressed @iomaganaris' comments. - Add a PyJIT integration test * Re-enable python bindings by default
Here's a little test for this:
(updated example)