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

View-Refactor: mdspan implementation updates #7288

Merged
merged 5 commits into from
Sep 6, 2024

Conversation

crtrott
Copy link
Member

@crtrott crtrott commented Sep 3, 2024

This is a piece of #7286 fixing a few small mdspan things. I will open a PR on the mdspan implementation shortly also attempting to write a test for one of the conversion issues exposed and fixed here. (padded_stride_type::init_padding takes an extents_type as argument, which previously would have required other_mapping.extents() to be convertible to extents_type. The function constraint is only "is_constructible" though, so we need to explicitly cast before calling the helper.

MDSpan PR here: kokkos/mdspan#358

@@ -17,6 +17,7 @@
#pragma once

#include <tuple>
#include <complex>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure you want/need to include <complex> here ? It's surprising.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@romintomasetti romintomasetti Sep 4, 2024

Choose a reason for hiding this comment

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

But isn't this pair-like thingy used for slicing ? If so, I would be surprised that slicing is allowed with a complex... I can't image how bad a code would be if complex numbers were used for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is by the standard.

Copy link
Member Author

Choose a reason for hiding this comment

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

turns out that the ISO C++ standard defines the exposition only concept pair-like which is defined through tuple-like which is defined here: https://eel.is/c++draft/tuple.like#concept:tuple-like

So complex<double> is a valid slice specifier for submdspan because its pair-like and double is convertible to index_type

Copy link
Contributor

Choose a reason for hiding this comment

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

It is a draft right ? If so I would refrain supporting such a ill-formed case.

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 this is final. This was discussed in the committee and it is basically not avoidable. We want "convertible to index_type" to be valid, that means floating points will be valid. And the committee did not feel like adding an explicit "convertible to index_type but not floating point" to the specification of all these things in mdspan.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, then I wouldn't go against the committee.

But in this specific case, you're still including complex in a very central file, so any downstream project using Kokkos would have complex included ?!

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 is already the case, because you get it indirectly through Kokkos_Complex

Copy link
Contributor

Choose a reason for hiding this comment

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

I still think that Kokkos should not pull <xomplex> for me, but do what you think is best. I won't block for this of course 😉

@@ -95,6 +95,7 @@ struct padded_extent {
using static_array_type = typename static_array_type_for_padded_extent<
padding_value, _Extents, _ExtentToPadIdx, _Extents::rank()>::type;

MDSPAN_INLINE_FUNCTION
Copy link
Contributor

Choose a reason for hiding this comment

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

inline is implicitly implied I think. Would be good to remove that useless specifier if so.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

My 2 cents is that doing things "for code style consistency" is a bad practice IMO. In this case, stripping out INLINE makes the code shorter and more to the point, and remove a clearly useless specifier.

But do whatever you want 😄

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 confirm that this is up to date with what we merged in kokkos/mdspan

@crtrott
Copy link
Member Author

crtrott commented Sep 6, 2024

Please confirm that this is up to date with what we merged in kokkos/mdspan

Obviously I intended it to be and it is, but isn't checking this part of the review ;-)

@dalg24 dalg24 closed this Sep 6, 2024
@dalg24 dalg24 reopened this Sep 6, 2024
@dalg24
Copy link
Member

dalg24 commented Sep 6, 2024

(could not think of a better way to trigger the CI and it did not work...)

@dalg24
Copy link
Member

dalg24 commented Sep 6, 2024

Obviously there is a CI SKIP directive...

@dalg24 dalg24 merged commit d4af7c8 into kokkos:develop Sep 6, 2024
1 check was pending
@ndellingwood
Copy link
Contributor

Should the mdspan interop updates get a changelog entry/section?

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.

5 participants