-
Notifications
You must be signed in to change notification settings - Fork 28
Wrap scal #331
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
Draft
amklinv-nnl
wants to merge
2
commits into
kokkos:main
Choose a base branch
from
amklinv-nnl:wrap_scal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Wrap scal #331
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| //@HEADER | ||
| // ************************************************************************ | ||
| // | ||
| // Kokkos v. 4.0 | ||
| // Copyright (2022) National Technology & Engineering | ||
| // Solutions of Sandia, LLC (NTESS). | ||
| // | ||
| // Under the terms of Contract DE-NA0003525 with NTESS, | ||
| // the U.S. Government retains certain rights in this software. | ||
| // | ||
| // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://kokkos.org/LICENSE for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| // ************************************************************************ | ||
| //@HEADER | ||
|
|
||
| #ifndef LINALG_INCLUDE_EXPERIMENTAL___P1673_BITS_BLAS_HELPERS_HPP_ | ||
| #define LINALG_INCLUDE_EXPERIMENTAL___P1673_BITS_BLAS_HELPERS_HPP_ | ||
|
|
||
| #include <complex> | ||
| #include <mdspan/mdspan.hpp> | ||
| #include <type_traits> | ||
| #ifdef KOKKOS_ENABLE_CBLAS | ||
| #include "cblas.h" | ||
| #endif | ||
|
|
||
| namespace MDSPAN_IMPL_STANDARD_NAMESPACE { | ||
| namespace MDSPAN_IMPL_PROPOSED_NAMESPACE { | ||
| inline namespace __p1673_version_0 { | ||
| namespace linalg { | ||
| namespace impl { | ||
|
|
||
| template<class ValueType> | ||
| constexpr bool is_blas_value_type_v = | ||
| std::is_same_v<ValueType, float> || | ||
| std::is_same_v<ValueType, double> || | ||
| std::is_same_v<ValueType, std::complex<float>> || | ||
| std::is_same_v<ValueType, std::complex<double>>; | ||
|
|
||
| template<class Layout> | ||
| constexpr bool is_blas_layout_type_v = | ||
| // Assume that we have a C BLAS, which accepts | ||
| // both row-major and column-major layouts. | ||
| // | ||
| // This just means that the layouts COULD be valid. | ||
| // For layout_stride, we need to check the strides first. | ||
| std::is_same_v<Layout, layout_left> || | ||
| std::is_same_v<Layout, layout_right> || | ||
| // AMK 5/20/26 - layout_left_padded and layout_right_padded were added in C++26. | ||
| // According to cppreference, padded layouts are covered by the same feature test as submdspan. | ||
| #ifdef __cpp_lib_submdspan | ||
| std::is_same_v<Layout, layout_left_padded> || | ||
| std::is_same_v<Layout, layout_right_padded> || | ||
| #endif | ||
| std::is_same_v<Layout, layout_stride>; | ||
|
|
||
| // The BLAS accepts accessors that deal with pointers to memory: | ||
| // default_accessor and aligned_accessor. | ||
| // Those are both templated classes, so we can't just use is_same_v directly. | ||
| // | ||
| // scale doesn't accept conjugated_accessor or scaled_accessor | ||
| // because those are read-only accessors, and scale needs to | ||
| // write to the mdspan's elements. | ||
|
|
||
| template<class Accessor> | ||
| constexpr bool is_default_accessor_v = false; | ||
|
|
||
| template<class ElementType> | ||
| constexpr bool is_default_accessor_v<default_accessor<ElementType>> = true; | ||
|
|
||
| template<class Accessor> | ||
| constexpr bool is_aligned_accessor_v = false; | ||
|
|
||
| #ifdef __cpp_lib_aligned_accessor | ||
| template<class ElementType, std::size_t ByteAlignment> | ||
| constexpr bool is_aligned_accessor_v<aligned_accessor<ElementType, ByteAlignment>> = true; | ||
| #endif | ||
|
|
||
| template<class Accessor> | ||
| constexpr bool is_blas_accessor_type_v = | ||
| is_default_accessor_v<Accessor> || | ||
| is_aligned_accessor_v<Accessor>; | ||
|
|
||
| // We made the above queries traits, with their typical `_v` prefix. | ||
| // We make maybe_can_blas_scale() a function. | ||
| // That's a matter of taste; it could be a trait too. | ||
|
|
||
| } // end namespace impl | ||
| } // end namespace linalg | ||
| } // end inline namespace __p1673_version_0 | ||
| } // end namespace MDSPAN_IMPL_PROPOSED_NAMESPACE | ||
| } // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE | ||
|
|
||
| #endif //LINALG_INCLUDE_EXPERIMENTAL___P1673_BITS_BLAS_HELPERS_HPP_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per [mdspan.layout.reqmnts] 19, we can't call
x.stride(0)until we know thatx.is_strided()istrue.incxmight be larger thann.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also acceptable to turn this into a compile-time check. We don't have to worry too much about weird layouts for which
is_strided()istruesometimes butis_always_strided()isfalse.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, strided layout mappings can have stride zero.
layout_stridecannot, unless its corresponding extent is also zero. Ifincxis zero, then we should also returnfalse.