Skip to content

Add Constant Type and Operators - #222

Merged
MrBurmark merged 8 commits into
mainfrom
feature/burmark1/constants
Sep 22, 2026
Merged

MrBurmark merged 8 commits into
mainfrom
feature/burmark1/constants

Conversation

@MrBurmark

@MrBurmark MrBurmark commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Add a constant type that takes a compile-time value as a template parameter. Support arithmetic between constants that produces a constant.

constant<0> zero;
constant<1> one;
auto two = one + one;
static_assert(two == 2);
static_assert(std::same_as<decltype(two), constant<2>>);

The ultimate goal with this is use it as part of a RAJA::transparent_range class that I'm thinking about adding that stores the input begin, end, and stride exactly as they were given. My hope is to improve some cases in RAJAPerf and beyond where the BASE and RAJA differ by knowledge of such exact values. For example we often assume that ranges start at 0 but RAJA ranges always have a runtime begin value, knowledge of which does not cross the host device barrier. This is responsible for some differences between kernel which takes its ranges on the host and launch which takes ranges on the device.

Comment thread include/camp/number/number.hpp Resolved
rhornung67
rhornung67 previously approved these changes Sep 22, 2026

@rhornung67 rhornung67 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@MrBurmark I'm OK with this going in for the patch release, but I will leave the final call up to you. If this will require changes to user code, is it too much for a patch release? Also, where should we document those changes?

@MrBurmark

MrBurmark commented Sep 22, 2026 •

Copy link
Copy Markdown
Member Author

I'll remove the places that this was used in favor or integral_constant for compatibility.

Comment thread include/camp/number/number.hpp Resolved
Comment thread include/camp/number/number.hpp Resolved
Avoid unexpected non-short-circuiting && and ||

Co-authored-by: Jason Burmark <MrBurmark@users.noreply.github.com>
Comment thread include/camp/list/list.hpp Resolved
Comment thread include/camp/number/number.hpp Resolved
Comment thread include/camp/number/number.hpp Resolved
Co-authored-by: Jason Burmark <MrBurmark@users.noreply.github.com>
@MrBurmark

Copy link
Copy Markdown
Member Author

I reverted the places where constant was used inplace of constant so user code doesn't have to change.

Comment thread include/camp/number/number.hpp Resolved
adayton1
adayton1 previously approved these changes Sep 22, 2026
Comment thread include/camp/number.hpp Resolved
Comment thread include/camp/number/number.hpp Resolved
@adayton1

Copy link
Copy Markdown
Member

Can you update the pull request description now that integral_constant is no longer being deprecated?

Co-authored-by: Jason Burmark <MrBurmark@users.noreply.github.com>
@MrBurmark

Copy link
Copy Markdown
Member Author

Can you update the pull request description now that integral_constant is no longer being deprecated?

done.

Comment thread include/camp/number.hpp Resolved
Also change spacing to better reflect intent.

Co-authored-by: Jason Burmark <MrBurmark@users.noreply.github.com>
@MrBurmark
MrBurmark merged commit 8bcae2f into main Sep 22, 2026
13 checks passed
@MrBurmark
MrBurmark deleted the feature/burmark1/constants branch September 22, 2026 20:11
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.

4 participants