Skip to content
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
10 changes: 3 additions & 7 deletions include/fused_kernel/core/constexpr_libs/constexpr_cmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,8 @@ namespace cxp {
struct min {
struct BaseFunc {
using InstanceType = fk::BinaryType;
template <typename ST>
FK_HOST_DEVICE_FUSE auto exec(const ST s1, const ST s2)
-> std::enable_if_t<std::is_fundamental_v<ST>, ST> {
template <typename ST> requires(std::is_fundamental_v<ST>)
FK_HOST_DEVICE_FUSE auto exec(const ST s1, const ST s2) {
return base::min(s1, s2);
}
};
Expand Down Expand Up @@ -841,10 +840,7 @@ namespace cxp {
return base::clamp(val, minV, maxV);
}
};
template <typename... Types>
static constexpr inline auto f(const Types &...vals) {
return Exec<BaseFunc>::exec(vals...);
}
CXP_F_FUNC
};

// ---------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions include/fused_kernel/core/constexpr_libs/constexpr_saturate.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct saturate_cast {
struct BaseFunc {
using InstanceType = fk::UnaryType;
template <typename ST>
FK_HOST_DEVICE_FUSE auto exec(const ST &s) {
FK_HOST_DEVICE_FUSE auto exec(const ST s) {
using Target_T = fk::VBase<OT>;
using Target = std::remove_cv_t<Target_T>;
using Source_T = ST;
Expand Down Expand Up @@ -141,7 +141,7 @@ struct saturate_cast {
};

template <typename T>
FK_HOST_DEVICE_FUSE auto f(const T &val) {
FK_HOST_DEVICE_FUSE auto f(const T val) {
static_assert(fk::AreSS<OT, T>::value || fk::AreVVEqCN<OT, T>::value,
"saturate_cast can not cast vector to non vector or the other way arround, or from vector to "
"vector of different channel number.");
Expand Down
10 changes: 5 additions & 5 deletions include/fused_kernel/core/constexpr_libs/constexpr_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace cxp {
struct vector_and {
template <typename T>
FK_HOST_DEVICE_FUSE bool f(const T& value) {
FK_HOST_DEVICE_FUSE bool f(const T value) {
if constexpr (fk::validCUDAVec<T>) {
using VecBoolType = fk::bool_<fk::cn<T>>;
const auto valBool = cast<VecBoolType>::f(value);
Expand All @@ -44,13 +44,13 @@ namespace cxp {
struct discard {
template <size_t... Idx, typename I>
FK_HOST_DEVICE_FUSE auto f_helper(const std::index_sequence<Idx...>&,
const I& input) {
const I input) {
using BaseType = fk::VBase<I>;
using OutputType = typename fk::VectorType<BaseType, NewNumChannels>::type_v;
return OutputType{fk::static_get<Idx>(input)...};
}
template <typename I>
FK_HOST_DEVICE_FUSE auto f(const I& input)
FK_HOST_DEVICE_FUSE auto f(const I input)
-> std::enable_if_t<(fk::cn<I> >= 2) && (NewNumChannels < fk::cn<I>),
typename fk::VectorType<fk::VBase<I>, NewNumChannels>::type_v> {
// Remove the explicit template argument <NewNumChannels> here:
Expand All @@ -61,7 +61,7 @@ namespace cxp {
template <size_t... Idx>
struct vector_reorder {
template <typename VT>
FK_HOST_DEVICE_FUSE VT f(const VT& v) {
FK_HOST_DEVICE_FUSE VT f(const VT v) {
static_assert(fk::validCUDAVec<VT>, "Non valid CUDA vetor type: vector_reorder");
static_assert(fk::cn<VT> >= 2, "Minimum number of channels is 2: vector_reorder");
static_assert(sizeof...(Idx) == fk::cn<VT>, "Number of indices must match number of channels");
Expand All @@ -72,7 +72,7 @@ namespace cxp {
template <typename Op>
struct vector_reduce {
template <typename VT>
FK_HOST_DEVICE_FUSE auto f(const VT& v) {
FK_HOST_DEVICE_FUSE auto f(const VT v) {
if constexpr (std::is_same_v<typename Op::InstanceType, fk::UnaryType>) {
using IT = typename Op::InputType;
if constexpr (fk::cn<VT> == 1) {
Expand Down
16 changes: 8 additions & 8 deletions include/fused_kernel/core/constexpr_libs/constexpr_vector_exec.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace cxp {
template <typename Op>
struct Exec<Op, std::enable_if_t<std::is_same_v<typename Op::InstanceType, fk::UnaryType>>> {
template <typename T>
FK_HOST_DEVICE_FUSE auto exec(const T& val) {
FK_HOST_DEVICE_FUSE auto exec(const T val) {
if constexpr (std::is_fundamental_v<T>) {
return Op::exec(val);
} else {
Expand All @@ -47,7 +47,7 @@ namespace cxp {
template <typename Op>
struct Exec<Op, std::enable_if_t<std::is_same_v<typename Op::InstanceType, fk::BinaryType>>> {
template <typename ST1, typename ST2>
FK_HOST_DEVICE_FUSE auto exec(const ST1& s1, const ST2& s2)
FK_HOST_DEVICE_FUSE auto exec(const ST1 s1, const ST2 s2)
-> std::enable_if_t<fk::AreSS<ST1, ST2>::value, decltype(Op::exec(std::declval<ST1>(), std::declval<ST2>()))> {
return Op::exec(s1, s2);
}
Expand All @@ -59,12 +59,12 @@ namespace cxp {
// This allows variadic folds (cxp::sum::f, cxp::max::f, cxp::min::f, ...) to be
// instantiated with parameter packs of size 1.
template <typename ST>
FK_HOST_DEVICE_FUSE auto exec(const ST& s)
FK_HOST_DEVICE_FUSE auto exec(const ST s)
-> std::enable_if_t<!fk::validCUDAVec<ST>, ST> {
return s;
}
template <fk::vector_type VT>
FK_HOST_DEVICE_FUSE auto exec(const VT& v)
FK_HOST_DEVICE_FUSE auto exec(const VT v)
-> decltype(Op::exec(std::declval<fk::VBase<VT>>(), std::declval<fk::VBase<VT>>())) {
if constexpr (fk::cn<VT> == 1) {
return v.x;
Expand All @@ -77,7 +77,7 @@ namespace cxp {
}
}
template <typename VT, typename ST>
FK_HOST_DEVICE_FUSE auto exec(const VT& v, const ST& s)
FK_HOST_DEVICE_FUSE auto exec(const VT v, const ST s)
-> std::enable_if_t<fk::AreVS<VT, ST>::value,
fk::VectorType_t<decltype(Op::exec(std::declval<fk::VBase<VT>>(), std::declval<ST>())), fk::cn<VT>>> {
using BaseO = decltype(Op::exec(std::declval<fk::VBase<VT>>(), std::declval<ST>()));
Expand All @@ -92,7 +92,7 @@ namespace cxp {
}
}
template <typename ST, typename VT>
FK_HOST_DEVICE_FUSE auto exec(const ST& s, const VT& v)
FK_HOST_DEVICE_FUSE auto exec(const ST s, const VT v)
-> std::enable_if_t<fk::AreSV<ST, VT>::value,
fk::VectorType_t<decltype(Op::exec(std::declval<ST>(), std::declval<fk::VBase<VT>>())), fk::cn<VT>>> {
using BaseO = decltype(Op::exec(std::declval<ST>(), std::declval<fk::VBase<VT>>()));
Expand All @@ -107,7 +107,7 @@ namespace cxp {
}
}
template <typename VT1, typename VT2>
FK_HOST_DEVICE_FUSE auto exec(const VT1& v1, const VT2& v2)
FK_HOST_DEVICE_FUSE auto exec(const VT1 v1, const VT2 v2)
-> std::enable_if_t<fk::AreVVEqCN<VT1, VT2>::value,
fk::VectorType_t<decltype(Op::exec(std::declval<fk::VBase<VT1>>(), std::declval<fk::VBase<VT2>>())), fk::cn<VT1>>> {
using BaseO = decltype(Op::exec(std::declval<fk::VBase<VT1>>(), std::declval<fk::VBase<VT2>>()));
Expand All @@ -127,7 +127,7 @@ namespace cxp {
struct Exec<Op, std::enable_if_t<std::is_same_v<typename Op::InstanceType, fk::TernaryType>>> {
template <fk::vector_type VT1, fk::vector_type VT2, fk::vector_type VT3>
requires(fk::AreVVEqCN<VT1, VT2>::value && fk::AreVVEqCN<VT1, VT3>::value)
FK_HOST_DEVICE_FUSE auto exec(const VT1& v1, const VT2& v2, const VT3& v3) {
FK_HOST_DEVICE_FUSE auto exec(const VT1 v1, const VT2 v2, const VT3 v3) {
using BaseO = decltype(Op::exec(std::declval<fk::VBase<VT1>>(), std::declval<fk::VBase<VT2>>(), std::declval<fk::VBase<VT3>>()));
if constexpr (fk::cn<VT1> == 1) {
return fk::VectorType_t<BaseO, 1>{Op::exec(v1.x, v2.x, v3.x)};
Expand Down
Loading