Skip to content

Comments

Optimise integer division#645

Draft
neworderofjamie wants to merge 7 commits intomasterfrom
fast_divide
Draft

Optimise integer division#645
neworderofjamie wants to merge 7 commits intomasterfrom
fast_divide

Conversation

@neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Dec 3, 2024

One of the issues with code GeNN generates is that there are a lot of index calculations. A sizeable proportion of these involve dividing by integers which are known at code generation time but not at compile time. This means we miss out on compiler optimisations here which will turn them into essentially fixed point multiplication by the reciprocal. Luckily, the magic required has been encapsulated in libdivide. Benchmarking libdivide's branchless algorithms shows them to result in decent speedup in divide-heavy code.

TODO:

  • Branchless version does not support dividing by 1 - probably need to test:
    • If all merged fields are 1 - don't divide at all
    • If no merged fields are 1 - use branchless fast divide
    • If mixed, don't use fast divide
  • Make fast dividing backend-specific

@codecov
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.93%. Comparing base (ea3f9ab) to head (b8919d4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #645      +/-   ##
==========================================
- Coverage   87.83%   85.93%   -1.91%     
==========================================
  Files         104        5      -99     
  Lines       14104     1045   -13059     
==========================================
- Hits        12388      898   -11490     
+ Misses       1716      147    -1569     

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

@neworderofjamie neworderofjamie changed the title Automate detection of homogeneous parameters and remove integer division Optimise integer division Dec 3, 2024
@neworderofjamie neworderofjamie changed the base branch from master to improved_heterogeneity December 3, 2024 15:32
Base automatically changed from improved_heterogeneity to master January 6, 2025 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant