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

Deprecate Kokkos::Details::ArithTraits #1748

Merged
merged 2 commits into from
Mar 24, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions batched/KokkosBatched_Util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ struct is_vector : public std::false_type {};

template <typename Ta, typename Tb>
struct is_same_mag_type {
static const bool is_specialized =
(Kokkos::Details::ArithTraits<Ta>::is_specialized &&
Kokkos::Details::ArithTraits<Tb>::is_specialized);
static const bool is_specialized = (Kokkos::ArithTraits<Ta>::is_specialized &&
Kokkos::ArithTraits<Tb>::is_specialized);

static const bool is_mag_type_same =
std::is_same<typename Kokkos::Details::ArithTraits<Ta>::mag_type,
typename Kokkos::Details::ArithTraits<Tb>::mag_type>::value;
std::is_same<typename Kokkos::ArithTraits<Ta>::mag_type,
typename Kokkos::ArithTraits<Tb>::mag_type>::value;

static const bool value = is_specialized && is_mag_type_same;
};
Expand Down
6 changes: 2 additions & 4 deletions batched/dense/impl/KokkosBatched_AddRadial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ struct SerialAddRadialInternal {
#endif
for (int i = 0; i < m; ++i) {
// const auto a_real = RealPart(A[i*as]);
const auto a_real =
Kokkos::Details::ArithTraits<ValueType>::real(A[i * as]);
const auto a_real = Kokkos::ArithTraits<ValueType>::real(A[i * as]);
A[i * as] += ValueType(minus_abs_tiny) * ValueType(a_real < 0);
A[i * as] += ValueType(abs_tiny) * ValueType(a_real >= 0);
}
Expand All @@ -62,8 +61,7 @@ struct TeamAddRadialInternal {

Kokkos::parallel_for(Kokkos::TeamThreadRange(member, m), [&](const int &i) {
// const auto a_real = RealPart(A[i*as]);
const auto a_real =
Kokkos::Details::ArithTraits<ValueType>::real(A[i * as]);
const auto a_real = Kokkos::ArithTraits<ValueType>::real(A[i * as]);
A[i * as] += ValueType(minus_abs_tiny) * ValueType(a_real < 0);
A[i * as] += ValueType(abs_tiny) * ValueType(a_real >= 0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct SerialApplyLeftHouseholderInternal {
for (int j = 0; j < n; ++j) {
value_type tmp = a1t[j * a1ts];
for (int i = 0; i < m; ++i)
tmp += Kokkos::Details::ArithTraits<value_type>::conj(u2[i * u2s]) *
tmp += Kokkos::ArithTraits<value_type>::conj(u2[i * u2s]) *
A2[i * as0 + j * as1];
w1t[j] = tmp * inv_tau; // /= (*tau);
}
Expand Down Expand Up @@ -109,7 +109,7 @@ struct SerialApplyRightHouseholderInternal {
for (int j = 0; j < n; ++j)
for (int i = 0; i < m; ++i)
A2[i * as0 + j * as1] -=
w1[i] * Kokkos::Details::ArithTraits<ValueType>::conj(u2[j * u2s]);
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 @@ -59,7 +59,7 @@ struct TeamVectorApplyLeftHouseholderInternal {
Kokkos::parallel_reduce(
Kokkos::ThreadVectorRange(member, m),
[&](const int &i, value_type &val) {
val += Kokkos::Details::ArithTraits<value_type>::conj(u2[i * u2s]) *
val += Kokkos::ArithTraits<value_type>::conj(u2[i * u2s]) *
A2[i * as0 + j * as1];
},
tmp);
Expand Down Expand Up @@ -146,8 +146,7 @@ struct TeamVectorApplyRightHouseholderInternal {
Kokkos::parallel_for(
Kokkos::ThreadVectorRange(member, m), [&](const int &i) {
A2[i * as0 + j * as1] -=
w1[i] * Kokkos::Details::ArithTraits<ValueType>::conj(
u2[j * u2s]);
w1[i] * Kokkos::ArithTraits<ValueType>::conj(u2[j * u2s]);
});
});
} else {
Expand All @@ -156,8 +155,7 @@ struct TeamVectorApplyRightHouseholderInternal {
Kokkos::parallel_for(
Kokkos::TeamThreadRange(member, m), [&](const int &i) {
A2[i * as0 + j * as1] -=
w1[i] * Kokkos::Details::ArithTraits<ValueType>::conj(
u2[j * u2s]);
w1[i] * Kokkos::ArithTraits<ValueType>::conj(u2[j * u2s]);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct SerialEigendecompositionInternal {
"Serial eigendecomposition on device and/or without LAPACK "
"is not implemented yet");
// typedef RealType real_type;
// typedef Kokkos::Details::ArithTraits<real_type> ats;
// typedef Kokkos::ArithTraits<real_type> ats;

// const real_type one(1), zero(0), tol = 1e2*ats::epsilon();
// //const Kokkos::pair<real_type,real_type> identity(one, zero);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct SerialEigenvalueInternal {
const bool restart = false,
const int user_max_iteration = -1) {
typedef RealType real_type;
typedef Kokkos::Details::ArithTraits<real_type> ats;
typedef Kokkos::ArithTraits<real_type> ats;
const real_type zero(0), nan(ats::nan()), tol = 1e2 * ats::epsilon();
const int max_iteration = user_max_iteration < 0 ? 300 : user_max_iteration;

Expand Down
4 changes: 2 additions & 2 deletions batched/dense/impl/KokkosBatched_Francis_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ struct SerialFrancisInternal {
} else {
const value_type val = H[(m - 1) * hs];
const auto dist_lambda1 =
Kokkos::Details::ArithTraits<value_type>::abs(lambda1.real() - val);
Kokkos::ArithTraits<value_type>::abs(lambda1.real() - val);
const auto dist_lambda2 =
Kokkos::Details::ArithTraits<value_type>::abs(lambda2.real() - val);
Kokkos::ArithTraits<value_type>::abs(lambda2.real() - val);
const value_type lambda =
dist_lambda1 < dist_lambda2 ? lambda1.real() : lambda2.real();
s = 2 * lambda;
Expand Down
7 changes: 3 additions & 4 deletions batched/dense/impl/KokkosBatched_Givens_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ struct SerialGivensInternal {
} else {
// here we do not care overflow caused by the division although it is
// probable....
r = Kokkos::Details::ArithTraits<value_type>::sqrt(chi1 * chi1 +
chi2 * chi2);
r = Kokkos::ArithTraits<value_type>::sqrt(chi1 * chi1 + chi2 * chi2);
cs = chi1 / r;
sn = chi2 / r;

if (Kokkos::Details::ArithTraits<value_type>::abs(chi1) >
Kokkos::Details::ArithTraits<value_type>::abs(chi2) &&
if (Kokkos::ArithTraits<value_type>::abs(chi1) >
Kokkos::ArithTraits<value_type>::abs(chi2) &&
cs < zero) {
cs = -cs;
sn = -sn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct SerialHessenbergQR_WithShiftInternal {
/* */ ValueType *HH, const int hs0, const int hs1, const ValueType shift,
/* */ Kokkos::pair<ValueType, ValueType> *GG, const bool request_schur) {
typedef ValueType value_type;
// typedef Kokkos::Details::ArithTraits<value_type> ats;
// typedef Kokkos::ArithTraits<value_type> ats;

const int hs = hs0 + hs1;
const value_type zero(0), one(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct SerialLeftHouseholderInternal {
/* */ ValueType* x2, const int x2s,
/* */ ValueType* tau) {
typedef ValueType value_type;
typedef typename Kokkos::Details::ArithTraits<ValueType>::mag_type mag_type;
typedef typename Kokkos::ArithTraits<ValueType>::mag_type mag_type;

const mag_type zero(0);
const mag_type half(0.5);
Expand All @@ -58,11 +58,10 @@ struct SerialLeftHouseholderInternal {
}

/// compute magnitude of chi1, equal to norm2 of chi1
const mag_type norm_chi1 =
Kokkos::Details::ArithTraits<value_type>::abs(*chi1);
const mag_type norm_chi1 = Kokkos::ArithTraits<value_type>::abs(*chi1);

/// compute 2 norm of x using norm_chi1 and norm_x2
const mag_type norm_x = Kokkos::Details::ArithTraits<mag_type>::sqrt(
const mag_type norm_x = Kokkos::ArithTraits<mag_type>::sqrt(
norm_x2_square + norm_chi1 * norm_chi1);

/// compute alpha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct TeamVectorLeftHouseholderInternal {
/* */ ValueType *x2, const int x2s,
/* */ ValueType *tau) {
typedef ValueType value_type;
typedef typename Kokkos::Details::ArithTraits<ValueType>::mag_type mag_type;
typedef typename Kokkos::ArithTraits<ValueType>::mag_type mag_type;

const mag_type zero(0);
const mag_type half(0.5);
Expand Down Expand Up @@ -64,11 +64,10 @@ struct TeamVectorLeftHouseholderInternal {
}

/// compute magnitude of chi1, equal to norm2 of chi1
const mag_type norm_chi1 =
Kokkos::Details::ArithTraits<value_type>::abs(*chi1);
const mag_type norm_chi1 = Kokkos::ArithTraits<value_type>::abs(*chi1);

/// compute 2 norm of x using norm_chi1 and norm_x2
const mag_type norm_x = Kokkos::Details::ArithTraits<mag_type>::sqrt(
const mag_type norm_x = Kokkos::ArithTraits<mag_type>::sqrt(
norm_x2_square + norm_chi1 * norm_chi1);

/// compute alpha
Expand Down
2 changes: 1 addition & 1 deletion batched/dense/impl/KokkosBatched_LU_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ KOKKOS_INLINE_FUNCTION int SerialLU_Internal<Algo::LU::Unblocked>::invoke(
if (tiny != 0) {
ValueType &alpha11_reference = A[p * as0 + p * as1];
const auto alpha11_real =
Kokkos::Details::ArithTraits<ValueType>::real(alpha11_reference);
Kokkos::ArithTraits<ValueType>::real(alpha11_reference);
alpha11_reference += minus_abs_tiny * ValueType(alpha11_real < 0);
alpha11_reference += abs_tiny * ValueType(alpha11_real >= 0);
}
Expand Down
2 changes: 1 addition & 1 deletion batched/dense/impl/KokkosBatched_LU_Team_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ KOKKOS_INLINE_FUNCTION int TeamLU_Internal<Algo::LU::Unblocked>::invoke(
if (member.team_rank() == 0) {
ValueType &alpha11_reference = A[p * as0 + p * as1];
const auto alpha11_real =
Kokkos::Details::ArithTraits<ValueType>::real(alpha11_reference);
Kokkos::ArithTraits<ValueType>::real(alpha11_reference);
alpha11_reference += minus_abs_tiny * ValueType(alpha11_real < 0);
alpha11_reference += abs_tiny * ValueType(alpha11_real >= 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct SerialLeftEigenvectorFromSchurInternal {
/* */ ValueType *w,
const int *blks) {
typedef ValueType value_type;
typedef Kokkos::Details::ArithTraits<value_type> ats;
typedef Kokkos::ArithTraits<value_type> ats;
// typedef typename ats::mag_type mag_type;
typedef Kokkos::complex<value_type> complex_type;

Expand Down
8 changes: 4 additions & 4 deletions batched/dense/impl/KokkosBatched_Normalize_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct SerialNormalizeInternal {
/* */ ValueType *KOKKOS_RESTRICT v,
const int vs) {
typedef ValueType value_type;
typedef Kokkos::Details::ArithTraits<value_type> ats;
typedef Kokkos::ArithTraits<value_type> ats;
typedef typename ats::mag_type mag_type;

mag_type norm(0);
Expand All @@ -42,7 +42,7 @@ struct SerialNormalizeInternal {
const auto v_at_i = v[i * vs];
norm += ats::real(v_at_i * ats::conj(v_at_i));
}
norm = Kokkos::Details::ArithTraits<mag_type>::sqrt(norm);
norm = Kokkos::ArithTraits<mag_type>::sqrt(norm);
#if defined(KOKKOS_ENABLE_PRAGMA_UNROLL)
#pragma unroll
#endif
Expand All @@ -58,7 +58,7 @@ struct SerialNormalizeInternal {
/* */ RealType *KOKKOS_RESTRICT vi,
const int vis) {
typedef RealType real_type;
typedef Kokkos::Details::ArithTraits<real_type> ats;
typedef Kokkos::ArithTraits<real_type> ats;
typedef typename ats::mag_type mag_type;

mag_type norm(0);
Expand All @@ -70,7 +70,7 @@ struct SerialNormalizeInternal {
const auto vi_at_i = vi[i * vis];
norm += vr_at_i * vr_at_i + vi_at_i * vi_at_i;
}
norm = Kokkos::Details::ArithTraits<mag_type>::sqrt(norm);
norm = Kokkos::ArithTraits<mag_type>::sqrt(norm);
#if defined(KOKKOS_ENABLE_PRAGMA_UNROLL)
#pragma unroll
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct SerialRightEigenvectorFromSchurInternal {
/* */ ValueType *w,
const int *blks) {
typedef ValueType value_type;
typedef Kokkos::Details::ArithTraits<value_type> ats;
typedef Kokkos::ArithTraits<value_type> ats;
// typedef typename ats::mag_type mag_type;
typedef Kokkos::complex<value_type> complex_type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct SerialSchur2x2Internal {
Kokkos::complex<RealType>* lambda2,
bool* is_complex) {
typedef RealType real_type;
typedef Kokkos::Details::ArithTraits<real_type> ats;
typedef Kokkos::ArithTraits<real_type> ats;
const real_type zero(0), one(1), half(0.5), minus_one(-1);
/// compute G = [ gamma -sigma;
/// sigma gamma ];
Expand Down
2 changes: 1 addition & 1 deletion batched/dense/impl/KokkosBatched_Schur_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct SerialSchurInternal {
const bool restart = false,
const int user_max_iteration = -1) {
typedef RealType real_type;
typedef Kokkos::Details::ArithTraits<real_type> ats;
typedef Kokkos::ArithTraits<real_type> ats;
const real_type /* one(1), */ zero(0), tol = 1e2 * ats::epsilon();
const int max_iteration = user_max_iteration < 0 ? 300 : user_max_iteration;
if (wlen < m * 5)
Expand Down
8 changes: 4 additions & 4 deletions batched/dense/impl/KokkosBatched_Trmm_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ SerialTrmmInternalLeftLower<Algo::Trmm::Unblocked>::invoke(
const ValueType *KOKKOS_RESTRICT A, const int as0, const int as1,
/**/ ValueType *KOKKOS_RESTRICT B, const int bs0, const int bs1) {
const ScalarType one(1.0), zero(0.0);
typedef Kokkos::Details::ArithTraits<ValueType> AT;
typedef Kokkos::ArithTraits<ValueType> AT;
int left_m = am;
int right_n = bn;
// echo-TODO: See about coniditionally setting conjOp at compile time.
Expand Down Expand Up @@ -162,7 +162,7 @@ SerialTrmmInternalRightLower<Algo::Trmm::Unblocked>::invoke(
const ValueType *KOKKOS_RESTRICT A, const int as0, const int as1,
/**/ ValueType *KOKKOS_RESTRICT B, const int bs0, const int bs1) {
const ScalarType one(1.0), zero(0.0);
typedef Kokkos::Details::ArithTraits<ValueType> AT;
typedef Kokkos::ArithTraits<ValueType> AT;
int left_m = bm;
int right_n = an;
// echo-TODO: See about coniditionally setting conjOp at compile time.
Expand Down Expand Up @@ -248,7 +248,7 @@ SerialTrmmInternalLeftUpper<Algo::Trmm::Unblocked>::invoke(
const ValueType *KOKKOS_RESTRICT A, const int as0, const int as1,
/**/ ValueType *KOKKOS_RESTRICT B, const int bs0, const int bs1) {
const ScalarType one(1.0), zero(0.0);
typedef Kokkos::Details::ArithTraits<ValueType> AT;
typedef Kokkos::ArithTraits<ValueType> AT;
int left_m = am;
int right_n = bn;
// echo-TODO: See about coniditionally setting conjOp at compile time.
Expand Down Expand Up @@ -330,7 +330,7 @@ SerialTrmmInternalRightUpper<Algo::Trmm::Unblocked>::invoke(
const ValueType *KOKKOS_RESTRICT A, const int as0, const int as1,
/**/ ValueType *KOKKOS_RESTRICT B, const int bs0, const int bs1) {
const ScalarType one(1.0), zero(0.0);
typedef Kokkos::Details::ArithTraits<ValueType> AT;
typedef Kokkos::ArithTraits<ValueType> AT;
int left_m = bm;
int right_n = an;
// echo-TODO: See about coniditionally setting conjOp at compile time.
Expand Down
8 changes: 4 additions & 4 deletions batched/dense/impl/KokkosBatched_Vector_SIMD_Arith.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator++(Vector<SIMD<T>, l> &a, int) {
Vector<SIMD<T>, l> a0 = a;
a = a + typename Kokkos::Details::ArithTraits<T>::mag_type(1);
a = a + typename Kokkos::ArithTraits<T>::mag_type(1);
return a0;
}

template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator++(Vector<SIMD<T>, l> &a) {
a = a + typename Kokkos::Details::ArithTraits<T>::mag_type(1);
a = a + typename Kokkos::ArithTraits<T>::mag_type(1);
return a;
}

Expand Down Expand Up @@ -355,15 +355,15 @@ template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_TYPE(T, l)
operator--(Vector<SIMD<T>, l> &a, int) {
Vector<SIMD<T>, l> a0 = a;
a = a - typename Kokkos::Details::ArithTraits<T>::mag_type(1);
a = a - typename Kokkos::ArithTraits<T>::mag_type(1);
return a0;
}

template <typename T, int l>
KOKKOS_FORCEINLINE_FUNCTION static KOKKOSKERNELS_SIMD_ARITH_RETURN_REFERENCE_TYPE(
T, l)
operator--(Vector<SIMD<T>, l> &a) {
a = a - typename Kokkos::Details::ArithTraits<T>::mag_type(1);
a = a - typename Kokkos::ArithTraits<T>::mag_type(1);
return a;
}

Expand Down
Loading