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

This will make mdspan and its tests work with HIP #233

Merged
merged 11 commits into from
Jan 30, 2023

Conversation

crtrott
Copy link
Member

@crtrott crtrott commented Jan 27, 2023

Note I didn't address benchmarks and examples, just tests. Also the biggest change is a patch gtest so it compiles with that clang version with C++20.

@@ -115,11 +115,15 @@ static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or
# define _MDSPAN_NO_UNIQUE_ADDRESS
#endif

// AMDs HIP compiler seems to have issues with concepts
// it pretends concepts exist, but doesn't ship <concept>
#ifndef __HIPCC__
Copy link
Member

Choose a reason for hiding this comment

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

But that would be defined regardless of whether it is amdclang++ or some other HIP-capable compiler.
Should we guard depending on whether HIP was enabled at configuration time?
(not asking you to change, wondering what the right thing to do might be)
I see that we don't have such a "HIP enabled" macro define anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

No for now whether HIPCC is defined is good enough. We can revisit later and refine based on compiler version when we have evidence which ones work.

#endif

#ifdef _MDSPAN_HAS_HIP
# define MDSPAN_CTAD _MDSPAN_HOST_DEVICE
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer CTAD -> DEDUCTION_GUIDE

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

@@ -321,9 +321,16 @@ class mdspan

MDSPAN_INLINE_FUNCTION
friend constexpr void swap(mdspan& x, mdspan& y) noexcept {
// can't call the std::swap inside on HIP
#ifndef _MDSPAN_HAS_HIP
Copy link
Member

Choose a reason for hiding this comment

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

is that a FIXME? do you want to annotate with something greppable?

Copy link
Member Author

Choose a reason for hiding this comment

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

not really. There is nothing to fix, its just what we have to do.

Copy link
Member

Choose a reason for hiding this comment

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

do we consider it as a defect in the toolchain?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really. I mean no one says we can call random std:: function on device ...

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 said it would be great if we could :-)

@@ -102,7 +102,9 @@ TEST(TestMDSpanSwap, std_swap_dynamic_extents) {
__MDSPAN_TESTS_RUN_TEST(test_mdspan_std_swap_dynamic_extents())
}


// On HIP we actually don't call through to swap via ADL
// so the foo swap test which has sideeffects will fail
Copy link
Member

Choose a reason for hiding this comment

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

sideeffects -> side effects

Consider annotating here too

Copy link
Member Author

Choose a reason for hiding this comment

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

as I said I don't think there is anything to fix?

template<class T>
void mallocManaged(T** ptr, size_t size) { (void) cudaMallocManaged(ptr, size); }
template<class T>
void freeManaged(T* ptr) { (void) cudaFree(ptr); }
Copy link
Member

Choose a reason for hiding this comment

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

I don't like the name but I suppose you were afraid of ambiguities?

Copy link
Member Author

Choose a reason for hiding this comment

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

partly, partly making clear that this is managed memory equivalent and that it needs to be that, because we use the allocations from both host and device in the tests.

@dalg24 dalg24 mentioned this pull request Jan 28, 2023
Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Please do a follow up PR where you pin the GTest version and apply the patch

@crtrott crtrott merged commit d8a0b8a into kokkos:stable Jan 30, 2023
@crtrott crtrott deleted the make-hip-work branch February 1, 2023 03:47
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.

2 participants