Skip to content

Commit

Permalink
Flatten assign op calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencilcaseman committed Aug 20, 2024
1 parent 3b206e7 commit 6c79f57
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 75 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,15 @@ librapid/bindings/python/generated
dist/

*.pyc
examples/CMakeFiles
examples/CTestTestfile.cmake
examples/Makefile
examples/cmake_install.cmake
test/CMakeFiles
test/CTestTestfile.cmake
test/Makefile
test/cmake_install.cmake
cmake_install.cmake
DartConfiguration.tcl
CTestTestfile.cmake
Makefile
14 changes: 7 additions & 7 deletions librapid/include/librapid/array/assignOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace librapid {
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void
LIBRAPID_FLATTEN LIBRAPID_ALWAYS_INLINE void
assign(array::ArrayContainer<ShapeType_, Storage<StorageScalar>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
using Function = detail::Function<descriptor::Trivial, Functor_, Args...>;
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace librapid {
typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void
LIBRAPID_FLATTEN LIBRAPID_ALWAYS_INLINE void
assign(array::ArrayContainer<ShapeType_, FixedStorage<StorageScalar, StorageSize...>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
using Function = detail::Function<descriptor::Trivial, Functor_, Args...>;
Expand Down Expand Up @@ -137,7 +137,7 @@ namespace librapid {
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void
LIBRAPID_FLATTEN LIBRAPID_ALWAYS_INLINE void
assignParallel(array::ArrayContainer<ShapeType_, Storage<StorageScalar>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
using Function = detail::Function<descriptor::Trivial, Functor_, Args...>;
Expand Down Expand Up @@ -201,7 +201,7 @@ namespace librapid {
typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void assignParallel(
LIBRAPID_FLATTEN LIBRAPID_ALWAYS_INLINE void assignParallel(
array::ArrayContainer<ShapeType_, FixedStorage<StorageScalar, StorageSize...>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
using Function = detail::Function<descriptor::Trivial, Functor_, Args...>;
Expand Down Expand Up @@ -356,7 +356,7 @@ namespace librapid {
namespace cuda {
template<typename T>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto dataSourceExtractor(const T &obj) {
if constexpr(typetraits::TypeInfo<T>::type ==
if constexpr (typetraits::TypeInfo<T>::type ==
::librapid::detail::LibRapidType::Scalar) {
return obj;
} else {
Expand Down Expand Up @@ -545,8 +545,8 @@ namespace librapid {
reinterpret_cast<Scalar *>(lhs.storage().begin()),
function);
}
} // namespace detail
} // namespace detail
#endif // LIBRAPID_HAS_CUDA
} // namespace librapid

#endif // LIBRAPID_ARRAY_ASSIGN_OPS_HPP
#endif // LIBRAPID_ARRAY_ASSIGN_OPS_HPP
94 changes: 47 additions & 47 deletions librapid/include/librapid/array/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,8 @@ namespace librapid {
/// \return Sine function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto sin(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Sin, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
sin(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Sin, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Sin>(
std::forward<VAL>(val));
}
Expand All @@ -958,8 +958,8 @@ namespace librapid {
/// \return Cosine function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto cos(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Cos, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
cos(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Cos, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Cos>(
std::forward<VAL>(val));
}
Expand All @@ -973,8 +973,8 @@ namespace librapid {
/// \return Tangent function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto tan(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Tan, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
tan(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Tan, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Tan>(
std::forward<VAL>(val));
}
Expand All @@ -988,8 +988,8 @@ namespace librapid {
/// \return Arcsine function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto asin(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Asin, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
asin(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Asin, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Asin>(
std::forward<VAL>(val));
}
Expand All @@ -1003,8 +1003,8 @@ namespace librapid {
/// \return Arccosine function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto acos(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Acos, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
acos(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Acos, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Acos>(
std::forward<VAL>(val));
}
Expand All @@ -1018,8 +1018,8 @@ namespace librapid {
/// \return Arctangent function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto atan(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Atan, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
atan(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Atan, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Atan>(
std::forward<VAL>(val));
}
Expand All @@ -1033,8 +1033,8 @@ namespace librapid {
/// \return Hyperbolic sine function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto sinh(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Sinh, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
sinh(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Sinh, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Sinh>(
std::forward<VAL>(val));
}
Expand All @@ -1048,8 +1048,8 @@ namespace librapid {
/// \return Hyperbolic cosine function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto cosh(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Cosh, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
cosh(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Cosh, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Cosh>(
std::forward<VAL>(val));
}
Expand All @@ -1063,8 +1063,8 @@ namespace librapid {
/// \return Hyperbolic tangent function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto tanh(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Tanh, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
tanh(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Tanh, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Tanh>(
std::forward<VAL>(val));
}
Expand All @@ -1078,8 +1078,8 @@ namespace librapid {
/// \return Hyperbolic sine function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto asinh(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Asinh, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
asinh(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Asinh, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Asinh>(
std::forward<VAL>(val));
}
Expand All @@ -1093,8 +1093,8 @@ namespace librapid {
/// \return Hyperbolic cosine function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto acosh(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Acosh, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
acosh(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Acosh, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Acosh>(
std::forward<VAL>(val));
}
Expand All @@ -1108,8 +1108,8 @@ namespace librapid {
/// \return Hyperbolic tangent function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto atanh(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Atanh, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
atanh(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Atanh, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Atanh>(
std::forward<VAL>(val));
}
Expand All @@ -1123,8 +1123,8 @@ namespace librapid {
/// \return Exponential function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto exp(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Exp, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
exp(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Exp, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Exp>(
std::forward<VAL>(val));
}
Expand All @@ -1138,8 +1138,8 @@ namespace librapid {
/// \return Exponential function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto exp2(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Exp2, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
exp2(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Exp2, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Exp2>(
std::forward<VAL>(val));
}
Expand All @@ -1153,8 +1153,8 @@ namespace librapid {
/// \return Exponential function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto exp10(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Exp10, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
exp10(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Exp10, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Exp10>(
std::forward<VAL>(val));
}
Expand All @@ -1168,8 +1168,8 @@ namespace librapid {
/// \return Natural logarithm function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto log(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Log, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
log(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Log, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Log>(
std::forward<VAL>(val));
}
Expand All @@ -1183,8 +1183,8 @@ namespace librapid {
/// \return Base 10 logarithm function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto log10(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Log10, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
log10(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Log10, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Log10>(
std::forward<VAL>(val));
}
Expand All @@ -1198,8 +1198,8 @@ namespace librapid {
/// \return Base 2 logarithm function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto log2(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Log2, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
log2(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Log2, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Log2>(
std::forward<VAL>(val));
}
Expand All @@ -1213,8 +1213,8 @@ namespace librapid {
/// \return Square root function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto sqrt(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Sqrt, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
sqrt(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Sqrt, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Sqrt>(
std::forward<VAL>(val));
}
Expand All @@ -1228,8 +1228,8 @@ namespace librapid {
/// \return Cube root function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto cbrt(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Cbrt, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
cbrt(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Cbrt, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Cbrt>(
std::forward<VAL>(val));
}
Expand All @@ -1243,8 +1243,8 @@ namespace librapid {
/// \return Absolute value function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto abs(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Abs, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
abs(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Abs, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Abs>(
std::forward<VAL>(val));
}
Expand All @@ -1258,8 +1258,8 @@ namespace librapid {
/// \return Floor function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto floor(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Floor, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
floor(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Floor, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Floor>(
std::forward<VAL>(val));
}
Expand All @@ -1273,11 +1273,11 @@ namespace librapid {
/// \return Ceiling function object
template<class VAL>
requires(detail::IsArrayOp<VAL>)
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto ceil(VAL &&val)
-> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Ceil, VAL> {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto
ceil(VAL &&val) -> detail::Function<typetraits::DescriptorType_t<VAL>, detail::Ceil, VAL> {
return detail::makeFunction<typetraits::DescriptorType_t<VAL>, detail::Ceil>(
std::forward<VAL>(val));
}
} // namespace librapid

#endif // LIBRAPID_ARRAY_OPERATIONS_HPP
#endif // LIBRAPID_ARRAY_OPERATIONS_HPP
6 changes: 4 additions & 2 deletions librapid/include/librapid/core/gnuConfig.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#ifndef LIBRAPID_CORE_GNU_CONFIG_HPP
#define LIBRAPID_CORE_GNU_CONFIG_HPP

#define LIBRAPID_INLINE inline
#define LIBRAPID_INLINE inline

#if defined(LIBRAPID_NO_ALWAYS_INLINE)
# define LIBRAPID_ALWAYS_INLINE inline
#else
# define LIBRAPID_ALWAYS_INLINE inline __attribute__((always_inline))
#endif

#define LIBRAPID_FLATTEN __attribute__((flatten))

#if defined(LIBRAPID_ENABLE_ASSERT)

# define LIBRAPID_ASSERT(condition, message, ...) \
Expand Down Expand Up @@ -43,4 +45,4 @@

#endif // LIBRAPID_ENABLE_ASSERT

#endif // LIBRAPID_CORE_GNU_CONFIG_HPP
#endif // LIBRAPID_CORE_GNU_CONFIG_HPP
Loading

0 comments on commit 6c79f57

Please sign in to comment.