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

Value-View Interface #289

Open
wants to merge 57 commits into
base: develop
Choose a base branch
from
Open

Value-View Interface #289

wants to merge 57 commits into from

Conversation

mdavis36
Copy link
Collaborator

@mdavis36 mdavis36 commented Jul 23, 2024

Summary

  • This PR introduces the foundational features necessary for refactoring our current classes & objects in a way that is not too obstructive to the codebase.
    • A working ManagedVector (MV) implementation.
      • MV unit testing.
      • This currently lives within the Spheral headers. It will need to be refactored in the future and moved into CHAI with a better implementation.
    • The Value-View Interface Pattern (VVI) that is based around the experimental chai::ManagedSharedPtr.
      • Documentation on VVI in Spheral RTD. Preview here.
      • Example class patterns for:
        • Basic class w/ MV member.
        • CRTP pattern.
        • Abstract interface iheritance w/ MV member.
      • Implementation of VVI for Spheral::QuadraticInterpolator.
    • ctest c++ unit testing for ensuring semantic behavior of classes is working as expected with VVI.
      • Unit testing for Spheral::QuadraticInterpolator w/ and w/o VVI.
      • The start of unit tests for Spheral::Field. Incomplete
    • Gitlab CI:
      • make test at the end of the build stage.
      • SPHERAL_ENABLE_VVI=On for +cuda builds.

ToDo :

  • Annotate RELEASE_NOTES.md with notable changes.
  • Create LLNLSpheral PR pointing at this branch. (PR#105)
  • LLNLSpheral PR has passed all tests.

…; Moving SphArray.hh to Utilities/ManagedVector.hh
…d organization for VVI macros; Differentiating between Ptr and Ref syntax metaclasses with vvi pattern.
…o provide a clearer API for using VVI to users.
…Better default behavior for Value Interfaces, def copy-ctor, assign op and eq op behavior is baked in for free in the ValueInterface class.
…or defining default Ctor, Copy, Ass and Eq operations.
src/CMakeLists.txt Outdated Show resolved Hide resolved
jmikeowen
jmikeowen previously approved these changes Sep 17, 2024
Copy link
Collaborator

@jmikeowen jmikeowen left a comment

Choose a reason for hiding this comment

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

Looking good once tests all pass

ldowen
ldowen previously approved these changes Oct 14, 2024
Comment on lines +211 to +213
mInterp(0.0, kernel.kernelExtent(), numPoints, Wlookup<KernelType>(kernel)),
mGradInterp(0.0, kernel.kernelExtent(), numPoints, gradWlookup<KernelType>(kernel)),
mGrad2Interp(0.0, kernel.kernelExtent(), numPoints, grad2Wlookup<KernelType>(kernel)),
Copy link
Collaborator Author

@mdavis36 mdavis36 Nov 22, 2024

Choose a reason for hiding this comment

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

@jmikeowen These are the changes I needed to revert. NVCC isn't happy with the local variable kernel in the lambda captures when compiling for the device.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I see, so you have to go back to externally defined functors. This is harmless enough, but kind of a bummer since I like the compact (and I think clearer) lambda function version. Do we think this is something that newer versions of nvcc can/will correct? Seems like they're not supporting standard C++ things here.

Also, since RAJA relies on lamda functions for it's trickery as well, what's teh salient difference here? Is it the reference capturing [&] version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

RAJA requires capturing by value [=] so a copy of the object must be taken into a host-device lambda.

In this specific case the lambda is used for construction of the Interpreter. When VVI + Cuda are enabled the underlying ManagedSharedPtr tries to invoke the constructor on both the host and device. Meaning kernel isn't available to the lambda invoked on the device, we need a copy of it to be passed over to the device in order to be able to call it correctly.

There are a couple of ways of getting back to an interface where we provide a lambda:

  1. Construct interpreters from factory functions that are able to construct w/ appropriate size on Host + Device, then fill the interpreter on the host and copy the contents to the device.
  2. Have the interprter take a handle to the kernel object then define the lambda as [=](const double, const kernel) { return kernel ... } so the interpreter can pass the kernel internally in it's constructor.

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