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

Propose increasing column limit to 120. #2255

Merged
merged 4 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ SortIncludes: false
AlignConsecutiveAssignments: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
ColumnLimit: 120
17 changes: 17 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Add formatting and other uninteresting commits here and
# 'git blame $file' will skip them IF
# A) you have it configured to do so globally (dangerous, this will break git blame on repos that don't have a .git-blame-ignore-revs file.
# git config --global blame.ignoreRevsFile .git-blame-ignore-revs
# OR
# B) you have it configured to do so locally (tedious, you have to remember to do this in every KK clone)
# git config blame.ignoreRevsFile .git-blame-ignore-revs
# OR
# C) you have an aliased blame command for KokkosKernels:
# git config --global alias.kkblame 'blame --ignore-revs-file=.git-blame-ignore-revs'
# NOTE: this implies you run 'git kkblame $file'
# OR
# D) you explicitly tell blame to skip them
# git blame --ignore-revs-file=.git-blame-ignore-revs $file
#
# List skips here:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

6 changes: 3 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ permissions:

jobs:
clang-format-check:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install Dependencies
run: sudo apt install clang-format-8
run: sudo apt install clang-format-16

- name: check
run: |
Expand All @@ -26,7 +26,7 @@ jobs:
# For every file changed, apply clang-format
for file in $(git diff --name-only origin/$GITHUB_BASE_REF | egrep '.*\.cpp$|.*\.hpp$|.*\.h$'); do
if [ -e $file ]; then
clang-format-8 -i -style=file $file
clang-format-16 -i -style=file $file
git add $file
fi
done
Expand Down
276 changes: 96 additions & 180 deletions batched/KokkosBatched_Util.hpp

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions batched/dense/impl/KokkosBatched_AddRadial_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ namespace KokkosBatched {
/// ===========

template <typename ScalarType, typename AViewType>
KOKKOS_INLINE_FUNCTION int SerialAddRadial::invoke(const ScalarType tiny,
const AViewType &A) {
return SerialAddRadialInternal::invoke(
(A.extent(0) < A.extent(1) ? A.extent(0) : A.extent(1)), tiny, A.data(),
(A.stride_0() + A.stride_1()));
KOKKOS_INLINE_FUNCTION int SerialAddRadial::invoke(const ScalarType tiny, const AViewType &A) {
return SerialAddRadialInternal::invoke((A.extent(0) < A.extent(1) ? A.extent(0) : A.extent(1)), tiny, A.data(),
(A.stride_0() + A.stride_1()));
}

///
Expand All @@ -41,11 +39,10 @@ KOKKOS_INLINE_FUNCTION int SerialAddRadial::invoke(const ScalarType tiny,

template <typename MemberType>
template <typename ScalarType, typename AViewType>
KOKKOS_INLINE_FUNCTION int TeamAddRadial<MemberType>::invoke(
const MemberType &member, const ScalarType tiny, const AViewType &A) {
return TeamAddRadialInternal::invoke(
member, (A.extent(0) < A.extent(1) ? A.extent(0) : A.extent(1)), tiny,
A.data(), (A.stride_0() + A.stride_1()));
KOKKOS_INLINE_FUNCTION int TeamAddRadial<MemberType>::invoke(const MemberType &member, const ScalarType tiny,
const AViewType &A) {
return TeamAddRadialInternal::invoke(member, (A.extent(0) < A.extent(1) ? A.extent(0) : A.extent(1)), tiny, A.data(),
(A.stride_0() + A.stride_1()));
}

} // end namespace KokkosBatched
Expand Down
9 changes: 3 additions & 6 deletions batched/dense/impl/KokkosBatched_AddRadial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ namespace KokkosBatched {
struct SerialAddRadialInternal {
template <typename ScalarType, typename ValueType>
KOKKOS_INLINE_FUNCTION static int invoke(const int m, const ScalarType tiny,
/* */ ValueType *KOKKOS_RESTRICT A,
const int as) {
/* */ ValueType *KOKKOS_RESTRICT A, const int as) {
const auto abs_tiny = tiny > 0 ? tiny : -tiny;
const auto minus_abs_tiny = -abs_tiny;

Expand All @@ -52,10 +51,8 @@ struct SerialAddRadialInternal {
/// ==================
struct TeamAddRadialInternal {
template <typename MemberType, typename ScalarType, typename ValueType>
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member,
const int m, const ScalarType tiny,
/* */ ValueType *KOKKOS_RESTRICT A,
const int as) {
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const int m, const ScalarType tiny,
/* */ ValueType *KOKKOS_RESTRICT A, const int as) {
const auto abs_tiny = tiny > 0 ? tiny : -tiny;
const auto minus_abs_tiny = -abs_tiny;

Expand Down
42 changes: 19 additions & 23 deletions batched/dense/impl/KokkosBatched_ApplyGivens_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ namespace KokkosBatched {
///
struct SerialApplyLeftGivensInternal {
template <typename ValueType>
KOKKOS_INLINE_FUNCTION static int invoke(
const Kokkos::pair<ValueType, ValueType> G, const int n,
/* */ ValueType *a1t, const int a1ts,
/* */ ValueType *a2t, const int a2ts) {
KOKKOS_INLINE_FUNCTION static int invoke(const Kokkos::pair<ValueType, ValueType> G, const int n,
/* */ ValueType *a1t, const int a1ts,
/* */ ValueType *a2t, const int a2ts) {
typedef ValueType value_type;
if (n == 0) return 0; // quick return
if (G.first == value_type(1) && G.second == value_type(0)) return 0;
Expand All @@ -59,10 +58,9 @@ struct SerialApplyLeftGivensInternal {

struct SerialApplyRightGivensInternal {
template <typename ValueType>
KOKKOS_INLINE_FUNCTION static int invoke(
const Kokkos::pair<ValueType, ValueType> G, const int m,
/* */ ValueType *a1, const int a1s,
/* */ ValueType *a2, const int a2s) {
KOKKOS_INLINE_FUNCTION static int invoke(const Kokkos::pair<ValueType, ValueType> G, const int m,
/* */ ValueType *a1, const int a1s,
/* */ ValueType *a2, const int a2s) {
typedef ValueType value_type;
if (m == 0) return 0; // quick return
if (G.first == value_type(1) && G.second == value_type(0)) return 0;
Expand All @@ -88,12 +86,11 @@ struct SerialApplyRightGivensInternal {

struct SerialApplyLeftRightGivensInternal {
template <typename ValueType>
KOKKOS_INLINE_FUNCTION static int invoke(
const Kokkos::pair<ValueType, ValueType> &G12, const int &m, const int &n,
/* */ ValueType *KOKKOS_RESTRICT a1t,
/* */ ValueType *KOKKOS_RESTRICT a2t,
/* */ ValueType *KOKKOS_RESTRICT a1,
/* */ ValueType *KOKKOS_RESTRICT a2, const int &as0, const int &as1) {
KOKKOS_INLINE_FUNCTION static int invoke(const Kokkos::pair<ValueType, ValueType> &G12, const int &m, const int &n,
/* */ ValueType *KOKKOS_RESTRICT a1t,
/* */ ValueType *KOKKOS_RESTRICT a2t,
/* */ ValueType *KOKKOS_RESTRICT a1,
/* */ ValueType *KOKKOS_RESTRICT a2, const int &as0, const int &as1) {
typedef ValueType value_type;
if (G12.first == value_type(1) && G12.second == value_type(0)) return 0;
if (m == 0 && n == 0) return 0; // quick return
Expand Down Expand Up @@ -124,15 +121,14 @@ struct SerialApplyLeftRightGivensInternal {
}

template <typename ValueType>
KOKKOS_INLINE_FUNCTION static int invoke(
const Kokkos::pair<ValueType, ValueType> &G12,
const Kokkos::pair<ValueType, ValueType> &G13, const int &m, const int &n,
/* */ ValueType *KOKKOS_RESTRICT a1t,
/* */ ValueType *KOKKOS_RESTRICT a2t,
/* */ ValueType *KOKKOS_RESTRICT a3t,
/* */ ValueType *KOKKOS_RESTRICT a1,
/* */ ValueType *KOKKOS_RESTRICT a2,
/* */ ValueType *KOKKOS_RESTRICT a3, const int &as0, const int &as1) {
KOKKOS_INLINE_FUNCTION static int invoke(const Kokkos::pair<ValueType, ValueType> &G12,
const Kokkos::pair<ValueType, ValueType> &G13, const int &m, const int &n,
/* */ ValueType *KOKKOS_RESTRICT a1t,
/* */ ValueType *KOKKOS_RESTRICT a2t,
/* */ ValueType *KOKKOS_RESTRICT a3t,
/* */ ValueType *KOKKOS_RESTRICT a1,
/* */ ValueType *KOKKOS_RESTRICT a2,
/* */ ValueType *KOKKOS_RESTRICT a3, const int &as0, const int &as1) {
typedef ValueType value_type;
if (m == 0 && n == 0) return 0; // quick return

Expand Down
30 changes: 12 additions & 18 deletions batched/dense/impl/KokkosBatched_ApplyHouseholder_Serial_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,21 @@ namespace KokkosBatched {
/// ===========

template <>
template <typename uViewType, typename tauViewType, typename AViewType,
typename wViewType>
KOKKOS_INLINE_FUNCTION int SerialApplyHouseholder<Side::Left>::invoke(
const uViewType &u2, const tauViewType &tau, const AViewType &A,
const wViewType &w) {
return SerialApplyLeftHouseholderInternal::invoke(
A.extent(0) - 1, A.extent(1), tau.data(), u2.data(), u2.stride(0),
A.data(), A.stride(1), A.data() + A.stride(0), A.stride(0), A.stride(1),
w.data());
template <typename uViewType, typename tauViewType, typename AViewType, typename wViewType>
KOKKOS_INLINE_FUNCTION int SerialApplyHouseholder<Side::Left>::invoke(const uViewType &u2, const tauViewType &tau,
const AViewType &A, const wViewType &w) {
return SerialApplyLeftHouseholderInternal::invoke(A.extent(0) - 1, A.extent(1), tau.data(), u2.data(), u2.stride(0),
A.data(), A.stride(1), A.data() + A.stride(0), A.stride(0),
A.stride(1), w.data());
}

template <>
template <typename uViewType, typename tauViewType, typename AViewType,
typename wViewType>
KOKKOS_INLINE_FUNCTION int SerialApplyHouseholder<Side::Right>::invoke(
const uViewType &u2, const tauViewType &tau, const AViewType &A,
const wViewType &w) {
return SerialApplyRightHouseholderInternal::invoke(
A.extent(0), A.extent(1) - 1, tau.data(), u2.data(), u2.stride(0),
A.data(), A.stride(0), A.data() + A.stride(1), A.stride(0), A.stride(1),
w.data());
template <typename uViewType, typename tauViewType, typename AViewType, typename wViewType>
KOKKOS_INLINE_FUNCTION int SerialApplyHouseholder<Side::Right>::invoke(const uViewType &u2, const tauViewType &tau,
const AViewType &A, const wViewType &w) {
return SerialApplyRightHouseholderInternal::invoke(A.extent(0), A.extent(1) - 1, tau.data(), u2.data(), u2.stride(0),
A.data(), A.stride(0), A.data() + A.stride(1), A.stride(0),
A.stride(1), w.data());
}

} // namespace KokkosBatched
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ namespace KokkosBatched {
///
struct SerialApplyLeftHouseholderInternal {
template <typename ValueType>
KOKKOS_INLINE_FUNCTION static int invoke(const int m, const int n,
const ValueType* tau,
KOKKOS_INLINE_FUNCTION static int invoke(const int m, const int n, const ValueType* tau,
/* */ ValueType* u2, const int u2s,
/* */ ValueType* a1t, const int a1ts,
/* */ ValueType* A2, const int as0,
const int as1,
/* */ ValueType* A2, const int as0, const int as1,
/* */ ValueType* w1t) {
typedef ValueType value_type;

Expand All @@ -55,9 +53,7 @@ struct SerialApplyLeftHouseholderInternal {
// w1t /= tau
for (int j = 0; j < n; ++j) {
value_type tmp = a1t[j * a1ts];
for (int i = 0; i < m; ++i)
tmp += Kokkos::ArithTraits<value_type>::conj(u2[i * u2s]) *
A2[i * as0 + j * as1];
for (int i = 0; i < m; ++i) tmp += Kokkos::ArithTraits<value_type>::conj(u2[i * u2s]) * A2[i * as0 + j * as1];
w1t[j] = tmp * inv_tau; // /= (*tau);
}

Expand All @@ -74,12 +70,10 @@ struct SerialApplyLeftHouseholderInternal {

struct SerialApplyRightHouseholderInternal {
template <typename ValueType>
KOKKOS_INLINE_FUNCTION static int invoke(const int m, const int n,
const ValueType* tau,
KOKKOS_INLINE_FUNCTION static int invoke(const int m, const int n, const ValueType* tau,
/* */ ValueType* u2, const int u2s,
/* */ ValueType* a1, const int a1s,
/* */ ValueType* A2, const int as0,
const int as1,
/* */ ValueType* A2, const int as0, const int as1,
/* */ ValueType* w1) {
typedef ValueType value_type;
/// u2 n x 1
Expand Down Expand Up @@ -107,9 +101,7 @@ struct SerialApplyRightHouseholderInternal {

// A2 -= w1 * u2' (ger with conjugate)
for (int j = 0; j < n; ++j)
for (int i = 0; i < m; ++i)
A2[i * as0 + j * as1] -=
w1[i] * Kokkos::ArithTraits<ValueType>::conj(u2[j * u2s]);
for (int i = 0; i < m; ++i) A2[i * as0 + j * as1] -= w1[i] * Kokkos::ArithTraits<ValueType>::conj(u2[j * u2s]);

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,23 @@ namespace KokkosBatched {

template <typename MemberType>
struct TeamVectorApplyHouseholder<MemberType, Side::Left> {
template <typename uViewType, typename tauViewType, typename AViewType,
typename wViewType>
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member,
const uViewType &u2,
const tauViewType &tau,
const AViewType &A,
const wViewType &w) {
return TeamVectorApplyLeftHouseholderInternal::invoke(
member, A.extent(0) - 1, A.extent(1), tau.data(), u2.data(),
u2.stride(0), A.data(), A.stride(1), A.data() + A.stride(0),
A.stride(0), A.stride(1), w.data());
template <typename uViewType, typename tauViewType, typename AViewType, typename wViewType>
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const uViewType &u2, const tauViewType &tau,
const AViewType &A, const wViewType &w) {
return TeamVectorApplyLeftHouseholderInternal::invoke(member, A.extent(0) - 1, A.extent(1), tau.data(), u2.data(),
u2.stride(0), A.data(), A.stride(1), A.data() + A.stride(0),
A.stride(0), A.stride(1), w.data());
}
};

template <typename MemberType>
struct TeamVectorApplyHouseholder<MemberType, Side::Right> {
template <typename uViewType, typename tauViewType, typename AViewType,
typename wViewType>
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member,
const uViewType &u2,
const tauViewType &tau,
const AViewType &A,
const wViewType &w) {
return TeamVectorApplyRightHouseholderInternal::invoke(
member, A.extent(0), A.extent(1) - 1, tau.data(), u2.data(),
u2.stride(0), A.data(), A.stride(0), A.data() + A.stride(1),
A.stride(0), A.stride(1), w.data());
template <typename uViewType, typename tauViewType, typename AViewType, typename wViewType>
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const uViewType &u2, const tauViewType &tau,
const AViewType &A, const wViewType &w) {
return TeamVectorApplyRightHouseholderInternal::invoke(member, A.extent(0), A.extent(1) - 1, tau.data(), u2.data(),
u2.stride(0), A.data(), A.stride(0), A.data() + A.stride(1),
A.stride(0), A.stride(1), w.data());
}
};

Expand Down
Loading
Loading