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

Fix symmetric_matrix_rank_k_update, hermitian_matrix_rank_k_update, and symmetric_matrix_rank_1_update #263

Merged
merged 11 commits into from
Jan 16, 2024

Conversation

mhoemmen
Copy link
Contributor

@mhoemmen mhoemmen commented Jan 15, 2024

What this pull request fixes:

  1. Add a trait that identifies an ExecutionPolicy as a valid (possibly custom) execution policy. (Note that it's forbidden for users to specialize std::is_execution_policy_v.)

  2. Fix build errors when calling the following functions with or without an alpha (but no execution policy), by constraining ExecutionPolicy overloads (see Ambigious Template Definitions For "symmetric_matrix_rank_k_update" #261)

    • symmetric_matrix_rank_k_update
    • hermitian_matrix_rank_k_update
    • symmetric_matrix_rank_1_update
  3. Fix actual bugs in both the with-alpha and no-alpha symmetric_matrix_rank_k_update and hermitian_matrix_rank_k_update overloads that were giving the wrong answers

  4. Drive-by fix for submdspan-related build errors in tests and examples, probably due to reference mdspan namespace changes that haven't been tested in this repository recently

What this pull request does not fix or do:

  1. Generally constrain all the ExecutionPolicy overloads of all the algorithms

Fixes #261.

Header and namespace seem to have changed since last time.
Constrain symmetric_matrix_rank_k_update ExecutionPolicy overloads
so that the compiler can distinguish them from alpha overloads.
Algorithm was giving incorrect results.
This commit fixes that and
improves the associated regression test.
Add a regression test that didn't build before this change,
and now builds correctly.
1. Fix ambiguous overload for the no-scalar case
2. Fix the algorithm (so it gives the right answer,
   for both the scalar and no-scalar cases)
1. Fix ambiguous overload for the no-scalar case
2. Fix the algorithm (so it gives the right answer
   for the no-scalar case; the with-scalar case
   was already fixed in a previous commit)
Add a new trait for testing whether an ExecutionPolicy is a valid
execution policy (either std::is_execution_policy_v or custom).
Use it in symmetric_matrix_rank_k_update and
hermitian_matrix_rank_k_update.
The reference implementation needs to implement all constraints of
symmetric_matrix_rank_1_update in order to disambiguate overloads.

Add a regression test as well.
@mhoemmen mhoemmen changed the title Fix 261 Disambiguate symmetric_matrix_rank_k_update overloads, and fix algorithm bug Jan 15, 2024
@mhoemmen mhoemmen changed the title Disambiguate symmetric_matrix_rank_k_update overloads, and fix algorithm bug Fix symmetric_matrix_rank_k_update and hermitian_matrix_rank_k_update Jan 15, 2024
@@ -4,8 +4,9 @@
// This must be defined before including any mdspan headers.
#define MDSPAN_USE_PAREN_OPERATOR 1

#include <experimental/mdspan>
#include "experimental/__p2630_bits/submdspan.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

Why explicitly include __p2630_bits/submdspan.hpp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dalg24 It didn't build (with GCC 11.4 + CMake 3.22.1, otherwise default settings) otherwise. I really just did this:

cmake ../../../src/kokkos/stdBLAS -DLINALG_ENABLE_TESTS=ON -DLINALG_ENABLE_EXAMPLES=ON
make -j12

and got errors about not finding submdspan. Note that there's no <experimental/submdspan> header to include.

Copy link
Member

@dalg24 dalg24 Jan 16, 2024

Choose a reason for hiding this comment

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

I think the issue might be that we were meant to include <mdspan/mdspan.hpp>

https://github.com/kokkos/mdspan/blob/fddbcb85fcff3b450593669ef40914f09cf40f71/include/mdspan/mdspan.hpp#L37-L40

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of the following headers exist.

  • experimental/submdspan
  • experimental/submdspan.hpp
  • mdspan/submdspan
  • mdspan/submdspan.hpp

Copy link

Choose a reason for hiding this comment

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

Shouldn't <mdspan/mdspan.hpp> include the submdspan headers?

@@ -17,7 +18,8 @@
using std::experimental::extents;
using std::full_extent; // not in experimental namespace
using std::experimental::mdspan;
using std::experimental::submdspan;

using MDSPAN_IMPL_STANDARD_NAMESPACE :: submdspan;
Copy link
Member

Choose a reason for hiding this comment

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

Formatted weirdly. Also why is it not available from the same namespace as mdspan?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see above comment (it really didn't build otherwise).

@mhoemmen mhoemmen changed the title Fix symmetric_matrix_rank_k_update and hermitian_matrix_rank_k_update Fix symmetric_matrix_rank_k_update, hermitian_matrix_rank_k_update, and symmetric_matrix_rank_1_update Jan 16, 2024
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.

Header includes issues can be straighten out later

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.

Ambigious Template Definitions For "symmetric_matrix_rank_k_update"
3 participants