Skip to content

Commit

Permalink
A few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencilcaseman committed Nov 7, 2023
1 parent cdfa7b5 commit df7c735
Show file tree
Hide file tree
Showing 9 changed files with 472 additions and 477 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ jobs:
LIBRAPID_GET_FFTW: OFF
CC: /usr/local/opt/llvm/bin/clang
CXX: /usr/local/opt/llvm/bin/clang++
CIBW_ENVIRONMENT: CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++
CIBW_ENVIRONMENT: CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ CMAKE_BUILD_PARALLEL_LEVEL=1
CMAKE_C_COMPILER: /usr/local/opt/llvm/bin/clang
CMAKE_CXX_COMPILER: /usr/local/opt/llvm/bin/clang++

Expand All @@ -357,7 +357,7 @@ jobs:
LIBRAPID_GET_FFTW: OFF
CC: ${RUNNER_TOOL_CACHE}/llvm/bin/clang
CXX: ${RUNNER_TOOL_CACHE}/llvm/bin/clang++
CIBW_ENVIRONMENT: CC=${RUNNER_TOOL_CACHE}/llvm/bin/clang CXX=${RUNNER_TOOL_CACHE}/llvm/bin/clang++
CIBW_ENVIRONMENT: CC=${RUNNER_TOOL_CACHE}/llvm/bin/clang CXX=${RUNNER_TOOL_CACHE}/llvm/bin/clang++ CMAKE_BUILD_PARALLEL_LEVEL=1
CMAKE_C_COMPILER: ${RUNNER_TOOL_CACHE}/llvm/bin/clang
CMAKE_CXX_COMPILER: ${RUNNER_TOOL_CACHE}/llvm/bin/clang++

Expand All @@ -378,6 +378,7 @@ jobs:
GITHUB_ACTIONS: ON
LIBRAPID_GET_BLAS: ON
LIBRAPID_GET_FFTW: OFF
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=1

- name: Store Artifacts
uses: actions/upload-artifact@v3
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ if (${SKBUILD})
)
FetchContent_MakeAvailable(pybind11)

# Set CMAKE_BUILD_PARALLEL_LEVEL=1 to reduce memory usage
set(CMAKE_BUILD_PARALLEL_LEVEL 1)

# Set environment variable CMAKE_BUILD_PARALLEL_LEVEL=1 to reduce memory usage
set(ENV{CMAKE_BUILD_PARALLEL_LEVEL} 1)

# Run auto-generation script
# 1. Find the Python executable
# 2. cd into 'librapid/bindings/generators'
Expand Down
6 changes: 3 additions & 3 deletions examples/example-cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace lrc = librapid;

auto main() -> int {
#if defined(LIBRAPID_HAS_CUDA)
auto cudaArray = lrc::Array<float, lrc::backend::CUDA>::fromData({{1, 2, 3}, {4, 5, 6}});
auto cudaArray = lrc::Array<float, lrc::backend::CUDA>({{1, 2, 3}, {4, 5, 6}});
fmt::print("CUDA Array:\n{}\n", cudaArray);

// Operations on CUDA arrays work exactly the same as on CPU arrays
Expand All @@ -26,13 +26,13 @@ auto main() -> int {
// Linear algebra operations also work
fmt::print("Transposed CUDA Array:\n{}\n", lrc::transpose(prod));

auto vector = lrc::Array<float, lrc::backend::CUDA>::fromData({{1, 2, 3}});
auto vector = lrc::Array<float, lrc::backend::CUDA>({{1, 2, 3}});
fmt::print("Array: \n{}\n", cudaArray);
fmt::print("Vector: \n{}\n", vector);
fmt::print("Matrix dot Vector^T:\n{}\n", lrc::dot(cudaArray, lrc::transpose(vector)));
#else
fmt::print("CUDA not enabled in this build of librapid\n");
fmt::print("Check the documentation for more information on enabling OpenCL\n");
fmt::print("Check the documentation for more information on enabling CUDA\n");
fmt::print("https://librapid.readthedocs.io/en/latest/cmakeIntegration.html#librapid-use-cuda\n");
#endif // LIBRAPID_HAS_CUDA

Expand Down
4 changes: 2 additions & 2 deletions examples/example-opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ auto main() -> int {
// (You can pass (true, true) to select the device manually)
lrc::configureOpenCL(true);

auto openclArray = lrc::Array<float, lrc::backend::OpenCL>::fromData({{1, 2, 3}, {4, 5, 6}});
auto openclArray = lrc::Array<float, lrc::backend::OpenCL>({{1, 2, 3}, {4, 5, 6}});
fmt::print("OpenCL Array:\n{}\n", openclArray);

// Operations on OpenCL arrays work exactly the same as on CPU arrays
Expand All @@ -31,7 +31,7 @@ auto main() -> int {
// Linear algebra operations also work
fmt::print("Transposed OpenCL Array:\n{}\n", lrc::transpose(prod));

auto vector = lrc::Array<float, lrc::backend::OpenCL>::fromData({{1, 2, 3}});
auto vector = lrc::Array<float, lrc::backend::OpenCL>({{1, 2, 3}});
fmt::print("Array: \n{}\n", openclArray);
fmt::print("Vector: \n{}\n", vector);
fmt::print("Matrix dot Vector^T:\n{}\n", lrc::dot(openclArray, lrc::transpose(vector)));
Expand Down
25 changes: 14 additions & 11 deletions librapid/include/librapid/array/shape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,7 @@ namespace librapid {
/// \param shapes Remaining (optional) inputs
/// \return True if all inputs have the same shape, false otherwise
template<typename First, typename Second, typename... Rest>
requires(typetraits::IsSizeType<First>::value &&
typetraits::IsSizeType<Second>::value &&
requires(typetraits::IsSizeType<First>::value && typetraits::IsSizeType<Second>::value &&
(typetraits::IsSizeType<Rest>::value && ...))
LIBRAPID_NODISCARD LIBRAPID_INLINE bool
shapesMatch(const std::tuple<First, Second, Rest...> &shapes) {
Expand All @@ -797,17 +796,21 @@ namespace librapid {
[](auto, auto, auto... rest) { return std::make_tuple(rest...); }, shapes));
}
}


template<typename First>
requires(typetraits::IsSizeType<First>::value)
LIBRAPID_NODISCARD LIBRAPID_INLINE bool
shapesMatch(const std::tuple<First> &shapes) {
return true;
}

/// \sa shapesMatch
// template<typename First, typename Second, typename... Rest>
// requires(typetraits::IsSizeType<First>::value && typetraits::IsSizeType<Second>::value &&
// (typetraits::IsSizeType<Rest>::value && ...))
// LIBRAPID_NODISCARD LIBRAPID_INLINE bool shapesMatch(const First &first, const Second &second,
// const Rest &...shapes) {
// if constexpr (sizeof...(Rest) == 0) {
// return first == second;
// } else {
// return first == second && shapesMatch(first, shapes...);
// requires(typetraits::IsSizeType<First>::value && typetraits::IsSizeType<Second>::value
//&& (typetraits::IsSizeType<Rest>::value && ...)) LIBRAPID_NODISCARD LIBRAPID_INLINE bool
//shapesMatch(const First &first, const Second &second, const Rest &...shapes) { if constexpr
//(sizeof...(Rest) == 0) { return first == second; } else { return first == second &&
//shapesMatch(first, shapes...);
// }
// }

Expand Down
Loading

0 comments on commit df7c735

Please sign in to comment.