Skip to content

Comments

Support NMake build system for building generated code#700

Merged
neworderofjamie merged 15 commits intomasterfrom
nmake
Aug 28, 2025
Merged

Support NMake build system for building generated code#700
neworderofjamie merged 15 commits intomasterfrom
nmake

Conversation

@neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Aug 6, 2025

I switched GeNN's Windows build system (both for building GeNN itself and generated code) from using NMake to MSBuild a long time ago as it's a nicer build system but, for building generated code, it has some disadvantages:

  1. If you install the CUDA toolkit using Conda, the plugin required to build CUDA with MSBuild does not get installed
  2. Neither ISPC or HIP provides MSBuild plugins and, with NMake, you can fall back on writing build rules by hand

Therefore, in this PR, I have resurrected support for building generated CUDA code using NMAKE if the MSBuild plugins are not available. I have also tidied up a couple of other Windows build related things:

  1. Before GeNN 5, when using GeNN from C++, we linked against the generated code library which required a few awkward things which are no longer required as GeNN 5 always dynamically loads generated code:
    a. Decorating all the exported things with __declspec(dllexport) when we build the generated code and __declspec(dllimport) when we link against it.
    b. Windows libraries needed to be generated in the same directory as the script rather than in the _CODE directory which, in turn, also required them to have unique names. This is also no longer required and Windows now builds libraries called runner into the _CODE directory.
  2. Another issue with Conda is that CUDA libraries don't live in $(CUDA_PATH)/x64/lib so we have added a separate CUDA_LIBRARY_PATH environment variable (that defaults to $(CUDA_PATH)/x64/lib) but can be overridden. I think this will also help with other weird environments.

@codecov
Copy link

codecov bot commented Aug 6, 2025

Codecov Report

❌ Patch coverage is 1.61290% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.43%. Comparing base (2e66f81) to head (bae045d).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/genn/backends/cuda/backend.cc 0.00% 28 Missing ⚠️
src/genn/genn/code_generator/generateNMakefile.cc 0.00% 17 Missing ⚠️
src/genn/backends/single_threaded_cpu/backend.cc 0.00% 8 Missing ⚠️
pygenn/genn_model.py 0.00% 4 Missing ⚠️
src/genn/genn/code_generator/generateMSBuild.cc 0.00% 3 Missing ⚠️
...nclude/genn/backends/single_threaded_cpu/backend.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #700      +/-   ##
==========================================
- Coverage   88.83%   88.43%   -0.40%     
==========================================
  Files         106      107       +1     
  Lines       14749    14232     -517     
==========================================
- Hits        13102    12586     -516     
+ Misses       1647     1646       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@neworderofjamie neworderofjamie marked this pull request as ready for review August 27, 2025 08:01
@neworderofjamie neworderofjamie added this to the GeNN 5.3.0 milestone Aug 27, 2025
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.

I wish this could be a little less messy, but I appreciate the trade-off between the better build system (MSBuild) and the arguably more universal one (NMake) ... in terms of details, I need to trust you that this works.

@neworderofjamie
Copy link
Contributor Author

It's a very annoying trade-off - I would just say to get rid of MSBuild for building generated code but NMake doesn't seem to track dependencies and that makes it way slower to build generated code

@neworderofjamie neworderofjamie merged commit 46a416a into master Aug 28, 2025
1 check passed
@neworderofjamie neworderofjamie deleted the nmake branch August 28, 2025 09:02
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.

3 participants