Skip to content

Add generic device policies #2036

Open
artv3 wants to merge 3 commits into
developfrom
artv3/generic-device-policies
Open

Add generic device policies #2036
artv3 wants to merge 3 commits into
developfrom
artv3/generic-device-policies

Conversation

@artv3

@artv3 artv3 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

@artv3 artv3 requested a review from a team June 8, 2026 23:51
@artv3 artv3 self-assigned this Jun 8, 2026
@artv3 artv3 added this to the July 2026 Release milestone Jun 9, 2026
RAJA treats ``Teams(i,j,k)`` and ``Threads(i,j,k)`` as an (x,y,z) ordering.
For users who prefer SYCL's (dim0, dim1, dim2) ordering, RAJA provides
``Teams::sycl_order(dim0, dim1, dim2)`` and
``Threads::sycl_order(dim0, dim1, dim2)``, which map to the RAJA (x,y,z)

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.

Is this what is meant, or should a more explicit mapping be documented here?

Suggested change
``Threads::sycl_order(dim0, dim1, dim2)``, which map to the RAJA (x,y,z)
``Threads::sycl_order(dim0, dim1, dim2)``, which map to the RAJA (z,y,x)

Comment thread include/RAJA/policy/device.hpp Outdated

// kernel (For) index mapping
template<int nx_threads>
using device_global_size_x_direct = RAJA::cuda_global_size_x_direct<nx_threads>;

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.

There are more policies than these. Check out the cuda or hip policy file where there are policies for the cartesian product of things like this.

  • (|flatten) x (global|block|thread) x (|size) x (x|y|z|xy|xz|yx|yz|zx|zy|xyz|xzy|yxz|yzx|zxy|zyx) x (direct_unchecked|direct|loop) x (|unchecked)
  • (global|block|thread) x (x|y|z|xy|xz|yx|yz|zx|zy|xyz|xzy|yxz|yzx|zxy|zyx) x (syncable_loop)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where should we draw the line in terms of providing device generics? I think it would be a little burdensome in terms of boilerplate to have using device_policy = .... for all possible cartesian products of policies.

We could probably automatically emit device generics with a .hpp.in + CMake file configure type interface, which would just cover all the cases in <backend>/policy.hpp, and error out if there isn't a backend specific implementation available. This is probably a bit cleaner and maintainable than manually generating a long list of aliases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also--not sure if we can generate SYCL analogues to all of these cartesian product policies. However we could just leave the policies undefined in the case of SYCL

Comment thread include/RAJA/policy/device.hpp Outdated
using device_global_thread_z = RAJA::cuda_global_thread_z;

// kernel (loop) index mapping
using device_thread_x_direct = RAJA::cuda_thread_x_direct;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to rewrite some examples like launch_flatten using the generic names? It could simplify the examples

Comment thread include/RAJA/policy/device.hpp Outdated

// kernel (For) index mapping
template<int nx_threads>
using device_global_size_x_direct = RAJA::cuda_global_size_x_direct<nx_threads>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where should we draw the line in terms of providing device generics? I think it would be a little burdensome in terms of boilerplate to have using device_policy = .... for all possible cartesian products of policies.

We could probably automatically emit device generics with a .hpp.in + CMake file configure type interface, which would just cover all the cases in <backend>/policy.hpp, and error out if there isn't a backend specific implementation available. This is probably a bit cleaner and maintainable than manually generating a long list of aliases.

@johnbowen42

Copy link
Copy Markdown
Contributor

@artv3 @MrBurmark I pushed a commit containing an automatic CMake based file generation for device.hpp that will emit it directly into the build tree at config time. It emits a large roughly 6000 line file but it contains a relatively comprehensive list of policies. Let me know if you like this approach, if not we can revert the commit and keep the manually-maintained list

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.

3 participants