Skip to content

Commit

Permalink
Merge branch 'test' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencilcaseman committed Nov 7, 2023
2 parents ad4fb8c + 1a5469e commit cf85246
Show file tree
Hide file tree
Showing 24 changed files with 1,158 additions and 1,097 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ name: Wheels
on:
push:
branches:
- this_is_a_dummy_branch

# push:
# branches:
# - "**"
# pull_request:
# branches:
# - "**"
# workflow_dispatch:
# workflow_call:
- "**"
pull_request:
branches:
- "**"
workflow_dispatch:
workflow_call:

jobs:
# Build the wheels for Linux, Windows and macOS for CPython 3.7 and newer
Expand Down
2 changes: 1 addition & 1 deletion cmake/ArchDetect2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int main() {
}" SIMD_FMA3)

# Check AVX
check_simd_capability("-mavx" "/arch:AVX" "AVX" "
check_simd_capability("-mavx" "" "AVX" "
#include <immintrin.h>
int main() {
__m256 a = _mm256_set_ps(-1.0f, 2.0f, -3.0f, 4.0f, -1.0f, 2.0f, -3.0f, 4.0f);
Expand Down
28 changes: 14 additions & 14 deletions librapid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def Array(*args, **kwargs):
int64: _librapid.ArrayInt64CPU,
uint32: _librapid.ArrayUInt32CPU,
uint64: _librapid.ArrayUInt64CPU,
Complex32: _librapid.ArrayComplexFloatCPU,
Complex64: _librapid.ArrayComplexDoubleCPU,
# Complex32: _librapid.ArrayComplexFloatCPU,
# Complex64: _librapid.ArrayComplexDoubleCPU,
}

arrayType = cpuTypeList.get(dtype, None)
Expand All @@ -129,8 +129,8 @@ def Array(*args, **kwargs):
int64: _librapid.ArrayInt64OpenCL,
uint32: _librapid.ArrayUInt32OpenCL,
uint64: _librapid.ArrayUInt64OpenCL,
Complex32: _librapid.ArrayComplexFloatOpenCL,
Complex64: _librapid.ArrayComplexDoubleOpenCL,
# Complex32: _librapid.ArrayComplexFloatOpenCL,
# Complex64: _librapid.ArrayComplexDoubleOpenCL,
}

arrayType = openclTypeList.get(dtype, None)
Expand All @@ -148,8 +148,8 @@ def Array(*args, **kwargs):
int64: _librapid.ArrayInt64CUDA,
uint32: _librapid.ArrayUInt32CUDA,
uint64: _librapid.ArrayUInt64CUDA,
Complex32: _librapid.ArrayComplexFloatCUDA,
Complex64: _librapid.ArrayComplexDoubleCUDA,
# Complex32: _librapid.ArrayComplexFloatCUDA,
# Complex64: _librapid.ArrayComplexDoubleCUDA,
}

arrayType = cudaTypeList.get(dtype, None)
Expand Down Expand Up @@ -189,8 +189,8 @@ def isArray(obj):
_librapid.ArrayInt64CPU,
_librapid.ArrayUInt32CPU,
_librapid.ArrayUInt64CPU,
_librapid.ArrayComplexFloatCPU,
_librapid.ArrayComplexDoubleCPU
# _librapid.ArrayComplexFloatCPU,
# _librapid.ArrayComplexDoubleCPU
]:
return True

Expand All @@ -201,8 +201,8 @@ def isArray(obj):
_librapid.ArrayInt64OpenCL,
_librapid.ArrayUInt32OpenCL,
_librapid.ArrayUInt64OpenCL,
_librapid.ArrayComplexFloatOpenCL,
_librapid.ArrayComplexDoubleOpenCL
# _librapid.ArrayComplexFloatOpenCL,
# _librapid.ArrayComplexDoubleOpenCL
]:
return True

Expand All @@ -213,8 +213,8 @@ def isArray(obj):
_librapid.ArrayInt64CUDA,
_librapid.ArrayUInt32CUDA,
_librapid.ArrayUInt64CUDA,
_librapid.ArrayComplexFloatCUDA,
_librapid.ArrayComplexDoubleCUDA
# _librapid.ArrayComplexFloatCUDA,
# _librapid.ArrayComplexDoubleCUDA
]:
return True

Expand Down Expand Up @@ -327,8 +327,8 @@ def getSeed():
int64 = DataType("int64", 8)
uint32 = DataType("uint32", 4)
uint64 = DataType("uint64", 8)
Complex32 = DataType("Complex32", 8)
Complex64 = DataType("Complex64", 16)
# Complex32 = DataType("Complex32", 8)
# Complex64 = DataType("Complex64", 16)

CPU = Backend("CPU")
OpenCL = Backend("OpenCL")
Expand Down
4 changes: 2 additions & 2 deletions librapid/bindings/generators/arrayGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ def generateFunctionsForArray(config):
"sqrt",
"cbrt",
"exp",
# "exp2",
# "exp10",
"exp2",
"exp10",
"log",
"log2",
"log10"
Expand Down
78 changes: 32 additions & 46 deletions librapid/include/librapid/array/assignOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ namespace librapid {
/// \tparam Args The argument types of the function
/// \param lhs The array container to assign to
/// \param function The function to assign
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args,
typename std::enable_if_t<!typetraits::HasCustomEval<detail::Function<
descriptor::Trivial, Functor_, Args...>>::value,
int>>
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void
assign(array::ArrayContainer<ShapeType_, Storage<StorageScalar>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
Expand Down Expand Up @@ -73,10 +72,9 @@ namespace librapid {
/// \tparam Functor_ The function type
/// \tparam Args The argument types of the function
template<typename ShapeType_, typename StorageScalar, size_t... StorageSize,
typename Functor_, typename... Args,
typename std::enable_if_t<!typetraits::HasCustomEval<detail::Function<
descriptor::Trivial, Functor_, Args...>>::value,
int>>
typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void
assign(array::ArrayContainer<ShapeType_, FixedStorage<StorageScalar, StorageSize...>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
Expand Down Expand Up @@ -136,10 +134,9 @@ namespace librapid {
/// \param function The function to assign
/// \see assign(array::ArrayContainer<ShapeType_, Storage<StorageScalar>>
/// &lhs, const detail::Function<descriptor::Trivial, Functor_, Args...> &function)
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args,
typename std::enable_if_t<!typetraits::HasCustomEval<detail::Function<
descriptor::Trivial, Functor_, Args...>>::value,
int>>
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void
assignParallel(array::ArrayContainer<ShapeType_, Storage<StorageScalar>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
Expand Down Expand Up @@ -201,10 +198,9 @@ namespace librapid {
/// \tparam Functor_ The function type
/// \tparam Args The argument types of the function
template<typename ShapeType_, typename StorageScalar, size_t... StorageSize,
typename Functor_, typename... Args,
typename std::enable_if_t<!typetraits::HasCustomEval<detail::Function<
descriptor::Trivial, Functor_, Args...>>::value,
int>>
typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void assignParallel(
array::ArrayContainer<ShapeType_, FixedStorage<StorageScalar, StorageSize...>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
Expand Down Expand Up @@ -283,18 +279,14 @@ namespace librapid {

#if defined(LIBRAPID_HAS_OPENCL)
namespace opencl {
template<typename T, typename std::enable_if_t<typetraits::TypeInfo<T>::type !=
::librapid::detail::LibRapidType::Scalar,
int> = 0>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto dataSourceExtractor(const T &obj) {
return obj.storage().data();
}

template<typename T, typename std::enable_if_t<typetraits::TypeInfo<T>::type ==
::librapid::detail::LibRapidType::Scalar,
int> = 0>
template<typename T>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto dataSourceExtractor(const T &obj) {
return obj;
if constexpr (typetraits::TypeInfo<T>::type ==
::librapid::detail::LibRapidType::Scalar) {
return obj;
} else {
return obj.storage().data();
}
}

template<typename T>
Expand Down Expand Up @@ -337,10 +329,9 @@ namespace librapid {
} // namespace opencl

namespace detail {
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args,
typename std::enable_if_t<!typetraits::HasCustomEval<detail::Function<
descriptor::Trivial, Functor_, Args...>>::value,
int>>
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void
assign(array::ArrayContainer<ShapeType_, OpenCLStorage<StorageScalar>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
Expand All @@ -363,18 +354,14 @@ namespace librapid {

#if defined(LIBRAPID_HAS_CUDA)
namespace cuda {
template<typename T, typename std::enable_if_t<typetraits::TypeInfo<T>::type !=
::librapid::detail::LibRapidType::Scalar,
int> = 0>
template<typename T>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto dataSourceExtractor(const T &obj) {
return obj.storage().begin();
}

template<typename T, typename std::enable_if_t<typetraits::TypeInfo<T>::type ==
::librapid::detail::LibRapidType::Scalar,
int> = 0>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE const auto &dataSourceExtractor(const T &obj) {
return obj;
if constexpr(typetraits::TypeInfo<T>::type ==
::librapid::detail::LibRapidType::Scalar) {
return obj;
} else {
return obj.storage().begin();
}
}

template<typename T>
Expand Down Expand Up @@ -531,10 +518,9 @@ namespace librapid {
/// \tparam Args The argument types of the function
/// \param lhs The array container to assign to
/// \param function The function to assign
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args,
typename std::enable_if_t<!typetraits::HasCustomEval<detail::Function<
descriptor::Trivial, Functor_, Args...>>::value,
int>>
template<typename ShapeType_, typename StorageScalar, typename Functor_, typename... Args>
requires(!typetraits::HasCustomEval<
detail::Function<descriptor::Trivial, Functor_, Args...>>::value)
LIBRAPID_ALWAYS_INLINE void
assign(array::ArrayContainer<ShapeType_, CudaStorage<StorageScalar>> &lhs,
const detail::Function<descriptor::Trivial, Functor_, Args...> &function) {
Expand Down
46 changes: 19 additions & 27 deletions librapid/include/librapid/array/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,33 +109,24 @@ namespace librapid {
namespace detail {
// Descriptor is defined in "forward.hpp"

template<
typename Packet, typename T,
typename std::enable_if_t<
typetraits::TypeInfo<T>::type != ::librapid::detail::LibRapidType::Scalar, int> = 0>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE Packet packetExtractor(const T &obj,
size_t index) {
static_assert(std::is_same_v<Packet, decltype(obj.packet(index))>,
"Packet types do not match");
return obj.packet(index);
}

template<
typename Packet, typename T,
typename std::enable_if_t<
typetraits::TypeInfo<T>::type == ::librapid::detail::LibRapidType::Scalar, int> = 0>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE Packet packetExtractor(const T &obj, size_t) {
return Packet(obj);
template<typename Packet, typename T>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE Packet packetExtractor(const T &obj, size_t index) {
if constexpr (detail::IsArrayType<T>::val) {
static_assert(std::is_same_v<Packet, decltype(obj.packet(index))>,
"Packet types do not match");
return obj.packet(index);
} else {
return Packet(obj);
}
}

template<typename T, typename std::enable_if_t<detail::IsArrayType<T>::val, int> = 0>
template<typename T>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto scalarExtractor(const T &obj, size_t index) {
return obj.scalar(index);
}

template<typename T, typename std::enable_if_t<!detail::IsArrayType<T>::val, int> = 0>
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto scalarExtractor(const T &obj, size_t) {
return obj;
if constexpr(detail::IsArrayType<T>::val) {
return obj.scalar(index);
} else {
return obj;
}
}

template<typename First, typename... Rest>
Expand Down Expand Up @@ -228,8 +219,8 @@ namespace librapid {
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE Iterator end() const;

template<typename T, typename Char, size_t N, typename Ctx>
void str(const fmt::formatter<T, Char> &format, char bracket, char separator, const char (&formatString)[N],
Ctx &ctx) const;
void str(const fmt::formatter<T, Char> &format, char bracket, char separator,
const char (&formatString)[N], Ctx &ctx) const;

private:
/// Implementation detail -- evaluates the function at the given index,
Expand Down Expand Up @@ -339,7 +330,8 @@ namespace librapid {
template<typename T, typename Char, size_t N, typename Ctx>
LIBRAPID_ALWAYS_INLINE void
Function<desc, Functor, Args...>::str(const fmt::formatter<T, Char> &format, char bracket,
char separator, const char (&formatString)[N], Ctx &ctx) const {
char separator, const char (&formatString)[N],
Ctx &ctx) const {
createGeneralArrayView(*this).str(format, bracket, separator, formatString, ctx);
}
} // namespace detail
Expand Down
Loading

0 comments on commit cf85246

Please sign in to comment.