Skip to content
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

PyGeNN exception handling #433

Merged
merged 3 commits into from
Jul 6, 2021
Merged

Conversation

neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Jul 6, 2021

This has been annoying me for ages - C++ exceptions weren't making it through to Python so debugging errors was a nightmare. As discussed in #359, I thought this was a Windows issue but, I think, this is just because, on Windows, there's no default exception handler so a C++ program that throws e.g. a std::exception into the ether, displays no output and terminates. This is what was happening with all exceptions emanating from C++ (aside for, for some reason, exceptions generated by create_backend which I had manually added an exception handler for previously 🤷‍♂️). After reading the documentation again, there is some additional SWIG directives which can be added to add a blanket mapping of standard C++ exceptions to SWIG (which in turn maps them to Python) (https://github.com/swig/swig/blob/master/Lib/exception.i#L289-L307). This seems to work very nicely even from the CUDA code that was emitting the weird warnings discussed in #359!

Fixed #359

@neworderofjamie neworderofjamie added this to the GeNN 4.5.0 milestone Jul 6, 2021
@neworderofjamie neworderofjamie requested a review from tnowotny July 6, 2021 10:44
Copy link
Member

@tnowotny tnowotny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one ... this should make life a little easier in the future.
I haven't looked into why all the tests seem to have failed though ...

@neworderofjamie
Copy link
Contributor Author

neworderofjamie commented Jul 6, 2021

Amusingly, it seems to be because whatever awful things the IJRAs are doing to @jamesturner246 's machine is using all the GPU memory 😄

@codecov
Copy link

codecov bot commented Jul 6, 2021

Codecov Report

Merging #433 (5c3b254) into master (5cb7dff) will increase coverage by 5.54%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #433      +/-   ##
==========================================
+ Coverage   82.34%   87.88%   +5.54%     
==========================================
  Files          68       78      +10     
  Lines       13303    16410    +3107     
==========================================
+ Hits        10954    14422    +3468     
+ Misses       2349     1988     -361     
Impacted Files Coverage Δ
include/genn/genn/synapseGroupInternal.h 75.00% <0.00%> (-25.00%) ⬇️
include/genn/genn/models.h 61.29% <0.00%> (-13.71%) ⬇️
include/genn/genn/currentSource.h 77.77% <0.00%> (-9.73%) ⬇️
include/genn/genn/customUpdate.h 93.33% <0.00%> (-6.67%) ⬇️
src/genn/genn/code_generator/backendBase.cc 87.68% <0.00%> (-5.49%) ⬇️
include/genn/genn/snippet.h 85.24% <0.00%> (-4.56%) ⬇️
src/genn/genn/currentSource.cc 79.71% <0.00%> (-2.11%) ⬇️
include/genn/genn/synapseGroup.h 90.69% <0.00%> (-1.99%) ⬇️
include/genn/backends/cuda/backend.h 96.15% <0.00%> (-1.58%) ⬇️
include/genn/genn/code_generator/backendSIMT.h 98.50% <0.00%> (-1.50%) ⬇️
... and 59 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5cb7dff...5c3b254. Read the comment docs.

@neworderofjamie neworderofjamie merged commit af73a4b into master Jul 6, 2021
@neworderofjamie neworderofjamie deleted the pygenn_exception_handling branch July 6, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception handling issues on Windows
2 participants