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

Add Kokkos::mdspan #11533

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

Swiftb0y
Copy link
Member

@Swiftb0y Swiftb0y commented May 3, 2023

mdspan will be in C++23 and could greatly help with making the audio engine more flexible. It allows to interpret a contiguous chunk of memory as a multidimensional std::span. The result is that the iteration logic can be separate from the memory access logic (and thus the memory layout), allowing us to write generic audio algorithms which can easily adapt to different channel layouts (consider surround audio and STEMs).
This PR contains a demo commit to confirm the changes to the build actually work, no meaningful work has yet been done in any mixxx-related audio code.

@github-actions github-actions bot added the build label May 3, 2023
@JoergAtGithub
Copy link
Member

Sounds good to me!

@daschuer
Copy link
Member

daschuer commented May 4, 2023

Nice.

It would be interesting if auto vectorization is still done when we for instance use it for:

void SampleUtil::applyAlternatingGain(CSAMPLE* pBuffer, CSAMPLE gain1,

Unfortunatly MSVC 2019 is not able to compile it:

Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(67): error C7568: argument list missing after assumed function template 'is_empty_v'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(67): error C2059: syntax error: '!'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(67): error C7568: argument list missing after assumed function template 'is_empty_v'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(68): error C2332: 'struct': missing tag name
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(68): error C3306: 'Kokkos::detail::<unnamed-tag>': unnamed class template is not allowed
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(82): error C2639: trailing return type 'int' of deduction guide should be a specialization of 'Kokkos::detail::__compressed_pair'
D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(98): note: see reference to class template instantiation 'Kokkos::detail::<unnamed-tag><_T,_U>' being compiled
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(82): error C2643: deduction guide should be declared in the same scope as the corresponding class template 'Kokkos::detail::__compressed_pair'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(82): error C2178: 'Kokkos::detail::<unnamed-tag><_T,_U>::__compressed_pair' cannot be declared with 'constexpr' specifier
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(82): error C2610: 'int Kokkos::detail::<unnamed-tag><_T,_U>::__compressed_pair(void) noexcept': is not a special member function or comparison operator which can be defaulted
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(84): error C2061: syntax error: identifier '__compressed_pair'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(84): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(84): error C2610: 'int Kokkos::detail::<unnamed-tag><_T,_U>::__compressed_pair(void) noexcept': is not a special member function or comparison operator which can be defaulted
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(86): error C2061: syntax error: identifier '__compressed_pair'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(86): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(86): error C2610: 'int Kokkos::detail::<unnamed-tag><_T,_U>::__compressed_pair(void) noexcept': is not a special member function or comparison operator which can be defaulted
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(88): error C2143: syntax error: missing ';' before '&'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(88): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(88): error C2178: 'Kokkos::detail::<unnamed-tag><_T,_U>::__compressed_pair' cannot be declared with 'constexpr' specifier
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(89): error C2238: unexpected token(s) preceding ';'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(91): error C2143: syntax error: missing ';' before '&'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(91): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(91): error C2178: 'Kokkos::detail::<unnamed-tag><_T,_U>::__compressed_pair' cannot be declared with 'constexpr' specifier
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(92): error C2238: unexpected token(s) preceding ';'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(94): error C2523: 'Kokkos::detail::<unnamed-tag><_T,_U>::~__compressed_pair': destructor tag mismatch
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(97): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(104): error C7568: argument list missing after assumed function template 'is_empty_v'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(104): error C2062: type 'unknown-type' unexpected
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(104): error C7568: argument list missing after assumed function template 'is_empty_v'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(105): error C2332: 'struct': missing tag name
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(136): error C2953: 'Kokkos::detail::<unnamed-tag>': class template has already been defined
D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(105): note: see declaration of 'Kokkos::detail::<unnamed-tag>'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(142): error C7568: argument list missing after assumed function template 'is_empty_v'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(142): error C7568: argument list missing after assumed function template 'is_empty_v'
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(142): error C2062: type 'unknown-type' unexpected
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(148): error C2332: 'struct': missing tag name
Error: D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(190): error C2953: 'Kokkos::detail::<unnamed-tag>': class template has already been defined
D:\a\mixxx\mixxx\lib\mdspan\include\experimental\__p0009_bits\compressed_pair.hpp(148): note: see declaration of 'Kokkos::detail::<unnamed-tag>'
[242/870] Building CXX object CMakeFiles\mixxx-lib.dir\src\analyzer\analyzerwaveform.cpp.obj
ninja: build stopped: subcommand failed.
Error: Process completed with exit code 1.

@Swiftb0y
Copy link
Member Author

Swiftb0y commented May 4, 2023

It would be interesting if auto vectorization is still done when we for instance use it for:

Yes, I'm quite certain though it probably depends on the complexity of layout and the accessor implementation. Unfortunately there is not much accessible documentation for mdspan yet. These are probably the best:

Unfortunatly MSVC 2019 is not able to compile it:

They seem to be aware but not doing particularly much about it. kokkos/mdspan#26

We could conditionally use the vcpkg port on MSVC, though I don't really want to look into this right now.

@JoergAtGithub
Copy link
Member

If it compiles with VS2022, it should be OK for the Main branch. This is because Qt6 requires Windows 10 (build 1809 or later) and on these newer Windows10 versions, VS2022 is supported as well.

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the stale Stale issues that haven't been updated for a long time. label Aug 3, 2023
@github-actions github-actions bot removed the stale Stale issues that haven't been updated for a long time. label Aug 21, 2023
@Swiftb0y
Copy link
Member Author

It builds. I'll remove the demo commit and remove draft now.

@Swiftb0y Swiftb0y marked this pull request as ready for review September 14, 2023 17:59
@Swiftb0y Swiftb0y changed the title [RFC] Add Kokkos::mdspan Add Kokkos::mdspan Sep 14, 2023
@daschuer daschuer marked this pull request as draft September 17, 2023 07:34
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

LGTM.

However let's keep it as draft to not merge an unused library to our lib folder.
If one starts to refactor our code using mdspan they can base on this PR.

@Swiftb0y
Copy link
Member Author

Fine for me.

Copy link

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the stale Stale issues that haven't been updated for a long time. label Jan 26, 2024
@github-actions github-actions bot removed the stale Stale issues that haven't been updated for a long time. label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants