Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support resource constructs in RAJA Teams #1029

Merged
merged 34 commits into from
Aug 18, 2021
Merged

Conversation

artv3
Copy link
Member

@artv3 artv3 commented Apr 23, 2021

Summary

  • This PR will introduce resource constructs in RAJA Teams.
  • The challenge here is that RAJA Teams offers run-time support thus we need a way to choose resource type at run-time.

TODO:

  • Refactor launch policies to follow the pattern in policy.hpp
  • Change RAJA teams resource name to compute grid to avoid confusion with the resource construct
  • Rather than using Place argument to select run-time, we can choose which back-end based on the Resource type

API changes:
RAJA::expt::Resources -> RAJA::expt::Grid.

resources::Cuda &cuda_res = res.cuda;
//resources::Cuda::get_default();
/* Use the zero stream until resource is better supported */
cudaStream_t stream = cuda_res.get_stream();
Copy link
Member Author

Choose a reason for hiding this comment

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

@mdavis36 is this all we need? and does this look reasonable? Idea here is to pass in a TeamResource struct that holds all supported back-ends an we choose the right one depending on what is being called.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to support events that would need a bit more. What's making the decision as to which backend to use? Is it controlled by the caller somehow? I ask because if it is, it might make sense for it to be a variant-like type where the TeamResource only contains one resource, but could contain any of a compile-time list of them, if it's out of the caller's control then maybe tuple of them makes sense so the types are known. If the types can't be known, then some more error checking is needed to make sure the resource is the right kind.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes the caller chooses the backend, its base on run-time parameter in the launch API. Basically an enum for HOST or DEVICE.

Copy link
Member

Choose a reason for hiding this comment

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

So, perhaps, pass a resource of type rather than enum to identify type could be a nice model? If it's using the camp platform enum the number is already there in the erased resource type.

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds pretty good to me, we had some other ideas as well. I'll explore them and push to this branch.

@rhornung67
Copy link
Member

@artv3 should this PR get merged for the release also since you mention the RAJA::expt::Resources stuff in the docs for naming kernels.

@artv3
Copy link
Member Author

artv3 commented Jun 1, 2021

@artv3 should this PR get merged for the release also since you mention the RAJA::expt::Resources stuff in the docs for naming kernels.

Actually, the Resources object used Teams is different than the CAMP resource. This PR will rename RAJA::expt::Resources to RAJA::expt::Grid and introduce support for CAMP Resource. But yes, I think we have pretty good path forward (based on conversations) to add the CAMP resource support.

@rhornung67
Copy link
Member

@artv3 should this PR get merged for the release also since you mention the RAJA::expt::Resources stuff in the docs for naming kernels.

Actually, the Resources object used Teams is different than the CAMP resource. This PR will rename RAJA::expt::Resources to RAJA::expt::Grid and introduce support for CAMP Resource. But yes, I think we have pretty good path forward (based on conversations) to add the CAMP resource support.

Sounds good. Thanks.

@artv3 artv3 marked this pull request as ready for review June 10, 2021 22:41
@artv3
Copy link
Member Author

artv3 commented Jun 10, 2021

@trws @MrBurmark @mdavis36 , by combining idea's I've put together support for resources in RAJA Teams. The example examples/teams_resource.cpp illustrates how we can maintain compatibility with runtime policy selection.

@artv3 artv3 changed the title [WIP] Support resource constructs in RAJA Teams Support resource constructs in RAJA Teams Jun 10, 2021
@artv3
Copy link
Member Author

artv3 commented Jun 14, 2021

Thanks all!, @mdavis36 sounds good on the example. I'll work on that to make sure behavior is as expected.

@rhornung67 rhornung67 mentioned this pull request Jun 16, 2021
@artv3
Copy link
Member Author

artv3 commented Jun 16, 2021

Something is off, the example in resource-teams.cpp isn't running the kernels asynchronously... digging into it...

@artv3
Copy link
Member Author

artv3 commented Jun 17, 2021

Something is off, the example in resource-teams.cpp isn't running the kernels asynchronously... digging into it...

I figured it out, just need to update with develop and it will be ready to merge.


template <typename BODY_IN>
static resources::EventProxy<resources::Resource>
exec(RAJA::resources::Resource res, LaunchContext const &ctx, BODY_IN &&body_in)
Copy link
Member

@MrBurmark MrBurmark Aug 2, 2021

Choose a reason for hiding this comment

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

Should this take a Cuda resource instead of a type erased resource? I'm thinking about this with the aim of having a way to use non type erased resource with teams at some point.

Copy link
Member Author

@artv3 artv3 Aug 12, 2021

Choose a reason for hiding this comment

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

I would be in favor of doing it with the next iteration of the API since we will be making some larger design changes.

@@ -46,6 +42,7 @@ __global__ void launch_global_fcn(LaunchContext ctx, BODY body_in)

template <bool async>
struct LaunchExecute<RAJA::expt::cuda_launch_t<async, 0>> {

template <typename BODY_IN>
static void exec(LaunchContext const &ctx, BODY_IN &&body_in)
Copy link
Member

@MrBurmark MrBurmark Aug 2, 2021

Choose a reason for hiding this comment

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

Can this be removed or implemented with the resource version?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can, let me see what I can do.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it can, but I'll make the change after the release along with API rework.

@rhornung67
Copy link
Member

@artv3 I merged the SYCL PR and pulled develop into your PR branch. It can be merged next when tests pass.

@artv3
Copy link
Member Author

artv3 commented Aug 17, 2021

@rhornung67 Travis is hanging -- are we still good to merge?

@rhornung67
Copy link
Member

Yes. Go ahead and merge.

@artv3 artv3 merged commit 49cef7e into develop Aug 18, 2021
@artv3 artv3 deleted the feature/resource/teams branch August 18, 2021 15:33
@artv3 artv3 mentioned this pull request Sep 7, 2021
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.

6 participants