Skip to content

add tuple_size to camp::array#194

Open
gberg617 wants to merge 2 commits into
mainfrom
feature/bergel1/array-tuple-size
Open

add tuple_size to camp::array#194
gberg617 wants to merge 2 commits into
mainfrom
feature/bergel1/array-tuple-size

Conversation

@gberg617

@gberg617 gberg617 commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

Add tuple_size to camp::array. This is needed in order to use camp::apply on arrays.

@gberg617 gberg617 self-assigned this Mar 4, 2026
rhornung67
rhornung67 previously approved these changes Mar 4, 2026
Comment thread include/camp/tuple.hpp Outdated
@adayton1

adayton1 commented Mar 5, 2026

Copy link
Copy Markdown
Member

I'm actually wondering if we should remove camp::array since we should be able to use std::array in device code now that we require c++17 (almost everything in std::array is constexpr in c++17, and everything is constexpr in c++20). With nvcc you have to supply the --expt-relaxed-constexpr flag, which will make all constexpr function __host__ __device__, but with amdclang, constexpr automatically implies __host__ __device__.

@gberg617

gberg617 commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator Author

I'm actually wondering if we should remove camp::array since we should be able to use std::array in device code now that we require c++17 (almost everything in std::array is constexpr in c++17, and everything is constexpr in c++20). With nvcc you have to supply the --expt-relaxed-constexpr flag, which will make all constexpr function __host__ __device__, but with amdclang, constexpr automatically implies __host__ __device__.

I would be fine with this. It doesn't look like it's used in RAJA, other than in my SubView PR.

@gberg617

gberg617 commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator Author

See #195

@gberg617 gberg617 closed this Mar 5, 2026
@gberg617 gberg617 reopened this Jun 27, 2026
@gberg617 gberg617 force-pushed the feature/bergel1/array-tuple-size branch from 217244a to 34d0659 Compare July 1, 2026 17:50
Comment thread include/camp/tuple.hpp
#include <sstream>
#include <type_traits>

#include "camp/array.hpp"

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.

This still seems backwards. tuple should be able to exist without knowing about array.

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.

If array needs tuple_size from tuple.hpp, then just have array.hpp include tuple.hpp. But tuple should be able to stand alone independent of array.

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.

Really the base declaration of tuple_size and tuple_element should be in a separate header that both tuple.hpp and array.hpp could include.

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.

Where is camp apply defined? That's what this is all about, is that in some higher level common header?

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.

Does it make more sense to change camp::apply to use std::tuple_size?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What about two separate headers: one for traits common to both array and tuple (such as tuple_size), and another for common implementations (such as apply, invoke, etc..)?

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.

tuple_size isn't used in that many places, how about just using std::tuple_size as we should have been doing all along? We can make camp::tuple_size an alias for std::tuple_size.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I think something like that can work. My previous point was about moving camp's tuple_size and apply(...) to a separate header so that traits/methods that are common to both camp tuples and arrays don't live in tuple.hpp, but are instead included in there as well as array.hpp. Hopefully this would address the concerns that @adayton1 mentions above.

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