From ead088f20ef52c77f517a9540b876ec8abc963ca Mon Sep 17 00:00:00 2001 From: Mitya <8863314@gmail.com> Date: Tue, 22 Oct 2024 12:24:56 +0300 Subject: [PATCH 01/74] Compiled cuBool and run tests with CUDA 12.6 --- .gitmodules | 3 --- CMakeLists.txt | 12 ++++++------ cubool/sources/cuda/cuda_vector.cu | 2 ++ cubool/sources/cuda/kernels/spewiseadd.cuh | 2 ++ cubool/sources/cuda/kernels/spewisemult.cuh | 2 ++ cubool/sources/cuda/kernels/spgemv.cuh | 2 ++ cubool/sources/cuda/kernels/spgemv_t.cuh | 2 ++ cubool/sources/cuda/kernels/spreduce.cuh | 2 ++ cubool/sources/cuda/kernels/sptranspose2.cuh | 2 ++ cubool/sources/utils/data_utils.hpp | 1 + deps/cub | 1 - deps/nsparse-um/CMakeLists.txt | 3 ++- deps/nsparse-um/include/nsparse/unified_allocator.h | 2 +- deps/nsparse-um/test/CMakeLists.txt | 3 ++- deps/nsparse/test/CMakeLists.txt | 3 ++- 15 files changed, 28 insertions(+), 14 deletions(-) delete mode 160000 deps/cub diff --git a/.gitmodules b/.gitmodules index 3adb3ec..f98d82d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "deps/gtest"] path = deps/gtest url = https://github.com/google/googletest.git -[submodule "deps/cub"] - path = deps/cub - url = https://github.com/NVIDIA/cub.git diff --git a/CMakeLists.txt b/CMakeLists.txt index fb9212a..e3ab3eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,12 +33,12 @@ endif() # Configure cuda dependencies if (CUBOOL_WITH_CUDA) message(STATUS "Add cub as cuda utility") - set(CUB_ENABLE_HEADER_TESTING OFF CACHE BOOL "" FORCE) - set(CUB_ENABLE_TESTING OFF CACHE BOOL "" FORCE) - set(CUB_ENABLE_EXAMPLES OFF CACHE BOOL "" FORCE) - add_subdirectory(deps/cub) - add_library(cub INTERFACE IMPORTED) - target_link_libraries(cub INTERFACE CUB::CUB) + # set(CUB_ENABLE_HEADER_TESTING OFF CACHE BOOL "" FORCE) + # set(CUB_ENABLE_TESTING OFF CACHE BOOL "" FORCE) + # set(CUB_ENABLE_EXAMPLES OFF CACHE BOOL "" FORCE) + # add_subdirectory(deps/cub) + # add_library(cub INTERFACE IMPORTED) + # target_link_libraries(cub INTERFACE CUB::CUB) message(STATUS "Add nsparse library as crs matrix multiplication backend") add_subdirectory(deps/nsparse-um) diff --git a/cubool/sources/cuda/cuda_vector.cu b/cubool/sources/cuda/cuda_vector.cu index ced56a0..f2fa9b0 100644 --- a/cubool/sources/cuda/cuda_vector.cu +++ b/cubool/sources/cuda/cuda_vector.cu @@ -29,6 +29,8 @@ #include #include +#include + namespace cubool { CudaVector::CudaVector(size_t nrows, CudaInstance &instance) diff --git a/cubool/sources/cuda/kernels/spewiseadd.cuh b/cubool/sources/cuda/kernels/spewiseadd.cuh index f6ad892..d1e1e87 100644 --- a/cubool/sources/cuda/kernels/spewiseadd.cuh +++ b/cubool/sources/cuda/kernels/spewiseadd.cuh @@ -27,6 +27,8 @@ #include +#include + namespace cubool { namespace kernels { diff --git a/cubool/sources/cuda/kernels/spewisemult.cuh b/cubool/sources/cuda/kernels/spewisemult.cuh index a4705de..6d17a46 100644 --- a/cubool/sources/cuda/kernels/spewisemult.cuh +++ b/cubool/sources/cuda/kernels/spewisemult.cuh @@ -30,6 +30,8 @@ #include #include +#include + namespace cubool { namespace kernels { diff --git a/cubool/sources/cuda/kernels/spgemv.cuh b/cubool/sources/cuda/kernels/spgemv.cuh index 7340174..818ff62 100644 --- a/cubool/sources/cuda/kernels/spgemv.cuh +++ b/cubool/sources/cuda/kernels/spgemv.cuh @@ -32,6 +32,8 @@ #include #include +#include + namespace cubool { namespace kernels { diff --git a/cubool/sources/cuda/kernels/spgemv_t.cuh b/cubool/sources/cuda/kernels/spgemv_t.cuh index 6225d71..2a5db83 100644 --- a/cubool/sources/cuda/kernels/spgemv_t.cuh +++ b/cubool/sources/cuda/kernels/spgemv_t.cuh @@ -32,6 +32,8 @@ #include #include +#include + namespace cubool { namespace kernels { diff --git a/cubool/sources/cuda/kernels/spreduce.cuh b/cubool/sources/cuda/kernels/spreduce.cuh index 3a15bb1..cfcf398 100644 --- a/cubool/sources/cuda/kernels/spreduce.cuh +++ b/cubool/sources/cuda/kernels/spreduce.cuh @@ -30,6 +30,8 @@ #include #include +#include + namespace cubool { namespace kernels { diff --git a/cubool/sources/cuda/kernels/sptranspose2.cuh b/cubool/sources/cuda/kernels/sptranspose2.cuh index 8c50e45..c686818 100644 --- a/cubool/sources/cuda/kernels/sptranspose2.cuh +++ b/cubool/sources/cuda/kernels/sptranspose2.cuh @@ -29,6 +29,8 @@ #include #include +#include + namespace cubool { namespace kernels { diff --git a/cubool/sources/utils/data_utils.hpp b/cubool/sources/utils/data_utils.hpp index 2356382..b7863b3 100644 --- a/cubool/sources/utils/data_utils.hpp +++ b/cubool/sources/utils/data_utils.hpp @@ -27,6 +27,7 @@ #include #include +#include namespace cubool { diff --git a/deps/cub b/deps/cub deleted file mode 160000 index b229817..0000000 --- a/deps/cub +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b229817e3963fc942c7cc2c61715a6b2b2c49bed diff --git a/deps/nsparse-um/CMakeLists.txt b/deps/nsparse-um/CMakeLists.txt index ee5ac0d..cdc4463 100644 --- a/deps/nsparse-um/CMakeLists.txt +++ b/deps/nsparse-um/CMakeLists.txt @@ -3,7 +3,8 @@ project(nsparse_um LANGUAGES CXX CUDA) add_library(nsparse_um INTERFACE) target_include_directories(nsparse_um INTERFACE include/) -target_link_libraries(nsparse_um INTERFACE cub) +# target_link_libraries(nsparse_um INTERFACE cub) +target_link_libraries(nsparse_um INTERFACE) target_compile_options(nsparse_um INTERFACE $<$: --expt-relaxed-constexpr --expt-extended-lambda>) if (CUBOOL_BUILD_NSPARSE_TESTS) diff --git a/deps/nsparse-um/include/nsparse/unified_allocator.h b/deps/nsparse-um/include/nsparse/unified_allocator.h index ea6a98b..c15f19e 100644 --- a/deps/nsparse-um/include/nsparse/unified_allocator.h +++ b/deps/nsparse-um/include/nsparse/unified_allocator.h @@ -3,7 +3,7 @@ #include #include #include -#include +// #include #include #include diff --git a/deps/nsparse-um/test/CMakeLists.txt b/deps/nsparse-um/test/CMakeLists.txt index 3bece29..6a29690 100644 --- a/deps/nsparse-um/test/CMakeLists.txt +++ b/deps/nsparse-um/test/CMakeLists.txt @@ -3,7 +3,8 @@ project(nsparse_um_test CXX CUDA) add_executable(${PROJECT_NAME} src/nsparse_test.cu src/utils.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse_um cub) +# target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse_um cub) +target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse_um) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) diff --git a/deps/nsparse/test/CMakeLists.txt b/deps/nsparse/test/CMakeLists.txt index 9e71d90..9927725 100644 --- a/deps/nsparse/test/CMakeLists.txt +++ b/deps/nsparse/test/CMakeLists.txt @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.11) project(nsparse_test CXX CUDA) add_executable(${PROJECT_NAME} src/nsparse_test.cu src/utils.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse cub) +# target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse cub) +target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) From 443d78deae3a4ef525e722afba2a5db3f1c08948 Mon Sep 17 00:00:00 2001 From: Mitya <8863314@gmail.com> Date: Tue, 22 Oct 2024 12:47:31 +0300 Subject: [PATCH 02/74] Temporary removed python package support for compiling rpq algorithm --- CMakeLists.txt | 4 ++-- cubool/CMakeLists.txt | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3ab3eb..da9e6d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ endif() add_subdirectory(cubool) # Copy scripts into binary directory -file(COPY scripts DESTINATION ${CMAKE_BINARY_DIR}/) +# file(COPY scripts DESTINATION ${CMAKE_BINARY_DIR}/) # Copy python related stuff -file(COPY python DESTINATION ${CMAKE_BINARY_DIR}/) \ No newline at end of file +# file(COPY python DESTINATION ${CMAKE_BINARY_DIR}/) diff --git a/cubool/CMakeLists.txt b/cubool/CMakeLists.txt index 092504b..88591de 100644 --- a/cubool/CMakeLists.txt +++ b/cubool/CMakeLists.txt @@ -246,14 +246,14 @@ if (CUBOOL_BUILD_TESTS) endif() # Copy cubool library after build if allowed -if (CUBOOL_COPY_TO_PY_PACKAGE) - set(LIBRARY_FILE_NAME ${TARGET_FILE_NAME}) - - add_custom_command( - TARGET cubool POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E - copy - "${CMAKE_BINARY_DIR}/cubool/${LIBRARY_FILE_NAME}" - "${CMAKE_BINARY_DIR}/python/pycubool" - COMMENT "Copy ${LIBRARY_FILE_NAME} compiled lib into python folder") -endif() \ No newline at end of file +# if (CUBOOL_COPY_TO_PY_PACKAGE) +# set(LIBRARY_FILE_NAME ${TARGET_FILE_NAME}) +# +# add_custom_command( +# TARGET cubool POST_BUILD +# COMMAND "${CMAKE_COMMAND}" -E +# copy +# "${CMAKE_BINARY_DIR}/cubool/${LIBRARY_FILE_NAME}" +# "${CMAKE_BINARY_DIR}/python/pycubool" +# COMMENT "Copy ${LIBRARY_FILE_NAME} compiled lib into python folder") +# endif() From f429420f50c6297171f8cd7c485e1a6379fef2d5 Mon Sep 17 00:00:00 2001 From: Mitya <8863314@gmail.com> Date: Tue, 5 Nov 2024 20:57:12 +0300 Subject: [PATCH 03/74] Fixed cubool tests --- cubool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubool/CMakeLists.txt b/cubool/CMakeLists.txt index 88591de..406510c 100644 --- a/cubool/CMakeLists.txt +++ b/cubool/CMakeLists.txt @@ -219,7 +219,7 @@ endforeach() if (CUBOOL_WITH_CUDA) set_target_properties(cubool PROPERTIES CUDA_STANDARD 14) set_target_properties(cubool PROPERTIES CUDA_STANDARD_REQUIRED ON) - set_target_properties(cubool PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + # set_target_properties(cubool PROPERTIES CUDA_SEPARABLE_COMPILATION ON) # Settings: https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/ From e434bb145970a835f9470fc4870f1295b669e80b Mon Sep 17 00:00:00 2001 From: Mitya <8863314@gmail.com> Date: Tue, 5 Nov 2024 22:41:40 +0300 Subject: [PATCH 04/74] Implemented applying inverted mask --- cubool/CMakeLists.txt | 5 + cubool/include/cubool/cubool.h | 26 ++++ cubool/sources/backend/matrix_base.hpp | 3 +- cubool/sources/core/matrix.cpp | 44 +++++- cubool/sources/core/matrix.hpp | 3 +- .../cuBool_Matrix_EWiseMultInverted.cpp | 44 ++++++ cubool/sources/cuda/cuda_matrix.hpp | 3 +- .../cuda/cuda_matrix_ewisemult_inverted.cu | 63 ++++++++ .../cuda/kernels/spewisemultinverted.cuh | 106 ++++++++++++++ .../sequential/sq_ewisemultinverted.cpp | 105 ++++++++++++++ .../sequential/sq_ewisemultinverted.hpp | 42 ++++++ cubool/sources/sequential/sq_matrix.cpp | 26 ++++ cubool/sources/sequential/sq_matrix.hpp | 1 + cubool/tests/CMakeLists.txt | 3 + .../tests/test_matrix_ewisemult_inverted.cpp | 134 ++++++++++++++++++ 15 files changed, 604 insertions(+), 4 deletions(-) create mode 100644 cubool/sources/cuBool_Matrix_EWiseMultInverted.cpp create mode 100644 cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu create mode 100644 cubool/sources/cuda/kernels/spewisemultinverted.cuh create mode 100644 cubool/sources/sequential/sq_ewisemultinverted.cpp create mode 100644 cubool/sources/sequential/sq_ewisemultinverted.hpp create mode 100644 cubool/tests/test_matrix_ewisemult_inverted.cpp diff --git a/cubool/CMakeLists.txt b/cubool/CMakeLists.txt index 406510c..cd80032 100644 --- a/cubool/CMakeLists.txt +++ b/cubool/CMakeLists.txt @@ -87,6 +87,7 @@ set(CUBOOL_C_API_SOURCES sources/cuBool_Matrix_Reduce2.cpp sources/cuBool_Matrix_EWiseAdd.cpp sources/cuBool_Matrix_EWiseMult.cpp + sources/cuBool_Matrix_EWiseMultInverted.cpp sources/cuBool_Vector_New.cpp sources/cuBool_Vector_Build.cpp sources/cuBool_Vector_SetElement.cpp @@ -125,6 +126,7 @@ if (CUBOOL_WITH_CUDA) sources/cuda/cuda_matrix.cu sources/cuda/cuda_matrix_ewiseadd.cu sources/cuda/cuda_matrix_ewisemult.cu + sources/cuda/cuda_matrix_ewisemult_inverted.cu sources/cuda/cuda_matrix_kronecker.cu sources/cuda/cuda_matrix_multiply.cu sources/cuda/cuda_matrix_transpose.cu @@ -147,6 +149,7 @@ if (CUBOOL_WITH_CUDA) sources/cuda/kernels/spgemv_t.cuh sources/cuda/kernels/spewiseadd.cuh sources/cuda/kernels/spewisemult.cuh + sources/cuda/kernels/spewisemultinverted.cuh sources/cuda/kernels/sptranspose.cuh sources/cuda/kernels/sptranspose2.cuh sources/cuda/kernels/spkron.cuh @@ -173,6 +176,8 @@ if (CUBOOL_WITH_SEQUENTIAL) sources/sequential/sq_ewiseadd.hpp sources/sequential/sq_ewisemult.cpp sources/sequential/sq_ewisemult.hpp + sources/sequential/sq_ewisemultinverted.cpp + sources/sequential/sq_ewisemultinverted.hpp sources/sequential/sq_spgemm.cpp sources/sequential/sq_spgemm.hpp sources/sequential/sq_spgemv.cpp diff --git a/cubool/include/cubool/cubool.h b/cubool/include/cubool/cubool.h index cd16bb3..ef7d9b5 100644 --- a/cubool/include/cubool/cubool.h +++ b/cubool/include/cubool/cubool.h @@ -925,4 +925,30 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Kronecker( cuBool_Hints hints ); +/** + * Performs result = left + ~right, where + * '+' is boolean semiring 'or' operation + * '~' is operation for invert matrix (0 swaps to 1 and 1 to 0) + * + * @note Matrices must be compatible + * dim(result) = M x N + * dim(left) = M x N + * dim(right) = M x N + * + * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time + * + * @param result[out] Destination matrix to store result + * @param left Source matrix to be added + * @param right Source matrix to be inverted and added + * @param hints Hints for the operation + * + * @return Error code on this operation + */ +CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseMulInverted( + cuBool_Matrix result, + cuBool_Matrix matrix, + cuBool_Matrix mask, + cuBool_Hints hints +); + #endif //CUBOOL_CUBOOL_H diff --git a/cubool/sources/backend/matrix_base.hpp b/cubool/sources/backend/matrix_base.hpp index 5332031..8842eb9 100644 --- a/cubool/sources/backend/matrix_base.hpp +++ b/cubool/sources/backend/matrix_base.hpp @@ -49,6 +49,7 @@ namespace cubool { virtual void kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) = 0; virtual void eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) = 0; virtual void eWiseMult(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) = 0; + virtual void eWiseMultInverted(const MatrixBase &matrix, const MatrixBase &mask, bool checkTime) = 0; virtual index getNrows() const = 0; virtual index getNcols() const = 0; @@ -59,4 +60,4 @@ namespace cubool { } -#endif //CUBOOL_MATRIX_BASE_HPP \ No newline at end of file +#endif //CUBOOL_MATRIX_BASE_HPP diff --git a/cubool/sources/core/matrix.cpp b/cubool/sources/core/matrix.cpp index 571b010..730fe63 100644 --- a/cubool/sources/core/matrix.cpp +++ b/cubool/sources/core/matrix.cpp @@ -349,6 +349,48 @@ namespace cubool { mHnd->eWiseMult(*a->mHnd, *b->mHnd, false); } + void Matrix::eWiseMultInverted(const MatrixBase &matrix, const MatrixBase &mask, bool checkTime) { + + const auto* mat = dynamic_cast(&matrix); + const auto* msk = dynamic_cast(&mask); + + CHECK_RAISE_ERROR(mat != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); + CHECK_RAISE_ERROR(msk != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); + + index M = mat->getNrows(); + index N = msk->getNcols(); + + CHECK_RAISE_ERROR(M == msk->getNrows(), InvalidArgument, "Passed matrices have incompatible size"); + CHECK_RAISE_ERROR(N == msk->getNcols(), InvalidArgument, "Passed matrices have incompatible size"); + + CHECK_RAISE_ERROR(M == this->getNrows(), InvalidArgument, "Matrix has incompatible size for operation result"); + CHECK_RAISE_ERROR(N == this->getNcols(), InvalidArgument, "Matrix has incompatible size for operation result"); + + mat->commitCache(); + msk->commitCache(); + this->releaseCache(); + + /* + if (checkTime) { + TIMER_ACTION(timer, mHnd->eWiseMult(*a->mHnd, *b->mHnd, false)); + + LogStream stream(*Library::getLogger()); + stream << Logger::Level::Info + << "Time: " << timer.getElapsedTimeMs() << " ms " + << "Matrix::eWiseMult: " + << this->getDebugMarker() << " = " + << a->getDebugMarker() << " + " + << b->getDebugMarker() << LogStream::cmt; + + return; + } + */ + + mHnd->eWiseMultInverted(*mat->mHnd, *msk->mHnd, false); + } + + + index Matrix::getNrows() const { return mHnd->getNrows(); } @@ -396,4 +438,4 @@ namespace cubool { // Clear arrays releaseCache(); } -} \ No newline at end of file +} diff --git a/cubool/sources/core/matrix.hpp b/cubool/sources/core/matrix.hpp index 20cb890..6c4d38b 100644 --- a/cubool/sources/core/matrix.hpp +++ b/cubool/sources/core/matrix.hpp @@ -56,6 +56,7 @@ namespace cubool { void kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) override; void eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) override; void eWiseMult(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; + void eWiseMultInverted(const MatrixBase &matrix, const MatrixBase &mask, bool checkTime) override; index getNrows() const override; index getNcols() const override; @@ -77,4 +78,4 @@ namespace cubool { } -#endif //CUBOOL_MATRIX_HPP \ No newline at end of file +#endif //CUBOOL_MATRIX_HPP diff --git a/cubool/sources/cuBool_Matrix_EWiseMultInverted.cpp b/cubool/sources/cuBool_Matrix_EWiseMultInverted.cpp new file mode 100644 index 0000000..37fe607 --- /dev/null +++ b/cubool/sources/cuBool_Matrix_EWiseMultInverted.cpp @@ -0,0 +1,44 @@ +/**********************************************************************************/ +/* MIT License */ +/* */ +/* Copyright (c) 2020, 2021 JetBrains-Research */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining a copy */ +/* of this software and associated documentation files (the "Software"), to deal */ +/* in the Software without restriction, including without limitation the rights */ +/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */ +/* copies of the Software, and to permit persons to whom the Software is */ +/* furnished to do so, subject to the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be included in all */ +/* copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */ +/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */ +/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */ +/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */ +/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */ +/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ +/* SOFTWARE. */ +/**********************************************************************************/ + +#include + +CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseMulInverted( + cuBool_Matrix result, + cuBool_Matrix matrix, + cuBool_Matrix mask, + cuBool_Hints hints +) { + CUBOOL_BEGIN_BODY + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(mask) + auto resultM = (cubool::Matrix *) result; + auto matrixM = (cubool::Matrix *) matrix; + auto maskM = (cubool::Matrix *) mask; + + resultM->eWiseMultInverted(*matrixM, *maskM, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_END_BODY +} diff --git a/cubool/sources/cuda/cuda_matrix.hpp b/cubool/sources/cuda/cuda_matrix.hpp index e19fec1..9f1b7a2 100644 --- a/cubool/sources/cuda/cuda_matrix.hpp +++ b/cubool/sources/cuda/cuda_matrix.hpp @@ -56,6 +56,7 @@ namespace cubool { void kronecker(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; void eWiseAdd(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; void eWiseMult(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; + void eWiseMultInverted(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; index getNrows() const override; index getNcols() const override; @@ -79,4 +80,4 @@ namespace cubool { }; }; -#endif //CUBOOL_CUDA_MATRIX_HPP \ No newline at end of file +#endif //CUBOOL_CUDA_MATRIX_HPP diff --git a/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu b/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu new file mode 100644 index 0000000..2e0fa87 --- /dev/null +++ b/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu @@ -0,0 +1,63 @@ +/**********************************************************************************/ +/* MIT License */ +/* */ +/* Copyright (c) 2020, 2021 JetBrains-Research */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining a copy */ +/* of this software and associated documentation files (the "Software"), to deal */ +/* in the Software without restriction, including without limitation the rights */ +/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */ +/* copies of the Software, and to permit persons to whom the Software is */ +/* furnished to do so, subject to the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be included in all */ +/* copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */ +/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */ +/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */ +/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */ +/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */ +/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ +/* SOFTWARE. */ +/**********************************************************************************/ + +#include +#include + +namespace cubool { + + void CudaMatrix::eWiseMultInverted(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + auto a = dynamic_cast(&aBase); + auto b = dynamic_cast(&bBase); + + CHECK_RAISE_ERROR(a != nullptr, InvalidArgument, "Passed matrix does not belong to csr matrix class"); + CHECK_RAISE_ERROR(b != nullptr, InvalidArgument, "Passed matrix does not belong to csr matrix class"); + + index M = this->getNrows(); + index N = this->getNcols(); + + + assert(a->getNrows() == M); + assert(a->getNcols() == N); + + assert(b->getNrows() == M); + assert(b->getNcols() == N); + + if (a->isMatrixEmpty() || b->isMatrixEmpty()) { + this->clearAndResizeStorageToDim(); + return; + } + + // Ensure csr proper csr format even if empty + a->resizeStorageToDim(); + b->resizeStorageToDim(); + + kernels::SpVectorEWiseMultInverted> spFunctor; + auto result = spFunctor(a->mMatrixImpl, b->mMatrixImpl); + + // Assign the actual impl result to this storage + this->mMatrixImpl = std::move(result); + } + +} diff --git a/cubool/sources/cuda/kernels/spewisemultinverted.cuh b/cubool/sources/cuda/kernels/spewisemultinverted.cuh new file mode 100644 index 0000000..353bc97 --- /dev/null +++ b/cubool/sources/cuda/kernels/spewisemultinverted.cuh @@ -0,0 +1,106 @@ +/**********************************************************************************/ +/* MIT License */ +/* */ +/* Copyright (c) 2020, 2021 JetBrains-Research */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining a copy */ +/* of this software and associated documentation files (the "Software"), to deal */ +/* in the Software without restriction, including without limitation the rights */ +/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */ +/* copies of the Software, and to permit persons to whom the Software is */ +/* furnished to do so, subject to the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be included in all */ +/* copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */ +/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */ +/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */ +/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */ +/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */ +/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ +/* SOFTWARE. */ +/**********************************************************************************/ + +#ifndef CUBOOL_SPEWISEMULT_CUH +#define CUBOOL_SPEWISEMULT_CUH + +#include +#include +#include +#include + +#include + +namespace cubool { + namespace kernels { + + template + struct SpVectorEWiseMultInverted { + template + using ContainerType = thrust::device_vector::other>; + using MatrixType = nsparse::matrix; + using LargeIndexType = unsigned long; + + static_assert(sizeof(LargeIndexType) > sizeof(IndexType), "Values intersection index must be larger"); + + static void fillIndices(const MatrixType& m, ContainerType& out) { + thrust::for_each(thrust::counting_iterator(0), thrust::counting_iterator(m.m_vals), + [rowOffset=m.m_row_index.data(), colIndex=m.m_col_index.data(), + outIndices=out.data(), nrows=m.m_rows, ncols=m.m_cols] __device__ (IndexType valueId) { + LargeIndexType row = findNearestRowIdx(valueId, nrows, rowOffset); + LargeIndexType col = colIndex[valueId]; + LargeIndexType index = row * ncols + col; + outIndices[valueId] = index; + }); + } + + MatrixType operator()(const MatrixType& a, const MatrixType& b) { + auto aNvals = a.m_vals; + auto bNvals = b.m_vals; + auto worst = aNvals; + + // Allocate memory for the worst case scenario + ContainerType inputA(aNvals); + ContainerType inputB(bNvals); + + fillIndices(a, inputA); + fillIndices(b, inputB); + + ContainerType intersected(worst); + + auto out = thrust::set_difference(inputA.begin(), inputA.end(), + inputB.begin(), inputB.end(), + intersected.begin()); + + // Count result nvals count + auto nvals = thrust::distance(intersected.begin(), out); + + ContainerType rowOffsetTmp(a.m_rows + 1); + ContainerType colIndex(nvals); + + thrust::fill(rowOffsetTmp.begin(), rowOffsetTmp.end(), 0); + + thrust::for_each(thrust::counting_iterator(0), thrust::counting_iterator(nvals), + [rowOffset=rowOffsetTmp.data(), colIndex=colIndex.data(), intersected=intersected.data(), + nrows=a.m_rows, ncols=a.m_cols] __device__ (IndexType valueId) { + LargeIndexType i = intersected[valueId]; + LargeIndexType row = i / ncols; + LargeIndexType col = i % ncols; + atomicAdd((rowOffset + row).get(), 1); + colIndex[valueId] = (IndexType) col; + }); + + ContainerType rowOffset(a.m_rows + 1); + thrust::exclusive_scan(rowOffsetTmp.begin(), rowOffsetTmp.end(), rowOffset.begin(), 0, thrust::plus()); + + assert(nvals == rowOffset.back()); + + return MatrixType(std::move(colIndex), std::move(rowOffset), a.m_rows, a.m_cols, nvals); + } + }; + + } +} + +#endif //CUBOOL_SPEWISEMULT_CUH diff --git a/cubool/sources/sequential/sq_ewisemultinverted.cpp b/cubool/sources/sequential/sq_ewisemultinverted.cpp new file mode 100644 index 0000000..ee810c9 --- /dev/null +++ b/cubool/sources/sequential/sq_ewisemultinverted.cpp @@ -0,0 +1,105 @@ +/**********************************************************************************/ +/* MIT License */ +/* */ +/* Copyright (c) 2020, 2021 JetBrains-Research */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining a copy */ +/* of this software and associated documentation files (the "Software"), to deal */ +/* in the Software without restriction, including without limitation the rights */ +/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */ +/* copies of the Software, and to permit persons to whom the Software is */ +/* furnished to do so, subject to the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be included in all */ +/* copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */ +/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */ +/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */ +/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */ +/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */ +/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ +/* SOFTWARE. */ +/**********************************************************************************/ + +#include +#include + +namespace cubool { + + void sq_ewisemultinverted(const CsrData& a, const CsrData& b, CsrData& out) { + out.rowOffsets.resize(a.nrows + 1, 0); + + size_t nvals = 0; + + // Count nnz of the result matrix to allocate memory + for (index i = 0; i < a.nrows; i++) { + index ak = a.rowOffsets[i]; + index bk = b.rowOffsets[i]; + index asize = a.rowOffsets[i + 1] - ak; + index bsize = b.rowOffsets[i + 1] - bk; + + const index* ar = &a.colIndices[ak]; + const index* br = &b.colIndices[bk]; + const index* arend = ar + asize; + const index* brend = br + bsize; + + index nvalsInRow = 0; + + while (ar != arend && br != brend) { + if (*ar == *br) { + ar++; + br++; + } + else if (*ar < *br) { + nvalsInRow++; + ar++; + } + else { + br++; + } + } + nvalsInRow += arend - ar; + + nvals += nvalsInRow; + out.rowOffsets[i] = nvalsInRow; + } + + // Eval row offsets + exclusive_scan(out.rowOffsets.begin(), out.rowOffsets.end(), 0); + + // Allocate memory for values + out.nvals = nvals; + out.colIndices.resize(nvals); + + // Fill sorted column indices + size_t k = 0; + for (index i = 0; i < a.nrows; i++) { + const index* ar = &a.colIndices[a.rowOffsets[i]]; + const index* br = &b.colIndices[b.rowOffsets[i]]; + const index* arend = &a.colIndices[a.rowOffsets[i + 1]]; + const index* brend = &b.colIndices[b.rowOffsets[i + 1]]; + + while (ar != arend && br != brend) { + if (*ar == *br) { + ar++; + br++; + } + else if (*ar < *br) { + out.colIndices[k] = *ar; + k++; + ar++; + } + else { + br++; + } + } + + while (ar != arend) { + out.colIndices[k] = *ar; + k++; + ar++; + } + } + } +} diff --git a/cubool/sources/sequential/sq_ewisemultinverted.hpp b/cubool/sources/sequential/sq_ewisemultinverted.hpp new file mode 100644 index 0000000..99b2615 --- /dev/null +++ b/cubool/sources/sequential/sq_ewisemultinverted.hpp @@ -0,0 +1,42 @@ +/**********************************************************************************/ +/* MIT License */ +/* */ +/* Copyright (c) 2020, 2021 JetBrains-Research */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining a copy */ +/* of this software and associated documentation files (the "Software"), to deal */ +/* in the Software without restriction, including without limitation the rights */ +/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */ +/* copies of the Software, and to permit persons to whom the Software is */ +/* furnished to do so, subject to the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be included in all */ +/* copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */ +/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */ +/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */ +/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */ +/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */ +/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ +/* SOFTWARE. */ +/**********************************************************************************/ + +#ifndef CUBOOL_SQ_EWISEMULTINVERTED_HPP +#define CUBOOL_SQ_EWISEMULTINVERTED_HPP + +#include + +namespace cubool { + + /** + * Element-wise multiplication of the matrices `a` and inverted `b`. + * + * @param a Input matrix + * @param b Input matrix, which will be inverted before multiplication + * @param[out] out Where to store the result + */ + void sq_ewisemultinverted(const CsrData& a, const CsrData& b, CsrData& out); +} + +#endif //CUBOOL_SQ_EWISEMULTINVERTED_HPP diff --git a/cubool/sources/sequential/sq_matrix.cpp b/cubool/sources/sequential/sq_matrix.cpp index df96e4e..00473f1 100644 --- a/cubool/sources/sequential/sq_matrix.cpp +++ b/cubool/sources/sequential/sq_matrix.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -235,6 +236,31 @@ namespace cubool { this->mData = std::move(out); } + void SqMatrix::eWiseMultInverted(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + auto a = dynamic_cast(&aBase); + auto b = dynamic_cast(&bBase); + + CHECK_RAISE_ERROR(a != nullptr, InvalidArgument, "Provided matrix does not belongs to sequential matrix class"); + CHECK_RAISE_ERROR(b != nullptr, InvalidArgument, "Provided matrix does not belongs to sequential matrix class"); + + assert(a->getNrows() == this->getNrows()); + assert(a->getNcols() == this->getNcols()); + assert(a->getNrows() == b->getNrows()); + assert(a->getNcols() == b->getNcols()); + + CsrData out; + out.nrows = this->getNrows(); + out.ncols = this->getNcols(); + + a->allocateStorage(); + b->allocateStorage(); + sq_ewisemultinverted(a->mData, b->mData, out); + + this->mData = std::move(out); + } + + + index SqMatrix::getNrows() const { return mData.nrows; } diff --git a/cubool/sources/sequential/sq_matrix.hpp b/cubool/sources/sequential/sq_matrix.hpp index 1a3f539..d348232 100644 --- a/cubool/sources/sequential/sq_matrix.hpp +++ b/cubool/sources/sequential/sq_matrix.hpp @@ -51,6 +51,7 @@ namespace cubool { void kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) override; void eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) override; void eWiseMult(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; + void eWiseMultInverted(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; index getNrows() const override; index getNcols() const override; diff --git a/cubool/tests/CMakeLists.txt b/cubool/tests/CMakeLists.txt index 0e0f620..84ddc96 100644 --- a/cubool/tests/CMakeLists.txt +++ b/cubool/tests/CMakeLists.txt @@ -34,6 +34,9 @@ target_link_libraries(test_matrix_ewiseadd PUBLIC testing) add_executable(test_matrix_ewisemult test_matrix_ewisemult.cpp) target_link_libraries(test_matrix_ewisemult PUBLIC testing) +add_executable(test_matrix_ewisemult_inverted test_matrix_ewisemult_inverted.cpp) +target_link_libraries(test_matrix_ewisemult_inverted PUBLIC testing) + add_executable(test_vector_misc test_vector_misc.cpp) target_link_libraries(test_vector_misc PUBLIC testing) diff --git a/cubool/tests/test_matrix_ewisemult_inverted.cpp b/cubool/tests/test_matrix_ewisemult_inverted.cpp new file mode 100644 index 0000000..2e32520 --- /dev/null +++ b/cubool/tests/test_matrix_ewisemult_inverted.cpp @@ -0,0 +1,134 @@ +#include "cubool/cubool.h" +#include +#include + +using DataMatrix = std::vector>; + +static void printTestingMatrix(const testing::Matrix &matrix, std::string name = "") { + if (name != "") { + std::cout << name << std::endl; + } + + for (int i = 0; i < matrix.nvals; i++) { + printf("(%d, %d)\n", matrix.rowsIndex[i], matrix.colsIndex[i]); + } +} + +static void printCuboolMatrix(cuBool_Matrix matrix, std::string name = "") { + if (name != "") { + std::cout << name << std::endl; + } + + cuBool_Index nvals; + cuBool_Matrix_Nvals(matrix, &nvals); + std::vector rows(nvals), cols(nvals); + cuBool_Matrix_ExtractPairs(matrix, rows.data(), cols.data(), &nvals); + + for (int i = 0; i < nvals; i++) { + printf("(%d, %d)\n", rows[i], cols[i]); + } +} + +void testApplyNotMask(const DataMatrix &matrix_data, const DataMatrix &mask_data) { + cuBool_Index nrows, ncols; + nrows = matrix_data.size(); + ncols = matrix_data[0].size(); + testing::Matrix test_matrix = testing::Matrix::generatet(nrows, ncols, + [&matrix_data](cuBool_Index i, cuBool_Index j) { return matrix_data[i][j]; }); + nrows = mask_data.size(); + ncols = mask_data[0].size(); + testing::Matrix test_mask = testing::Matrix::generatet(nrows, ncols, + [&mask_data](cuBool_Index i, cuBool_Index j) { return mask_data[i][j]; }); + + cuBool_Matrix matrix, mask, result; + ASSERT_EQ(cuBool_Matrix_New(&matrix, test_matrix.nrows, test_matrix.ncols), CUBOOL_STATUS_SUCCESS); + ASSERT_EQ(cuBool_Matrix_New(&mask, test_mask.nrows, test_mask.ncols), CUBOOL_STATUS_SUCCESS); + ASSERT_EQ(cuBool_Matrix_New(&result, test_matrix.nrows, test_matrix.ncols), CUBOOL_STATUS_SUCCESS); + + ASSERT_EQ(cuBool_Matrix_Build(matrix, test_matrix.rowsIndex.data(), test_matrix.colsIndex.data(), test_matrix.nvals, + CUBOOL_HINT_VALUES_SORTED & CUBOOL_HINT_NO_DUPLICATES), CUBOOL_STATUS_SUCCESS); + ASSERT_EQ(cuBool_Matrix_Build(mask, test_mask.rowsIndex.data(), test_mask.colsIndex.data(), test_mask.nvals, + CUBOOL_HINT_VALUES_SORTED & CUBOOL_HINT_NO_DUPLICATES), CUBOOL_STATUS_SUCCESS); + + cuBool_Matrix_EWiseMulInverted(result, matrix, mask, CUBOOL_HINT_NO); + + // validate value of algorithm + cuBool_Index nvals; + cuBool_Matrix_Nvals(result, &nvals); + std::vector rows(nvals), cols(nvals); + cuBool_Matrix_ExtractPairs(result, rows.data(), cols.data(), &nvals); + + cuBool_Matrix_Free(matrix); + cuBool_Matrix_Free(mask); + cuBool_Matrix_Free(result); + + auto mask_data_inverted = mask_data; + for (auto &row : mask_data_inverted) { + for (int &value : row) { + value = !value; + } + } + + std::vector result_data(matrix_data.size(), std::vector(matrix_data[0].size(), 0)); + for (int i = 0; i < nvals; i++) { + result_data[rows[i]][cols[i]] = 1; + } + + for (int i = 0; i < matrix_data.size(); i++) { + for (int j = 0; j < matrix_data[0].size(); j++) { + ASSERT_EQ(matrix_data[i][j] * mask_data_inverted[i][j], result_data[i][j]); + } + } + +} + +TEST(cuBool_Matrix, ApplyMatrix) { + ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); + + DataMatrix matrix { + {1, 0, 0}, + {0, 0, 0}, + {0, 1, 0}, + }; + + DataMatrix mask { + {0, 1, 1}, + {1, 0, 1}, + {0, 1, 1}, + }; + // iverted is + // 1 0 0 + // 0 1 0 + // 1 0 0 + // matrix & ~mask must have (0, 0) + + testApplyNotMask(matrix, mask); + + ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); +} + +TEST(cuBool_Matrix, ApplyMatrixRandom) { + ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); + + for (int i = 0; i < 102; i++) { + int n = rand() % 10 + 1; + int m = rand() % 10 + 1; + + DataMatrix matrix(n, std::vector(m, 0)); + DataMatrix mask(n, std::vector(m, 0)); + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + matrix[i][j] = rand() & 1; + mask[i][j] = rand() & 1; + } + } + + testApplyNotMask(matrix, mask); + } + + ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); +} + + +CUBOOL_GTEST_MAIN From 2f5daace52f8ff9aab55924e2612fa62aedd1c76 Mon Sep 17 00:00:00 2001 From: Mitya <8863314@gmail.com> Date: Sun, 24 Nov 2024 23:49:19 +0300 Subject: [PATCH 05/74] Fixed mistake in matrix ewise add --- cubool/sources/cuda/kernels/spmerge.cuh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubool/sources/cuda/kernels/spmerge.cuh b/cubool/sources/cuda/kernels/spmerge.cuh index 8a14f8d..7a5b62d 100644 --- a/cubool/sources/cuda/kernels/spmerge.cuh +++ b/cubool/sources/cuda/kernels/spmerge.cuh @@ -53,7 +53,7 @@ namespace cubool { assert(a.m_cols == b.m_cols); IndexType rows = a.m_rows; - IndexType cols = a.m_rows; + IndexType cols = a.m_cols; constexpr auto config_merge = make_bin_seq< From 99f1d8ef722a7b88be8fd61b15456f5658799d5e Mon Sep 17 00:00:00 2001 From: Dmitriy Kozenko <8863314@gmail.com> Date: Sun, 16 Feb 2025 23:43:32 +0300 Subject: [PATCH 06/74] Fixed errors in cmake: incorrect compile options for NVCC --- cubool/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cubool/CMakeLists.txt b/cubool/CMakeLists.txt index cd80032..451efd0 100644 --- a/cubool/CMakeLists.txt +++ b/cubool/CMakeLists.txt @@ -206,11 +206,7 @@ target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_MAJOR=${CUBOOL_VERSION_ target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_MINOR=${CUBOOL_VERSION_MINOR}) target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_SUB=${CUBOOL_VERSION_SUB}) -target_compile_features(cubool PUBLIC cxx_std_14) - -target_compile_options(cubool PRIVATE $<$: -Wall>) -target_compile_options(cubool PRIVATE $<$,$>: -O2>) -target_compile_options(cubool PRIVATE $<$,$>: -O0>) +target_compile_features(cubool PUBLIC cxx_std_17) set_target_properties(cubool PROPERTIES CXX_STANDARD 17) set_target_properties(cubool PROPERTIES CXX_STANDARD_REQUIRED ON) From b40486326dbd9bacb763afbf4956e23ecc61f9d3 Mon Sep 17 00:00:00 2001 From: Dmitriy Kozenko <8863314@gmail.com> Date: Wed, 19 Feb 2025 00:01:52 +0300 Subject: [PATCH 07/74] Added option for using matrix addition optimization from nsparse --- CMakeLists.txt | 2 + cubool/CMakeLists.txt | 2 + cubool/sources/cuda/kernels/spmerge.cuh | 71 +++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index da9e6d9..a432980 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ option(CUBOOL_WITH_NAIVE "Build library with naive and naive-shared dens option(CUBOOL_BUILD_TESTS "Build project unit-tests with gtest" ON) option(CUBOOL_COPY_TO_PY_PACKAGE "Copy compiled shared library into python package folder (for package use purposes)" ON) +option(CUBOOL_USE_NSPARSE_MERGE_FUNCTOR "Use nsparse optimiztion for matrix addition function" ON) + set(CUBOOL_VERSION_MAJOR 1) set(CUBOOL_VERSION_MINOR 0) set(CUBOOL_VERSION_SUB 0) diff --git a/cubool/CMakeLists.txt b/cubool/CMakeLists.txt index 451efd0..5434c02 100644 --- a/cubool/CMakeLists.txt +++ b/cubool/CMakeLists.txt @@ -206,6 +206,8 @@ target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_MAJOR=${CUBOOL_VERSION_ target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_MINOR=${CUBOOL_VERSION_MINOR}) target_compile_definitions(cubool PRIVATE CUBOOL_VERSION_SUB=${CUBOOL_VERSION_SUB}) +target_compile_definitions(cubool PRIVATE CUBOOL_USE_NSPARSE_MERGE_FUNCTOR=$) + target_compile_features(cubool PUBLIC cxx_std_17) set_target_properties(cubool PROPERTIES CXX_STANDARD 17) diff --git a/cubool/sources/cuda/kernels/spmerge.cuh b/cubool/sources/cuda/kernels/spmerge.cuh index 7a5b62d..96805cb 100644 --- a/cubool/sources/cuda/kernels/spmerge.cuh +++ b/cubool/sources/cuda/kernels/spmerge.cuh @@ -29,9 +29,13 @@ #include #include +#include +#include + namespace cubool { namespace kernels { +#if CUBOOL_USE_NSPARSE_MERGE_FUNCTOR template class SpMergeFunctor { public: @@ -77,6 +81,73 @@ namespace cubool { private: nsparse::unique_merge_functor_t uniqueMergeFunctor; }; +#else + template + class SpMergeFunctor { + public: + template + using ContainerType = thrust::device_vector::other>; + using MatrixType = nsparse::matrix; + using LargeIndexType = unsigned long; + + static void fillIndices(const MatrixType& m, ContainerType& out) { + thrust::for_each(thrust::counting_iterator(0), thrust::counting_iterator(m.m_vals), + [rowOffset=m.m_row_index.data(), colIndex=m.m_col_index.data(), + outIndices=out.data(), nrows=m.m_rows, ncols=m.m_cols] __device__ (IndexType valueId) { + LargeIndexType row = findNearestRowIdx(valueId, nrows, rowOffset); + LargeIndexType col = colIndex[valueId]; + LargeIndexType index = row * ncols + col; + outIndices[valueId] = index; + }); + } + + MatrixType operator()(const MatrixType& a, const MatrixType& b) { + auto aNvals = a.m_vals; + auto bNvals = b.m_vals; + // auto worst = std::min(aNvals, bNvals); + auto worst = aNvals + bNvals; + + // Allocate memory for the worst case scenario + ContainerType inputA(aNvals); + ContainerType inputB(bNvals); + + fillIndices(a, inputA); + fillIndices(b, inputB); + + ContainerType intersected(worst); + + auto out = thrust::set_union(inputA.begin(), inputA.end(), + inputB.begin(), inputB.end(), + intersected.begin()); + + // Count result nvals count + auto nvals = thrust::distance(intersected.begin(), out); + + ContainerType rowOffsetTmp(a.m_rows + 1); + ContainerType colIndex(nvals); + + thrust::fill(rowOffsetTmp.begin(), rowOffsetTmp.end(), 0); + + thrust::for_each(thrust::counting_iterator(0), thrust::counting_iterator(nvals), + [rowOffset=rowOffsetTmp.data(), colIndex=colIndex.data(), intersected=intersected.data(), + nrows=a.m_rows, ncols=a.m_cols] __device__ (IndexType valueId) { + LargeIndexType i = intersected[valueId]; + LargeIndexType row = i / ncols; + LargeIndexType col = i % ncols; + atomicAdd((rowOffset + row).get(), 1); + colIndex[valueId] = (IndexType) col; + }); + + ContainerType rowOffset(a.m_rows + 1); + thrust::exclusive_scan(rowOffsetTmp.begin(), rowOffsetTmp.end(), rowOffset.begin(), 0, thrust::plus()); + + assert(nvals == rowOffset.back()); + + return MatrixType(std::move(colIndex), std::move(rowOffset), a.m_rows, a.m_cols, nvals); + } + }; + +#endif } } From f81ccea03657b19641776d4bdbe215c653c36cd4 Mon Sep 17 00:00:00 2001 From: Dmitriy Kozenko <8863314@gmail.com> Date: Sat, 19 Apr 2025 22:48:49 +0300 Subject: [PATCH 08/74] Updated gtest version to last release for compability with last cmake version --- deps/gtest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/gtest b/deps/gtest index d9c309f..6910c9d 160000 --- a/deps/gtest +++ b/deps/gtest @@ -1 +1 @@ -Subproject commit d9c309fdab807b716c2cf4d4a42989b8c34f712a +Subproject commit 6910c9d9165801d8827d628cb72eb7ea9dd538c5 From da6be345f8a3a0962887e7f1f934adc9b07058bb Mon Sep 17 00:00:00 2001 From: Dmitriy Kozenko <8863314@gmail.com> Date: Sat, 3 May 2025 15:49:38 +0300 Subject: [PATCH 09/74] Restored python package build --- CMakeLists.txt | 12 ++---------- cubool/CMakeLists.txt | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a432980..a6404f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,14 +34,6 @@ endif() # Configure cuda dependencies if (CUBOOL_WITH_CUDA) - message(STATUS "Add cub as cuda utility") - # set(CUB_ENABLE_HEADER_TESTING OFF CACHE BOOL "" FORCE) - # set(CUB_ENABLE_TESTING OFF CACHE BOOL "" FORCE) - # set(CUB_ENABLE_EXAMPLES OFF CACHE BOOL "" FORCE) - # add_subdirectory(deps/cub) - # add_library(cub INTERFACE IMPORTED) - # target_link_libraries(cub INTERFACE CUB::CUB) - message(STATUS "Add nsparse library as crs matrix multiplication backend") add_subdirectory(deps/nsparse-um) endif() @@ -60,7 +52,7 @@ endif() add_subdirectory(cubool) # Copy scripts into binary directory -# file(COPY scripts DESTINATION ${CMAKE_BINARY_DIR}/) +file(COPY scripts DESTINATION ${CMAKE_BINARY_DIR}/) # Copy python related stuff -# file(COPY python DESTINATION ${CMAKE_BINARY_DIR}/) +file(COPY python DESTINATION ${CMAKE_BINARY_DIR}/) diff --git a/cubool/CMakeLists.txt b/cubool/CMakeLists.txt index 5434c02..ed3cb41 100644 --- a/cubool/CMakeLists.txt +++ b/cubool/CMakeLists.txt @@ -222,7 +222,6 @@ endforeach() if (CUBOOL_WITH_CUDA) set_target_properties(cubool PROPERTIES CUDA_STANDARD 14) set_target_properties(cubool PROPERTIES CUDA_STANDARD_REQUIRED ON) - # set_target_properties(cubool PROPERTIES CUDA_SEPARABLE_COMPILATION ON) # Settings: https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/ @@ -249,14 +248,14 @@ if (CUBOOL_BUILD_TESTS) endif() # Copy cubool library after build if allowed -# if (CUBOOL_COPY_TO_PY_PACKAGE) -# set(LIBRARY_FILE_NAME ${TARGET_FILE_NAME}) -# -# add_custom_command( -# TARGET cubool POST_BUILD -# COMMAND "${CMAKE_COMMAND}" -E -# copy -# "${CMAKE_BINARY_DIR}/cubool/${LIBRARY_FILE_NAME}" -# "${CMAKE_BINARY_DIR}/python/pycubool" -# COMMENT "Copy ${LIBRARY_FILE_NAME} compiled lib into python folder") -# endif() +if (CUBOOL_COPY_TO_PY_PACKAGE) + set(LIBRARY_FILE_NAME ${TARGET_FILE_NAME}) + + add_custom_command( + TARGET cubool POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E + copy + "${CMAKE_BINARY_DIR}/cubool/${LIBRARY_FILE_NAME}" + "${CMAKE_BINARY_DIR}/python/pycubool" + COMMENT "Copy ${LIBRARY_FILE_NAME} compiled lib into python folder") +endif() From 69d38a67d74cc032ab9c313721f40cba2f79125c Mon Sep 17 00:00:00 2001 From: Dmitriy Kozenko <8863314@gmail.com> Date: Sat, 3 May 2025 17:07:42 +0300 Subject: [PATCH 10/74] Removed temporary solutions for preparing PR --- cubool/include/cubool/cubool.h | 14 +++++------ cubool/sources/core/matrix.cpp | 10 +++----- cubool/sources/cuda/kernels/spmerge.cuh | 1 - .../tests/test_matrix_ewisemult_inverted.cpp | 25 ------------------- deps/nsparse-um/CMakeLists.txt | 1 - .../include/nsparse/unified_allocator.h | 1 - deps/nsparse-um/test/CMakeLists.txt | 1 - deps/nsparse/test/CMakeLists.txt | 1 - 8 files changed, 11 insertions(+), 43 deletions(-) diff --git a/cubool/include/cubool/cubool.h b/cubool/include/cubool/cubool.h index ef7d9b5..2859542 100644 --- a/cubool/include/cubool/cubool.h +++ b/cubool/include/cubool/cubool.h @@ -926,20 +926,20 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Kronecker( ); /** - * Performs result = left + ~right, where - * '+' is boolean semiring 'or' operation + * Performs result = left * ~right, where + * '*' is boolean semiring 'and' operation * '~' is operation for invert matrix (0 swaps to 1 and 1 to 0) * - * @note Matrices must be compatible + * @note To perform this operation matrices must be compatible + * dim(left) = M x T + * dim(right) = T x N * dim(result) = M x N - * dim(left) = M x N - * dim(right) = M x N * * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time * * @param result[out] Destination matrix to store result - * @param left Source matrix to be added - * @param right Source matrix to be inverted and added + * @param left Source matrix to be multiplied + * @param right Source matrix to be inverted and multiplied * @param hints Hints for the operation * * @return Error code on this operation diff --git a/cubool/sources/core/matrix.cpp b/cubool/sources/core/matrix.cpp index 730fe63..49e35c3 100644 --- a/cubool/sources/core/matrix.cpp +++ b/cubool/sources/core/matrix.cpp @@ -370,21 +370,19 @@ namespace cubool { msk->commitCache(); this->releaseCache(); - /* if (checkTime) { - TIMER_ACTION(timer, mHnd->eWiseMult(*a->mHnd, *b->mHnd, false)); + TIMER_ACTION(timer, mHnd->eWiseMultInverted(*mat->mHnd, *msk->mHnd, false)); LogStream stream(*Library::getLogger()); stream << Logger::Level::Info << "Time: " << timer.getElapsedTimeMs() << " ms " - << "Matrix::eWiseMult: " + << "Matrix::eWiseMultInverted: " << this->getDebugMarker() << " = " - << a->getDebugMarker() << " + " - << b->getDebugMarker() << LogStream::cmt; + << mat->getDebugMarker() << " + " + << msk->getDebugMarker() << LogStream::cmt; return; } - */ mHnd->eWiseMultInverted(*mat->mHnd, *msk->mHnd, false); } diff --git a/cubool/sources/cuda/kernels/spmerge.cuh b/cubool/sources/cuda/kernels/spmerge.cuh index 96805cb..4734e35 100644 --- a/cubool/sources/cuda/kernels/spmerge.cuh +++ b/cubool/sources/cuda/kernels/spmerge.cuh @@ -104,7 +104,6 @@ namespace cubool { MatrixType operator()(const MatrixType& a, const MatrixType& b) { auto aNvals = a.m_vals; auto bNvals = b.m_vals; - // auto worst = std::min(aNvals, bNvals); auto worst = aNvals + bNvals; // Allocate memory for the worst case scenario diff --git a/cubool/tests/test_matrix_ewisemult_inverted.cpp b/cubool/tests/test_matrix_ewisemult_inverted.cpp index 2e32520..250ba55 100644 --- a/cubool/tests/test_matrix_ewisemult_inverted.cpp +++ b/cubool/tests/test_matrix_ewisemult_inverted.cpp @@ -4,31 +4,6 @@ using DataMatrix = std::vector>; -static void printTestingMatrix(const testing::Matrix &matrix, std::string name = "") { - if (name != "") { - std::cout << name << std::endl; - } - - for (int i = 0; i < matrix.nvals; i++) { - printf("(%d, %d)\n", matrix.rowsIndex[i], matrix.colsIndex[i]); - } -} - -static void printCuboolMatrix(cuBool_Matrix matrix, std::string name = "") { - if (name != "") { - std::cout << name << std::endl; - } - - cuBool_Index nvals; - cuBool_Matrix_Nvals(matrix, &nvals); - std::vector rows(nvals), cols(nvals); - cuBool_Matrix_ExtractPairs(matrix, rows.data(), cols.data(), &nvals); - - for (int i = 0; i < nvals; i++) { - printf("(%d, %d)\n", rows[i], cols[i]); - } -} - void testApplyNotMask(const DataMatrix &matrix_data, const DataMatrix &mask_data) { cuBool_Index nrows, ncols; nrows = matrix_data.size(); diff --git a/deps/nsparse-um/CMakeLists.txt b/deps/nsparse-um/CMakeLists.txt index cdc4463..91ed084 100644 --- a/deps/nsparse-um/CMakeLists.txt +++ b/deps/nsparse-um/CMakeLists.txt @@ -3,7 +3,6 @@ project(nsparse_um LANGUAGES CXX CUDA) add_library(nsparse_um INTERFACE) target_include_directories(nsparse_um INTERFACE include/) -# target_link_libraries(nsparse_um INTERFACE cub) target_link_libraries(nsparse_um INTERFACE) target_compile_options(nsparse_um INTERFACE $<$: --expt-relaxed-constexpr --expt-extended-lambda>) diff --git a/deps/nsparse-um/include/nsparse/unified_allocator.h b/deps/nsparse-um/include/nsparse/unified_allocator.h index c15f19e..9c3b2f8 100644 --- a/deps/nsparse-um/include/nsparse/unified_allocator.h +++ b/deps/nsparse-um/include/nsparse/unified_allocator.h @@ -3,7 +3,6 @@ #include #include #include -// #include #include #include diff --git a/deps/nsparse-um/test/CMakeLists.txt b/deps/nsparse-um/test/CMakeLists.txt index 6a29690..6a1aaff 100644 --- a/deps/nsparse-um/test/CMakeLists.txt +++ b/deps/nsparse-um/test/CMakeLists.txt @@ -3,7 +3,6 @@ project(nsparse_um_test CXX CUDA) add_executable(${PROJECT_NAME} src/nsparse_test.cu src/utils.cpp) -# target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse_um cub) target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse_um) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/deps/nsparse/test/CMakeLists.txt b/deps/nsparse/test/CMakeLists.txt index 9927725..5abd415 100644 --- a/deps/nsparse/test/CMakeLists.txt +++ b/deps/nsparse/test/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.11) project(nsparse_test CXX CUDA) add_executable(${PROJECT_NAME} src/nsparse_test.cu src/utils.cpp) -# target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse cub) target_link_libraries(${PROJECT_NAME} PRIVATE gtest_main nsparse) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) From f304b58dc2cf61d7234d47399f1c13dafa255df2 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 12 Mar 2025 14:11:55 +0300 Subject: [PATCH 11/74] ci: run on self-hosted platform --- .github/workflows/ubuntu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index cd33dd3..d448174 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -4,7 +4,7 @@ name: Ubuntu on: push: - branches: [ master ] + branches: [ master, self-hosted-runner ] pull_request: branches: [ master ] workflow_dispatch: @@ -12,7 +12,7 @@ on: jobs: build: name: Build ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} - runs-on: ${{ matrix.os }} + runs-on: self-hosted strategy: fail-fast: false matrix: From fb6867b865cfc4ba4eb1872cb03062c14d6b55b9 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 12 Mar 2025 19:34:30 +0300 Subject: [PATCH 12/74] ci: update versions of packages --- .github/workflows/ubuntu.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d448174..6f16225 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -26,10 +26,10 @@ jobs: artifact: "cubool-ubuntu-build.tar.xz" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: '3.7' @@ -76,7 +76,7 @@ jobs: run: tar cfz ${{ env.artifact }} ${{ env.build_dir }} - name: Upload binary - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact }} path: ${{ env.artifact }} \ No newline at end of file From 21de87c7b674dd7864db54f30a4ab01fd4ef2cb3 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 12 Mar 2025 20:02:33 +0300 Subject: [PATCH 13/74] ci: comment unnecessary python installation --- .github/workflows/ubuntu.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 6f16225..3622014 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -29,9 +29,9 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v5 - with: - python-version: '3.7' + # - uses: actions/setup-python@v5 + # with: + # python-version: '3.7' - name: Install CUDA env: From 4d5e940cc2969b4748725fa79212199c39c4482e Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 14:04:08 +0300 Subject: [PATCH 14/74] ci: left only the installation step --- .github/workflows/ubuntu.yml | 70 ++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 3622014..fae441e 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -17,9 +17,9 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-18.04 - cuda: "10.1" - gcc: 8 + - os: ubuntu-24.04 + cuda: "12.8" + gcc: 11 env: build_dir: "build" config: "Release" @@ -36,47 +36,39 @@ jobs: - name: Install CUDA env: cuda: ${{ matrix.cuda }} - run: | - source ./scripts/install_cuda_ubuntu.sh - if [[ $? -eq 0 ]]; then - # Set paths for subsequent steps, using ${CUDA_PATH} - echo "Adding CUDA to CUDA_PATH, PATH and LD_LIBRARY_PATH" - echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV - echo "${CUDA_PATH}/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - fi + run: ./scripts/install_cuda_ubuntu.sh shell: bash - - name: Install and configure GCC and GXX - run: | - sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} - echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + # - name: Install and configure GCC and GXX + # run: | + # sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} + # echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV + # echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + # echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES + # - name: Configure CMake build + # run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES - - name: Build library sources - working-directory: ${{ env.build_dir }} - run: cmake --build . --target all --verbose -j `nproc` + # - name: Build library sources + # working-directory: ${{ env.build_dir }} + # run: cmake --build . --target all --verbose -j `nproc` - - name: Run unit-tests (sequential backend) - working-directory: ${{ env.build_dir }} - run: bash scripts/run_tests_fallback.sh - shell: bash + # - name: Run unit-tests (sequential backend) + # working-directory: ${{ env.build_dir }} + # run: bash scripts/run_tests_fallback.sh + # shell: bash - - name: Run regression-tests (sequential backend) - working-directory: ${{ env.build_dir }}/python - run: bash run_tests.sh - shell: bash + # - name: Run regression-tests (sequential backend) + # working-directory: ${{ env.build_dir }}/python + # run: bash run_tests.sh + # shell: bash - - name: Prepare upload binary - shell: bash - run: tar cfz ${{ env.artifact }} ${{ env.build_dir }} + # - name: Prepare upload binary + # shell: bash + # run: tar cfz ${{ env.artifact }} ${{ env.build_dir }} - - name: Upload binary - uses: actions/upload-artifact@v4 - with: - name: ${{ env.artifact }} - path: ${{ env.artifact }} \ No newline at end of file + # - name: Upload binary + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.artifact }} + # path: ${{ env.artifact }} \ No newline at end of file From 0c28baf0e4cf6a8803faf4b8f4e32c3a74f061af Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 14:04:40 +0300 Subject: [PATCH 15/74] feat(install_cuda): update the installation script --- scripts/install_cuda_ubuntu.sh | 90 +++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 22 deletions(-) diff --git a/scripts/install_cuda_ubuntu.sh b/scripts/install_cuda_ubuntu.sh index 8c7e5ed..65ebe60 100644 --- a/scripts/install_cuda_ubuntu.sh +++ b/scripts/install_cuda_ubuntu.sh @@ -1,8 +1,12 @@ # Original script from https://github.com/ptheywood/cuda-cmake-github-actions CUDA_PACKAGES_IN=( - "command-line-tools" - "libraries-dev" + "cuda-compiler" + "cuda-cudart-dev" + "cuda-nvtx" + "cuda-nvrtc-dev" + "libcurand-dev" # 11-0+ + "cuda-cccl" # 11.4+, provides cub and thrust. On 11.3 known as cuda-thrust-11-3 ) # returns 0 (true) if a >= b @@ -32,6 +36,7 @@ function version_lt() { CUDA_VERSION_MAJOR_MINOR=${cuda} # Split the version. +# We (might/probably) don't know PATCH at this point - it depends which version gets installed. CUDA_MAJOR=$(echo "${CUDA_VERSION_MAJOR_MINOR}" | cut -d. -f1) CUDA_MINOR=$(echo "${CUDA_VERSION_MAJOR_MINOR}" | cut -d. -f2) CUDA_PATCH=$(echo "${CUDA_VERSION_MAJOR_MINOR}" | cut -d. -f3) @@ -64,41 +69,81 @@ fi ## Select CUDA packages to install CUDA_PACKAGES="" for package in "${CUDA_PACKAGES_IN[@]}" -do : +do : + # @todo This is not perfect. Should probably provide a separate list for diff versions # cuda-compiler-X-Y if CUDA >= 9.1 else cuda-nvcc-X-Y - if [[ "${package}" == "nvcc" ]] && version_ge "$CUDA_VERSION_MAJOR_MINOR" "9.1" ; then - package="compiler" - elif [[ "${package}" == "compiler" ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "9.1" ; then - package="nvcc" + if [[ "${package}" == "cuda-nvcc" ]] && version_ge "$CUDA_VERSION_MAJOR_MINOR" "9.1" ; then + package="cuda-compiler" + elif [[ "${package}" == "cuda-compiler" ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "9.1" ; then + package="cuda-nvcc" + # CUB/Thrust are packages in cuda-thrust in 11.3, but cuda-cccl in 11.4+ + elif [[ "${package}" == "cuda-thrust" || "${package}" == "cuda-cccl" ]]; then + # CUDA cuda-thrust >= 11.4 + if version_ge "$CUDA_VERSION_MAJOR_MINOR" "11.4" ; then + package="cuda-cccl" + # Use cuda-thrust > 11.2 + elif version_ge "$CUDA_VERSION_MAJOR_MINOR" "11.3" ; then + package="cuda-thrust" + # Do not include this pacakge < 11.3 + else + continue + fi + fi + # CUDA 11+ includes lib* / lib*-dev packages, which if they existed previously where cuda-cu*- / cuda-cu*-dev- + if [[ ${package} == libcu* ]] && version_lt "$CUDA_VERSION_MAJOR_MINOR" "11.0" ; then + package="${package/libcu/cuda-cu}" fi # Build the full package name and append to the string. - CUDA_PACKAGES+=" cuda-${package}-${CUDA_MAJOR}-${CUDA_MINOR}" + CUDA_PACKAGES+=" ${package}-${CUDA_MAJOR}-${CUDA_MINOR}" done echo "CUDA_PACKAGES ${CUDA_PACKAGES}" +CPU_ARCH="x86_64" PIN_FILENAME="cuda-ubuntu${UBUNTU_VERSION}.pin" -PIN_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/${PIN_FILENAME}" -APT_KEY_URL="http://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/7fa2af80.pub" -REPO_URL="http://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/" +PIN_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/${CPU_ARCH}/${PIN_FILENAME}" +# apt keyring package now available https://developer.nvidia.com/blog/updating-the-cuda-linux-gpg-repository-key/ +KERYRING_PACKAGE_FILENAME="cuda-keyring_1.0-1_all.deb" +KEYRING_PACKAGE_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/${CPU_ARCH}/${KERYRING_PACKAGE_FILENAME}" +REPO_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/${CPU_ARCH}/" echo "PIN_FILENAME ${PIN_FILENAME}" echo "PIN_URL ${PIN_URL}" -echo "APT_KEY_URL ${APT_KEY_URL}" +echo "KEYRING_PACKAGE_URL ${KEYRING_PACKAGE_URL}" -sudo rm -r /var/lib/apt/lists/* -sudo apt-get clean -sudo apt-get update +# Detect if the script is being run as root, storing true/false in is_root. +is_root=false +if (( $EUID == 0)); then + is_root=true +fi +# Find if sudo is available +has_sudo=false +if command -v sudo &> /dev/null ; then + has_sudo=true +fi +# Decide if we can proceed or not (root or sudo is required) and if so store whether sudo should be used or not. +if [ "$is_root" = false ] && [ "$has_sudo" = false ]; then + echo "Root or sudo is required. Aborting." + exit 1 +elif [ "$is_root" = false ] ; then + USE_SUDO=sudo +else + USE_SUDO= +fi + +$USE_SUDO rm -r /var/lib/apt/lists/* +$USE_SUDO apt-get clean +$USE_SUDO apt-get update ## Install echo "Adding CUDA Repository" wget ${PIN_URL} -sudo mv ${PIN_FILENAME} /etc/apt/preferences.d/cuda-repository-pin-600 -sudo apt-key adv --fetch-keys ${APT_KEY_URL} -sudo add-apt-repository "deb ${REPO_URL} /" -sudo apt-get update +$USE_SUDO mv ${PIN_FILENAME} /etc/apt/preferences.d/cuda-repository-pin-600 +wget ${KEYRING_PACKAGE_URL} && ${USE_SUDO} dpkg -i ${KERYRING_PACKAGE_FILENAME} && rm ${KERYRING_PACKAGE_FILENAME} +$USE_SUDO add-apt-repository "deb ${REPO_URL} /" +$USE_SUDO apt-get update echo "Installing CUDA packages ${CUDA_PACKAGES}" -sudo apt-get -y install ${CUDA_PACKAGES} +$USE_SUDO apt-get -y install ${CUDA_PACKAGES} if [[ $? -ne 0 ]]; then echo "CUDA Installation Error." @@ -109,7 +154,8 @@ fi CUDA_PATH=/usr/local/cuda-${CUDA_MAJOR}.${CUDA_MINOR} echo "CUDA_PATH=${CUDA_PATH}" export CUDA_PATH=${CUDA_PATH} - export PATH="$CUDA_PATH/bin:$PATH" export LD_LIBRARY_PATH="$CUDA_PATH/lib:$LD_LIBRARY_PATH" -nvcc -V \ No newline at end of file +export LD_LIBRARY_PATH="$CUDA_PATH/lib64:$LD_LIBRARY_PATH" +# Check nvcc is now available. +nvcc -V From 444fac7eb475a083d60c62a5c837fd8a0fbc09ce Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 14:07:58 +0300 Subject: [PATCH 16/74] ci: add source command for installation script startup --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index fae441e..c305a0e 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -36,7 +36,7 @@ jobs: - name: Install CUDA env: cuda: ${{ matrix.cuda }} - run: ./scripts/install_cuda_ubuntu.sh + run: source ./scripts/install_cuda_ubuntu.sh shell: bash # - name: Install and configure GCC and GXX From 71729151bddfc038231b05267776c8110642a8f6 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 17:49:38 +0300 Subject: [PATCH 17/74] fix(install_cuda): add correct url --- scripts/install_cuda_ubuntu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_cuda_ubuntu.sh b/scripts/install_cuda_ubuntu.sh index 65ebe60..f5d95ba 100644 --- a/scripts/install_cuda_ubuntu.sh +++ b/scripts/install_cuda_ubuntu.sh @@ -102,7 +102,7 @@ CPU_ARCH="x86_64" PIN_FILENAME="cuda-ubuntu${UBUNTU_VERSION}.pin" PIN_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/${CPU_ARCH}/${PIN_FILENAME}" # apt keyring package now available https://developer.nvidia.com/blog/updating-the-cuda-linux-gpg-repository-key/ -KERYRING_PACKAGE_FILENAME="cuda-keyring_1.0-1_all.deb" +KERYRING_PACKAGE_FILENAME="cuda-keyring_1.1-1_all.deb" KEYRING_PACKAGE_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/${CPU_ARCH}/${KERYRING_PACKAGE_FILENAME}" REPO_URL="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/${CPU_ARCH}/" From b95f94cab33aa17106c9c1825dd1c31cdba1760e Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 18:37:59 +0300 Subject: [PATCH 18/74] ci: add gcc and g++ installation --- .github/workflows/ubuntu.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index c305a0e..500b2d1 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -19,7 +19,7 @@ jobs: include: - os: ubuntu-24.04 cuda: "12.8" - gcc: 11 + gcc: 14.2 env: build_dir: "build" config: "Release" @@ -39,12 +39,12 @@ jobs: run: source ./scripts/install_cuda_ubuntu.sh shell: bash - # - name: Install and configure GCC and GXX - # run: | - # sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} - # echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV - # echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - # echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + - name: Install and configure GCC and GXX + run: | + sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} + export СС=/usr/bin/gcc-${{ matrix.gcc }} + export CXX=/usr/bin/g++-${{ matrix.gcc }} + export CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }} # - name: Configure CMake build # run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES From 4eb72e7fdb5abab1e58ce39d0d38b3b1d9ab3fe9 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 18:54:42 +0300 Subject: [PATCH 19/74] ci: add cmake config --- .github/workflows/ubuntu.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 500b2d1..6ada5f8 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -19,7 +19,7 @@ jobs: include: - os: ubuntu-24.04 cuda: "12.8" - gcc: 14.2 + gcc: 14 env: build_dir: "build" config: "Release" @@ -39,19 +39,19 @@ jobs: run: source ./scripts/install_cuda_ubuntu.sh shell: bash - - name: Install and configure GCC and GXX + # sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} + - name: Export gcc and g++ variables run: | - sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} export СС=/usr/bin/gcc-${{ matrix.gcc }} export CXX=/usr/bin/g++-${{ matrix.gcc }} export CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }} - # - name: Configure CMake build - # run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES + - name: Configure CMake build + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES - # - name: Build library sources - # working-directory: ${{ env.build_dir }} - # run: cmake --build . --target all --verbose -j `nproc` + - name: Build library sources + working-directory: ${{ env.build_dir }} + run: cmake --build . --target all --verbose -j `nproc` # - name: Run unit-tests (sequential backend) # working-directory: ${{ env.build_dir }} From 93d3c08059d746998f9cf481c7a9498b5acdb78b Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 18:55:57 +0300 Subject: [PATCH 20/74] fix: add correct version of gcc --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 6ada5f8..c26f975 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -19,7 +19,7 @@ jobs: include: - os: ubuntu-24.04 cuda: "12.8" - gcc: 14 + gcc: 13 env: build_dir: "build" config: "Release" From 6143a65e543b8b6373cf08f3076de372c5c240cc Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 19:07:10 +0300 Subject: [PATCH 21/74] fix: correct env variables export --- .github/workflows/ubuntu.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index c26f975..d577ca4 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -42,9 +42,9 @@ jobs: # sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} - name: Export gcc and g++ variables run: | - export СС=/usr/bin/gcc-${{ matrix.gcc }} - export CXX=/usr/bin/g++-${{ matrix.gcc }} - export CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }} + echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - name: Configure CMake build run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES From 7e57342bf144628e0d5d50ada078794d8c862b50 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 20:02:00 +0300 Subject: [PATCH 22/74] fix: add cudacxx flag to cmake --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d577ca4..936c5d4 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -47,7 +47,7 @@ jobs: echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES -CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc - name: Build library sources working-directory: ${{ env.build_dir }} From 1bc181163760372cf692ee458f6e72336c0723f5 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 20:13:25 +0300 Subject: [PATCH 23/74] fix: add cuda architecture flag in cmake --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 936c5d4..7ba59c7 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -47,7 +47,7 @@ jobs: echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES -CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES -D CMAKE_CUDA_ARCHITECTURES=native - name: Build library sources working-directory: ${{ env.build_dir }} From db88a3f0a28687b0cd3825ea6fb4b022753e83a1 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Mar 2025 20:25:14 +0300 Subject: [PATCH 24/74] fix: add cudacxx env variable --- .github/workflows/ubuntu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 7ba59c7..6e683c1 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -45,6 +45,7 @@ jobs: echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES -D CMAKE_CUDA_ARCHITECTURES=native From 66803695d81ee930378f44a77badd3bd1b1f1fb9 Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 16:57:34 +0300 Subject: [PATCH 25/74] ci: delete cuda architecture flag --- .github/workflows/ubuntu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 6e683c1..bf98193 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive # - uses: actions/setup-python@v5 # with: # python-version: '3.7' @@ -48,7 +48,7 @@ jobs: echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES -D CMAKE_CUDA_ARCHITECTURES=native + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES - name: Build library sources working-directory: ${{ env.build_dir }} From 2cd33f1814533a32dc3c0597464a170d724249db Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 17:12:31 +0300 Subject: [PATCH 26/74] ci: add unit and regression tests --- .github/workflows/ubuntu.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index bf98193..8821339 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -54,22 +54,22 @@ jobs: working-directory: ${{ env.build_dir }} run: cmake --build . --target all --verbose -j `nproc` - # - name: Run unit-tests (sequential backend) - # working-directory: ${{ env.build_dir }} - # run: bash scripts/run_tests_fallback.sh - # shell: bash + - name: Run unit-tests (sequential backend) + working-directory: ${{ env.build_dir }} + run: bash scripts/run_tests_fallback.sh + shell: bash - # - name: Run regression-tests (sequential backend) - # working-directory: ${{ env.build_dir }}/python - # run: bash run_tests.sh - # shell: bash + - name: Run regression-tests (sequential backend) + working-directory: ${{ env.build_dir }}/python + run: bash run_tests.sh + shell: bash - # - name: Prepare upload binary - # shell: bash - # run: tar cfz ${{ env.artifact }} ${{ env.build_dir }} + - name: Prepare upload binary + shell: bash + run: tar cfz ${{ env.artifact }} ${{ env.build_dir }} - # - name: Upload binary - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.artifact }} - # path: ${{ env.artifact }} \ No newline at end of file + - name: Upload binary + uses: actions/upload-artifact@v4 + with: + name: ${{ env.artifact }} + path: ${{ env.artifact }} From 86e50673122b46ebabb2a44a86a20383b4432fee Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 17:49:07 +0300 Subject: [PATCH 27/74] ci: change working directory --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 8821339..3f79427 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -55,7 +55,7 @@ jobs: run: cmake --build . --target all --verbose -j `nproc` - name: Run unit-tests (sequential backend) - working-directory: ${{ env.build_dir }} + # working-directory: ${{ env.build_dir }} run: bash scripts/run_tests_fallback.sh shell: bash From ea7798014733d5c5c0776419cc085222ad1d4126 Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 17:56:42 +0300 Subject: [PATCH 28/74] ci: change the way of running scripts --- .github/workflows/ubuntu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 3f79427..591c25e 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -55,8 +55,8 @@ jobs: run: cmake --build . --target all --verbose -j `nproc` - name: Run unit-tests (sequential backend) - # working-directory: ${{ env.build_dir }} - run: bash scripts/run_tests_fallback.sh + working-directory: ${{ env.build_dir }} + run: bash ../scripts/run_tests_fallback.sh shell: bash - name: Run regression-tests (sequential backend) From 300a36aba7660526c9e19a0a10d45e99d8e4647b Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 18:24:08 +0300 Subject: [PATCH 29/74] ci: add python working directory toregression tests --- .github/workflows/ubuntu.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 591c25e..42de5f0 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -60,8 +60,8 @@ jobs: shell: bash - name: Run regression-tests (sequential backend) - working-directory: ${{ env.build_dir }}/python - run: bash run_tests.sh + working-directory: python + run: bash ./run_tests.sh shell: bash - name: Prepare upload binary From 850ab4ac5cd0d2794ea80f0c06505ec28a8d7ba9 Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 20:45:38 +0300 Subject: [PATCH 30/74] ci: call tests from build directory --- .github/workflows/ubuntu.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 42de5f0..eb7a4f3 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -54,14 +54,14 @@ jobs: working-directory: ${{ env.build_dir }} run: cmake --build . --target all --verbose -j `nproc` - - name: Run unit-tests (sequential backend) + - name: Run unit-tests working-directory: ${{ env.build_dir }} - run: bash ../scripts/run_tests_fallback.sh + run: bash scripts/run_tests_fallback.sh shell: bash - - name: Run regression-tests (sequential backend) - working-directory: python - run: bash ./run_tests.sh + - name: Run regression-tests + working-directory: ${{ env.build_dir }}/python + run: bash run_tests.sh shell: bash - name: Prepare upload binary From 934aa5c6968a2768c2aa00cdcecc3b53eae7a8cd Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 21:00:34 +0300 Subject: [PATCH 31/74] ci: turn on the flag with tests --- .github/workflows/ubuntu.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index eb7a4f3..3a9eb42 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -48,7 +48,7 @@ jobs: echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - name: Build library sources working-directory: ${{ env.build_dir }} diff --git a/README.md b/README.md index 160a767..e0bcb23 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ $ bash ./scripts/run_tests_all.sh By default, the following cmake options will be automatically enabled: - `CUBOOL_WITH_CUDA` - build library with actual cuda backend -- `CUBOOL_WITH_SEQUENTIAL` - build library witt cpu based backend +- `CUBOOL_WITH_SEQUENTIAL` - build library with cpu based backend - `CUBOOL_WITH_TESTS` - build library unit-tests collection > Note: in order to provide correct GCC version for CUDA sources compiling, From 749cde1652dd2130711a712bcb42a5ec65c52f8c Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 21:13:05 +0300 Subject: [PATCH 32/74] ci: comment build stage --- .github/workflows/ubuntu.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 3a9eb42..3a0e1bc 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -28,16 +28,16 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: recursive + submodules: true # - uses: actions/setup-python@v5 # with: # python-version: '3.7' - - name: Install CUDA - env: - cuda: ${{ matrix.cuda }} - run: source ./scripts/install_cuda_ubuntu.sh - shell: bash + # - name: Install CUDA + # env: + # cuda: ${{ matrix.cuda }} + # run: source ./scripts/install_cuda_ubuntu.sh + # shell: bash # sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} - name: Export gcc and g++ variables @@ -48,21 +48,21 @@ jobs: echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES - name: Build library sources working-directory: ${{ env.build_dir }} run: cmake --build . --target all --verbose -j `nproc` - - name: Run unit-tests - working-directory: ${{ env.build_dir }} - run: bash scripts/run_tests_fallback.sh - shell: bash + # - name: Run unit-tests + # working-directory: ${{ env.build_dir }} + # run: bash scripts/run_tests_fallback.sh + # shell: bash - - name: Run regression-tests - working-directory: ${{ env.build_dir }}/python - run: bash run_tests.sh - shell: bash + # - name: Run regression-tests + # working-directory: ${{ env.build_dir }}/python + # run: bash run_tests.sh + # shell: bash - name: Prepare upload binary shell: bash From 8130fed85b3d62730f80bae0bcdc3d0dd19741f6 Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 20 Mar 2025 21:37:57 +0300 Subject: [PATCH 33/74] fix(cmake): uncomment test build --- .github/workflows/ubuntu.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 3a0e1bc..f54d5c4 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive # - uses: actions/setup-python@v5 # with: # python-version: '3.7' @@ -48,21 +48,21 @@ jobs: echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=YES + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - name: Build library sources working-directory: ${{ env.build_dir }} run: cmake --build . --target all --verbose -j `nproc` - # - name: Run unit-tests - # working-directory: ${{ env.build_dir }} - # run: bash scripts/run_tests_fallback.sh - # shell: bash + - name: Run unit-tests + working-directory: ${{ env.build_dir }} + run: bash scripts/run_tests_fallback.sh + shell: bash - # - name: Run regression-tests - # working-directory: ${{ env.build_dir }}/python - # run: bash run_tests.sh - # shell: bash + - name: Run regression-tests + working-directory: ${{ env.build_dir }}/python + run: bash run_tests.sh + shell: bash - name: Prepare upload binary shell: bash From ce82e3c26ab14c5ded0999c388e64882aa433aaa Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 10 Apr 2025 19:36:43 +0300 Subject: [PATCH 34/74] ci: add job with test in pipeline --- .github/workflows/ubuntu.yml | 77 ++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index f54d5c4..bfd12c0 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -9,10 +9,15 @@ on: branches: [ master ] workflow_dispatch: +env: + build_dir: "build" + config: "Release" + artifact: "cubool-ubuntu-build.tar.xz" + jobs: build: name: Build ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} - runs-on: self-hosted + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: @@ -20,50 +25,37 @@ jobs: - os: ubuntu-24.04 cuda: "12.8" gcc: 13 - env: - build_dir: "build" - config: "Release" - artifact: "cubool-ubuntu-build.tar.xz" steps: - uses: actions/checkout@v4 with: submodules: recursive - # - uses: actions/setup-python@v5 - # with: - # python-version: '3.7' - # - name: Install CUDA - # env: - # cuda: ${{ matrix.cuda }} - # run: source ./scripts/install_cuda_ubuntu.sh - # shell: bash + - uses: actions/setup-python@v5 + with: + python-version: '3.7' + + - name: Install CUDA + env: + cuda: ${{ matrix.cuda }} + run: source ./scripts/install_cuda_ubuntu.sh + shell: bash - # sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} - name: Export gcc and g++ variables run: | + sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV +# echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - - name: Build library sources + - name: Build librarnamey sources working-directory: ${{ env.build_dir }} run: cmake --build . --target all --verbose -j `nproc` - - name: Run unit-tests - working-directory: ${{ env.build_dir }} - run: bash scripts/run_tests_fallback.sh - shell: bash - - - name: Run regression-tests - working-directory: ${{ env.build_dir }}/python - run: bash run_tests.sh - shell: bash - - name: Prepare upload binary shell: bash run: tar cfz ${{ env.artifact }} ${{ env.build_dir }} @@ -73,3 +65,36 @@ jobs: with: name: ${{ env.artifact }} path: ${{ env.artifact }} + + + test: + name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + runs-on: self-hosted + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + cuda: "12.8" + gcc: 13 + + steps: + - name: Download binary artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.artifact }} + + - name: Unarchive artifact + run: | + tar xzf ${{ env.artifact }} + rm ${{ env.artifact }} + + - name: Run unit-tests + working-directory: ${{ env.build_dir }} + run: bash scripts/run_tests_fallback.sh + shell: bash + + - name: Run regression-tests + working-directory: ${{ env.build_dir }}/python + run: bash run_tests.sh + shell: bash From 76cebaa542499704cebe79059b213d1a7fb0adea Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 10 Apr 2025 19:40:53 +0300 Subject: [PATCH 35/74] fix: change python version --- .github/workflows/ubuntu.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index bfd12c0..2377c1f 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -33,7 +33,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: '3.7' + python-version: '3.12' - name: Install CUDA env: @@ -69,6 +69,7 @@ jobs: test: name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + needs: build runs-on: self-hosted strategy: fail-fast: false From d7c00887e83e834f3d2ee9f487b672477a21b213 Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 10 Apr 2025 19:44:30 +0300 Subject: [PATCH 36/74] ci: add cudacxx env variable --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 2377c1f..5c2a558 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -47,7 +47,7 @@ jobs: echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV -# echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV + echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON From aa64a88a1673e45dab962330855a759502667742 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 21 Apr 2025 12:42:08 +0300 Subject: [PATCH 37/74] ci: add separate pipeline for self-hosted --- .github/workflows/self-hosted.yml | 79 +++++++++++++++++++++++++++++++ .github/workflows/ubuntu.yml | 65 +++++++------------------ 2 files changed, 97 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/self-hosted.yml diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml new file mode 100644 index 0000000..6651d6d --- /dev/null +++ b/.github/workflows/self-hosted.yml @@ -0,0 +1,79 @@ +# Original script from https://github.com/ptheywood/cuda-cmake-github-actions + +name: Ubuntu + +on: + push: + branches: [ master, self-hosted-runner ] + pull_request: + branches: [ master ] + workflow_dispatch: + +env: + build_dir: "build" + config: "Release" + +jobs: + build: + name: Build ${{ matrix.self-hosted }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + runs-on: ${{ matrix.self-hosted }} + strategy: + fail-fast: false + matrix: + include: + - self-hosted: ubuntu-24.04 + cuda: "12.8" + gcc: 13 + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install CUDA + env: + cuda: ${{ matrix.cuda }} + run: source ./scripts/install_cuda_ubuntu.sh + shell: bash + + - name: Export gcc and g++ variables + run: | + sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} + echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV + + - name: Configure CMake build + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON + + - name: Build library sources + working-directory: ${{ env.build_dir }} + run: cmake --build . --target all --verbose -j `nproc` + + test: + name: Test ${{ matrix.self-hosted }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + needs: build + runs-on: ${{ matrix.self-hosted }} + strategy: + fail-fast: false + matrix: + include: + - self-hosted: ubuntu-24.04 + cuda: "12.8" + gcc: 13 + + steps: + - name: Run unit-tests + working-directory: ${{ env.build_dir }} + run: bash scripts/run_tests_fallback.sh + shell: bash + + - name: Run regression-tests + working-directory: ${{ env.build_dir }}/python + run: bash run_tests.sh + shell: bash diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 5c2a558..7bd0334 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -9,11 +9,6 @@ on: branches: [ master ] workflow_dispatch: -env: - build_dir: "build" - config: "Release" - artifact: "cubool-ubuntu-build.tar.xz" - jobs: build: name: Build ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} @@ -22,9 +17,13 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-24.04 - cuda: "12.8" - gcc: 13 + - os: [ubuntu-18.04, ubuntu-24.04] + cuda: ["10.1", "12.8"] + gcc: [8, 13] + env: + build_dir: "build" + config: "Release" + artifact: "cubool-${{ matrix.os }}-build.tar.xz" steps: - uses: actions/checkout@v4 @@ -36,12 +35,18 @@ jobs: python-version: '3.12' - name: Install CUDA - env: - cuda: ${{ matrix.cuda }} - run: source ./scripts/install_cuda_ubuntu.sh + run: | + source ./scripts/install_cuda_ubuntu.sh + if [[ $? -eq 0 ]]; then + # Set paths for subsequent steps, using ${CUDA_PATH} + echo "Adding CUDA to CUDA_PATH, PATH and LD_LIBRARY_PATH" + echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV + echo "${CUDA_PATH}/bin" >> $GITHUB_PATH + echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + fi shell: bash - - name: Export gcc and g++ variables + - name: Install and configure GCC and GXX run: | sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV @@ -52,7 +57,7 @@ jobs: - name: Configure CMake build run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - - name: Build librarnamey sources + - name: Build library sources working-directory: ${{ env.build_dir }} run: cmake --build . --target all --verbose -j `nproc` @@ -65,37 +70,3 @@ jobs: with: name: ${{ env.artifact }} path: ${{ env.artifact }} - - - test: - name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} - needs: build - runs-on: self-hosted - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-24.04 - cuda: "12.8" - gcc: 13 - - steps: - - name: Download binary artifact - uses: actions/download-artifact@v4 - with: - name: ${{ env.artifact }} - - - name: Unarchive artifact - run: | - tar xzf ${{ env.artifact }} - rm ${{ env.artifact }} - - - name: Run unit-tests - working-directory: ${{ env.build_dir }} - run: bash scripts/run_tests_fallback.sh - shell: bash - - - name: Run regression-tests - working-directory: ${{ env.build_dir }}/python - run: bash run_tests.sh - shell: bash From b4167d92727384064cad0b5e2803e2d901af7599 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 21 Apr 2025 13:33:46 +0300 Subject: [PATCH 38/74] ci: add correct platform --- .github/workflows/self-hosted.yml | 14 +++++++------- .github/workflows/ubuntu.yml | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 6651d6d..21b5dc5 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -1,6 +1,6 @@ # Original script from https://github.com/ptheywood/cuda-cmake-github-actions -name: Ubuntu +name: Self-Hosted on: push: @@ -15,13 +15,13 @@ env: jobs: build: - name: Build ${{ matrix.self-hosted }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} - runs-on: ${{ matrix.self-hosted }} + name: Build ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + runs-on: self-hosted strategy: fail-fast: false matrix: include: - - self-hosted: ubuntu-24.04 + - os: ubuntu-24.04 cuda: "12.8" gcc: 13 @@ -56,14 +56,14 @@ jobs: run: cmake --build . --target all --verbose -j `nproc` test: - name: Test ${{ matrix.self-hosted }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} needs: build - runs-on: ${{ matrix.self-hosted }} + runs-on: self-hosted strategy: fail-fast: false matrix: include: - - self-hosted: ubuntu-24.04 + - os: ubuntu-24.04 cuda: "12.8" gcc: 13 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 7bd0334..a9a6932 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -4,7 +4,7 @@ name: Ubuntu on: push: - branches: [ master, self-hosted-runner ] + branches: [ master ] pull_request: branches: [ master ] workflow_dispatch: @@ -17,24 +17,25 @@ jobs: fail-fast: false matrix: include: - - os: [ubuntu-18.04, ubuntu-24.04] - cuda: ["10.1", "12.8"] - gcc: [8, 13] + - os: ubuntu-18.04 + cuda: "10.1" + gcc: 8 env: build_dir: "build" config: "Release" - artifact: "cubool-${{ matrix.os }}-build.tar.xz" + artifact: "cubool-ubuntu-build.tar.xz" steps: - uses: actions/checkout@v4 with: - submodules: recursive - + submodules: true - uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install CUDA + env: + cuda: ${{ matrix.cuda }} run: | source ./scripts/install_cuda_ubuntu.sh if [[ $? -eq 0 ]]; then @@ -52,7 +53,6 @@ jobs: echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON From 071309e57dc80ba5e597957c83640af5ecc4d666 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 21 Apr 2025 22:47:32 +0300 Subject: [PATCH 39/74] ci: add environment variables in test stage --- .github/workflows/self-hosted.yml | 16 ++++------------ .github/workflows/ubuntu.yml | 4 +--- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 21b5dc5..12f7876 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -30,19 +30,11 @@ jobs: with: submodules: recursive - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install CUDA - env: - cuda: ${{ matrix.cuda }} - run: source ./scripts/install_cuda_ubuntu.sh - shell: bash - - - name: Export gcc and g++ variables + - name: Set environment variables run: | - sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} + echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV + echo "${CUDA_PATH}/bin" >> $GITHUB_PATH + echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH} >> $GITHUB_ENV echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index a9a6932..cadc199 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -4,7 +4,7 @@ name: Ubuntu on: push: - branches: [ master ] + branches: [ master, self-hosted-runner ] pull_request: branches: [ master ] workflow_dispatch: @@ -34,8 +34,6 @@ jobs: python-version: '3.12' - name: Install CUDA - env: - cuda: ${{ matrix.cuda }} run: | source ./scripts/install_cuda_ubuntu.sh if [[ $? -eq 0 ]]; then From fc4296deb8ccba182ec894ab4b0453b382110497 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 21 Apr 2025 23:09:38 +0300 Subject: [PATCH 40/74] fix: delete extra quotes --- .github/workflows/self-hosted.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 12f7876..cd60f9e 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -34,7 +34,7 @@ jobs: run: | echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV echo "${CUDA_PATH}/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH} >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV From f98ea6c8fdff23f732e38e0dddf4e78b6dfb1c72 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 21 Apr 2025 23:41:22 +0300 Subject: [PATCH 41/74] ci: add error status of pipeline --- .github/workflows/self-hosted.yml | 6 ++++++ .github/workflows/ubuntu.yml | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index cd60f9e..0ec6df7 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -61,11 +61,17 @@ jobs: steps: - name: Run unit-tests + id: unit-test working-directory: ${{ env.build_dir }} run: bash scripts/run_tests_fallback.sh shell: bash - name: Run regression-tests + id: regression-test working-directory: ${{ env.build_dir }}/python run: bash run_tests.sh shell: bash + + - name: Return test code + if: ${{ steps.unit-test.outcome == 'failure' || steps.regression-test.outcome == 'failure' }} + run: exit 1 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index cadc199..d2c25b9 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -4,7 +4,7 @@ name: Ubuntu on: push: - branches: [ master, self-hosted-runner ] + branches: [ master, self-hosted-runnernner ] pull_request: branches: [ master ] workflow_dispatch: @@ -17,9 +17,9 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-18.04 - cuda: "10.1" - gcc: 8 + - os: ubuntu-24.04 + cuda: "12.8" + gcc: 13 env: build_dir: "build" config: "Release" From 374e060804d690623dbc555721c394ba10193a34 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 23 Apr 2025 17:55:56 +0300 Subject: [PATCH 42/74] ci: add test script start up --- .github/workflows/self-hosted.yml | 14 +++----------- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 0ec6df7..c3b1ee8 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -61,17 +61,9 @@ jobs: steps: - name: Run unit-tests - id: unit-test - working-directory: ${{ env.build_dir }} - run: bash scripts/run_tests_fallback.sh - shell: bash + working-directory: ${{ env.build_dir }}/scripts + run: chmod +x scripts/run_tests_fallback.sh && ./scripts/run_tests_fallback.sh - name: Run regression-tests - id: regression-test working-directory: ${{ env.build_dir }}/python - run: bash run_tests.sh - shell: bash - - - name: Return test code - if: ${{ steps.unit-test.outcome == 'failure' || steps.regression-test.outcome == 'failure' }} - run: exit 1 + run: chmod +x run_tests.sh && ./run_tests.sh diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d2c25b9..5766fdd 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -4,7 +4,7 @@ name: Ubuntu on: push: - branches: [ master, self-hosted-runnernner ] + branches: [ master, self-hosted-runner ] pull_request: branches: [ master ] workflow_dispatch: From 176bf18f1a176dabc093d933e068294371e5bfd1 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 23 Apr 2025 18:40:08 +0300 Subject: [PATCH 43/74] fix: change working directory --- .github/workflows/self-hosted.yml | 2 +- .github/workflows/ubuntu.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index c3b1ee8..fc4e756 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -61,7 +61,7 @@ jobs: steps: - name: Run unit-tests - working-directory: ${{ env.build_dir }}/scripts + working-directory: ${{ env.build_dir }} run: chmod +x scripts/run_tests_fallback.sh && ./scripts/run_tests_fallback.sh - name: Run regression-tests diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 5766fdd..9c622d6 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -29,11 +29,14 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + - uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install CUDA + env: + cuda: ${{ matrix.cuda }} run: | source ./scripts/install_cuda_ubuntu.sh if [[ $? -eq 0 ]]; then From 1660aabffe1e64ca30d7c763f5e99a8abb912a0f Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 24 Apr 2025 12:50:01 +0300 Subject: [PATCH 44/74] ci: change way of test start up --- .github/workflows/self-hosted.yml | 8 ++++++-- .github/workflows/ubuntu.yml | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index fc4e756..5539e15 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -62,8 +62,12 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} - run: chmod +x scripts/run_tests_fallback.sh && ./scripts/run_tests_fallback.sh + run: chmod +x scripts/run_tests_all.sh && ./scripts/run_tests_all.sh - name: Run regression-tests working-directory: ${{ env.build_dir }}/python - run: chmod +x run_tests.sh && ./run_tests.sh + run: | + echo "PYTHONPATH=`pwd`:$PYTHONPATH" >> $GITHUB_ENV + cd tests + python3 -m unittest discover -v + # chmod +x run_tests.sh && ./run_tests.sh diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9c622d6..92ff42e 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -17,9 +17,9 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-24.04 - cuda: "12.8" - gcc: 13 + - os: ubuntu-20.04 + cuda: "10.1" + gcc: 8 env: build_dir: "build" config: "Release" From 1e156a8fce2c00f49bc542cd0fd800a8eec53b33 Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 24 Apr 2025 20:57:43 +0300 Subject: [PATCH 45/74] ci: change tests run --- .github/workflows/self-hosted.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 5539e15..642a8e8 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -62,7 +62,7 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} - run: chmod +x scripts/run_tests_all.sh && ./scripts/run_tests_all.sh + run: chmod +x scripts/run_tests_fallback.sh && ./scripts/run_tests_fallback.sh - name: Run regression-tests working-directory: ${{ env.build_dir }}/python diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 92ff42e..55302b8 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-22.04 cuda: "10.1" gcc: 8 env: From 0101c7e8f087e86e2cb9ac9a7c593b7c857698de Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 24 Apr 2025 22:39:25 +0300 Subject: [PATCH 46/74] ci: add check for failed tests --- .github/workflows/self-hosted.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 642a8e8..1c25c5d 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -46,7 +46,7 @@ jobs: - name: Build library sources working-directory: ${{ env.build_dir }} run: cmake --build . --target all --verbose -j `nproc` - + test: name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} needs: build @@ -62,12 +62,18 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} - run: chmod +x scripts/run_tests_fallback.sh && ./scripts/run_tests_fallback.sh + run: | + output=$(chmod +x scripts/run_tests_fallback.sh && ./scripts/run_tests_fallback.sh) + echo $output + if echo "$output" | grep -qE "FAILED|ERROR"; then + exit 1 + fi - name: Run regression-tests working-directory: ${{ env.build_dir }}/python run: | - echo "PYTHONPATH=`pwd`:$PYTHONPATH" >> $GITHUB_ENV - cd tests - python3 -m unittest discover -v - # chmod +x run_tests.sh && ./run_tests.sh + output=$(chmod +x run_tests.sh && ./run_tests.sh) + echo $output + if echo "$output" | grep -qE "FAILED|ERROR"; then + exit 1 + fi From e0ce1cb9bb2f7f2ab09c2eea352b8077f77ff29f Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 24 Apr 2025 23:11:15 +0300 Subject: [PATCH 47/74] ci: add newlines in output --- .github/workflows/self-hosted.yml | 12 +++++------- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 1c25c5d..1386d73 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -62,18 +62,16 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} - run: | - output=$(chmod +x scripts/run_tests_fallback.sh && ./scripts/run_tests_fallback.sh) - echo $output - if echo "$output" | grep -qE "FAILED|ERROR"; then + run: + chmod +x scripts/run_tests_fallback.sh + if ./scripts/run_tests_fallback.sh | tee /dev/tty | grep -qE "FAILED|ERROR"; then exit 1 fi - name: Run regression-tests working-directory: ${{ env.build_dir }}/python run: | - output=$(chmod +x run_tests.sh && ./run_tests.sh) - echo $output - if echo "$output" | grep -qE "FAILED|ERROR"; then + chmod +x run_tests.sh + if ./run_tests.sh | tee /dev/tty | grep -qE "FAILED|ERROR"; then exit 1 fi diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 55302b8..4bbc9ca 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -18,7 +18,7 @@ jobs: matrix: include: - os: ubuntu-22.04 - cuda: "10.1" + cuda: "11.7" gcc: 8 env: build_dir: "build" From e3416cc6db2f9bbaaad7cf43ae243d1804ba8853 Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 24 Apr 2025 23:19:37 +0300 Subject: [PATCH 48/74] fix: add minimal version of gcc in ubuntu --- .github/workflows/self-hosted.yml | 2 +- .github/workflows/ubuntu.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 1386d73..e1ea7c6 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -62,7 +62,7 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} - run: + run: | chmod +x scripts/run_tests_fallback.sh if ./scripts/run_tests_fallback.sh | tee /dev/tty | grep -qE "FAILED|ERROR"; then exit 1 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 4bbc9ca..6eba06f 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -18,8 +18,8 @@ jobs: matrix: include: - os: ubuntu-22.04 - cuda: "11.7" - gcc: 8 + cuda: "11.6" + gcc: 11 env: build_dir: "build" config: "Release" From faf132daea6cd0b2ba07558557668903c3f512ff Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 25 Apr 2025 01:32:10 +0300 Subject: [PATCH 49/74] fix: change tty --- .github/workflows/self-hosted.yml | 6 ++++-- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index e1ea7c6..babc75e 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -64,7 +64,8 @@ jobs: working-directory: ${{ env.build_dir }} run: | chmod +x scripts/run_tests_fallback.sh - if ./scripts/run_tests_fallback.sh | tee /dev/tty | grep -qE "FAILED|ERROR"; then + tty=$(readlink /proc/$$/fd/2) + if ./scripts/run_tests_fallback.sh | tee $tty | grep -qE "FAILED|ERROR"; then exit 1 fi @@ -72,6 +73,7 @@ jobs: working-directory: ${{ env.build_dir }}/python run: | chmod +x run_tests.sh - if ./run_tests.sh | tee /dev/tty | grep -qE "FAILED|ERROR"; then + tty=$(readlink /proc/$$/fd/2) + if ./run_tests.sh | tee $tty | grep -qE "FAILED|ERROR"; then exit 1 fi diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 6eba06f..8d92764 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -18,7 +18,7 @@ jobs: matrix: include: - os: ubuntu-22.04 - cuda: "11.6" + cuda: "11.7" gcc: 11 env: build_dir: "build" From fbab4039c03c65df4da09f8f7ba68e8418838d64 Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 25 Apr 2025 02:11:29 +0300 Subject: [PATCH 50/74] ci: use tee to generate pipeline --- .github/workflows/self-hosted.yml | 8 ++++---- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index babc75e..0b96bc7 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -64,8 +64,8 @@ jobs: working-directory: ${{ env.build_dir }} run: | chmod +x scripts/run_tests_fallback.sh - tty=$(readlink /proc/$$/fd/2) - if ./scripts/run_tests_fallback.sh | tee $tty | grep -qE "FAILED|ERROR"; then + ./scripts/run_tests_fallback.sh | tee >(grep -E "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) + if [ $HAS_ERRORS == true ]; then exit 1 fi @@ -73,7 +73,7 @@ jobs: working-directory: ${{ env.build_dir }}/python run: | chmod +x run_tests.sh - tty=$(readlink /proc/$$/fd/2) - if ./run_tests.sh | tee $tty | grep -qE "FAILED|ERROR"; then + ./run_tests.sh | tee >(grep -E "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) + if [ $HAS_ERRORS == true ]; then exit 1 fi diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 8d92764..d590eab 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -19,7 +19,7 @@ jobs: include: - os: ubuntu-22.04 cuda: "11.7" - gcc: 11 + gcc: 10 env: build_dir: "build" config: "Release" From 7431fb53990c82e31c864030eada1afcd0ac5a75 Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 25 Apr 2025 02:37:44 +0300 Subject: [PATCH 51/74] ci: add double brackets --- .github/workflows/self-hosted.yml | 8 ++++---- .github/workflows/ubuntu.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 0b96bc7..e46eb5a 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -64,8 +64,8 @@ jobs: working-directory: ${{ env.build_dir }} run: | chmod +x scripts/run_tests_fallback.sh - ./scripts/run_tests_fallback.sh | tee >(grep -E "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) - if [ $HAS_ERRORS == true ]; then + ./scripts/run_tests_fallback.sh | tee >(grep -qE "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) + if [[ $HAS_ERRORS == "true" ]]; then exit 1 fi @@ -73,7 +73,7 @@ jobs: working-directory: ${{ env.build_dir }}/python run: | chmod +x run_tests.sh - ./run_tests.sh | tee >(grep -E "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) - if [ $HAS_ERRORS == true ]; then + ./run_tests.sh | tee >(grep -qE "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) + if [[ $HAS_ERRORS == "true" ]]; then exit 1 fi diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d590eab..54871c9 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -19,7 +19,7 @@ jobs: include: - os: ubuntu-22.04 cuda: "11.7" - gcc: 10 + gcc: 9 env: build_dir: "build" config: "Release" From d80229c566bacd57827d712f6bef2d51e0e17858 Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 25 Apr 2025 03:05:12 +0300 Subject: [PATCH 52/74] test: add test print --- .github/workflows/self-hosted.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index e46eb5a..58f423a 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -66,6 +66,7 @@ jobs: chmod +x scripts/run_tests_fallback.sh ./scripts/run_tests_fallback.sh | tee >(grep -qE "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) if [[ $HAS_ERRORS == "true" ]]; then + echo Test exit 1 fi From 78a1ab78e392b7953ec2ce35a733ed252be07ad5 Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 25 Apr 2025 03:26:04 +0300 Subject: [PATCH 53/74] ci: delete unnecessary print --- .github/workflows/self-hosted.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 58f423a..e46eb5a 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -66,7 +66,6 @@ jobs: chmod +x scripts/run_tests_fallback.sh ./scripts/run_tests_fallback.sh | tee >(grep -qE "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) if [[ $HAS_ERRORS == "true" ]]; then - echo Test exit 1 fi From 2320e7813588c7cb12bc9bd0ac1dbb8a843c48ec Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 25 Apr 2025 13:12:58 +0300 Subject: [PATCH 54/74] ci: add tests result artifact --- .github/workflows/self-hosted.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index e46eb5a..a3eea7a 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -51,6 +51,9 @@ jobs: name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} needs: build runs-on: self-hosted + env: + unit-test-file: test_fallback.txt + regression-test-file: test_regression.txt strategy: fail-fast: false matrix: @@ -64,16 +67,28 @@ jobs: working-directory: ${{ env.build_dir }} run: | chmod +x scripts/run_tests_fallback.sh - ./scripts/run_tests_fallback.sh | tee >(grep -qE "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) - if [[ $HAS_ERRORS == "true" ]]; then + ./scripts/run_tests_fallback.sh | tee ${{ env.unit-test-file }} + if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then exit 1 fi + - name: Upload unit tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.unit-test-file }} + path: ${{ env.build_dir }}/${{ env.unit-test-file }} + - name: Run regression-tests working-directory: ${{ env.build_dir }}/python run: | chmod +x run_tests.sh - ./run_tests.sh | tee >(grep -qE "FAILED|ERROR" && echo "HAS_ERRORS=true" >> $GITHUB_ENV) - if [[ $HAS_ERRORS == "true" ]]; then + ./run_tests.sh | tee ${{ env.regression-test-file }} + if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then exit 1 fi + + - name: Upload regression tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.regression-test-file }} + path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} From 7d9a039224c39098501f450d2b2a0bbf43fbc0e8 Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 25 Apr 2025 13:28:24 +0300 Subject: [PATCH 55/74] ci: add check for result as separate step --- .github/workflows/self-hosted.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index a3eea7a..ad64773 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -68,27 +68,35 @@ jobs: run: | chmod +x scripts/run_tests_fallback.sh ./scripts/run_tests_fallback.sh | tee ${{ env.unit-test-file }} - if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then - exit 1 - fi - name: Upload unit tests resutls uses: actions/upload-artifact@v4 with: name: ${{ env.unit-test-file }} path: ${{ env.build_dir }}/${{ env.unit-test-file }} + + - name: Check for unit tests results + working-directory: ${{ env.build_dir }} + run: | + if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then + exit 1 + fi - name: Run regression-tests working-directory: ${{ env.build_dir }}/python run: | chmod +x run_tests.sh ./run_tests.sh | tee ${{ env.regression-test-file }} - if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then - exit 1 - fi - name: Upload regression tests resutls uses: actions/upload-artifact@v4 with: name: ${{ env.regression-test-file }} path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} + + - name: Check for regression tests results + working-directory: ${{ env.build_dir }}/python + run: | + if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then + exit 1 + fi From c547aa0e139a8ac8bb713dd55f10e387c3c3bc5a Mon Sep 17 00:00:00 2001 From: Kostya Date: Sun, 4 May 2025 00:25:21 +0300 Subject: [PATCH 56/74] test: check for workspace variable --- .github/workflows/self-hosted.yml | 134 +++++++++++++++--------------- 1 file changed, 68 insertions(+), 66 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index ad64773..364bf4e 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -1,5 +1,3 @@ -# Original script from https://github.com/ptheywood/cuda-cmake-github-actions - name: Self-Hosted on: @@ -26,77 +24,81 @@ jobs: gcc: 13 steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Set environment variables + - name: Cleanup workspace run: | - echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV - echo "${CUDA_PATH}/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV + echo ${{ github.workspace }} - - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON + # - uses: actions/checkout@v4 + # with: + # submodules: recursive - - name: Build library sources - working-directory: ${{ env.build_dir }} - run: cmake --build . --target all --verbose -j `nproc` + # - name: Set environment variables + # run: | + # echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV + # echo "${CUDA_PATH}/bin" >> $GITHUB_PATH + # echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + # echo "CC=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV + # echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + # echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + # echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - test: - name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} - needs: build - runs-on: self-hosted - env: - unit-test-file: test_fallback.txt - regression-test-file: test_regression.txt - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-24.04 - cuda: "12.8" - gcc: 13 + # - name: Configure CMake build + # run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - steps: - - name: Run unit-tests - working-directory: ${{ env.build_dir }} - run: | - chmod +x scripts/run_tests_fallback.sh - ./scripts/run_tests_fallback.sh | tee ${{ env.unit-test-file }} + # - name: Build library sources + # working-directory: ${{ env.build_dir }} + # run: cmake --build . --target all --verbose -j `nproc` + + # test: + # name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + # needs: build + # runs-on: self-hosted + # env: + # unit-test-file: test_fallback.txt + # regression-test-file: test_regression.txt + # strategy: + # fail-fast: false + # matrix: + # include: + # - os: ubuntu-24.04 + # cuda: "12.8" + # gcc: 13 - - name: Upload unit tests resutls - uses: actions/upload-artifact@v4 - with: - name: ${{ env.unit-test-file }} - path: ${{ env.build_dir }}/${{ env.unit-test-file }} + # steps: + # - name: Run unit-tests + # working-directory: ${{ env.build_dir }} + # run: | + # chmod +x scripts/run_tests_fallback.sh + # ./scripts/run_tests_fallback.sh | tee ${{ env.unit-test-file }} + + # - name: Upload unit tests resutls + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.unit-test-file }} + # path: ${{ env.build_dir }}/${{ env.unit-test-file }} - - name: Check for unit tests results - working-directory: ${{ env.build_dir }} - run: | - if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then - exit 1 - fi + # - name: Check for unit tests results + # working-directory: ${{ env.build_dir }} + # run: | + # if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then + # exit 1 + # fi - - name: Run regression-tests - working-directory: ${{ env.build_dir }}/python - run: | - chmod +x run_tests.sh - ./run_tests.sh | tee ${{ env.regression-test-file }} + # - name: Run regression-tests + # working-directory: ${{ env.build_dir }}/python + # run: | + # chmod +x run_tests.sh + # ./run_tests.sh | tee ${{ env.regression-test-file }} - - name: Upload regression tests resutls - uses: actions/upload-artifact@v4 - with: - name: ${{ env.regression-test-file }} - path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} + # - name: Upload regression tests resutls + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.regression-test-file }} + # path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} - - name: Check for regression tests results - working-directory: ${{ env.build_dir }}/python - run: | - if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then - exit 1 - fi + # - name: Check for regression tests results + # working-directory: ${{ env.build_dir }}/python + # run: | + # if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then + # exit 1 + # fi From 66dead93e18c5e82c117d4e64d2f214dc51b818f Mon Sep 17 00:00:00 2001 From: Kostya Date: Sun, 4 May 2025 02:28:59 +0300 Subject: [PATCH 57/74] ci: add clean up of repo --- .github/workflows/self-hosted.yml | 131 +++++++++++++++--------------- 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 364bf4e..21e9cef 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -26,79 +26,80 @@ jobs: steps: - name: Cleanup workspace run: | - echo ${{ github.workspace }} + rm -rf ${{ github.workspace }}/* + rm -rf ${{ github.workspace }}/.* - # - uses: actions/checkout@v4 - # with: - # submodules: recursive + - uses: actions/checkout@v4 + with: + submodules: recursive - # - name: Set environment variables - # run: | - # echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV - # echo "${CUDA_PATH}/bin" >> $GITHUB_PATH - # echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - # echo "CC=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV - # echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - # echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - # echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV + - name: Set environment variables + run: | + echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV + echo "${CUDA_PATH}/bin" >> $GITHUB_PATH + echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + echo "CC=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - # - name: Configure CMake build - # run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON + - name: Configure CMake build + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - # - name: Build library sources - # working-directory: ${{ env.build_dir }} - # run: cmake --build . --target all --verbose -j `nproc` + - name: Build library sources + working-directory: ${{ env.build_dir }} + run: cmake --build . --target all --verbose -j `nproc` - # test: - # name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} - # needs: build - # runs-on: self-hosted - # env: - # unit-test-file: test_fallback.txt - # regression-test-file: test_regression.txt - # strategy: - # fail-fast: false - # matrix: - # include: - # - os: ubuntu-24.04 - # cuda: "12.8" - # gcc: 13 + test: + name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + needs: build + runs-on: self-hosted + env: + unit-test-file: test_fallback.txt + regression-test-file: test_regression.txt + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + cuda: "12.8" + gcc: 13 - # steps: - # - name: Run unit-tests - # working-directory: ${{ env.build_dir }} - # run: | - # chmod +x scripts/run_tests_fallback.sh - # ./scripts/run_tests_fallback.sh | tee ${{ env.unit-test-file }} + steps: + - name: Run unit-tests + working-directory: ${{ env.build_dir }} + run: | + chmod +x scripts/run_tests_fallback.sh + ./scripts/run_tests_fallback.sh | tee ${{ env.unit-test-file }} - # - name: Upload unit tests resutls - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.unit-test-file }} - # path: ${{ env.build_dir }}/${{ env.unit-test-file }} + - name: Upload unit tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.unit-test-file }} + path: ${{ env.build_dir }}/${{ env.unit-test-file }} - # - name: Check for unit tests results - # working-directory: ${{ env.build_dir }} - # run: | - # if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then - # exit 1 - # fi + - name: Check for unit tests results + working-directory: ${{ env.build_dir }} + run: | + if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then + exit 1 + fi - # - name: Run regression-tests - # working-directory: ${{ env.build_dir }}/python - # run: | - # chmod +x run_tests.sh - # ./run_tests.sh | tee ${{ env.regression-test-file }} + - name: Run regression-tests + working-directory: ${{ env.build_dir }}/python + run: | + chmod +x run_tests.sh + ./run_tests.sh | tee ${{ env.regression-test-file }} - # - name: Upload regression tests resutls - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.regression-test-file }} - # path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} + - name: Upload regression tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.regression-test-file }} + path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} - # - name: Check for regression tests results - # working-directory: ${{ env.build_dir }}/python - # run: | - # if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then - # exit 1 - # fi + - name: Check for regression tests results + working-directory: ${{ env.build_dir }}/python + run: | + if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then + exit 1 + fi From 63e2384d931efb66621af241f2622d4fbb2f9f29 Mon Sep 17 00:00:00 2001 From: Kostya Date: Sun, 4 May 2025 03:18:24 +0300 Subject: [PATCH 58/74] ci: add tests on cpu --- .github/workflows/self-hosted-cpu.yaml | 103 ++++++++++++++++++ .../{self-hosted.yml => self-hosted-gpu.yml} | 16 ++- .github/workflows/ubuntu.yml | 2 +- 3 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/self-hosted-cpu.yaml rename .github/workflows/{self-hosted.yml => self-hosted-gpu.yml} (89%) diff --git a/.github/workflows/self-hosted-cpu.yaml b/.github/workflows/self-hosted-cpu.yaml new file mode 100644 index 0000000..b3dd0e1 --- /dev/null +++ b/.github/workflows/self-hosted-cpu.yaml @@ -0,0 +1,103 @@ +name: Self-Hosted-CPU + +on: + push: + branches: [ master, self-hosted-runner ] + pull_request: + branches: [ master ] + workflow_dispatch: + +env: + build_dir: "build" + config: "Release" + +jobs: + build: + name: Build ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + runs-on: self-hosted + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + cuda: "12.8" + gcc: 13 + + steps: + - name: Cleanup workspace + run: | + rm -rf ${{ github.workspace }}/* + rm -rf ${{ github.workspace }}/.* + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set environment variables + run: | + echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV + echo "${CUDA_PATH}/bin" >> $GITHUB_PATH + echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + echo "CC=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV + + - name: Configure CMake build + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON -DCUBOOL_WITH_CUDA=OFF + + - name: Build library sources + working-directory: ${{ env.build_dir }} + run: cmake --build . --target all --verbose -j `nproc` + + test: + name: Test ${{ matrix.cpu }} + needs: build + runs-on: self-hosted + env: + unit-test-file: test_all.txt + regression-test-file: test_regression.txt + strategy: + fail-fast: false + matrix: + include: + - cpu: Intel-Core-i7-4790 + + steps: + - name: Run unit-tests + working-directory: ${{ env.build_dir }} + run: | + chmod +x scripts/run_tests_all.sh + ./scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + + - name: Upload unit tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.unit-test-file }} + path: ${{ env.build_dir }}/${{ env.unit-test-file }} + + - name: Check for unit tests results + working-directory: ${{ env.build_dir }} + run: | + if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then + exit 1 + fi + + - name: Run regression-tests + working-directory: ${{ env.build_dir }}/python + run: | + chmod +x run_tests.sh + ./run_tests.sh | tee ${{ env.regression-test-file }} + + - name: Upload regression tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.regression-test-file }} + path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} + + - name: Check for regression tests results + working-directory: ${{ env.build_dir }}/python + run: | + if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then + exit 1 + fi diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted-gpu.yml similarity index 89% rename from .github/workflows/self-hosted.yml rename to .github/workflows/self-hosted-gpu.yml index 21e9cef..da81265 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted-gpu.yml @@ -1,4 +1,4 @@ -name: Self-Hosted +name: Self-Hosted-GPU on: push: @@ -51,33 +51,31 @@ jobs: run: cmake --build . --target all --verbose -j `nproc` test: - name: Test ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + name: Test ${{ matrix.gpu }} needs: build runs-on: self-hosted env: - unit-test-file: test_fallback.txt + unit-test-file: test_all.txt regression-test-file: test_regression.txt strategy: fail-fast: false matrix: include: - - os: ubuntu-24.04 - cuda: "12.8" - gcc: 13 + - gpu: NVIDIA-GeForce-GT-1030 steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} run: | - chmod +x scripts/run_tests_fallback.sh - ./scripts/run_tests_fallback.sh | tee ${{ env.unit-test-file }} + chmod +x scripts/run_tests_all.sh + ./scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} - name: Upload unit tests resutls uses: actions/upload-artifact@v4 with: name: ${{ env.unit-test-file }} path: ${{ env.build_dir }}/${{ env.unit-test-file }} - + - name: Check for unit tests results working-directory: ${{ env.build_dir }} run: | diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 54871c9..a644c9b 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -51,7 +51,7 @@ jobs: - name: Install and configure GCC and GXX run: | sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} - echo "СС=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV + echo "CC=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV From 3a7049fa460a23c0f4de7add5eb8fd148aa67689 Mon Sep 17 00:00:00 2001 From: Kostya Date: Sun, 4 May 2025 04:17:21 +0300 Subject: [PATCH 59/74] ci: delete run on test branches --- .github/workflows/self-hosted-cpu.yaml | 6 +++--- .github/workflows/self-hosted-gpu.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/self-hosted-cpu.yaml b/.github/workflows/self-hosted-cpu.yaml index b3dd0e1..b560846 100644 --- a/.github/workflows/self-hosted-cpu.yaml +++ b/.github/workflows/self-hosted-cpu.yaml @@ -2,7 +2,7 @@ name: Self-Hosted-CPU on: push: - branches: [ master, self-hosted-runner ] + branches: [ master ] pull_request: branches: [ master ] workflow_dispatch: @@ -79,7 +79,7 @@ jobs: - name: Check for unit tests results working-directory: ${{ env.build_dir }} run: | - if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then + if grep -q "FAILED" ${{ env.unit-test-file }}; then exit 1 fi @@ -98,6 +98,6 @@ jobs: - name: Check for regression tests results working-directory: ${{ env.build_dir }}/python run: | - if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then + if grep -q "FAILED" ${{ env.regression-test-file }}; then exit 1 fi diff --git a/.github/workflows/self-hosted-gpu.yml b/.github/workflows/self-hosted-gpu.yml index da81265..b130906 100644 --- a/.github/workflows/self-hosted-gpu.yml +++ b/.github/workflows/self-hosted-gpu.yml @@ -2,7 +2,7 @@ name: Self-Hosted-GPU on: push: - branches: [ master, self-hosted-runner ] + branches: [ master ] pull_request: branches: [ master ] workflow_dispatch: @@ -79,7 +79,7 @@ jobs: - name: Check for unit tests results working-directory: ${{ env.build_dir }} run: | - if cat ${{ env.unit-test-file }} | grep -q "FAILED"; then + if grep -q "FAILED" ${{ env.unit-test-file }}; then exit 1 fi @@ -98,6 +98,6 @@ jobs: - name: Check for regression tests results working-directory: ${{ env.build_dir }}/python run: | - if cat ${{ env.regression-test-file }} | grep -q "FAILED"; then + if grep -q "FAILED" ${{ env.regression-test-file }}; then exit 1 fi From 36a4776a93cabc7e9211ce77a0fe3b1b585a6a09 Mon Sep 17 00:00:00 2001 From: Kostya Date: Sun, 4 May 2025 04:19:17 +0300 Subject: [PATCH 60/74] ci: delete run on self-hosted branch --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index a644c9b..2470f9a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -4,7 +4,7 @@ name: Ubuntu on: push: - branches: [ master, self-hosted-runner ] + branches: [ master ] pull_request: branches: [ master ] workflow_dispatch: From 3ea12e7b94c98939a820c645c0248d7a216dadf1 Mon Sep 17 00:00:00 2001 From: Kostya Date: Tue, 6 May 2025 00:11:56 +0300 Subject: [PATCH 61/74] ci: delete cpu pipeline --- .github/workflows/self-hosted-cpu.yaml | 103 ------------------ .../{self-hosted-gpu.yml => self-hosted.yml} | 22 ++-- 2 files changed, 13 insertions(+), 112 deletions(-) delete mode 100644 .github/workflows/self-hosted-cpu.yaml rename .github/workflows/{self-hosted-gpu.yml => self-hosted.yml} (92%) diff --git a/.github/workflows/self-hosted-cpu.yaml b/.github/workflows/self-hosted-cpu.yaml deleted file mode 100644 index b560846..0000000 --- a/.github/workflows/self-hosted-cpu.yaml +++ /dev/null @@ -1,103 +0,0 @@ -name: Self-Hosted-CPU - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - workflow_dispatch: - -env: - build_dir: "build" - config: "Release" - -jobs: - build: - name: Build ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} - runs-on: self-hosted - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-24.04 - cuda: "12.8" - gcc: 13 - - steps: - - name: Cleanup workspace - run: | - rm -rf ${{ github.workspace }}/* - rm -rf ${{ github.workspace }}/.* - - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Set environment variables - run: | - echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV - echo "${CUDA_PATH}/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - echo "CC=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - - - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON -DCUBOOL_WITH_CUDA=OFF - - - name: Build library sources - working-directory: ${{ env.build_dir }} - run: cmake --build . --target all --verbose -j `nproc` - - test: - name: Test ${{ matrix.cpu }} - needs: build - runs-on: self-hosted - env: - unit-test-file: test_all.txt - regression-test-file: test_regression.txt - strategy: - fail-fast: false - matrix: - include: - - cpu: Intel-Core-i7-4790 - - steps: - - name: Run unit-tests - working-directory: ${{ env.build_dir }} - run: | - chmod +x scripts/run_tests_all.sh - ./scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} - - - name: Upload unit tests resutls - uses: actions/upload-artifact@v4 - with: - name: ${{ env.unit-test-file }} - path: ${{ env.build_dir }}/${{ env.unit-test-file }} - - - name: Check for unit tests results - working-directory: ${{ env.build_dir }} - run: | - if grep -q "FAILED" ${{ env.unit-test-file }}; then - exit 1 - fi - - - name: Run regression-tests - working-directory: ${{ env.build_dir }}/python - run: | - chmod +x run_tests.sh - ./run_tests.sh | tee ${{ env.regression-test-file }} - - - name: Upload regression tests resutls - uses: actions/upload-artifact@v4 - with: - name: ${{ env.regression-test-file }} - path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} - - - name: Check for regression tests results - working-directory: ${{ env.build_dir }}/python - run: | - if grep -q "FAILED" ${{ env.regression-test-file }}; then - exit 1 - fi diff --git a/.github/workflows/self-hosted-gpu.yml b/.github/workflows/self-hosted.yml similarity index 92% rename from .github/workflows/self-hosted-gpu.yml rename to .github/workflows/self-hosted.yml index b130906..bee36bb 100644 --- a/.github/workflows/self-hosted-gpu.yml +++ b/.github/workflows/self-hosted.yml @@ -24,11 +24,6 @@ jobs: gcc: 13 steps: - - name: Cleanup workspace - run: | - rm -rf ${{ github.workspace }}/* - rm -rf ${{ github.workspace }}/.* - - uses: actions/checkout@v4 with: submodules: recursive @@ -67,8 +62,7 @@ jobs: - name: Run unit-tests working-directory: ${{ env.build_dir }} run: | - chmod +x scripts/run_tests_all.sh - ./scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} - name: Upload unit tests resutls uses: actions/upload-artifact@v4 @@ -86,8 +80,7 @@ jobs: - name: Run regression-tests working-directory: ${{ env.build_dir }}/python run: | - chmod +x run_tests.sh - ./run_tests.sh | tee ${{ env.regression-test-file }} + source run_tests.sh | tee ${{ env.regression-test-file }} - name: Upload regression tests resutls uses: actions/upload-artifact@v4 @@ -101,3 +94,14 @@ jobs: if grep -q "FAILED" ${{ env.regression-test-file }}; then exit 1 fi + + clean: + name: Cleanup workspace + if: always() + runs-on: self-hosted + + steps: + - name: Cleanup workspace + run: | + rm -rf ${{ github.workspace }}/* + rm -rf ${{ github.workspace }}/.* From 033366abd4aaaab0ebce65f08bac005e51912124 Mon Sep 17 00:00:00 2001 From: Kostya Date: Tue, 6 May 2025 00:58:35 +0300 Subject: [PATCH 62/74] test: cleanup in failed pipeline --- .github/workflows/self-hosted.yml | 65 ++++++++++++++++--------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index bee36bb..7a9adcb 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -50,8 +50,8 @@ jobs: needs: build runs-on: self-hosted env: - unit-test-file: test_all.txt - regression-test-file: test_regression.txt + unit-test-file: test_all.log + regression-test-file: test_regression.log strategy: fail-fast: false matrix: @@ -59,41 +59,44 @@ jobs: - gpu: NVIDIA-GeForce-GT-1030 steps: - - name: Run unit-tests - working-directory: ${{ env.build_dir }} + - name: Fail run: | - source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + exit 1 + # - name: Run unit-tests + # working-directory: ${{ env.build_dir }} + # run: | + # source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} - - name: Upload unit tests resutls - uses: actions/upload-artifact@v4 - with: - name: ${{ env.unit-test-file }} - path: ${{ env.build_dir }}/${{ env.unit-test-file }} + # - name: Upload unit tests resutls + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.unit-test-file }} + # path: ${{ env.build_dir }}/${{ env.unit-test-file }} - - name: Check for unit tests results - working-directory: ${{ env.build_dir }} - run: | - if grep -q "FAILED" ${{ env.unit-test-file }}; then - exit 1 - fi + # - name: Check for unit tests results + # working-directory: ${{ env.build_dir }} + # run: | + # if grep -q "FAILED" ${{ env.unit-test-file }}; then + # exit 1 + # fi - - name: Run regression-tests - working-directory: ${{ env.build_dir }}/python - run: | - source run_tests.sh | tee ${{ env.regression-test-file }} + # - name: Run regression-tests + # working-directory: ${{ env.build_dir }}/python + # run: | + # source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} - - name: Upload regression tests resutls - uses: actions/upload-artifact@v4 - with: - name: ${{ env.regression-test-file }} - path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} + # - name: Upload regression tests resutls + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.regression-test-file }} + # path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} - - name: Check for regression tests results - working-directory: ${{ env.build_dir }}/python - run: | - if grep -q "FAILED" ${{ env.regression-test-file }}; then - exit 1 - fi + # - name: Check for regression tests results + # working-directory: ${{ env.build_dir }}/python + # run: | + # if grep -q "FAILED" ${{ env.regression-test-file }}; then + # exit 1 + # fi clean: name: Cleanup workspace From d85d41a4cdbddafadbf7e7ffe2c49b1689ffbf01 Mon Sep 17 00:00:00 2001 From: Kostya Date: Tue, 6 May 2025 01:03:23 +0300 Subject: [PATCH 63/74] ci: add needs in clean job --- .github/workflows/self-hosted.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 7a9adcb..d623928 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -1,4 +1,4 @@ -name: Self-Hosted-GPU +name: Self-Hosted on: push: @@ -100,6 +100,7 @@ jobs: clean: name: Cleanup workspace + needs: test if: always() runs-on: self-hosted From 5b0b33e4c8f38a3c0e76cfb493a82afc02dcfcd6 Mon Sep 17 00:00:00 2001 From: Kostya Date: Tue, 6 May 2025 01:09:15 +0300 Subject: [PATCH 64/74] ci: uncomment test pipeline --- .github/workflows/self-hosted.yml | 61 +++++++++++++++---------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index d623928..ee547b5 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -59,44 +59,41 @@ jobs: - gpu: NVIDIA-GeForce-GT-1030 steps: - - name: Fail + - name: Run unit-tests + working-directory: ${{ env.build_dir }} run: | - exit 1 - # - name: Run unit-tests - # working-directory: ${{ env.build_dir }} - # run: | - # source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} - # - name: Upload unit tests resutls - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.unit-test-file }} - # path: ${{ env.build_dir }}/${{ env.unit-test-file }} + - name: Upload unit tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.unit-test-file }} + path: ${{ env.build_dir }}/${{ env.unit-test-file }} - # - name: Check for unit tests results - # working-directory: ${{ env.build_dir }} - # run: | - # if grep -q "FAILED" ${{ env.unit-test-file }}; then - # exit 1 - # fi + - name: Check for unit tests results + working-directory: ${{ env.build_dir }} + run: | + if grep -q "FAILED" ${{ env.unit-test-file }}; then + exit 1 + fi - # - name: Run regression-tests - # working-directory: ${{ env.build_dir }}/python - # run: | - # source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} + - name: Run regression-tests + working-directory: ${{ env.build_dir }}/python + run: | + source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} - # - name: Upload regression tests resutls - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.regression-test-file }} - # path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} + - name: Upload regression tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.regression-test-file }} + path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} - # - name: Check for regression tests results - # working-directory: ${{ env.build_dir }}/python - # run: | - # if grep -q "FAILED" ${{ env.regression-test-file }}; then - # exit 1 - # fi + - name: Check for regression tests results + working-directory: ${{ env.build_dir }}/python + run: | + if grep -q "FAILED" ${{ env.regression-test-file }}; then + exit 1 + fi clean: name: Cleanup workspace From a82a79173a7eb489a7cdfaa4f3a936b21798adb1 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 7 May 2025 00:52:14 +0300 Subject: [PATCH 65/74] test: check cpu version of github runner --- .github/workflows/self-hosted.yml | 12 +++-- .github/workflows/ubuntu.yml | 81 +++++++++++++++++++++---------- 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index ee547b5..d7ff6aa 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -9,7 +9,6 @@ on: env: build_dir: "build" - config: "Release" jobs: build: @@ -22,6 +21,8 @@ jobs: - os: ubuntu-24.04 cuda: "12.8" gcc: 13 + env: + config: "Release" steps: - uses: actions/checkout@v4 @@ -46,17 +47,18 @@ jobs: run: cmake --build . --target all --verbose -j `nproc` test: - name: Test ${{ matrix.gpu }} + name: Test GPU ${{ matrix.gpu }} CUDA ${{ matrix.cuda }} needs: build runs-on: self-hosted env: - unit-test-file: test_all.log - regression-test-file: test_regression.log + unit-test-file: gpu_test_all.log + regression-test-file: gpu_test_regression.log strategy: fail-fast: false matrix: include: - gpu: NVIDIA-GeForce-GT-1030 + cuda: "12.9" steps: - name: Run unit-tests @@ -94,7 +96,7 @@ jobs: if grep -q "FAILED" ${{ env.regression-test-file }}; then exit 1 fi - + clean: name: Cleanup workspace needs: test diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 2470f9a..01313c2 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -9,6 +9,9 @@ on: branches: [ master ] workflow_dispatch: +env: + build_dir: "build" + jobs: build: name: Build ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} @@ -21,7 +24,6 @@ jobs: cuda: "11.7" gcc: 9 env: - build_dir: "build" config: "Release" artifact: "cubool-ubuntu-build.tar.xz" @@ -30,33 +32,11 @@ jobs: with: submodules: true - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install CUDA - env: - cuda: ${{ matrix.cuda }} - run: | - source ./scripts/install_cuda_ubuntu.sh - if [[ $? -eq 0 ]]; then - # Set paths for subsequent steps, using ${CUDA_PATH} - echo "Adding CUDA to CUDA_PATH, PATH and LD_LIBRARY_PATH" - echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV - echo "${CUDA_PATH}/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - fi - shell: bash - - - name: Install and configure GCC and GXX - run: | - sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} - echo "CC=/usr/bin/gcc-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV - echo "CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }}" >> $GITHUB_ENV + - name: Check CPU + run: cat /proc/cpuinfo - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON + run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON -DCUBOOL_WITH_CUDA=OFF - name: Build library sources working-directory: ${{ env.build_dir }} @@ -71,3 +51,52 @@ jobs: with: name: ${{ env.artifact }} path: ${{ env.artifact }} + + test: + name: Test CPU + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-22.04 + env: + unit-test-file: cpu_test_all.log + regression-test-file: cpu_test_regression.log + + steps: + - name: Run unit-tests + working-directory: ${{ env.build_dir }} + run: | + source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + + - name: Upload unit tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.unit-test-file }} + path: ${{ env.build_dir }}/${{ env.unit-test-file }} + + - name: Check for unit tests results + working-directory: ${{ env.build_dir }} + run: | + if grep -q "FAILED" ${{ env.unit-test-file }}; then + exit 1 + fi + + - name: Run regression-tests + working-directory: ${{ env.build_dir }}/python + run: | + source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} + + - name: Upload regression tests resutls + uses: actions/upload-artifact@v4 + with: + name: ${{ env.regression-test-file }} + path: ${{ env.build_dir }}/python/${{ env.regression-test-file }} + + - name: Check for regression tests results + working-directory: ${{ env.build_dir }}/python + run: | + if grep -q "FAILED" ${{ env.regression-test-file }}; then + exit 1 + fi From aec5bb93d61636247af272fa263ffa051991fae7 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 7 May 2025 01:05:43 +0300 Subject: [PATCH 66/74] ci: add tests for cpu use case --- .github/workflows/self-hosted.yml | 10 ++++++++-- .github/workflows/ubuntu.yml | 13 +++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index d7ff6aa..8f3d08d 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -3,8 +3,6 @@ name: Self-Hosted on: push: branches: [ master ] - pull_request: - branches: [ master ] workflow_dispatch: env: @@ -30,6 +28,7 @@ jobs: submodules: recursive - name: Set environment variables + shell: bash run: | echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV echo "${CUDA_PATH}/bin" >> $GITHUB_PATH @@ -40,10 +39,12 @@ jobs: echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build + shell: bash run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - name: Build library sources working-directory: ${{ env.build_dir }} + shell: bash run: cmake --build . --target all --verbose -j `nproc` test: @@ -63,6 +64,7 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} + shell: bash run: | source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} @@ -74,6 +76,7 @@ jobs: - name: Check for unit tests results working-directory: ${{ env.build_dir }} + shell: bash run: | if grep -q "FAILED" ${{ env.unit-test-file }}; then exit 1 @@ -81,6 +84,7 @@ jobs: - name: Run regression-tests working-directory: ${{ env.build_dir }}/python + shell: bash run: | source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} @@ -92,6 +96,7 @@ jobs: - name: Check for regression tests results working-directory: ${{ env.build_dir }}/python + shell: bash run: | if grep -q "FAILED" ${{ env.regression-test-file }}; then exit 1 @@ -105,6 +110,7 @@ jobs: steps: - name: Cleanup workspace + shell: bash run: | rm -rf ${{ github.workspace }}/* rm -rf ${{ github.workspace }}/.* diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 01313c2..384fcc4 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -32,14 +32,13 @@ jobs: with: submodules: true - - name: Check CPU - run: cat /proc/cpuinfo - - name: Configure CMake build + shell: bash run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON -DCUBOOL_WITH_CUDA=OFF - name: Build library sources working-directory: ${{ env.build_dir }} + shell: bash run: cmake --build . --target all --verbose -j `nproc` - name: Prepare upload binary @@ -53,13 +52,15 @@ jobs: path: ${{ env.artifact }} test: - name: Test CPU + name: Test CPU ${{ matrix.cpu }} + needs: build runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: ubuntu-22.04 + cpu: AMD-EPYC-7763 env: unit-test-file: cpu_test_all.log regression-test-file: cpu_test_regression.log @@ -67,6 +68,7 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} + shell: bash run: | source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} @@ -78,6 +80,7 @@ jobs: - name: Check for unit tests results working-directory: ${{ env.build_dir }} + shell: bash run: | if grep -q "FAILED" ${{ env.unit-test-file }}; then exit 1 @@ -85,6 +88,7 @@ jobs: - name: Run regression-tests working-directory: ${{ env.build_dir }}/python + shell: bash run: | source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} @@ -96,6 +100,7 @@ jobs: - name: Check for regression tests results working-directory: ${{ env.build_dir }}/python + shell: bash run: | if grep -q "FAILED" ${{ env.regression-test-file }}; then exit 1 From 412f0a68594ccba40374f4b626fd3b2378b5a156 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 7 May 2025 01:12:54 +0300 Subject: [PATCH 67/74] ci: delete shell from steps --- .github/workflows/self-hosted.yml | 8 -------- .github/workflows/ubuntu.yml | 7 ------- 2 files changed, 15 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 8f3d08d..3f0912f 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -28,7 +28,6 @@ jobs: submodules: recursive - name: Set environment variables - shell: bash run: | echo "CUDA_PATH=/usr/local/cuda-12.8" >> $GITHUB_ENV echo "${CUDA_PATH}/bin" >> $GITHUB_PATH @@ -39,12 +38,10 @@ jobs: echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build - shell: bash run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - name: Build library sources working-directory: ${{ env.build_dir }} - shell: bash run: cmake --build . --target all --verbose -j `nproc` test: @@ -64,7 +61,6 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} - shell: bash run: | source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} @@ -76,7 +72,6 @@ jobs: - name: Check for unit tests results working-directory: ${{ env.build_dir }} - shell: bash run: | if grep -q "FAILED" ${{ env.unit-test-file }}; then exit 1 @@ -84,7 +79,6 @@ jobs: - name: Run regression-tests working-directory: ${{ env.build_dir }}/python - shell: bash run: | source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} @@ -96,7 +90,6 @@ jobs: - name: Check for regression tests results working-directory: ${{ env.build_dir }}/python - shell: bash run: | if grep -q "FAILED" ${{ env.regression-test-file }}; then exit 1 @@ -110,7 +103,6 @@ jobs: steps: - name: Cleanup workspace - shell: bash run: | rm -rf ${{ github.workspace }}/* rm -rf ${{ github.workspace }}/.* diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 384fcc4..18812b6 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -33,16 +33,13 @@ jobs: submodules: true - name: Configure CMake build - shell: bash run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON -DCUBOOL_WITH_CUDA=OFF - name: Build library sources working-directory: ${{ env.build_dir }} - shell: bash run: cmake --build . --target all --verbose -j `nproc` - name: Prepare upload binary - shell: bash run: tar cfz ${{ env.artifact }} ${{ env.build_dir }} - name: Upload binary @@ -68,7 +65,6 @@ jobs: steps: - name: Run unit-tests working-directory: ${{ env.build_dir }} - shell: bash run: | source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} @@ -80,7 +76,6 @@ jobs: - name: Check for unit tests results working-directory: ${{ env.build_dir }} - shell: bash run: | if grep -q "FAILED" ${{ env.unit-test-file }}; then exit 1 @@ -88,7 +83,6 @@ jobs: - name: Run regression-tests working-directory: ${{ env.build_dir }}/python - shell: bash run: | source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} @@ -100,7 +94,6 @@ jobs: - name: Check for regression tests results working-directory: ${{ env.build_dir }}/python - shell: bash run: | if grep -q "FAILED" ${{ env.regression-test-file }}; then exit 1 From 6ab461bd8967160a1c6d737cda3a0dafdfe05ca4 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 7 May 2025 01:21:01 +0300 Subject: [PATCH 68/74] ci: add artifact download --- .github/workflows/ubuntu.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 18812b6..f5a49ff 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -11,6 +11,7 @@ on: env: build_dir: "build" + artifact: "cubool-ubuntu-build.tar.xz" jobs: build: @@ -25,7 +26,6 @@ jobs: gcc: 9 env: config: "Release" - artifact: "cubool-ubuntu-build.tar.xz" steps: - uses: actions/checkout@v4 @@ -63,6 +63,16 @@ jobs: regression-test-file: cpu_test_regression.log steps: + - uses: actions/download-artifact@v4 + with: + name: ${{ env.artifact }} + + - name: Unarchive artifact + run: | + tar xzf ${{ env.artifact }} + rm ${{ env.artifact }} + ls + - name: Run unit-tests working-directory: ${{ env.build_dir }} run: | From f782c5f2737d9215b1c18d84510f0edcf114b796 Mon Sep 17 00:00:00 2001 From: Kostya Date: Wed, 7 May 2025 01:56:36 +0300 Subject: [PATCH 69/74] ci: add cpu and gpu tests run --- .github/workflows/self-hosted.yml | 14 +++++++++----- .github/workflows/ubuntu.yml | 16 +++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 3f0912f..57ac676 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -3,6 +3,8 @@ name: Self-Hosted on: push: branches: [ master ] + pull_request: + branches: [ master ] workflow_dispatch: env: @@ -38,25 +40,27 @@ jobs: echo "CUDACXX=/usr/local/cuda-${{ matrix.cuda }}/bin/nvcc" >> $GITHUB_ENV - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON + run: | + cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - name: Build library sources working-directory: ${{ env.build_dir }} - run: cmake --build . --target all --verbose -j `nproc` + run: | + cmake --build . --target all --verbose -j `nproc` test: name: Test GPU ${{ matrix.gpu }} CUDA ${{ matrix.cuda }} needs: build runs-on: self-hosted - env: - unit-test-file: gpu_test_all.log - regression-test-file: gpu_test_regression.log strategy: fail-fast: false matrix: include: - gpu: NVIDIA-GeForce-GT-1030 cuda: "12.9" + env: + unit-test-file: gpu_test_all.log + regression-test-file: gpu_test_regression.log steps: - name: Run unit-tests diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index f5a49ff..6e020ca 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -1,5 +1,3 @@ -# Original script from https://github.com/ptheywood/cuda-cmake-github-actions - name: Ubuntu on: @@ -15,15 +13,13 @@ env: jobs: build: - name: Build ${{ matrix.os }} GCC ${{ matrix.gcc }} CUDA ${{ matrix.cuda }} + name: Build ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: ubuntu-22.04 - cuda: "11.7" - gcc: 9 env: config: "Release" @@ -33,14 +29,17 @@ jobs: submodules: true - name: Configure CMake build - run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON -DCUBOOL_WITH_CUDA=OFF + run: | + cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON -DCUBOOL_WITH_CUDA=OFF - name: Build library sources working-directory: ${{ env.build_dir }} - run: cmake --build . --target all --verbose -j `nproc` + run: | + cmake --build . --target all --verbose -j `nproc` - name: Prepare upload binary - run: tar cfz ${{ env.artifact }} ${{ env.build_dir }} + run: | + tar cfz ${{ env.artifact }} ${{ env.build_dir }} - name: Upload binary uses: actions/upload-artifact@v4 @@ -71,7 +70,6 @@ jobs: run: | tar xzf ${{ env.artifact }} rm ${{ env.artifact }} - ls - name: Run unit-tests working-directory: ${{ env.build_dir }} From db47b5c92f2503311a34557f86b100e2ef484ed1 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 26 May 2025 02:29:39 +0300 Subject: [PATCH 70/74] fix: corrections after review --- .github/workflows/self-hosted.yml | 17 +++++++---------- .github/workflows/ubuntu.yml | 17 +++++++---------- python/publish_pypi.sh | 1 + python/publish_t_pypi.sh | 1 + python/run_tests.sh | 1 + scripts/install_cuda_ubuntu.sh | 22 +++++++++++----------- scripts/run_tests_all.sh | 1 + scripts/run_tests_fallback.sh | 1 + 8 files changed, 30 insertions(+), 31 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 57ac676..8ca2f69 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -44,9 +44,8 @@ jobs: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON - name: Build library sources - working-directory: ${{ env.build_dir }} run: | - cmake --build . --target all --verbose -j `nproc` + cmake --build ${{ env.build_dir }} --target all --verbose -j `nproc` test: name: Test GPU ${{ matrix.gpu }} CUDA ${{ matrix.cuda }} @@ -66,7 +65,8 @@ jobs: - name: Run unit-tests working-directory: ${{ env.build_dir }} run: | - source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + bash scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + shell: bash - name: Upload unit tests resutls uses: actions/upload-artifact@v4 @@ -77,14 +77,13 @@ jobs: - name: Check for unit tests results working-directory: ${{ env.build_dir }} run: | - if grep -q "FAILED" ${{ env.unit-test-file }}; then - exit 1 - fi + ! grep -q "FAILED" ${{ env.unit-test-file }} - name: Run regression-tests working-directory: ${{ env.build_dir }}/python run: | - source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} + bash run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} + shell: bash - name: Upload regression tests resutls uses: actions/upload-artifact@v4 @@ -95,9 +94,7 @@ jobs: - name: Check for regression tests results working-directory: ${{ env.build_dir }}/python run: | - if grep -q "FAILED" ${{ env.regression-test-file }}; then - exit 1 - fi + ! grep -q "FAILED" ${{ env.regression-test-file }} clean: name: Cleanup workspace diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 6e020ca..26b646f 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -33,9 +33,8 @@ jobs: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DCUBOOL_BUILD_TESTS=ON -DCUBOOL_WITH_CUDA=OFF - name: Build library sources - working-directory: ${{ env.build_dir }} run: | - cmake --build . --target all --verbose -j `nproc` + cmake --build ${{ env.build_dir }} --target all --verbose -j `nproc` - name: Prepare upload binary run: | @@ -74,7 +73,8 @@ jobs: - name: Run unit-tests working-directory: ${{ env.build_dir }} run: | - source scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + bash scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} + shell: bash - name: Upload unit tests resutls uses: actions/upload-artifact@v4 @@ -85,14 +85,13 @@ jobs: - name: Check for unit tests results working-directory: ${{ env.build_dir }} run: | - if grep -q "FAILED" ${{ env.unit-test-file }}; then - exit 1 - fi + ! grep -q "FAILED" ${{ env.unit-test-file }} - name: Run regression-tests working-directory: ${{ env.build_dir }}/python run: | - source run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} + bash run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} + shell: bash - name: Upload regression tests resutls uses: actions/upload-artifact@v4 @@ -103,6 +102,4 @@ jobs: - name: Check for regression tests results working-directory: ${{ env.build_dir }}/python run: | - if grep -q "FAILED" ${{ env.regression-test-file }}; then - exit 1 - fi + ! grep -q "FAILED" ${{ env.regression-test-file }} diff --git a/python/publish_pypi.sh b/python/publish_pypi.sh index 40d4c65..0c78e87 100644 --- a/python/publish_pypi.sh +++ b/python/publish_pypi.sh @@ -1,2 +1,3 @@ +#!/bin/bash python3 setup.py sdist bdist_wheel twine upload --verbose dist/* \ No newline at end of file diff --git a/python/publish_t_pypi.sh b/python/publish_t_pypi.sh index aa781e1..d68cbdd 100644 --- a/python/publish_t_pypi.sh +++ b/python/publish_t_pypi.sh @@ -1,2 +1,3 @@ +#!/bin/bash python3 setup.py sdist bdist_wheel twine upload --verbose --repository testpypi dist/* \ No newline at end of file diff --git a/python/run_tests.sh b/python/run_tests.sh index febf012..0c216b3 100644 --- a/python/run_tests.sh +++ b/python/run_tests.sh @@ -1,3 +1,4 @@ +#!/bin/bash export PYTHONPATH="`pwd`:$PYTHONPATH" cd tests python3 -m unittest discover -v diff --git a/scripts/install_cuda_ubuntu.sh b/scripts/install_cuda_ubuntu.sh index f5d95ba..019f2aa 100644 --- a/scripts/install_cuda_ubuntu.sh +++ b/scripts/install_cuda_ubuntu.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Original script from https://github.com/ptheywood/cuda-cmake-github-actions CUDA_PACKAGES_IN=( @@ -17,7 +18,7 @@ function version_ge() { # returns 0 (true) if a > b function version_gt() { [ "$#" != "2" ] && echo "${FUNCNAME[0]} requires exactly 2 arguments." && exit 1 - [ "$1" = "$2" ] && return 1 || version_ge $1 $2 + [ "$1" = "$2" ] && return 1 || version_ge "$1" "$2" } # returns 0 (true) if a <= b function version_le() { @@ -27,13 +28,13 @@ function version_le() { # returns 0 (true) if a < b function version_lt() { [ "$#" != "2" ] && echo "${FUNCNAME[0]} requires exactly 2 arguments." && exit 1 - [ "$1" = "$2" ] && return 1 || version_le $1 $2 + [ "$1" = "$2" ] && return 1 || version_le "$1" "$2" } ## Select CUDA version # Get the cuda version from the environment as $cuda. -CUDA_VERSION_MAJOR_MINOR=${cuda} +CUDA_VERSION_MAJOR_MINOR=${cuda:=12.8} # Split the version. # We (might/probably) don't know PATCH at this point - it depends which version gets installed. @@ -60,7 +61,7 @@ if [ -z "${CUDA_MINOR}" ] ; then exit 1 fi # If we don't know the Ubuntu version, error. -if [ -z ${UBUNTU_VERSION} ]; then +if [ -z "${UBUNTU_VERSION}" ]; then echo "Error: Unknown Ubuntu version. Aborting." exit 1 fi @@ -112,7 +113,7 @@ echo "KEYRING_PACKAGE_URL ${KEYRING_PACKAGE_URL}" # Detect if the script is being run as root, storing true/false in is_root. is_root=false -if (( $EUID == 0)); then +if (( EUID == 0)); then is_root=true fi # Find if sudo is available @@ -120,7 +121,7 @@ has_sudo=false if command -v sudo &> /dev/null ; then has_sudo=true fi -# Decide if we can proceed or not (root or sudo is required) and if so store whether sudo should be used or not. +# Decide if we can proceed or not (root or sudo is required) and if so store whether sudo should be used or not. if [ "$is_root" = false ] && [ "$has_sudo" = false ]; then echo "Root or sudo is required. Aborting." exit 1 @@ -136,16 +137,15 @@ $USE_SUDO apt-get update ## Install echo "Adding CUDA Repository" -wget ${PIN_URL} -$USE_SUDO mv ${PIN_FILENAME} /etc/apt/preferences.d/cuda-repository-pin-600 -wget ${KEYRING_PACKAGE_URL} && ${USE_SUDO} dpkg -i ${KERYRING_PACKAGE_FILENAME} && rm ${KERYRING_PACKAGE_FILENAME} +wget "${PIN_URL}" +$USE_SUDO mv "${PIN_FILENAME}" /etc/apt/preferences.d/cuda-repository-pin-600 +wget "${KEYRING_PACKAGE_URL}" && ${USE_SUDO} dpkg -i ${KERYRING_PACKAGE_FILENAME} && rm ${KERYRING_PACKAGE_FILENAME} $USE_SUDO add-apt-repository "deb ${REPO_URL} /" $USE_SUDO apt-get update echo "Installing CUDA packages ${CUDA_PACKAGES}" -$USE_SUDO apt-get -y install ${CUDA_PACKAGES} -if [[ $? -ne 0 ]]; then +if ! $USE_SUDO apt-get -y install "${CUDA_PACKAGES}"; then echo "CUDA Installation Error." exit 1 fi diff --git a/scripts/run_tests_all.sh b/scripts/run_tests_all.sh index 8f2e7e0..1fd405f 100644 --- a/scripts/run_tests_all.sh +++ b/scripts/run_tests_all.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Runs all tests executables # Invoke this script within build directory ./cubool/tests/test_library_api diff --git a/scripts/run_tests_fallback.sh b/scripts/run_tests_fallback.sh index f468fc1..50a4f84 100644 --- a/scripts/run_tests_fallback.sh +++ b/scripts/run_tests_fallback.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Runs all tests executables # Invoke this script within build directory ./cubool/tests/test_library_api From 703449190c015dbbc1f5ffb15ea58e71aed80a1f Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 26 May 2025 19:09:45 +0300 Subject: [PATCH 71/74] style: add clang format --- .clang-format | 68 ++++ .github/workflows/clang-format.yml | 28 ++ cubool/include/cubool/cubool.h | 323 ++++++++---------- cubool/sources/backend/backend_base.hpp | 22 +- cubool/sources/backend/matrix_base.hpp | 30 +- cubool/sources/backend/vector_base.hpp | 26 +- cubool/sources/core/config.hpp | 11 +- cubool/sources/core/error.hpp | 91 ++--- cubool/sources/core/library.cpp | 73 ++-- cubool/sources/core/library.hpp | 38 +-- cubool/sources/core/matrix.cpp | 58 ++-- cubool/sources/core/matrix.hpp | 34 +- cubool/sources/core/object.cpp | 6 +- cubool/sources/core/object.hpp | 8 +- cubool/sources/core/vector.cpp | 58 ++-- cubool/sources/core/vector.hpp | 31 +- cubool/sources/core/version.hpp | 2 +- cubool/sources/cuBool_Common.hpp | 31 +- cubool/sources/cuBool_Finalize.cpp | 7 +- cubool/sources/cuBool_GetAbout.cpp | 20 +- cubool/sources/cuBool_GetDeviceCaps.cpp | 9 +- cubool/sources/cuBool_GetLicenseInfo.cpp | 42 +-- cubool/sources/cuBool_GetVersion.cpp | 13 +- cubool/sources/cuBool_Initialize.cpp | 6 +- cubool/sources/cuBool_Kronecker.cpp | 19 +- cubool/sources/cuBool_Matrix_Build.cpp | 19 +- cubool/sources/cuBool_Matrix_Duplicate.cpp | 19 +- cubool/sources/cuBool_Matrix_EWiseAdd.cpp | 19 +- cubool/sources/cuBool_Matrix_EWiseMult.cpp | 19 +- .../cuBool_Matrix_EWiseMultInverted.cpp | 25 +- cubool/sources/cuBool_Matrix_ExtractCol.cpp | 15 +- cubool/sources/cuBool_Matrix_ExtractPairs.cpp | 21 +- cubool/sources/cuBool_Matrix_ExtractRow.cpp | 15 +- .../cuBool_Matrix_ExtractSubMatrix.cpp | 23 +- cubool/sources/cuBool_Matrix_Free.cpp | 9 +- cubool/sources/cuBool_Matrix_Marker.cpp | 37 +- cubool/sources/cuBool_Matrix_Ncols.cpp | 13 +- cubool/sources/cuBool_Matrix_New.cpp | 13 +- cubool/sources/cuBool_Matrix_Nrows.cpp | 13 +- cubool/sources/cuBool_Matrix_Nvals.cpp | 13 +- cubool/sources/cuBool_Matrix_Reduce.cpp | 15 +- cubool/sources/cuBool_Matrix_Reduce2.cpp | 15 +- cubool/sources/cuBool_Matrix_SetElement.cpp | 13 +- cubool/sources/cuBool_Matrix_SetMarker.cpp | 13 +- cubool/sources/cuBool_Matrix_Transpose.cpp | 15 +- cubool/sources/cuBool_MxM.cpp | 19 +- cubool/sources/cuBool_MxV.cpp | 19 +- cubool/sources/cuBool_SetupLogger.cpp | 7 +- cubool/sources/cuBool_Vector_Build.cpp | 15 +- cubool/sources/cuBool_Vector_Duplicate.cpp | 19 +- cubool/sources/cuBool_Vector_EWiseAdd.cpp | 19 +- cubool/sources/cuBool_Vector_EWiseMult.cpp | 19 +- .../cuBool_Vector_ExtractSubVector.cpp | 19 +- .../sources/cuBool_Vector_ExtractValues.cpp | 17 +- cubool/sources/cuBool_Vector_Free.cpp | 9 +- cubool/sources/cuBool_Vector_Marker.cpp | 33 +- cubool/sources/cuBool_Vector_New.cpp | 9 +- cubool/sources/cuBool_Vector_Nrows.cpp | 13 +- cubool/sources/cuBool_Vector_Nvals.cpp | 13 +- cubool/sources/cuBool_Vector_Reduce.cpp | 13 +- cubool/sources/cuBool_Vector_SetElement.cpp | 11 +- cubool/sources/cuBool_Vector_SetMarker.cpp | 13 +- cubool/sources/cuBool_VxM.cpp | 25 +- cubool/sources/cuda/cuda_backend.cu | 14 +- cubool/sources/cuda/cuda_backend.hpp | 18 +- cubool/sources/cuda/cuda_instance.cu | 38 +-- cubool/sources/cuda/cuda_instance.hpp | 21 +- cubool/sources/cuda/cuda_matrix.cu | 22 +- cubool/sources/cuda/cuda_matrix.hpp | 40 +-- cubool/sources/cuda/cuda_matrix_ewiseadd.cu | 6 +- cubool/sources/cuda/cuda_matrix_ewisemult.cu | 6 +- .../cuda/cuda_matrix_ewisemult_inverted.cu | 6 +- .../cuda/cuda_matrix_extract_sub_matrix.cu | 6 +- cubool/sources/cuda/cuda_matrix_kronecker.cu | 6 +- cubool/sources/cuda/cuda_matrix_multiply.cu | 6 +- cubool/sources/cuda/cuda_matrix_reduce.cu | 6 +- cubool/sources/cuda/cuda_matrix_transpose.cu | 6 +- cubool/sources/cuda/cuda_vector.cu | 82 +++-- cubool/sources/cuda/cuda_vector.hpp | 32 +- cubool/sources/cuda/cuda_vector_ewiseadd.cu | 10 +- cubool/sources/cuda/cuda_vector_ewisemult.cu | 13 +- cubool/sources/cuda/cuda_vector_mxv.cu | 12 +- cubool/sources/cuda/cuda_vector_reduce.cu | 13 +- cubool/sources/cuda/cuda_vector_vxm.cu | 14 +- .../sources/cuda/details/host_allocator.hpp | 39 ++- cubool/sources/cuda/details/meta.hpp | 32 +- cubool/sources/cuda/details/sp_vector.hpp | 20 +- cubool/sources/io/logger.cpp | 20 +- cubool/sources/io/logger.hpp | 60 ++-- cubool/sources/sequential/sq_backend.cpp | 16 +- cubool/sources/sequential/sq_backend.hpp | 12 +- cubool/sources/sequential/sq_data.hpp | 14 +- cubool/sources/sequential/sq_ewiseadd.cpp | 42 +-- cubool/sources/sequential/sq_ewiseadd.hpp | 4 +- cubool/sources/sequential/sq_ewisemult.cpp | 32 +- cubool/sources/sequential/sq_ewisemult.hpp | 4 +- .../sequential/sq_ewisemultinverted.cpp | 26 +- .../sequential/sq_ewisemultinverted.hpp | 4 +- cubool/sources/sequential/sq_kronecker.cpp | 2 +- cubool/sources/sequential/sq_kronecker.hpp | 4 +- cubool/sources/sequential/sq_matrix.cpp | 39 ++- cubool/sources/sequential/sq_matrix.hpp | 28 +- cubool/sources/sequential/sq_reduce.cpp | 12 +- cubool/sources/sequential/sq_reduce.hpp | 4 +- cubool/sources/sequential/sq_spgemm.cpp | 12 +- cubool/sources/sequential/sq_spgemm.hpp | 4 +- cubool/sources/sequential/sq_spgemv.cpp | 14 +- cubool/sources/sequential/sq_spgemv.hpp | 4 +- cubool/sources/sequential/sq_submatrix.cpp | 6 +- cubool/sources/sequential/sq_submatrix.hpp | 4 +- cubool/sources/sequential/sq_subvector.cpp | 8 +- cubool/sources/sequential/sq_subvector.hpp | 4 +- cubool/sources/sequential/sq_transpose.cpp | 2 +- cubool/sources/sequential/sq_transpose.hpp | 4 +- cubool/sources/sequential/sq_vector.cpp | 46 +-- cubool/sources/sequential/sq_vector.hpp | 23 +- cubool/sources/utils/algo_utils.hpp | 10 +- cubool/sources/utils/data_utils.cpp | 26 +- cubool/sources/utils/data_utils.hpp | 6 +- cubool/sources/utils/timer.hpp | 6 +- cubool/tests/test_library_api.cpp | 23 +- cubool/tests/test_matrix_element.cpp | 20 +- cubool/tests/test_matrix_ewiseadd.cpp | 2 +- cubool/tests/test_matrix_ewisemult.cpp | 2 +- .../tests/test_matrix_ewisemult_inverted.cpp | 47 +-- cubool/tests/test_matrix_extract_vector.cpp | 2 +- cubool/tests/test_matrix_kronecker.cpp | 20 +- cubool/tests/test_matrix_misc.cpp | 32 +- cubool/tests/test_matrix_reduce.cpp | 18 +- cubool/tests/test_matrix_sub_matrix.cpp | 18 +- cubool/tests/test_vector_element.cpp | 18 +- cubool/tests/test_vector_ewiseadd.cpp | 2 +- cubool/tests/test_vector_ewisemult.cpp | 2 +- cubool/tests/test_vector_misc.cpp | 36 +- cubool/tests/test_vector_mxv.cpp | 2 +- cubool/tests/test_vector_sub_vector.cpp | 36 +- cubool/tests/test_vector_vxm.cpp | 2 +- cubool/utils/testing/matrix.hpp | 43 ++- cubool/utils/testing/matrix_ewiseadd.hpp | 38 +-- cubool/utils/testing/matrix_ewisemult.hpp | 12 +- cubool/utils/testing/matrix_generator.hpp | 19 +- cubool/utils/testing/matrix_kronecker.hpp | 6 +- cubool/utils/testing/matrix_mxm.hpp | 20 +- cubool/utils/testing/matrix_printing.hpp | 18 +- cubool/utils/testing/pair.hpp | 12 +- cubool/utils/testing/testing.hpp | 20 +- cubool/utils/testing/timer.hpp | 16 +- cubool/utils/testing/vector.hpp | 22 +- cubool/utils/testing/vector_functors.hpp | 36 +- 149 files changed, 1588 insertions(+), 1616 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/clang-format.yml diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..1e25605 --- /dev/null +++ b/.clang-format @@ -0,0 +1,68 @@ +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: Consecutive +AlignConsecutiveDeclarations: Consecutive +AlignConsecutiveMacros: Consecutive +AlignOperands: Align +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: true +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +ColumnLimit: 0 +CompactNamespaces: false +ContinuationIndentWidth: 8 +IndentCaseLabels: true +IndentPPDirectives: BeforeHash +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Left +ReflowComments: false +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 0 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Never \ No newline at end of file diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000..858cb9b --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,28 @@ +name: Clang Format + +on: + push: + branches: [ main ] + paths: + - '.github/**' + - 'cubool/**' + - '.clang-format' + pull_request: + branches: [ main ] + +jobs: + formatting-check: + name: Formatting Check + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + path: + - 'cubool' + steps: + - uses: actions/checkout@v4 + - name: Run clang-format style check + uses: jidicula/clang-format-action@v4.15.0 + with: + clang-format-version: '20' + check-path: ${{ matrix.path }} \ No newline at end of file diff --git a/cubool/include/cubool/cubool.h b/cubool/include/cubool/cubool.h index 2859542..a3c3646 100644 --- a/cubool/include/cubool/cubool.h +++ b/cubool/include/cubool/cubool.h @@ -119,12 +119,12 @@ typedef struct cuBool_DeviceCaps { char name[256]; bool cudaSupported; bool managedMem; - int major; - int minor; - int warp; - int globalMemoryKiBs; - int sharedMemoryPerMultiProcKiBs; - int sharedMemoryPerBlockKiBs; + int major; + int minor; + int warp; + int globalMemoryKiBs; + int sharedMemoryPerMultiProcKiBs; + int sharedMemoryPerBlockKiBs; } cuBool_DeviceCaps; /** @@ -133,8 +133,7 @@ typedef struct cuBool_DeviceCaps { * * @return Read-only library about info */ -CUBOOL_EXPORT CUBOOL_API const char* cuBool_GetAbout( -); +CUBOOL_EXPORT CUBOOL_API const char* cuBool_GetAbout(); /** * Query human-readable text info about the project implementation @@ -142,8 +141,7 @@ CUBOOL_EXPORT CUBOOL_API const char* cuBool_GetAbout( * @return Read-only library license info */ -CUBOOL_EXPORT CUBOOL_API const char* cuBool_GetLicenseInfo( -); +CUBOOL_EXPORT CUBOOL_API const char* cuBool_GetLicenseInfo(); /** * Query library version number in form MAJOR.MINOR @@ -156,10 +154,9 @@ CUBOOL_EXPORT CUBOOL_API const char* cuBool_GetLicenseInfo( * @return Error if failed to query version info */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_GetVersion( - int* major, - int* minor, - int* sub -); + int* major, + int* minor, + int* sub); /** * Allows to setup logging file for all operations, invoked after this function call. @@ -177,9 +174,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_GetVersion( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_SetupLogging( - const char* logFileName, - cuBool_Hints hints -); + const char* logFileName, + cuBool_Hints hints); /** * Initialize library instance object, which provides context to all library operations and primitives. @@ -193,8 +189,7 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_SetupLogging( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Initialize( - cuBool_Hints hints -); + cuBool_Hints hints); /** * Finalize library state and all objects, which were created on this library context. @@ -205,8 +200,7 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Initialize( * * @return Error code on this operation */ -CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Finalize( -); +CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Finalize(); /** * Query device capabilities/properties if cuda compatible device is present. @@ -217,8 +211,7 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Finalize( * @return Error if cuda device not present or if failed to query capabilities */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_GetDeviceCaps( - cuBool_DeviceCaps* deviceCaps -); + cuBool_DeviceCaps* deviceCaps); /** * Creates new sparse matrix with specified size. @@ -230,10 +223,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_GetDeviceCaps( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_New( - cuBool_Matrix* matrix, - cuBool_Index nrows, - cuBool_Index ncols -); + cuBool_Matrix* matrix, + cuBool_Index nrows, + cuBool_Index ncols); /** * Build sparse matrix from provided pairs array. Pairs are supposed to be stored @@ -252,12 +244,11 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_New( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Build( - cuBool_Matrix matrix, - const cuBool_Index* rows, - const cuBool_Index* cols, - cuBool_Index nvals, - cuBool_Hints hints -); + cuBool_Matrix matrix, + const cuBool_Index* rows, + const cuBool_Index* cols, + cuBool_Index nvals, + cuBool_Hints hints); /** * Sets specified (i, j) value of the matrix to True. @@ -271,10 +262,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Build( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_SetElement( - cuBool_Matrix matrix, - cuBool_Index i, - cuBool_Index j -); + cuBool_Matrix matrix, + cuBool_Index i, + cuBool_Index j); /** * Sets to the matrix specific debug string marker. @@ -286,9 +276,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_SetElement( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_SetMarker( - cuBool_Matrix matrix, - const char* marker -); + cuBool_Matrix matrix, + const char* marker); /** * Allows to get matrix debug string marker. @@ -306,10 +295,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_SetMarker( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Marker( - cuBool_Matrix matrix, - char* marker, - cuBool_Index* size -); + cuBool_Matrix matrix, + char* marker, + cuBool_Index* size); /** * Reads matrix data to the host visible CPU buffer as an array of values pair. @@ -325,11 +313,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Marker( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_ExtractPairs( - cuBool_Matrix matrix, - cuBool_Index* rows, - cuBool_Index* cols, - cuBool_Index* nvals -); + cuBool_Matrix matrix, + cuBool_Index* rows, + cuBool_Index* cols, + cuBool_Index* nvals); /** * Extracts sub-matrix of the input matrix and stores it into result matrix. @@ -355,14 +342,13 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_ExtractPairs( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_ExtractSubMatrix( - cuBool_Matrix result, - cuBool_Matrix matrix, - cuBool_Index i, - cuBool_Index j, - cuBool_Index nrows, - cuBool_Index ncols, - cuBool_Hints hints -); + cuBool_Matrix result, + cuBool_Matrix matrix, + cuBool_Index i, + cuBool_Index j, + cuBool_Index nrows, + cuBool_Index ncols, + cuBool_Hints hints); /** * Extract specified matrix row as vector. @@ -379,11 +365,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_ExtractSubMatrix( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_ExtractRow( - cuBool_Vector result, - cuBool_Matrix matrix, - cuBool_Index i, - cuBool_Hints hints -); + cuBool_Vector result, + cuBool_Matrix matrix, + cuBool_Index i, + cuBool_Hints hints); /** * Extract specified matrix col as vector. @@ -400,11 +385,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_ExtractRow( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_ExtractCol( - cuBool_Vector result, - cuBool_Matrix matrix, - cuBool_Index j, - cuBool_Hints hints -); + cuBool_Vector result, + cuBool_Matrix matrix, + cuBool_Index j, + cuBool_Hints hints); /** * Creates new sparse matrix, duplicates content and stores handle in the provided pointer. @@ -415,9 +399,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_ExtractCol( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Duplicate( - cuBool_Matrix matrix, - cuBool_Matrix* duplicated -); + cuBool_Matrix matrix, + cuBool_Matrix* duplicated); /** * Transpose source matrix and store result of this operation in result matrix. @@ -432,10 +415,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Duplicate( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Transpose( - cuBool_Matrix result, - cuBool_Matrix matrix, - cuBool_Hints hints -); + cuBool_Matrix result, + cuBool_Matrix matrix, + cuBool_Hints hints); /** * Query number of non-zero values of the matrix. @@ -446,9 +428,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Transpose( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Nvals( - cuBool_Matrix matrix, - cuBool_Index* nvals -); + cuBool_Matrix matrix, + cuBool_Index* nvals); /** * Query number of rows in the matrix. @@ -459,9 +440,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Nvals( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Nrows( - cuBool_Matrix matrix, - cuBool_Index* nrows -); + cuBool_Matrix matrix, + cuBool_Index* nrows); /** * Query number of columns in the matrix. @@ -472,9 +452,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Nrows( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Ncols( - cuBool_Matrix matrix, - cuBool_Index* ncols -); + cuBool_Matrix matrix, + cuBool_Index* ncols); /** * Deletes sparse matrix object. @@ -484,8 +463,7 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Ncols( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Free( - cuBool_Matrix matrix -); + cuBool_Matrix matrix); /** * Reduce the source matrix to the column vector. @@ -503,10 +481,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Free( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Reduce( - cuBool_Vector result, - cuBool_Matrix matrix, - cuBool_Hints hints -); + cuBool_Vector result, + cuBool_Matrix matrix, + cuBool_Hints hints); /** * Reduce the source matrix to the column matrix result (column vector). @@ -525,10 +502,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Reduce( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Reduce2( - cuBool_Matrix result, - cuBool_Matrix matrix, - cuBool_Hints hints -); + cuBool_Matrix result, + cuBool_Matrix matrix, + cuBool_Hints hints); /** * Performs result = left + right, where '+' is boolean semiring 'or' operation. @@ -548,11 +524,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_Reduce2( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseAdd( - cuBool_Matrix result, - cuBool_Matrix left, - cuBool_Matrix right, - cuBool_Hints hints -); + cuBool_Matrix result, + cuBool_Matrix left, + cuBool_Matrix right, + cuBool_Hints hints); /** * Performs result = left * right, where '*' is boolean semiring 'and' operation. @@ -572,11 +547,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseAdd( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseMult( - cuBool_Matrix result, - cuBool_Matrix left, - cuBool_Matrix right, - cuBool_Hints hints -); + cuBool_Matrix result, + cuBool_Matrix left, + cuBool_Matrix right, + cuBool_Hints hints); /** * Creates new sparse vector with specified size. @@ -587,9 +561,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseMult( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_New( - cuBool_Vector* vector, - cuBool_Index nrows -); + cuBool_Vector* vector, + cuBool_Index nrows); /** * Build sparse vector from provided indices array. @@ -606,11 +579,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_New( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Build( - cuBool_Vector vector, - const cuBool_Index* rows, - cuBool_Index nvals, - cuBool_Hints hints -); + cuBool_Vector vector, + const cuBool_Index* rows, + cuBool_Index nvals, + cuBool_Hints hints); /** * Sets specified (j) value of the vector to True. @@ -623,9 +595,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Build( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_SetElement( - cuBool_Vector vector, - cuBool_Index i -); + cuBool_Vector vector, + cuBool_Index i); /** * Sets to the vector specific debug string marker. @@ -637,9 +608,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_SetElement( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_SetMarker( - cuBool_Vector vector, - const char* marker -); + cuBool_Vector vector, + const char* marker); /** * Allows to get vector debug string marker. @@ -657,10 +627,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_SetMarker( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Marker( - cuBool_Vector vector, - char* marker, - cuBool_Index* size -); + cuBool_Vector vector, + char* marker, + cuBool_Index* size); /** * Reads vector data to the host visible CPU buffer as an array of indices. @@ -675,10 +644,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Marker( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_ExtractValues( - cuBool_Vector vector, - cuBool_Index* rows, - cuBool_Index* nvals -); + cuBool_Vector vector, + cuBool_Index* rows, + cuBool_Index* nvals); /** * Extracts sub-vector of the input vector and stores it into result vector. @@ -702,12 +670,11 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_ExtractValues( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_ExtractSubVector( - cuBool_Vector result, - cuBool_Vector vector, - cuBool_Index i, - cuBool_Index nrows, - cuBool_Hints hints -); + cuBool_Vector result, + cuBool_Vector vector, + cuBool_Index i, + cuBool_Index nrows, + cuBool_Hints hints); /** * Creates new sparse vector, duplicates content and stores handle in the provided pointer. @@ -718,9 +685,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_ExtractSubVector( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Duplicate( - cuBool_Vector vector, - cuBool_Vector* duplicated -); + cuBool_Vector vector, + cuBool_Vector* duplicated); /** * Query number of non-zero values of the vector. @@ -731,9 +697,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Duplicate( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Nvals( - cuBool_Vector vector, - cuBool_Index* nvals -); + cuBool_Vector vector, + cuBool_Index* nvals); /** * Query number of rows in the vector. @@ -744,9 +709,8 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Nvals( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Nrows( - cuBool_Vector vector, - cuBool_Index* nrows -); + cuBool_Vector vector, + cuBool_Index* nrows); /** * Deletes sparse vector object. @@ -756,8 +720,7 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Nrows( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Free( - cuBool_Vector vector -); + cuBool_Vector vector); /** @@ -772,10 +735,9 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Free( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Reduce( - cuBool_Index* result, - cuBool_Vector vector, - cuBool_Hints hints -); + cuBool_Index* result, + cuBool_Vector vector, + cuBool_Hints hints); /** * Performs result = left + right, where '+' is boolean semiring 'or' operation. @@ -795,11 +757,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Reduce( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_EWiseAdd( - cuBool_Vector result, - cuBool_Vector left, - cuBool_Vector right, - cuBool_Hints hints -); + cuBool_Vector result, + cuBool_Vector left, + cuBool_Vector right, + cuBool_Hints hints); /** * Performs result = left * right, where '*' is boolean semiring 'and' operation. @@ -819,11 +780,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_EWiseAdd( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_EWiseMult( - cuBool_Vector result, - cuBool_Vector left, - cuBool_Vector right, - cuBool_Hints hints -); + cuBool_Vector result, + cuBool_Vector left, + cuBool_Vector right, + cuBool_Hints hints); /** * Performs result (accum)= left x right evaluation, where source '+' and 'x' are boolean semiring operations. @@ -845,11 +805,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_EWiseMult( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_MxM( - cuBool_Matrix result, - cuBool_Matrix left, - cuBool_Matrix right, - cuBool_Hints hints -); + cuBool_Matrix result, + cuBool_Matrix left, + cuBool_Matrix right, + cuBool_Hints hints); /** * Performs result = left x right evaluation, where source '+' and 'x' are boolean semiring operations. @@ -870,11 +829,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_MxM( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_MxV( - cuBool_Vector result, - cuBool_Matrix left, - cuBool_Vector right, - cuBool_Hints hints -); + cuBool_Vector result, + cuBool_Matrix left, + cuBool_Vector right, + cuBool_Hints hints); /** * Performs result = left x right evaluation, where source '+' and 'x' are boolean semiring operations. @@ -895,11 +853,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_MxV( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_VxM( - cuBool_Vector result, - cuBool_Vector left, - cuBool_Matrix right, - cuBool_Hints hints -); + cuBool_Vector result, + cuBool_Vector left, + cuBool_Matrix right, + cuBool_Hints hints); /** * Performs result = left `kron` right, where `kron` is a Kronecker product for boolean semiring. @@ -919,11 +876,10 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_VxM( * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Kronecker( - cuBool_Matrix result, - cuBool_Matrix left, - cuBool_Matrix right, - cuBool_Hints hints -); + cuBool_Matrix result, + cuBool_Matrix left, + cuBool_Matrix right, + cuBool_Hints hints); /** * Performs result = left * ~right, where @@ -938,17 +894,16 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Kronecker( * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time * * @param result[out] Destination matrix to store result - * @param left Source matrix to be multiplied - * @param right Source matrix to be inverted and multiplied + * @param matrix Source matrix to be multiplied + * @param mask Source matrix to be inverted and multiplied * @param hints Hints for the operation * * @return Error code on this operation */ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseMulInverted( - cuBool_Matrix result, - cuBool_Matrix matrix, - cuBool_Matrix mask, - cuBool_Hints hints -); + cuBool_Matrix result, + cuBool_Matrix matrix, + cuBool_Matrix mask, + cuBool_Hints hints); -#endif //CUBOOL_CUBOOL_H +#endif//CUBOOL_CUBOOL_H diff --git a/cubool/sources/backend/backend_base.hpp b/cubool/sources/backend/backend_base.hpp index b81864e..be8bed0 100644 --- a/cubool/sources/backend/backend_base.hpp +++ b/cubool/sources/backend/backend_base.hpp @@ -33,17 +33,17 @@ namespace cubool { class BackendBase { public: - virtual ~BackendBase() = default; - virtual void initialize(hints initHints) = 0; - virtual void finalize() = 0; - virtual bool isInitialized() const = 0; - virtual MatrixBase* createMatrix(size_t nrows, size_t ncols) = 0; - virtual VectorBase* createVector(size_t nrows) = 0; - virtual void releaseMatrix(MatrixBase* matrixBase) = 0; - virtual void releaseVector(VectorBase* vectorBase) = 0; - virtual void queryCapabilities(cuBool_DeviceCaps& caps) = 0; + virtual ~BackendBase() = default; + virtual void initialize(hints initHints) = 0; + virtual void finalize() = 0; + virtual bool isInitialized() const = 0; + virtual MatrixBase* createMatrix(size_t nrows, size_t ncols) = 0; + virtual VectorBase* createVector(size_t nrows) = 0; + virtual void releaseMatrix(MatrixBase* matrixBase) = 0; + virtual void releaseVector(VectorBase* vectorBase) = 0; + virtual void queryCapabilities(cuBool_DeviceCaps& caps) = 0; }; -} +}// namespace cubool -#endif //CUBOOL_BACKEND_BASE_HPP +#endif//CUBOOL_BACKEND_BASE_HPP diff --git a/cubool/sources/backend/matrix_base.hpp b/cubool/sources/backend/matrix_base.hpp index 8842eb9..e8fda05 100644 --- a/cubool/sources/backend/matrix_base.hpp +++ b/cubool/sources/backend/matrix_base.hpp @@ -36,28 +36,28 @@ namespace cubool { public: virtual ~MatrixBase() = default; - virtual void setElement(index i, index j) = 0; - virtual void build(const index *rows, const index *cols, size_t nvals, bool isSorted, bool noDuplicates) = 0; - virtual void extract(index* rows, index* cols, size_t &nvals) = 0; - virtual void extractSubMatrix(const MatrixBase &otherBase, index i, index j, index nrows, index ncols, bool checkTime) = 0; + virtual void setElement(index i, index j) = 0; + virtual void build(const index* rows, const index* cols, size_t nvals, bool isSorted, bool noDuplicates) = 0; + virtual void extract(index* rows, index* cols, size_t& nvals) = 0; + virtual void extractSubMatrix(const MatrixBase& otherBase, index i, index j, index nrows, index ncols, bool checkTime) = 0; - virtual void clone(const MatrixBase& otherBase) = 0; - virtual void transpose(const MatrixBase &otherBase, bool checkTime) = 0; - virtual void reduce(const MatrixBase &otherBase, bool checkTime) = 0; + virtual void clone(const MatrixBase& otherBase) = 0; + virtual void transpose(const MatrixBase& otherBase, bool checkTime) = 0; + virtual void reduce(const MatrixBase& otherBase, bool checkTime) = 0; - virtual void multiply(const MatrixBase &aBase, const MatrixBase &bBase, bool accumulate, bool checkTime) = 0; - virtual void kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) = 0; - virtual void eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) = 0; - virtual void eWiseMult(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) = 0; - virtual void eWiseMultInverted(const MatrixBase &matrix, const MatrixBase &mask, bool checkTime) = 0; + virtual void multiply(const MatrixBase& aBase, const MatrixBase& bBase, bool accumulate, bool checkTime) = 0; + virtual void kronecker(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) = 0; + virtual void eWiseAdd(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) = 0; + virtual void eWiseMult(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) = 0; + virtual void eWiseMultInverted(const MatrixBase& matrix, const MatrixBase& mask, bool checkTime) = 0; virtual index getNrows() const = 0; virtual index getNcols() const = 0; virtual index getNvals() const = 0; - bool isZeroDim() const { return (size_t)getNrows() * (size_t)getNcols() == 0; } + bool isZeroDim() const { return (size_t) getNrows() * (size_t) getNcols() == 0; } }; -} +}// namespace cubool -#endif //CUBOOL_MATRIX_BASE_HPP +#endif//CUBOOL_MATRIX_BASE_HPP diff --git a/cubool/sources/backend/vector_base.hpp b/cubool/sources/backend/vector_base.hpp index ae95300..3755400 100644 --- a/cubool/sources/backend/vector_base.hpp +++ b/cubool/sources/backend/vector_base.hpp @@ -36,19 +36,19 @@ namespace cubool { public: virtual ~VectorBase() = default; - virtual void setElement(index i) = 0; - virtual void build(const index *rows, size_t nvals, bool isSorted, bool noDuplicates) = 0; - virtual void extract(index* rows, size_t &nvals) = 0; - virtual void extractSubVector(const VectorBase &otherBase, index i, index nrows, bool checkTime) = 0; - virtual void extractRow(const class MatrixBase& matrixBase, index i) = 0; - virtual void extractCol(const class MatrixBase& matrixBase, index j) = 0; - - virtual void clone(const VectorBase& otherBase) = 0; - virtual void reduce(index &result, bool checkTime) = 0; + virtual void setElement(index i) = 0; + virtual void build(const index* rows, size_t nvals, bool isSorted, bool noDuplicates) = 0; + virtual void extract(index* rows, size_t& nvals) = 0; + virtual void extractSubVector(const VectorBase& otherBase, index i, index nrows, bool checkTime) = 0; + virtual void extractRow(const class MatrixBase& matrixBase, index i) = 0; + virtual void extractCol(const class MatrixBase& matrixBase, index j) = 0; + + virtual void clone(const VectorBase& otherBase) = 0; + virtual void reduce(index& result, bool checkTime) = 0; virtual void reduceMatrix(const class MatrixBase& matrix, bool transpose, bool checkTime) = 0; - virtual void eWiseMult(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) = 0; - virtual void eWiseAdd(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) = 0; + virtual void eWiseMult(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) = 0; + virtual void eWiseAdd(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) = 0; virtual void multiplyVxM(const VectorBase& vBase, const class MatrixBase& mBase, bool checkTime) = 0; virtual void multiplyMxV(const class MatrixBase& mBase, const VectorBase& vBase, bool checkTime) = 0; @@ -58,6 +58,6 @@ namespace cubool { bool isZeroDim() const { return getNrows() == 0; } }; -} +}// namespace cubool -#endif //CUBOOL_VECTOR_BASE_HPP +#endif//CUBOOL_VECTOR_BASE_HPP diff --git a/cubool/sources/core/config.hpp b/cubool/sources/core/config.hpp index d1987a6..4721594 100644 --- a/cubool/sources/core/config.hpp +++ b/cubool/sources/core/config.hpp @@ -25,14 +25,17 @@ #ifndef CUBOOL_CONFIG_HPP #define CUBOOL_CONFIG_HPP -#include #include #include +#include namespace cubool { using index = cuBool_Index; using hints = cuBool_Hints; - struct Pair { cuBool_Index i; cuBool_Index j; }; -} + struct Pair { + cuBool_Index i; + cuBool_Index j; + }; +}// namespace cubool -#endif //CUBOOL_CONFIG_HPP \ No newline at end of file +#endif//CUBOOL_CONFIG_HPP \ No newline at end of file diff --git a/cubool/sources/core/error.hpp b/cubool/sources/core/error.hpp index ff6e4c4..95f4799 100644 --- a/cubool/sources/core/error.hpp +++ b/cubool/sources/core/error.hpp @@ -27,8 +27,8 @@ #include #include -#include #include +#include namespace cubool { @@ -36,23 +36,21 @@ namespace cubool { * Generic library exception. * Use this one in particular backend implementations. */ - class Exception: public std::exception { + class Exception : public std::exception { public: - Exception(std::string message, std::string function, std::string file, size_t line, cuBool_Status status, bool critical) - : std::exception(), - mMessage(std::move(message)), - mFunction(std::move(function)), - mFile(std::move(file)), - mLine(line), - nStatus(status), - mCritical(critical) { - + : std::exception(), + mMessage(std::move(message)), + mFunction(std::move(function)), + mFile(std::move(file)), + mLine(line), + nStatus(status), + mCritical(critical) { } Exception(const Exception& e) noexcept = default; - Exception(Exception&& e) noexcept = default; - ~Exception() noexcept override = default; + Exception(Exception&& e) noexcept = default; + ~Exception() noexcept override = default; const char* what() const noexcept override { if (!mCached) { @@ -94,13 +92,13 @@ namespace cubool { private: mutable std::string mWhatCached; - std::string mMessage; - std::string mFunction; - std::string mFile; - size_t mLine; - cuBool_Status nStatus; - bool mCritical; - mutable bool mCached = false; + std::string mMessage; + std::string mFunction; + std::string mFile; + size_t mLine; + cuBool_Status nStatus; + bool mCritical; + mutable bool mCached = false; }; /** @@ -108,46 +106,51 @@ namespace cubool { * @tparam Type Exception error code (type) */ template - class TException: public Exception { + class TException : public Exception { public: TException(std::string message, std::string&& function, std::string&& file, size_t line, bool critical) - : Exception(std::move(message), std::move(function), std::move(file), line, Type, critical) { - + : Exception(std::move(message), std::move(function), std::move(file), line, Type, critical) { } TException(const TException& other) noexcept = default; - TException(TException&& other) noexcept = default; - ~TException() noexcept override = default; + TException(TException&& other) noexcept = default; + ~TException() noexcept override = default; }; // Errors exposed to the C API - using Error = TException; - using DeviceError = TException; + using Error = TException; + using DeviceError = TException; using DeviceNotPresent = TException; - using MemOpFailed = TException; - using InvalidArgument = TException; - using InvalidState = TException; - using BackendError = TException; - using NotImplemented = TException; + using MemOpFailed = TException; + using InvalidArgument = TException; + using InvalidState = TException; + using BackendError = TException; + using NotImplemented = TException; -} +}// namespace cubool // An error, in theory, can recover after this -#define RAISE_ERROR(type, message) \ - do { \ - throw ::cubool::type(message, __FUNCTION__, __FILE__, __LINE__, false); \ +#define RAISE_ERROR(type, message) \ + do { \ + throw ::cubool::type(message, __FUNCTION__, __FILE__, __LINE__, false); \ } while (0); -#define CHECK_RAISE_ERROR(condition, type, message) \ - if (!(condition)) { RAISE_ERROR(type, #condition ": " message); } else { } +#define CHECK_RAISE_ERROR(condition, type, message) \ + if (!(condition)) { \ + RAISE_ERROR(type, #condition ": " message); \ + } else { \ + } // Critical errors, cause library shutdown -#define RAISE_CRITICAL_ERROR(type, message) \ - do { \ - throw ::cubool::type(message, __FUNCTION__, __FILE__, __LINE__, true); \ +#define RAISE_CRITICAL_ERROR(type, message) \ + do { \ + throw ::cubool::type(message, __FUNCTION__, __FILE__, __LINE__, true); \ } while (0); -#define CHECK_RAISE_CRITICAL_ERROR(condition, type, message) \ - if (!(condition)) { RAISE_CRITICAL_ERROR(type, #condition ": " message); } else { } +#define CHECK_RAISE_CRITICAL_ERROR(condition, type, message) \ + if (!(condition)) { \ + RAISE_CRITICAL_ERROR(type, #condition ": " message); \ + } else { \ + } -#endif //CUBOOL_ERROR_HPP +#endif//CUBOOL_ERROR_HPP diff --git a/cubool/sources/core/library.cpp b/cubool/sources/core/library.cpp index 4987011..b5f5493 100644 --- a/cubool/sources/core/library.cpp +++ b/cubool/sources/core/library.cpp @@ -22,34 +22,34 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include +#include +#include #include +#include #include #include -#include -#include #include #include +#include #include #include -#include #ifdef CUBOOL_WITH_CUDA -#include + #include #endif #ifdef CUBOOL_WITH_SEQUENTIAL -#include + #include #endif namespace cubool { - std::unordered_set Library::mAllocMatrices; - std::unordered_set Library::mAllocVectors; - std::shared_ptr Library::mBackend = nullptr; - std::shared_ptr Library::mLogger = std::make_shared(); - bool Library::mRelaxedRelease = false; + std::unordered_set Library::mAllocMatrices; + std::unordered_set Library::mAllocVectors; + std::shared_ptr Library::mBackend = nullptr; + std::shared_ptr Library::mLogger = std::make_shared(); + bool Library::mRelaxedRelease = false; void Library::initialize(hints initHints) { CHECK_RAISE_CRITICAL_ERROR(mBackend == nullptr, InvalidState, "Library already initialized"); @@ -97,12 +97,12 @@ namespace cubool { LogStream stream(*getLogger()); stream << Logger::Level::Info << "Enabled relaxed library finalize" << LogStream::cmt; - for (auto m: mAllocMatrices) { + for (auto m : mAllocMatrices) { stream << Logger::Level::Warning << "Implicitly release matrix " << m->getDebugMarker() << LogStream::cmt; delete m; } - for (auto v: mAllocVectors) { + for (auto v : mAllocVectors) { stream << Logger::Level::Warning << "Implicitly release vector " << v->getDebugMarker() << LogStream::cmt; delete v; } @@ -127,7 +127,7 @@ namespace cubool { CHECK_RAISE_CRITICAL_ERROR(mBackend != nullptr || mRelaxedRelease, InvalidState, "Library is not initialized"); } - void Library::setupLogging(const char *logFileName, cuBool_Hints hints) { + void Library::setupLogging(const char* logFileName, cuBool_Hints hints) { CHECK_RAISE_ERROR(logFileName != nullptr, InvalidArgument, "Null file name is not allowed"); auto logFile = std::make_shared(); @@ -142,19 +142,19 @@ namespace cubool { auto textLogger = std::make_shared(); textLogger->addFilter([=](Logger::Level level, const std::string& message) -> bool { - bool all = hints == 0x0 || (hints & CUBOOL_HINT_LOG_ALL); - bool error = hints & CUBOOL_HINT_LOG_ERROR; + bool all = hints == 0x0 || (hints & CUBOOL_HINT_LOG_ALL); + bool error = hints & CUBOOL_HINT_LOG_ERROR; bool warning = hints & CUBOOL_HINT_LOG_WARNING; return all || - (error && level == Logger::Level::Error) || - (warning && level == Logger::Level::Warning); + (error && level == Logger::Level::Error) || + (warning && level == Logger::Level::Warning); }); textLogger->addOnLoggerAction([=](size_t id, Logger::Level level, const std::string& message) { auto& file = *logFile; - const auto idSize = 10; + const auto idSize = 10; const auto levelSize = 20; file << "[" << std::setw(idSize) << id << std::setw(-1) << "]"; @@ -187,7 +187,7 @@ namespace cubool { logDeviceInfo(); } - Matrix *Library::createMatrix(size_t nrows, size_t ncols) { + Matrix* Library::createMatrix(size_t nrows, size_t ncols) { CHECK_RAISE_ERROR(nrows > 0, InvalidArgument, "Cannot create matrix with zero dimension"); CHECK_RAISE_ERROR(ncols > 0, InvalidArgument, "Cannot create matrix with zero dimension"); @@ -201,7 +201,7 @@ namespace cubool { return m; } - class Vector * Library::createVector(size_t nrows) { + class Vector* Library::createVector(size_t nrows) { CHECK_RAISE_ERROR(nrows > 0, InvalidArgument, "Cannot create vector with zero dimension"); auto v = new Vector(nrows, *mBackend); @@ -214,7 +214,7 @@ namespace cubool { return v; } - void Library::releaseMatrix(Matrix *matrix) { + void Library::releaseMatrix(Matrix* matrix) { if (mRelaxedRelease && !mBackend) return; CHECK_RAISE_ERROR(mAllocMatrices.find(matrix) != mAllocMatrices.end(), InvalidArgument, "No such matrix was allocated"); @@ -226,7 +226,7 @@ namespace cubool { delete matrix; } - void Library::releaseVector(class Vector *vector) { + void Library::releaseVector(class Vector* vector) { if (mRelaxedRelease && !mBackend) return; CHECK_RAISE_ERROR(mAllocVectors.find(vector) != mAllocVectors.end(), InvalidArgument, "No such vector was allocated"); @@ -246,15 +246,15 @@ namespace cubool { #endif } - void Library::queryCapabilities(cuBool_DeviceCaps &caps) { - caps.name[0] = '\0'; - caps.cudaSupported = false; - caps.managedMem = false; - caps.major = 0; - caps.minor = 0; - caps.warp = 0; - caps.globalMemoryKiBs = 0; - caps.sharedMemoryPerBlockKiBs = 0; + void Library::queryCapabilities(cuBool_DeviceCaps& caps) { + caps.name[0] = '\0'; + caps.cudaSupported = false; + caps.managedMem = false; + caps.major = 0; + caps.minor = 0; + caps.warp = 0; + caps.globalMemoryKiBs = 0; + caps.sharedMemoryPerBlockKiBs = 0; caps.sharedMemoryPerMultiProcKiBs = 0; mBackend->queryCapabilities(caps); @@ -273,13 +273,12 @@ namespace cubool { << " name: " << caps.name << "," << " major: " << caps.major << "," << " minor: " << caps.minor << "," - << " mem type: " << (caps.managedMem? "managed": "default") << "," + << " mem type: " << (caps.managedMem ? "managed" : "default") << "," << " warp size: " << caps.warp << "," << " globalMemoryKiBs: " << caps.globalMemoryKiBs << "," << " sharedMemoryPerMultiProcKiBs: " << caps.sharedMemoryPerMultiProcKiBs << "," << " sharedMemoryPerBlockKiBs: " << caps.sharedMemoryPerBlockKiBs; - } - else { + } else { stream << "Cuda device is not presented (fallback to cpu backend)"; } @@ -290,8 +289,8 @@ namespace cubool { return mBackend != nullptr; } - class Logger * Library::getLogger() { + class Logger* Library::getLogger() { return mLogger.get(); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/core/library.hpp b/cubool/sources/core/library.hpp index f1d2ffc..0660da1 100644 --- a/cubool/sources/core/library.hpp +++ b/cubool/sources/core/library.hpp @@ -27,35 +27,35 @@ #include #include -#include #include +#include namespace cubool { class Library { public: - static void initialize(hints initHints); - static void finalize(); - static void validate(); - static void setupLogging(const char* logFileName, cuBool_Hints hints); - static class Matrix *createMatrix(size_t nrows, size_t ncols); - static class Vector *createVector(size_t nrows); - static void releaseMatrix(class Matrix *matrix); - static void releaseVector(class Vector *vector); - static void handleError(const std::exception& error); - static void queryCapabilities(cuBool_DeviceCaps& caps); - static void logDeviceInfo(); - static bool isBackedInitialized(); + static void initialize(hints initHints); + static void finalize(); + static void validate(); + static void setupLogging(const char* logFileName, cuBool_Hints hints); + static class Matrix* createMatrix(size_t nrows, size_t ncols); + static class Vector* createVector(size_t nrows); + static void releaseMatrix(class Matrix* matrix); + static void releaseVector(class Vector* vector); + static void handleError(const std::exception& error); + static void queryCapabilities(cuBool_DeviceCaps& caps); + static void logDeviceInfo(); + static bool isBackedInitialized(); static class Logger* getLogger(); private: - static std::unordered_set mAllocMatrices; - static std::unordered_set mAllocVectors; + static std::unordered_set mAllocMatrices; + static std::unordered_set mAllocVectors; static std::shared_ptr mBackend; - static std::shared_ptr mLogger; - static bool mRelaxedRelease; + static std::shared_ptr mLogger; + static bool mRelaxedRelease; }; -} +}// namespace cubool -#endif //CUBOOL_LIBRARY_HPP \ No newline at end of file +#endif//CUBOOL_LIBRARY_HPP \ No newline at end of file diff --git a/cubool/sources/core/matrix.cpp b/cubool/sources/core/matrix.cpp index 49e35c3..eae9618 100644 --- a/cubool/sources/core/matrix.cpp +++ b/cubool/sources/core/matrix.cpp @@ -22,30 +22,30 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include +#include #include #include +#include #include #include -#include -#define TIMER_ACTION(timer, action) \ - Timer timer; \ - timer.start(); \ - action; \ +#define TIMER_ACTION(timer, action) \ + Timer timer; \ + timer.start(); \ + action; \ timer.end() namespace cubool { - Matrix::Matrix(size_t nrows, size_t ncols, BackendBase &backend) { - mHnd = backend.createMatrix(nrows, ncols); + Matrix::Matrix(size_t nrows, size_t ncols, BackendBase& backend) { + mHnd = backend.createMatrix(nrows, ncols); mProvider = &backend; } Matrix::~Matrix() { if (mHnd) { mProvider->releaseMatrix(mHnd); - mHnd = nullptr; + mHnd = nullptr; mProvider = nullptr; } } @@ -59,7 +59,7 @@ namespace cubool { mCachedJ.push_back(j); } - void Matrix::build(const index *rows, const index *cols, size_t nvals, bool isSorted, bool noDuplicates) { + void Matrix::build(const index* rows, const index* cols, size_t nvals, bool isSorted, bool noDuplicates) { CHECK_RAISE_ERROR(rows != nullptr || nvals == 0, InvalidArgument, "Null ptr rows array"); CHECK_RAISE_ERROR(cols != nullptr || nvals == 0, InvalidArgument, "Null ptr cols array"); @@ -74,7 +74,7 @@ namespace cubool { mHnd->build(rows, cols, nvals, isSorted, noDuplicates); } - void Matrix::extract(index *rows, index *cols, size_t &nvals) { + void Matrix::extract(index* rows, index* cols, size_t& nvals) { CHECK_RAISE_ERROR(rows != nullptr || getNvals() == 0, InvalidArgument, "Null ptr rows array"); CHECK_RAISE_ERROR(cols != nullptr || getNvals() == 0, InvalidArgument, "Null ptr cols array"); CHECK_RAISE_ERROR(getNvals() <= nvals, InvalidArgument, "Passed arrays size must be more or equal to the nvals of the matrix"); @@ -83,7 +83,7 @@ namespace cubool { mHnd->extract(rows, cols, nvals); } - void Matrix::extractSubMatrix(const MatrixBase &otherBase, index i, index j, index nrows, index ncols, bool checkTime) { + void Matrix::extractSubMatrix(const MatrixBase& otherBase, index i, index j, index nrows, index ncols, bool checkTime) { const auto* other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); @@ -101,7 +101,7 @@ namespace cubool { CHECK_RAISE_ERROR(ncols == this->getNcols(), InvalidArgument, "Result matrix has incompatible size for extracted sub-matrix range"); other->commitCache(); - this->releaseCache(); // Values of this matrix won't be used any more + this->releaseCache();// Values of this matrix won't be used any more if (checkTime) { TIMER_ACTION(timer, mHnd->extractSubMatrix(*other->mHnd, i, j, nrows, ncols, false)); @@ -120,7 +120,7 @@ namespace cubool { mHnd->extractSubMatrix(*other->mHnd, i, j, nrows, ncols, false); } - void Matrix::clone(const MatrixBase &otherBase) { + void Matrix::clone(const MatrixBase& otherBase) { const auto* other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); @@ -135,12 +135,12 @@ namespace cubool { CHECK_RAISE_ERROR(N == this->getNcols(), InvalidArgument, "Cloned matrix has incompatible size"); other->commitCache(); - this->releaseCache(); // Values of this matrix won't be used any more + this->releaseCache();// Values of this matrix won't be used any more mHnd->clone(*other->mHnd); } - void Matrix::transpose(const MatrixBase &otherBase, bool checkTime) { + void Matrix::transpose(const MatrixBase& otherBase, bool checkTime) { const auto* other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); @@ -152,7 +152,7 @@ namespace cubool { CHECK_RAISE_ERROR(N == this->getNrows(), InvalidArgument, "Transposed matrix has incompatible size"); this->commitCache(); - this->releaseCache(); // Values of this matrix won't be used any more + this->releaseCache();// Values of this matrix won't be used any more if (checkTime) { TIMER_ACTION(timer, mHnd->transpose(*other->mHnd, false)); @@ -170,7 +170,7 @@ namespace cubool { mHnd->transpose(*other->mHnd, false); } - void Matrix::reduce(const MatrixBase &otherBase, bool checkTime) { + void Matrix::reduce(const MatrixBase& otherBase, bool checkTime) { const auto* other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); @@ -181,7 +181,7 @@ namespace cubool { CHECK_RAISE_ERROR(1 == this->getNcols(), InvalidArgument, "Matrix has incompatible size"); other->commitCache(); - this->releaseCache(); // Values of this matrix won't be used any more + this->releaseCache();// Values of this matrix won't be used any more if (checkTime) { TIMER_ACTION(timer, mHnd->reduce(*other->mHnd, false)); @@ -199,7 +199,7 @@ namespace cubool { mHnd->reduce(*other->mHnd, false); } - void Matrix::multiply(const MatrixBase &aBase, const MatrixBase &bBase, bool accumulate, bool checkTime) { + void Matrix::multiply(const MatrixBase& aBase, const MatrixBase& bBase, bool accumulate, bool checkTime) { const auto* a = dynamic_cast(&aBase); const auto* b = dynamic_cast(&bBase); @@ -229,7 +229,7 @@ namespace cubool { stream << Logger::Level::Info << "Time: " << timer.getElapsedTimeMs() << " ms " << "Matrix::multiply: " - << this->getDebugMarker() << (accumulate? " += ": " = ") + << this->getDebugMarker() << (accumulate ? " += " : " = ") << a->getDebugMarker() << " x " << b->getDebugMarker() << LogStream::cmt; @@ -239,7 +239,7 @@ namespace cubool { mHnd->multiply(*a->mHnd, *b->mHnd, accumulate, false); } - void Matrix::kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void Matrix::kronecker(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { const auto* a = dynamic_cast(&aBase); const auto* b = dynamic_cast(&bBase); @@ -275,7 +275,7 @@ namespace cubool { mHnd->kronecker(*a->mHnd, *b->mHnd, false); } - void Matrix::eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void Matrix::eWiseAdd(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { const auto* a = dynamic_cast(&aBase); const auto* b = dynamic_cast(&bBase); @@ -312,7 +312,7 @@ namespace cubool { mHnd->eWiseAdd(*a->mHnd, *b->mHnd, false); } - void Matrix::eWiseMult(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void Matrix::eWiseMult(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { const auto* a = dynamic_cast(&aBase); const auto* b = dynamic_cast(&bBase); @@ -349,7 +349,7 @@ namespace cubool { mHnd->eWiseMult(*a->mHnd, *b->mHnd, false); } - void Matrix::eWiseMultInverted(const MatrixBase &matrix, const MatrixBase &mask, bool checkTime) { + void Matrix::eWiseMultInverted(const MatrixBase& matrix, const MatrixBase& mask, bool checkTime) { const auto* mat = dynamic_cast(&matrix); const auto* msk = dynamic_cast(&mask); @@ -388,7 +388,6 @@ namespace cubool { } - index Matrix::getNrows() const { return mHnd->getNrows(); } @@ -416,7 +415,7 @@ namespace cubool { if (cachedNvals == 0) return; - bool isSorted = false; + bool isSorted = false; bool noDuplicates = false; if (mHnd->getNvals() > 0) { @@ -427,8 +426,7 @@ namespace cubool { tmp->build(mCachedI.data(), mCachedJ.data(), cachedNvals, isSorted, noDuplicates); mHnd->eWiseAdd(*mHnd, *tmp, false); mProvider->releaseMatrix(tmp); - } - else { + } else { // Otherwise, new values are used to build matrix content mHnd->build(mCachedI.data(), mCachedJ.data(), cachedNvals, isSorted, noDuplicates); } @@ -436,4 +434,4 @@ namespace cubool { // Clear arrays releaseCache(); } -} +}// namespace cubool diff --git a/cubool/sources/core/matrix.hpp b/cubool/sources/core/matrix.hpp index 6c4d38b..6b3d037 100644 --- a/cubool/sources/core/matrix.hpp +++ b/cubool/sources/core/matrix.hpp @@ -25,10 +25,10 @@ #ifndef CUBOOL_MATRIX_HPP #define CUBOOL_MATRIX_HPP +#include +#include #include #include -#include -#include #include namespace cubool { @@ -37,26 +37,26 @@ namespace cubool { * Proxy matrix for the actual backend matrix implementation. * Behaves as validation/auxiliary layer. */ - class Matrix final: public MatrixBase, public Object { + class Matrix final : public MatrixBase, public Object { public: Matrix(size_t nrows, size_t ncols, BackendBase& backend); ~Matrix() override; void setElement(index i, index j) override; - void build(const index *rows, const index *cols, size_t nvals, bool isSorted, bool noDuplicates) override; - void extract(index *rows, index *cols, size_t &nvals) override; - void extractSubMatrix(const MatrixBase &otherBase, index i, index j, index nrows, index ncols, + void build(const index* rows, const index* cols, size_t nvals, bool isSorted, bool noDuplicates) override; + void extract(index* rows, index* cols, size_t& nvals) override; + void extractSubMatrix(const MatrixBase& otherBase, index i, index j, index nrows, index ncols, bool checkTime) override; - void clone(const MatrixBase &otherBase) override; - void transpose(const MatrixBase &otherBase, bool checkTime) override; - void reduce(const MatrixBase &otherBase, bool checkTime) override; + void clone(const MatrixBase& otherBase) override; + void transpose(const MatrixBase& otherBase, bool checkTime) override; + void reduce(const MatrixBase& otherBase, bool checkTime) override; - void multiply(const MatrixBase &aBase, const MatrixBase &bBase, bool accumulate, bool checkTime) override; - void kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) override; - void eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) override; - void eWiseMult(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; - void eWiseMultInverted(const MatrixBase &matrix, const MatrixBase &mask, bool checkTime) override; + void multiply(const MatrixBase& aBase, const MatrixBase& bBase, bool accumulate, bool checkTime) override; + void kronecker(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) override; + void eWiseAdd(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) override; + void eWiseMult(const MatrixBase& a, const MatrixBase& b, bool checkTime) override; + void eWiseMultInverted(const MatrixBase& matrix, const MatrixBase& mask, bool checkTime) override; index getNrows() const override; index getNcols() const override; @@ -72,10 +72,10 @@ namespace cubool { mutable std::vector mCachedJ; // Implementation handle references - MatrixBase* mHnd = nullptr; + MatrixBase* mHnd = nullptr; BackendBase* mProvider = nullptr; }; -} +}// namespace cubool -#endif //CUBOOL_MATRIX_HPP +#endif//CUBOOL_MATRIX_HPP diff --git a/cubool/sources/core/object.cpp b/cubool/sources/core/object.cpp index 550d53f..a74b301 100644 --- a/cubool/sources/core/object.cpp +++ b/cubool/sources/core/object.cpp @@ -22,8 +22,8 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include #include +#include namespace cubool { @@ -34,7 +34,7 @@ namespace cubool { mMarker = s.str(); } - void Object::setDebugMarker(const char *marker) { + void Object::setDebugMarker(const char* marker) { CHECK_RAISE_ERROR(marker, InvalidArgument, "Null pointer marker string"); // Marker = "$marker (address)" @@ -51,4 +51,4 @@ namespace cubool { return mMarker.length() + 1; } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/core/object.hpp b/cubool/sources/core/object.hpp index 75f8a00..868ae2b 100644 --- a/cubool/sources/core/object.hpp +++ b/cubool/sources/core/object.hpp @@ -33,15 +33,15 @@ namespace cubool { class Object { public: Object(); - void setDebugMarker(const char* marker); + void setDebugMarker(const char* marker); const char* getDebugMarker() const; - index getDebugMarkerSizeWithNullT() const; + index getDebugMarkerSizeWithNullT() const; protected: // Marker for debugging std::string mMarker; }; -} +}// namespace cubool -#endif //CUBOOL_OBJECT_HPP +#endif//CUBOOL_OBJECT_HPP diff --git a/cubool/sources/core/vector.cpp b/cubool/sources/core/vector.cpp index ca0ce5d..d5ac0f5 100644 --- a/cubool/sources/core/vector.cpp +++ b/cubool/sources/core/vector.cpp @@ -22,30 +22,30 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include -#include #include #include -#include +#include +#include #include +#include -#define TIMER_ACTION(timer, action) \ - Timer timer; \ - timer.start(); \ - action; \ +#define TIMER_ACTION(timer, action) \ + Timer timer; \ + timer.start(); \ + action; \ timer.end() namespace cubool { - Vector::Vector(size_t nrows, BackendBase &backend) { - mHnd = backend.createVector(nrows); + Vector::Vector(size_t nrows, BackendBase& backend) { + mHnd = backend.createVector(nrows); mProvider = &backend; } Vector::~Vector() { if (mHnd) { mProvider->releaseVector(mHnd); - mHnd = nullptr; + mHnd = nullptr; mProvider = nullptr; } } @@ -57,7 +57,7 @@ namespace cubool { mCachedI.push_back(i); } - void Vector::build(const index *rows, size_t nvals, bool isSorted, bool noDuplicates) { + void Vector::build(const index* rows, size_t nvals, bool isSorted, bool noDuplicates) { CHECK_RAISE_ERROR(rows != nullptr || nvals == 0, InvalidArgument, "Null ptr rows array"); this->releaseCache(); @@ -71,7 +71,7 @@ namespace cubool { mHnd->build(rows, nvals, isSorted, noDuplicates); } - void Vector::extract(index *rows, size_t &nvals) { + void Vector::extract(index* rows, size_t& nvals) { CHECK_RAISE_ERROR(rows != nullptr || getNvals() == 0, InvalidArgument, "Null ptr rows array"); CHECK_RAISE_ERROR(getNvals() <= nvals, InvalidArgument, "Passed arrays size must be more or equal to the nvals of the vector"); @@ -79,7 +79,7 @@ namespace cubool { mHnd->extract(rows, nvals); } - void Vector::extractSubVector(const VectorBase &otherBase, index i, index nrows, bool checkTime) { + void Vector::extractSubVector(const VectorBase& otherBase, index i, index nrows, bool checkTime) { const auto* other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed vector does not belong to core vector class"); @@ -91,7 +91,7 @@ namespace cubool { CHECK_RAISE_ERROR(nrows == this->getNrows(), InvalidArgument, "Result matrix has incompatible size for extracted sub-matrix range"); other->commitCache(); - this->releaseCache(); // Values of this vector won't be used any more + this->releaseCache();// Values of this vector won't be used any more if (checkTime) { TIMER_ACTION(timer, mHnd->extractSubVector(*other->mHnd, i, nrows, false)); @@ -110,7 +110,7 @@ namespace cubool { mHnd->extractSubVector(*other->mHnd, i, nrows, false); } - void Vector::extractRow(const class MatrixBase &matrixBase, index i) { + void Vector::extractRow(const class MatrixBase& matrixBase, index i) { const auto* matrix = dynamic_cast(&matrixBase); CHECK_RAISE_ERROR(matrix != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); @@ -122,7 +122,7 @@ namespace cubool { mHnd->extractRow(*matrix->mHnd, i); } - void Vector::extractCol(const class MatrixBase &matrixBase, index j) { + void Vector::extractCol(const class MatrixBase& matrixBase, index j) { const auto* matrix = dynamic_cast(&matrixBase); CHECK_RAISE_ERROR(matrix != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); @@ -134,7 +134,7 @@ namespace cubool { mHnd->extractCol(*matrix->mHnd, j); } - void Vector::clone(const VectorBase &otherBase) { + void Vector::clone(const VectorBase& otherBase) { const auto* other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed vector does not belong to core vector class"); @@ -147,12 +147,12 @@ namespace cubool { CHECK_RAISE_ERROR(M == this->getNrows(), InvalidArgument, "Cloned vector has incompatible size"); other->commitCache(); - this->releaseCache(); // Values of this vector won't be used any more + this->releaseCache();// Values of this vector won't be used any more mHnd->clone(*other->mHnd); } - void Vector::reduce(index &result, bool checkTime) { + void Vector::reduce(index& result, bool checkTime) { this->commitCache(); if (checkTime) { @@ -172,15 +172,14 @@ namespace cubool { mHnd->reduce(result, false); } - void Vector::reduceMatrix(const MatrixBase &matrixBase, bool transpose, bool checkTime) { + void Vector::reduceMatrix(const MatrixBase& matrixBase, bool transpose, bool checkTime) { const auto* matrix = dynamic_cast(&matrixBase); CHECK_RAISE_ERROR(matrix != nullptr, InvalidArgument, "Passed matrix does not belong to core matrix class"); if (transpose) { CHECK_RAISE_ERROR(matrix->getNcols() == this->getNrows(), InvalidArgument, "Passed matrix has incompatible size"); - } - else { + } else { CHECK_RAISE_ERROR(matrix->getNrows() == this->getNrows(), InvalidArgument, "Passed matrix has incompatible size"); } @@ -203,7 +202,7 @@ namespace cubool { mHnd->reduceMatrix(*matrix->mHnd, transpose, false); } - void Vector::eWiseMult(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) { + void Vector::eWiseMult(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) { const auto* a = dynamic_cast(&aBase); const auto* b = dynamic_cast(&bBase); @@ -236,7 +235,7 @@ namespace cubool { mHnd->eWiseMult(*a->mHnd, *b->mHnd, false); } - void Vector::eWiseAdd(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) { + void Vector::eWiseAdd(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) { const auto* a = dynamic_cast(&aBase); const auto* b = dynamic_cast(&bBase); @@ -269,7 +268,7 @@ namespace cubool { mHnd->eWiseAdd(*a->mHnd, *b->mHnd, false); } - void Vector::multiplyVxM(const VectorBase &vBase, const class MatrixBase &mBase, bool checkTime) { + void Vector::multiplyVxM(const VectorBase& vBase, const class MatrixBase& mBase, bool checkTime) { const auto* v = dynamic_cast(&vBase); const auto* m = dynamic_cast(&mBase); @@ -300,7 +299,7 @@ namespace cubool { mHnd->multiplyVxM(*v->mHnd, *m->mHnd, false); } - void Vector::multiplyMxV(const class MatrixBase &mBase, const VectorBase &vBase, bool checkTime) { + void Vector::multiplyMxV(const class MatrixBase& mBase, const VectorBase& vBase, bool checkTime) { const auto* v = dynamic_cast(&vBase); const auto* m = dynamic_cast(&mBase); @@ -351,7 +350,7 @@ namespace cubool { if (cachedNvals == 0) return; - bool isSorted = false; + bool isSorted = false; bool noDuplicates = false; if (mHnd->getNvals() > 0) { @@ -362,8 +361,7 @@ namespace cubool { tmp->build(mCachedI.data(), cachedNvals, isSorted, noDuplicates); mHnd->eWiseAdd(*mHnd, *tmp, false); mProvider->releaseVector(tmp); - } - else { + } else { // Otherwise, new values are used to build vector content mHnd->build(mCachedI.data(), cachedNvals, isSorted, noDuplicates); } @@ -372,4 +370,4 @@ namespace cubool { releaseCache(); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/core/vector.hpp b/cubool/sources/core/vector.hpp index f1aba19..68b05bc 100644 --- a/cubool/sources/core/vector.hpp +++ b/cubool/sources/core/vector.hpp @@ -25,33 +25,33 @@ #ifndef CUBOOL_VECTOR_HPP #define CUBOOL_VECTOR_HPP +#include +#include #include #include -#include -#include -#include #include +#include namespace cubool { - class Vector final: public VectorBase, public Object { + class Vector final : public VectorBase, public Object { public: Vector(size_t nrows, BackendBase& backendBase); ~Vector() override; void setElement(index i) override; - void build(const index *rows, size_t nvals, bool isSorted, bool noDuplicates) override; - void extract(index *rows, size_t &nvals) override; - void extractSubVector(const VectorBase &otherBase, index i, index nrows, bool checkTime) override; + void build(const index* rows, size_t nvals, bool isSorted, bool noDuplicates) override; + void extract(index* rows, size_t& nvals) override; + void extractSubVector(const VectorBase& otherBase, index i, index nrows, bool checkTime) override; void extractRow(const class MatrixBase& matrixBase, index i) override; void extractCol(const class MatrixBase& matrixBase, index j) override; - void clone(const VectorBase &otherBase) override; - void reduce(index &result, bool checkTime) override; - void reduceMatrix(const MatrixBase &matrix, bool transpose, bool checkTime) override; + void clone(const VectorBase& otherBase) override; + void reduce(index& result, bool checkTime) override; + void reduceMatrix(const MatrixBase& matrix, bool transpose, bool checkTime) override; - void eWiseMult(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) override; - void eWiseAdd(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) override; + void eWiseMult(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) override; + void eWiseAdd(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) override; void multiplyVxM(const VectorBase& vBase, const class MatrixBase& mBase, bool checkTime) override; void multiplyMxV(const class MatrixBase& mBase, const VectorBase& vBase, bool checkTime) override; @@ -59,7 +59,6 @@ namespace cubool { index getNvals() const override; private: - void releaseCache() const; void commitCache() const; @@ -67,10 +66,10 @@ namespace cubool { mutable std::vector mCachedI; // Implementation handle references - VectorBase* mHnd = nullptr; + VectorBase* mHnd = nullptr; BackendBase* mProvider = nullptr; }; -} +}// namespace cubool -#endif //CUBOOL_VECTOR_HPP \ No newline at end of file +#endif//CUBOOL_VECTOR_HPP \ No newline at end of file diff --git a/cubool/sources/core/version.hpp b/cubool/sources/core/version.hpp index 13aec3e..9e2dd96 100644 --- a/cubool/sources/core/version.hpp +++ b/cubool/sources/core/version.hpp @@ -34,4 +34,4 @@ /** Defined in cmake */ #define CUBOOL_SUB CUBOOL_VERSION_SUB -#endif //CUBOOL_VERSION_HPP +#endif//CUBOOL_VERSION_HPP diff --git a/cubool/sources/cuBool_Common.hpp b/cubool/sources/cuBool_Common.hpp index 0da816d..38842a4 100644 --- a/cubool/sources/cuBool_Common.hpp +++ b/cubool/sources/cuBool_Common.hpp @@ -25,35 +25,36 @@ #ifndef CUBOOL_CUBOOL_COMMON_HPP #define CUBOOL_CUBOOL_COMMON_HPP -#include #include -#include #include #include #include #include +#include #include +#include // State validation -#define CUBOOL_VALIDATE_LIBRARY \ +#define CUBOOL_VALIDATE_LIBRARY \ cubool::Library::validate(); // Arguments validation -#define CUBOOL_ARG_NOT_NULL(arg) \ +#define CUBOOL_ARG_NOT_NULL(arg) \ CHECK_RAISE_ERROR(arg != nullptr, InvalidArgument, "Passed null argument") -#define CUBOOL_BEGIN_BODY \ +#define CUBOOL_BEGIN_BODY \ try { -#define CUBOOL_END_BODY } \ - catch (const cubool::Error& err) { \ - cubool::Library::handleError(err); \ - return err.getStatus(); \ - } \ - catch (const std::exception& exc) { \ - cubool::Library::handleError(exc); \ - return CUBOOL_STATUS_ERROR; \ - } \ +#define CUBOOL_END_BODY \ + } \ + catch (const cubool::Error& err) { \ + cubool::Library::handleError(err); \ + return err.getStatus(); \ + } \ + catch (const std::exception& exc) { \ + cubool::Library::handleError(exc); \ + return CUBOOL_STATUS_ERROR; \ + } \ return cuBool_Status::CUBOOL_STATUS_SUCCESS; -#endif //CUBOOL_CUBOOL_COMMON_HPP +#endif//CUBOOL_CUBOOL_COMMON_HPP diff --git a/cubool/sources/cuBool_Finalize.cpp b/cubool/sources/cuBool_Finalize.cpp index e650cf0..419206f 100644 --- a/cubool/sources/cuBool_Finalize.cpp +++ b/cubool/sources/cuBool_Finalize.cpp @@ -24,10 +24,9 @@ #include -cuBool_Status cuBool_Finalize( -) { +cuBool_Status cuBool_Finalize() { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - cubool::Library::finalize(); + CUBOOL_VALIDATE_LIBRARY + cubool::Library::finalize(); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_GetAbout.cpp b/cubool/sources/cuBool_GetAbout.cpp index 151cb3a..8f28a24 100644 --- a/cubool/sources/cuBool_GetAbout.cpp +++ b/cubool/sources/cuBool_GetAbout.cpp @@ -26,16 +26,16 @@ const char* cuBool_GetAbout() { static const char about[] = - "CuBool is a linear boolean algebra library primitives and operations for \n" - "work with dense and sparse matrices written on the NVIDIA CUDA platform. The primary \n" - "goal of the library is implementation, testing and profiling algorithms for\n" - "solving *formal-language-constrained problems*, such as *context-free* \n" - "and *recursive* path queries with various semantics for graph databases." - "" - "Contributors:" - "- Egor Orachyov (Github: https://github.com/EgorOrachyov)\n" - "- Pavel Alimov (Github : https://github.com/Krekep)\n" - "- Semyon Grigorev (Github: https://github.com/gsvgit)"; + "CuBool is a linear boolean algebra library primitives and operations for \n" + "work with dense and sparse matrices written on the NVIDIA CUDA platform. The primary \n" + "goal of the library is implementation, testing and profiling algorithms for\n" + "solving *formal-language-constrained problems*, such as *context-free* \n" + "and *recursive* path queries with various semantics for graph databases." + "" + "Contributors:" + "- Egor Orachyov (Github: https://github.com/EgorOrachyov)\n" + "- Pavel Alimov (Github : https://github.com/Krekep)\n" + "- Semyon Grigorev (Github: https://github.com/gsvgit)"; return about; } \ No newline at end of file diff --git a/cubool/sources/cuBool_GetDeviceCaps.cpp b/cubool/sources/cuBool_GetDeviceCaps.cpp index 90fb5d6..1db60db 100644 --- a/cubool/sources/cuBool_GetDeviceCaps.cpp +++ b/cubool/sources/cuBool_GetDeviceCaps.cpp @@ -25,11 +25,10 @@ #include cuBool_Status cuBool_GetDeviceCaps( - cuBool_DeviceCaps* deviceCaps -) { + cuBool_DeviceCaps* deviceCaps) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(deviceCaps) - cubool::Library::queryCapabilities(*deviceCaps); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(deviceCaps) + cubool::Library::queryCapabilities(*deviceCaps); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_GetLicenseInfo.cpp b/cubool/sources/cuBool_GetLicenseInfo.cpp index fc04105..d3f22e4 100644 --- a/cubool/sources/cuBool_GetLicenseInfo.cpp +++ b/cubool/sources/cuBool_GetLicenseInfo.cpp @@ -26,27 +26,27 @@ const char* cuBool_GetLicenseInfo() { static const char license[] = - "MIT License\n" - "\n" - "Copyright (c) 2020 JetBrains-Research\n" - "\n" - "Permission is hereby granted, free of charge, to any person obtaining a copy\n" - "of this software and associated documentation files (the \"Software\"), to deal\n" - "in the Software without restriction, including without limitation the rights\n" - "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n" - "copies of the Software, and to permit persons to whom the Software is\n" - "furnished to do so, subject to the following conditions:\n" - "\n" - "The above copyright notice and this permission notice shall be included in all\n" - "copies or substantial portions of the Software.\n" - "\n" - "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" - "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" - "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n" - "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" - "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n" - "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n" - "SOFTWARE."; + "MIT License\n" + "\n" + "Copyright (c) 2020 JetBrains-Research\n" + "\n" + "Permission is hereby granted, free of charge, to any person obtaining a copy\n" + "of this software and associated documentation files (the \"Software\"), to deal\n" + "in the Software without restriction, including without limitation the rights\n" + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n" + "copies of the Software, and to permit persons to whom the Software is\n" + "furnished to do so, subject to the following conditions:\n" + "\n" + "The above copyright notice and this permission notice shall be included in all\n" + "copies or substantial portions of the Software.\n" + "\n" + "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n" + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n" + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n" + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n" + "SOFTWARE."; return license; } \ No newline at end of file diff --git a/cubool/sources/cuBool_GetVersion.cpp b/cubool/sources/cuBool_GetVersion.cpp index 8b2d288..c1617f3 100644 --- a/cubool/sources/cuBool_GetVersion.cpp +++ b/cubool/sources/cuBool_GetVersion.cpp @@ -25,13 +25,12 @@ #include cuBool_Status cuBool_GetVersion( - int *major, - int *minor, - int *sub -) { - auto MAJOR = (uint32_t)(CUBOOL_MAJOR); - auto MINOR = (uint32_t)(CUBOOL_MINOR); - auto SUB = (uint32_t)(CUBOOL_SUB); + int* major, + int* minor, + int* sub) { + auto MAJOR = (uint32_t) (CUBOOL_MAJOR); + auto MINOR = (uint32_t) (CUBOOL_MINOR); + auto SUB = (uint32_t) (CUBOOL_SUB); if (major) *major = MAJOR; diff --git a/cubool/sources/cuBool_Initialize.cpp b/cubool/sources/cuBool_Initialize.cpp index 820c065..be31c96 100644 --- a/cubool/sources/cuBool_Initialize.cpp +++ b/cubool/sources/cuBool_Initialize.cpp @@ -25,10 +25,8 @@ #include cuBool_Status cuBool_Initialize( - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - cubool::Library::initialize(hints); + cubool::Library::initialize(hints); CUBOOL_END_BODY } - diff --git a/cubool/sources/cuBool_Kronecker.cpp b/cubool/sources/cuBool_Kronecker.cpp index 4f11b64..358df8f 100644 --- a/cubool/sources/cuBool_Kronecker.cpp +++ b/cubool/sources/cuBool_Kronecker.cpp @@ -28,16 +28,15 @@ cuBool_Status cuBool_Kronecker( cuBool_Matrix result, cuBool_Matrix left, cuBool_Matrix right, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(left) - CUBOOL_ARG_NOT_NULL(right) - auto resultM = (cubool::Matrix *) result; - auto leftM = (cubool::Matrix *) left; - auto rightM = (cubool::Matrix *) right; - resultM->kronecker(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(left) + CUBOOL_ARG_NOT_NULL(right) + auto resultM = (cubool::Matrix*) result; + auto leftM = (cubool::Matrix*) left; + auto rightM = (cubool::Matrix*) right; + resultM->kronecker(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_Build.cpp b/cubool/sources/cuBool_Matrix_Build.cpp index 8ca6d3e..114527f 100644 --- a/cubool/sources/cuBool_Matrix_Build.cpp +++ b/cubool/sources/cuBool_Matrix_Build.cpp @@ -25,16 +25,15 @@ #include cuBool_Status cuBool_Matrix_Build( - cuBool_Matrix matrix, - const cuBool_Index *rows, - const cuBool_Index *cols, - cuBool_Index nvals, - cuBool_Hints hints -) { + cuBool_Matrix matrix, + const cuBool_Index* rows, + const cuBool_Index* cols, + cuBool_Index nvals, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - auto m = (cubool::Matrix *) matrix; - m->build(rows, cols, nvals, hints & CUBOOL_HINT_VALUES_SORTED, hints & CUBOOL_HINT_NO_DUPLICATES); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + auto m = (cubool::Matrix*) matrix; + m->build(rows, cols, nvals, hints & CUBOOL_HINT_VALUES_SORTED, hints & CUBOOL_HINT_NO_DUPLICATES); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_Duplicate.cpp b/cubool/sources/cuBool_Matrix_Duplicate.cpp index de47b15..f9dc5f0 100644 --- a/cubool/sources/cuBool_Matrix_Duplicate.cpp +++ b/cubool/sources/cuBool_Matrix_Duplicate.cpp @@ -25,16 +25,15 @@ #include cuBool_Status cuBool_Matrix_Duplicate( - cuBool_Matrix matrix, - cuBool_Matrix *duplicated -) { + cuBool_Matrix matrix, + cuBool_Matrix* duplicated) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(duplicated) - auto m = (cubool::Matrix *) matrix; - auto d = cubool::Library::createMatrix(m->getNrows(), m->getNcols()); - d->clone(*m); - *duplicated = (cuBool_Matrix_t *) d; + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(duplicated) + auto m = (cubool::Matrix*) matrix; + auto d = cubool::Library::createMatrix(m->getNrows(), m->getNcols()); + d->clone(*m); + *duplicated = (cuBool_Matrix_t*) d; CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_EWiseAdd.cpp b/cubool/sources/cuBool_Matrix_EWiseAdd.cpp index e8fe446..cc43d12 100644 --- a/cubool/sources/cuBool_Matrix_EWiseAdd.cpp +++ b/cubool/sources/cuBool_Matrix_EWiseAdd.cpp @@ -28,16 +28,15 @@ cuBool_Status cuBool_Matrix_EWiseAdd( cuBool_Matrix result, cuBool_Matrix left, cuBool_Matrix right, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(left) - CUBOOL_ARG_NOT_NULL(right) - auto resultM = (cubool::Matrix *) result; - auto leftM = (cubool::Matrix *) left; - auto rightM = (cubool::Matrix *) right; - resultM->eWiseAdd(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(left) + CUBOOL_ARG_NOT_NULL(right) + auto resultM = (cubool::Matrix*) result; + auto leftM = (cubool::Matrix*) left; + auto rightM = (cubool::Matrix*) right; + resultM->eWiseAdd(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_EWiseMult.cpp b/cubool/sources/cuBool_Matrix_EWiseMult.cpp index bfaf194..0edbd10 100644 --- a/cubool/sources/cuBool_Matrix_EWiseMult.cpp +++ b/cubool/sources/cuBool_Matrix_EWiseMult.cpp @@ -28,16 +28,15 @@ cuBool_Status cuBool_Matrix_EWiseMult( cuBool_Matrix result, cuBool_Matrix left, cuBool_Matrix right, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(left) - CUBOOL_ARG_NOT_NULL(right) - auto resultM = (cubool::Matrix *) result; - auto leftM = (cubool::Matrix *) left; - auto rightM = (cubool::Matrix *) right; - resultM->eWiseMult(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(left) + CUBOOL_ARG_NOT_NULL(right) + auto resultM = (cubool::Matrix*) result; + auto leftM = (cubool::Matrix*) left; + auto rightM = (cubool::Matrix*) right; + resultM->eWiseMult(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_EWiseMultInverted.cpp b/cubool/sources/cuBool_Matrix_EWiseMultInverted.cpp index 37fe607..c157129 100644 --- a/cubool/sources/cuBool_Matrix_EWiseMultInverted.cpp +++ b/cubool/sources/cuBool_Matrix_EWiseMultInverted.cpp @@ -25,20 +25,19 @@ #include CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Matrix_EWiseMulInverted( - cuBool_Matrix result, - cuBool_Matrix matrix, - cuBool_Matrix mask, - cuBool_Hints hints -) { + cuBool_Matrix result, + cuBool_Matrix matrix, + cuBool_Matrix mask, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(mask) - auto resultM = (cubool::Matrix *) result; - auto matrixM = (cubool::Matrix *) matrix; - auto maskM = (cubool::Matrix *) mask; + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(mask) + auto resultM = (cubool::Matrix*) result; + auto matrixM = (cubool::Matrix*) matrix; + auto maskM = (cubool::Matrix*) mask; - resultM->eWiseMultInverted(*matrixM, *maskM, hints & CUBOOL_HINT_TIME_CHECK); + resultM->eWiseMultInverted(*matrixM, *maskM, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } diff --git a/cubool/sources/cuBool_Matrix_ExtractCol.cpp b/cubool/sources/cuBool_Matrix_ExtractCol.cpp index 92fcf34..a90dd86 100644 --- a/cubool/sources/cuBool_Matrix_ExtractCol.cpp +++ b/cubool/sources/cuBool_Matrix_ExtractCol.cpp @@ -27,14 +27,13 @@ cuBool_Status cuBool_Matrix_ExtractCol( cuBool_Vector result, cuBool_Matrix matrix, - cuBool_Index j, - cuBool_Hints hints -) { + cuBool_Index j, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(matrix) - auto r = (cubool::Vector*) result; - auto m = (cubool::Matrix*) matrix; - r->extractCol(*m, j); + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + auto r = (cubool::Vector*) result; + auto m = (cubool::Matrix*) matrix; + r->extractCol(*m, j); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_ExtractPairs.cpp b/cubool/sources/cuBool_Matrix_ExtractPairs.cpp index 8a9087c..d3c2ade 100644 --- a/cubool/sources/cuBool_Matrix_ExtractPairs.cpp +++ b/cubool/sources/cuBool_Matrix_ExtractPairs.cpp @@ -26,17 +26,16 @@ cuBool_Status cuBool_Matrix_ExtractPairs( cuBool_Matrix matrix, - cuBool_Index *rows, - cuBool_Index *cols, - cuBool_Index *nvals -) { + cuBool_Index* rows, + cuBool_Index* cols, + cuBool_Index* nvals) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(nvals) - auto m = (cubool::Matrix *) matrix; - size_t count = *nvals; - m->extract(rows, cols, count); - *nvals = count; + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(nvals) + auto m = (cubool::Matrix*) matrix; + size_t count = *nvals; + m->extract(rows, cols, count); + *nvals = count; CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_ExtractRow.cpp b/cubool/sources/cuBool_Matrix_ExtractRow.cpp index a197570..70f0df3 100644 --- a/cubool/sources/cuBool_Matrix_ExtractRow.cpp +++ b/cubool/sources/cuBool_Matrix_ExtractRow.cpp @@ -27,14 +27,13 @@ cuBool_Status cuBool_Matrix_ExtractRow( cuBool_Vector result, cuBool_Matrix matrix, - cuBool_Index i, - cuBool_Hints hints -) { + cuBool_Index i, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(matrix) - auto r = (cubool::Vector*) result; - auto m = (cubool::Matrix*) matrix; - r->extractRow(*m, i); + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + auto r = (cubool::Vector*) result; + auto m = (cubool::Matrix*) matrix; + r->extractRow(*m, i); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_ExtractSubMatrix.cpp b/cubool/sources/cuBool_Matrix_ExtractSubMatrix.cpp index aa061ba..3ad5275 100644 --- a/cubool/sources/cuBool_Matrix_ExtractSubMatrix.cpp +++ b/cubool/sources/cuBool_Matrix_ExtractSubMatrix.cpp @@ -27,18 +27,17 @@ cuBool_Status cuBool_Matrix_ExtractSubMatrix( cuBool_Matrix result, cuBool_Matrix matrix, - cuBool_Index i, - cuBool_Index j, - cuBool_Index nrows, - cuBool_Index ncols, - cuBool_Hints hints -) { + cuBool_Index i, + cuBool_Index j, + cuBool_Index nrows, + cuBool_Index ncols, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(matrix) - auto r = (cubool::Matrix*) result; - auto m = (cubool::Matrix*) matrix; - r->extractSubMatrix(*m, i, j, nrows, ncols, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + auto r = (cubool::Matrix*) result; + auto m = (cubool::Matrix*) matrix; + r->extractSubMatrix(*m, i, j, nrows, ncols, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_Free.cpp b/cubool/sources/cuBool_Matrix_Free.cpp index 9769a9d..5e15a47 100644 --- a/cubool/sources/cuBool_Matrix_Free.cpp +++ b/cubool/sources/cuBool_Matrix_Free.cpp @@ -25,11 +25,10 @@ #include cuBool_Status cuBool_Matrix_Free( - cuBool_Matrix matrix -) { + cuBool_Matrix matrix) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - auto m = (cubool::Matrix *) matrix; - cubool::Library::releaseMatrix(m); + CUBOOL_VALIDATE_LIBRARY + auto m = (cubool::Matrix*) matrix; + cubool::Library::releaseMatrix(m); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_Marker.cpp b/cubool/sources/cuBool_Matrix_Marker.cpp index 399d17e..5125bd4 100644 --- a/cubool/sources/cuBool_Matrix_Marker.cpp +++ b/cubool/sources/cuBool_Matrix_Marker.cpp @@ -22,33 +22,32 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include -#include #include +#include +#include cuBool_Status cuBool_Matrix_Marker( cuBool_Matrix matrix, - char* marker, - cuBool_Index* size -) { + char* marker, + cuBool_Index* size) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(size) + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(size) - auto m = (cubool::Matrix*) matrix; - auto actualSize = m->getDebugMarkerSizeWithNullT(); - auto toCopy = std::min(*size, actualSize); + auto m = (cubool::Matrix*) matrix; + auto actualSize = m->getDebugMarkerSizeWithNullT(); + auto toCopy = std::min(*size, actualSize); - if (marker != nullptr && toCopy > 0) { - // C str (with \0) - const auto* text = m->getDebugMarker(); - std::memcpy(marker, text, toCopy); + if (marker != nullptr && toCopy > 0) { + // C str (with \0) + const auto* text = m->getDebugMarker(); + std::memcpy(marker, text, toCopy); - // Explicitly terminate (for case size < actualSize) - marker[toCopy - 1] = '\0'; - } + // Explicitly terminate (for case size < actualSize) + marker[toCopy - 1] = '\0'; + } - *size = actualSize; + *size = actualSize; CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_Ncols.cpp b/cubool/sources/cuBool_Matrix_Ncols.cpp index 617e9ee..42305fb 100644 --- a/cubool/sources/cuBool_Matrix_Ncols.cpp +++ b/cubool/sources/cuBool_Matrix_Ncols.cpp @@ -26,13 +26,12 @@ cuBool_Status cuBool_Matrix_Ncols( cuBool_Matrix matrix, - cuBool_Index *ncols -) { + cuBool_Index* ncols) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(ncols) - auto m = (cubool::Matrix *) matrix; - *ncols = m->getNcols(); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(ncols) + auto m = (cubool::Matrix*) matrix; + *ncols = m->getNcols(); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_New.cpp b/cubool/sources/cuBool_Matrix_New.cpp index 37897de..e947b62 100644 --- a/cubool/sources/cuBool_Matrix_New.cpp +++ b/cubool/sources/cuBool_Matrix_New.cpp @@ -25,13 +25,12 @@ #include cuBool_Status cuBool_Matrix_New( - cuBool_Matrix *matrix, - cuBool_Index nrows, - cuBool_Index ncols -) { + cuBool_Matrix* matrix, + cuBool_Index nrows, + cuBool_Index ncols) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - *matrix = (cuBool_Matrix_t *) cubool::Library::createMatrix(nrows, ncols); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + *matrix = (cuBool_Matrix_t*) cubool::Library::createMatrix(nrows, ncols); CUBOOL_END_BODY } diff --git a/cubool/sources/cuBool_Matrix_Nrows.cpp b/cubool/sources/cuBool_Matrix_Nrows.cpp index 247715c..85e7544 100644 --- a/cubool/sources/cuBool_Matrix_Nrows.cpp +++ b/cubool/sources/cuBool_Matrix_Nrows.cpp @@ -26,13 +26,12 @@ cuBool_Status cuBool_Matrix_Nrows( cuBool_Matrix matrix, - cuBool_Index *nrows -) { + cuBool_Index* nrows) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(nrows) - auto m = (cubool::Matrix *) matrix; - *nrows = m->getNrows(); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(nrows) + auto m = (cubool::Matrix*) matrix; + *nrows = m->getNrows(); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_Nvals.cpp b/cubool/sources/cuBool_Matrix_Nvals.cpp index 383694f..6490055 100644 --- a/cubool/sources/cuBool_Matrix_Nvals.cpp +++ b/cubool/sources/cuBool_Matrix_Nvals.cpp @@ -26,13 +26,12 @@ cuBool_Status cuBool_Matrix_Nvals( cuBool_Matrix matrix, - cuBool_Index *nvals -) { + cuBool_Index* nvals) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(nvals) - auto m = (cubool::Matrix *) matrix; - *nvals = m->getNvals(); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(nvals) + auto m = (cubool::Matrix*) matrix; + *nvals = m->getNvals(); CUBOOL_END_BODY } diff --git a/cubool/sources/cuBool_Matrix_Reduce.cpp b/cubool/sources/cuBool_Matrix_Reduce.cpp index 461d0e6..ca54b89 100644 --- a/cubool/sources/cuBool_Matrix_Reduce.cpp +++ b/cubool/sources/cuBool_Matrix_Reduce.cpp @@ -27,14 +27,13 @@ cuBool_Status cuBool_Matrix_Reduce( cuBool_Vector result, cuBool_Matrix matrix, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(matrix) - auto r = (cubool::Vector*) result; - auto m = (cubool::Matrix*) matrix; - r->reduceMatrix(*m, hints & CUBOOL_HINT_TRANSPOSE,hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + auto r = (cubool::Vector*) result; + auto m = (cubool::Matrix*) matrix; + r->reduceMatrix(*m, hints & CUBOOL_HINT_TRANSPOSE, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_Reduce2.cpp b/cubool/sources/cuBool_Matrix_Reduce2.cpp index 7496e1c..bac0706 100644 --- a/cubool/sources/cuBool_Matrix_Reduce2.cpp +++ b/cubool/sources/cuBool_Matrix_Reduce2.cpp @@ -27,14 +27,13 @@ cuBool_Status cuBool_Matrix_Reduce2( cuBool_Matrix result, cuBool_Matrix matrix, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(matrix) - auto r = (cubool::Matrix*) result; - auto m = (cubool::Matrix*) matrix; - r->reduce(*m, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + auto r = (cubool::Matrix*) result; + auto m = (cubool::Matrix*) matrix; + r->reduce(*m, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_SetElement.cpp b/cubool/sources/cuBool_Matrix_SetElement.cpp index a942f2e..b61871a 100644 --- a/cubool/sources/cuBool_Matrix_SetElement.cpp +++ b/cubool/sources/cuBool_Matrix_SetElement.cpp @@ -26,13 +26,12 @@ cuBool_Status cuBool_Matrix_SetElement( cuBool_Matrix matrix, - cuBool_Index i, - cuBool_Index j -) { + cuBool_Index i, + cuBool_Index j) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - auto m = (cubool::Matrix*) matrix; - m->setElement(i, j); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + auto m = (cubool::Matrix*) matrix; + m->setElement(i, j); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_SetMarker.cpp b/cubool/sources/cuBool_Matrix_SetMarker.cpp index 8296643..c0548ff 100644 --- a/cubool/sources/cuBool_Matrix_SetMarker.cpp +++ b/cubool/sources/cuBool_Matrix_SetMarker.cpp @@ -26,13 +26,12 @@ cuBool_Status cuBool_Matrix_SetMarker( cuBool_Matrix matrix, - const char* marker -) { + const char* marker) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(marker) - auto m = (cubool::Matrix*) matrix; - m->setDebugMarker(marker); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(marker) + auto m = (cubool::Matrix*) matrix; + m->setDebugMarker(marker); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Matrix_Transpose.cpp b/cubool/sources/cuBool_Matrix_Transpose.cpp index a7d3e4d..6832060 100644 --- a/cubool/sources/cuBool_Matrix_Transpose.cpp +++ b/cubool/sources/cuBool_Matrix_Transpose.cpp @@ -27,14 +27,13 @@ cuBool_Status cuBool_Matrix_Transpose( cuBool_Matrix result, cuBool_Matrix matrix, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(matrix) - auto r = (cubool::Matrix *) result; - auto m = (cubool::Matrix *) matrix; - r->transpose(*m, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + auto r = (cubool::Matrix*) result; + auto m = (cubool::Matrix*) matrix; + r->transpose(*m, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_MxM.cpp b/cubool/sources/cuBool_MxM.cpp index 5bfb9e7..464bb05 100644 --- a/cubool/sources/cuBool_MxM.cpp +++ b/cubool/sources/cuBool_MxM.cpp @@ -28,16 +28,15 @@ cuBool_Status cuBool_MxM( cuBool_Matrix result, cuBool_Matrix left, cuBool_Matrix right, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(left) - CUBOOL_ARG_NOT_NULL(right) - auto resultM = (cubool::Matrix *) result; - auto leftM = (cubool::Matrix *) left; - auto rightM = (cubool::Matrix *) right; - resultM->multiply(*leftM, *rightM, hints & CUBOOL_HINT_ACCUMULATE, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(left) + CUBOOL_ARG_NOT_NULL(right) + auto resultM = (cubool::Matrix*) result; + auto leftM = (cubool::Matrix*) left; + auto rightM = (cubool::Matrix*) right; + resultM->multiply(*leftM, *rightM, hints & CUBOOL_HINT_ACCUMULATE, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_MxV.cpp b/cubool/sources/cuBool_MxV.cpp index cc97147..25e423d 100644 --- a/cubool/sources/cuBool_MxV.cpp +++ b/cubool/sources/cuBool_MxV.cpp @@ -28,16 +28,15 @@ cuBool_Status cuBool_MxV( cuBool_Vector result, cuBool_Matrix matrix, cuBool_Vector vector, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(matrix) - CUBOOL_ARG_NOT_NULL(vector) - auto resultV = (cubool::Vector *) result; - auto left = (cubool::Matrix *) matrix; - auto right = (cubool::Vector *) vector; - resultV->multiplyMxV(*left, *right, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(matrix) + CUBOOL_ARG_NOT_NULL(vector) + auto resultV = (cubool::Vector*) result; + auto left = (cubool::Matrix*) matrix; + auto right = (cubool::Vector*) vector; + resultV->multiplyMxV(*left, *right, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_SetupLogger.cpp b/cubool/sources/cuBool_SetupLogger.cpp index b149bc0..8cf21fe 100644 --- a/cubool/sources/cuBool_SetupLogger.cpp +++ b/cubool/sources/cuBool_SetupLogger.cpp @@ -25,10 +25,9 @@ #include cuBool_Status cuBool_SetupLogging( - const char* logFileName, - cuBool_Hints hints -) { + const char* logFileName, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - cubool::Library::setupLogging(logFileName, hints); + cubool::Library::setupLogging(logFileName, hints); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_Build.cpp b/cubool/sources/cuBool_Vector_Build.cpp index 6bc3926..64fc09f 100644 --- a/cubool/sources/cuBool_Vector_Build.cpp +++ b/cubool/sources/cuBool_Vector_Build.cpp @@ -25,15 +25,14 @@ #include cuBool_Status cuBool_Vector_Build( - cuBool_Vector vector, + cuBool_Vector vector, const cuBool_Index* rows, - cuBool_Index nvals, - cuBool_Hints hints -) { + cuBool_Index nvals, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - auto v = (cubool::Vector *) vector; - v->build(rows, nvals, hints & CUBOOL_HINT_VALUES_SORTED, hints & CUBOOL_HINT_NO_DUPLICATES); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + auto v = (cubool::Vector*) vector; + v->build(rows, nvals, hints & CUBOOL_HINT_VALUES_SORTED, hints & CUBOOL_HINT_NO_DUPLICATES); CUBOOL_END_BODY } diff --git a/cubool/sources/cuBool_Vector_Duplicate.cpp b/cubool/sources/cuBool_Vector_Duplicate.cpp index 085587e..65b5f82 100644 --- a/cubool/sources/cuBool_Vector_Duplicate.cpp +++ b/cubool/sources/cuBool_Vector_Duplicate.cpp @@ -25,16 +25,15 @@ #include cuBool_Status cuBool_Vector_Duplicate( - cuBool_Vector vector, - cuBool_Vector* duplicated -) { + cuBool_Vector vector, + cuBool_Vector* duplicated) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - CUBOOL_ARG_NOT_NULL(duplicated) - auto v = (cubool::Vector *) vector; - auto d = cubool::Library::createVector(v->getNrows()); - d->clone(*v); - *duplicated = (cuBool_Vector_t *) d; + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + CUBOOL_ARG_NOT_NULL(duplicated) + auto v = (cubool::Vector*) vector; + auto d = cubool::Library::createVector(v->getNrows()); + d->clone(*v); + *duplicated = (cuBool_Vector_t*) d; CUBOOL_END_BODY } diff --git a/cubool/sources/cuBool_Vector_EWiseAdd.cpp b/cubool/sources/cuBool_Vector_EWiseAdd.cpp index 6a9c949..816aed7 100644 --- a/cubool/sources/cuBool_Vector_EWiseAdd.cpp +++ b/cubool/sources/cuBool_Vector_EWiseAdd.cpp @@ -28,16 +28,15 @@ cuBool_Status cuBool_Vector_EWiseAdd( cuBool_Vector result, cuBool_Vector left, cuBool_Vector right, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(left) - CUBOOL_ARG_NOT_NULL(right) - auto resultM = (cubool::Vector *) result; - auto leftM = (cubool::Vector *) left; - auto rightM = (cubool::Vector *) right; - resultM->eWiseAdd(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(left) + CUBOOL_ARG_NOT_NULL(right) + auto resultM = (cubool::Vector*) result; + auto leftM = (cubool::Vector*) left; + auto rightM = (cubool::Vector*) right; + resultM->eWiseAdd(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_EWiseMult.cpp b/cubool/sources/cuBool_Vector_EWiseMult.cpp index 0777f0a..9dc6c10 100644 --- a/cubool/sources/cuBool_Vector_EWiseMult.cpp +++ b/cubool/sources/cuBool_Vector_EWiseMult.cpp @@ -28,16 +28,15 @@ cuBool_Status cuBool_Vector_EWiseMult( cuBool_Vector result, cuBool_Vector left, cuBool_Vector right, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(left) - CUBOOL_ARG_NOT_NULL(right) - auto resultM = (cubool::Vector *) result; - auto leftM = (cubool::Vector *) left; - auto rightM = (cubool::Vector *) right; - resultM->eWiseMult(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(left) + CUBOOL_ARG_NOT_NULL(right) + auto resultM = (cubool::Vector*) result; + auto leftM = (cubool::Vector*) left; + auto rightM = (cubool::Vector*) right; + resultM->eWiseMult(*leftM, *rightM, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_ExtractSubVector.cpp b/cubool/sources/cuBool_Vector_ExtractSubVector.cpp index 55cda77..824549f 100644 --- a/cubool/sources/cuBool_Vector_ExtractSubVector.cpp +++ b/cubool/sources/cuBool_Vector_ExtractSubVector.cpp @@ -27,16 +27,15 @@ cuBool_Status cuBool_Vector_ExtractSubVector( cuBool_Vector result, cuBool_Vector vector, - cuBool_Index i, - cuBool_Index nrows, - cuBool_Hints hints -) { + cuBool_Index i, + cuBool_Index nrows, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(vector) - auto r = (cubool::Vector*) result; - auto v = (cubool::Vector*) vector; - r->extractSubVector(*v, i, nrows, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(vector) + auto r = (cubool::Vector*) result; + auto v = (cubool::Vector*) vector; + r->extractSubVector(*v, i, nrows, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } diff --git a/cubool/sources/cuBool_Vector_ExtractValues.cpp b/cubool/sources/cuBool_Vector_ExtractValues.cpp index cd885b9..acfde5a 100644 --- a/cubool/sources/cuBool_Vector_ExtractValues.cpp +++ b/cubool/sources/cuBool_Vector_ExtractValues.cpp @@ -27,15 +27,14 @@ cuBool_Status cuBool_Vector_ExtractValues( cuBool_Vector vector, cuBool_Index* rows, - cuBool_Index* nvals -) { + cuBool_Index* nvals) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - CUBOOL_ARG_NOT_NULL(nvals) - auto v = (cubool::Vector *) vector; - size_t count = *nvals; - v->extract(rows, count); - *nvals = count; + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + CUBOOL_ARG_NOT_NULL(nvals) + auto v = (cubool::Vector*) vector; + size_t count = *nvals; + v->extract(rows, count); + *nvals = count; CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_Free.cpp b/cubool/sources/cuBool_Vector_Free.cpp index 042c52c..020a35b 100644 --- a/cubool/sources/cuBool_Vector_Free.cpp +++ b/cubool/sources/cuBool_Vector_Free.cpp @@ -25,11 +25,10 @@ #include CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Vector_Free( - cuBool_Vector vector -) { + cuBool_Vector vector) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - auto v = (cubool::Vector *) vector; - cubool::Library::releaseVector(v); + CUBOOL_VALIDATE_LIBRARY + auto v = (cubool::Vector*) vector; + cubool::Library::releaseVector(v); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_Marker.cpp b/cubool/sources/cuBool_Vector_Marker.cpp index 03eb17a..5441a39 100644 --- a/cubool/sources/cuBool_Vector_Marker.cpp +++ b/cubool/sources/cuBool_Vector_Marker.cpp @@ -26,27 +26,26 @@ cuBool_Status cuBool_Vector_Marker( cuBool_Vector vector, - char* marker, - cuBool_Index* size -) { + char* marker, + cuBool_Index* size) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - CUBOOL_ARG_NOT_NULL(size) + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + CUBOOL_ARG_NOT_NULL(size) - auto v = (cubool::Vector*) vector; - auto actualSize = v->getDebugMarkerSizeWithNullT(); - auto toCopy = std::min(*size, actualSize); + auto v = (cubool::Vector*) vector; + auto actualSize = v->getDebugMarkerSizeWithNullT(); + auto toCopy = std::min(*size, actualSize); - if (marker != nullptr && toCopy > 0) { - // C str (with \0) - const auto* text = v->getDebugMarker(); - std::memcpy(marker, text, toCopy); + if (marker != nullptr && toCopy > 0) { + // C str (with \0) + const auto* text = v->getDebugMarker(); + std::memcpy(marker, text, toCopy); - // Explicitly terminate (for case size < actualSize) - marker[toCopy - 1] = '\0'; - } + // Explicitly terminate (for case size < actualSize) + marker[toCopy - 1] = '\0'; + } - *size = actualSize; + *size = actualSize; CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_New.cpp b/cubool/sources/cuBool_Vector_New.cpp index 768a6ee..113e92c 100644 --- a/cubool/sources/cuBool_Vector_New.cpp +++ b/cubool/sources/cuBool_Vector_New.cpp @@ -26,11 +26,10 @@ cuBool_Status cuBool_Vector_New( cuBool_Vector* vector, - cuBool_Index nrows -) { + cuBool_Index nrows) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - *vector = (cuBool_Vector_t *) cubool::Library::createVector(nrows); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + *vector = (cuBool_Vector_t*) cubool::Library::createVector(nrows); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_Nrows.cpp b/cubool/sources/cuBool_Vector_Nrows.cpp index ad5cd22..f9905bf 100644 --- a/cubool/sources/cuBool_Vector_Nrows.cpp +++ b/cubool/sources/cuBool_Vector_Nrows.cpp @@ -26,13 +26,12 @@ cuBool_Status cuBool_Vector_Nrows( cuBool_Vector vector, - cuBool_Index* nrows -) { + cuBool_Index* nrows) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - CUBOOL_ARG_NOT_NULL(nrows) - auto v = (cubool::Vector *) vector; - *nrows = v->getNrows(); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + CUBOOL_ARG_NOT_NULL(nrows) + auto v = (cubool::Vector*) vector; + *nrows = v->getNrows(); CUBOOL_END_BODY } diff --git a/cubool/sources/cuBool_Vector_Nvals.cpp b/cubool/sources/cuBool_Vector_Nvals.cpp index 0397304..0fbe9a5 100644 --- a/cubool/sources/cuBool_Vector_Nvals.cpp +++ b/cubool/sources/cuBool_Vector_Nvals.cpp @@ -26,13 +26,12 @@ cuBool_Status cuBool_Vector_Nvals( cuBool_Vector vector, - cuBool_Index* nvals -) { + cuBool_Index* nvals) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - CUBOOL_ARG_NOT_NULL(nvals) - auto v = (cubool::Vector *) vector; - *nvals = v->getNvals(); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + CUBOOL_ARG_NOT_NULL(nvals) + auto v = (cubool::Vector*) vector; + *nvals = v->getNvals(); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_Reduce.cpp b/cubool/sources/cuBool_Vector_Reduce.cpp index ee32c27..8b8c8bc 100644 --- a/cubool/sources/cuBool_Vector_Reduce.cpp +++ b/cubool/sources/cuBool_Vector_Reduce.cpp @@ -27,13 +27,12 @@ cuBool_Status cuBool_Vector_Reduce( cuBool_Index* result, cuBool_Vector vector, - cuBool_Hints hints -) { + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(vector) - auto v = (cubool::Vector*) vector; - v->reduce(*result, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(vector) + auto v = (cubool::Vector*) vector; + v->reduce(*result, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_SetElement.cpp b/cubool/sources/cuBool_Vector_SetElement.cpp index 39ec8e0..cbf052b 100644 --- a/cubool/sources/cuBool_Vector_SetElement.cpp +++ b/cubool/sources/cuBool_Vector_SetElement.cpp @@ -26,12 +26,11 @@ cuBool_Status cuBool_Vector_SetElement( cuBool_Vector vector, - cuBool_Index i -) { + cuBool_Index i) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - auto v = (cubool::Vector*) vector; - v->setElement(i); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + auto v = (cubool::Vector*) vector; + v->setElement(i); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_Vector_SetMarker.cpp b/cubool/sources/cuBool_Vector_SetMarker.cpp index 38c906c..418f216 100644 --- a/cubool/sources/cuBool_Vector_SetMarker.cpp +++ b/cubool/sources/cuBool_Vector_SetMarker.cpp @@ -26,13 +26,12 @@ cuBool_Status cuBool_Vector_SetMarker( cuBool_Vector vector, - const char* marker -) { + const char* marker) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(vector) - CUBOOL_ARG_NOT_NULL(marker) - auto v = (cubool::Vector*) vector; - v->setDebugMarker(marker); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(vector) + CUBOOL_ARG_NOT_NULL(marker) + auto v = (cubool::Vector*) vector; + v->setDebugMarker(marker); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuBool_VxM.cpp b/cubool/sources/cuBool_VxM.cpp index 5cda9d3..d1696fe 100644 --- a/cubool/sources/cuBool_VxM.cpp +++ b/cubool/sources/cuBool_VxM.cpp @@ -25,19 +25,18 @@ #include cuBool_Status cuBool_VxM( - cuBool_Vector result, - cuBool_Vector vector, - cuBool_Matrix matrix, - cuBool_Hints hints -) { + cuBool_Vector result, + cuBool_Vector vector, + cuBool_Matrix matrix, + cuBool_Hints hints) { CUBOOL_BEGIN_BODY - CUBOOL_VALIDATE_LIBRARY - CUBOOL_ARG_NOT_NULL(result) - CUBOOL_ARG_NOT_NULL(vector) - CUBOOL_ARG_NOT_NULL(matrix) - auto resultV = (cubool::Vector *) result; - auto left = (cubool::Vector *) vector; - auto right = (cubool::Matrix *) matrix; - resultV->multiplyVxM(*left, *right, hints & CUBOOL_HINT_TIME_CHECK); + CUBOOL_VALIDATE_LIBRARY + CUBOOL_ARG_NOT_NULL(result) + CUBOOL_ARG_NOT_NULL(vector) + CUBOOL_ARG_NOT_NULL(matrix) + auto resultV = (cubool::Vector*) result; + auto left = (cubool::Vector*) vector; + auto right = (cubool::Matrix*) matrix; + resultV->multiplyVxM(*left, *right, hints & CUBOOL_HINT_TIME_CHECK); CUBOOL_END_BODY } \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_backend.cu b/cubool/sources/cuda/cuda_backend.cu index f8d1eb4..4217f34 100644 --- a/cubool/sources/cuda/cuda_backend.cu +++ b/cubool/sources/cuda/cuda_backend.cu @@ -22,10 +22,10 @@ /* SOFTWARE. */ /**********************************************************************************/ +#include #include #include #include -#include #include #include @@ -71,7 +71,7 @@ namespace cubool { return mInstance != nullptr; } - MatrixBase *CudaBackend::createMatrix(size_t nrows, size_t ncols) { + MatrixBase* CudaBackend::createMatrix(size_t nrows, size_t ncols) { mMatCount++; return new CudaMatrix(nrows, ncols, getInstance()); } @@ -81,22 +81,22 @@ namespace cubool { return new CudaVector(nrows, getInstance()); } - void CudaBackend::releaseMatrix(MatrixBase *matrixBase) { + void CudaBackend::releaseMatrix(MatrixBase* matrixBase) { mMatCount--; delete matrixBase; } - void CudaBackend::releaseVector(VectorBase *vectorBase) { + void CudaBackend::releaseVector(VectorBase* vectorBase) { mVecCount--; delete vectorBase; } - void CudaBackend::queryCapabilities(cuBool_DeviceCaps &caps) { + void CudaBackend::queryCapabilities(cuBool_DeviceCaps& caps) { mInstance->queryDeviceCapabilities(caps); } - CudaInstance & CudaBackend::getInstance() { + CudaInstance& CudaBackend::getInstance() { return *mInstance; } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_backend.hpp b/cubool/sources/cuda/cuda_backend.hpp index 74bdf8b..59a7ea4 100644 --- a/cubool/sources/cuda/cuda_backend.hpp +++ b/cubool/sources/cuda/cuda_backend.hpp @@ -33,7 +33,7 @@ namespace cubool { /** * Main entry to cuda provided backend implementation. */ - class CudaBackend final: public BackendBase { + class CudaBackend final : public BackendBase { public: ~CudaBackend() override = default; @@ -41,20 +41,20 @@ namespace cubool { void finalize() override; bool isInitialized() const override; - MatrixBase *createMatrix(size_t nrows, size_t ncols) override; + MatrixBase* createMatrix(size_t nrows, size_t ncols) override; VectorBase* createVector(size_t nrows) override; - void releaseMatrix(MatrixBase *matrixBase) override; - void releaseVector(VectorBase* vectorBase) override; - void queryCapabilities(cuBool_DeviceCaps& caps) override; + void releaseMatrix(MatrixBase* matrixBase) override; + void releaseVector(VectorBase* vectorBase) override; + void queryCapabilities(cuBool_DeviceCaps& caps) override; CudaInstance& getInstance(); private: CudaInstance* mInstance; - size_t mMatCount = 0; - size_t mVecCount = 0; + size_t mMatCount = 0; + size_t mVecCount = 0; }; -} +}// namespace cubool -#endif //CUBOOL_CUDA_BACKEND_HPP \ No newline at end of file +#endif//CUBOOL_CUDA_BACKEND_HPP \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_instance.cu b/cubool/sources/cuda/cuda_instance.cu index 3562ff0..2301cfa 100644 --- a/cubool/sources/cuda/cuda_instance.cu +++ b/cubool/sources/cuda/cuda_instance.cu @@ -22,19 +22,19 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include -#include -#include #include +#include #include +#include +#include namespace cubool { volatile CudaInstance* CudaInstance::gInstance = nullptr; CudaInstance::CudaInstance(bool useManagedMemory) { - gInstance = this; - mMemoryType = useManagedMemory? Managed: Default; + gInstance = this; + mMemoryType = useManagedMemory ? Managed : Default; } CudaInstance::~CudaInstance() { @@ -44,7 +44,7 @@ namespace cubool { gInstance = nullptr; } - void CudaInstance::allocateOnGpu(void* &ptr, size_t size) const { + void CudaInstance::allocateOnGpu(void*& ptr, size_t size) const { cudaError error; switch (mMemoryType) { @@ -86,10 +86,10 @@ namespace cubool { } } - void CudaInstance::queryDeviceCapabilities(cuBool_DeviceCaps &deviceCaps) const { + void CudaInstance::queryDeviceCapabilities(cuBool_DeviceCaps& deviceCaps) const { const unsigned long long KiB = 1024; - int device; + int device; cudaError error = cudaGetDevice(&device); if (error == cudaSuccess) { @@ -98,14 +98,14 @@ namespace cubool { if (error == cudaSuccess) { strcpy(deviceCaps.name, deviceProp.name); - deviceCaps.cudaSupported = true; - deviceCaps.managedMem = mMemoryType == MemType::Managed; - deviceCaps.minor = deviceProp.minor; - deviceCaps.major = deviceProp.major; - deviceCaps.warp = deviceProp.warpSize; - deviceCaps.globalMemoryKiBs = deviceProp.totalGlobalMem / KiB; + deviceCaps.cudaSupported = true; + deviceCaps.managedMem = mMemoryType == MemType::Managed; + deviceCaps.minor = deviceProp.minor; + deviceCaps.major = deviceProp.major; + deviceCaps.warp = deviceProp.warpSize; + deviceCaps.globalMemoryKiBs = deviceProp.totalGlobalMem / KiB; deviceCaps.sharedMemoryPerMultiProcKiBs = deviceProp.sharedMemPerMultiprocessor / KiB; - deviceCaps.sharedMemoryPerBlockKiBs = deviceProp.sharedMemPerBlock / KiB; + deviceCaps.sharedMemoryPerBlockKiBs = deviceProp.sharedMemPerBlock / KiB; } } } @@ -115,12 +115,12 @@ namespace cubool { } bool CudaInstance::isCudaDeviceSupported() { - int device; + int device; cudaError error = cudaGetDevice(&device); return error == cudaSuccess; } - void CudaInstance::allocate(void* &ptr, size_t size) const { + void CudaInstance::allocate(void*& ptr, size_t size) const { ptr = malloc(size); CHECK_RAISE_ERROR(ptr != nullptr, MemOpFailed, "Failed to allocate memory on the CPU"); mHostAllocCount++; @@ -138,11 +138,11 @@ namespace cubool { } CudaInstance* CudaInstance::getInstancePtr() { - return (CudaInstance* ) gInstance; + return (CudaInstance*) gInstance; } bool CudaInstance::isInstancePresent() { return gInstance != nullptr; } -} +}// namespace cubool diff --git a/cubool/sources/cuda/cuda_instance.hpp b/cubool/sources/cuda/cuda_instance.hpp index 89f62da..a29e903 100644 --- a/cubool/sources/cuda/cuda_instance.hpp +++ b/cubool/sources/cuda/cuda_instance.hpp @@ -35,40 +35,39 @@ namespace cubool { */ class CudaInstance { public: - enum MemType { Default, Managed }; explicit CudaInstance(bool useManagedMemory); - CudaInstance(const CudaInstance& other) = delete; + CudaInstance(const CudaInstance& other) = delete; CudaInstance(CudaInstance&& other) noexcept = delete; ~CudaInstance(); // For custom host & device allocators - void allocate(void* &ptr, size_t s) const; - void allocateOnGpu(void* &ptr, size_t s) const; + void allocate(void*& ptr, size_t s) const; + void allocateOnGpu(void*& ptr, size_t s) const; void deallocate(void* ptr) const; void deallocateOnGpu(void* ptr) const; void queryDeviceCapabilities(cuBool_DeviceCaps& deviceCaps) const; - void syncHostDevice() const; + void syncHostDevice() const; MemType getMemoryType() const; - static bool isCudaDeviceSupported(); + static bool isCudaDeviceSupported(); static CudaInstance& getInstanceRef(); static CudaInstance* getInstancePtr(); - static bool isInstancePresent(); + static bool isInstancePresent(); private: - MemType mMemoryType = Default; - mutable size_t mHostAllocCount = 0; + MemType mMemoryType = Default; + mutable size_t mHostAllocCount = 0; mutable size_t mDeviceAllocCount = 0; static volatile CudaInstance* gInstance; }; -} +}// namespace cubool -#endif //CUBOOL_CUDA_INSTANCE_HPP \ No newline at end of file +#endif//CUBOOL_CUDA_INSTANCE_HPP \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_matrix.cu b/cubool/sources/cuda/cuda_matrix.cu index 6eec723..0b00ada 100644 --- a/cubool/sources/cuda/cuda_matrix.cu +++ b/cubool/sources/cuda/cuda_matrix.cu @@ -22,15 +22,15 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include +#include #include -#include +#include #include -#include +#include namespace cubool { - CudaMatrix::CudaMatrix(size_t nrows, size_t ncols, CudaInstance &instance) : mInstance(instance) { + CudaMatrix::CudaMatrix(size_t nrows, size_t ncols, CudaInstance& instance) : mInstance(instance) { mNrows = nrows; mNcols = ncols; } @@ -39,9 +39,9 @@ namespace cubool { RAISE_ERROR(NotImplemented, "This function is not supported for this matrix class"); } - void CudaMatrix::build(const index *rows, const index *cols, size_t nvals, bool isSorted, bool noDuplicates) { + void CudaMatrix::build(const index* rows, const index* cols, size_t nvals, bool isSorted, bool noDuplicates) { if (nvals == 0) { - mMatrixImpl.zero_dim(); // no content, empty matrix + mMatrixImpl.zero_dim();// no content, empty matrix return; } @@ -55,7 +55,7 @@ namespace cubool { this->transferToDevice(rowOffsets, colIndices); } - void CudaMatrix::extract(index *rows, index *cols, size_t &nvals) { + void CudaMatrix::extract(index* rows, index* cols, size_t& nvals) { assert(nvals >= getNvals()); // Set nvals to the exact number of nnz values @@ -72,7 +72,7 @@ namespace cubool { } } - void CudaMatrix::clone(const MatrixBase &otherBase) { + void CudaMatrix::clone(const MatrixBase& otherBase) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed matrix does not belong to csr matrix class"); @@ -125,7 +125,7 @@ namespace cubool { return mMatrixImpl.m_vals == 0; } - void CudaMatrix::transferToDevice(const std::vector &rowOffsets, const std::vector &colIndices) const { + void CudaMatrix::transferToDevice(const std::vector& rowOffsets, const std::vector& colIndices) const { // Create device buffers and copy data from the cpu side thrust::device_vector> rowsDeviceVec(rowOffsets.size()); thrust::device_vector> colsDeviceVec(colIndices.size()); @@ -137,7 +137,7 @@ namespace cubool { mMatrixImpl = std::move(MatrixImplType(std::move(colsDeviceVec), std::move(rowsDeviceVec), getNrows(), getNcols(), colIndices.size())); } - void CudaMatrix::transferFromDevice(std::vector &rowOffsets, std::vector &colIndices) const { + void CudaMatrix::transferFromDevice(std::vector& rowOffsets, std::vector& colIndices) const { rowOffsets.resize(mMatrixImpl.m_row_index.size()); colIndices.resize(mMatrixImpl.m_col_index.size()); @@ -145,4 +145,4 @@ namespace cubool { thrust::copy(mMatrixImpl.m_col_index.begin(), mMatrixImpl.m_col_index.end(), colIndices.begin()); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_matrix.hpp b/cubool/sources/cuda/cuda_matrix.hpp index 9f1b7a2..49ab555 100644 --- a/cubool/sources/cuda/cuda_matrix.hpp +++ b/cubool/sources/cuda/cuda_matrix.hpp @@ -26,37 +26,37 @@ #define CUBOOL_CUDA_MATRIX_HPP #include -#include #include +#include #include namespace cubool { - class CudaMatrix: public MatrixBase { + class CudaMatrix : public MatrixBase { public: template using DeviceAlloc = details::DeviceAllocator; template - using HostAlloc = details::HostAllocator; + using HostAlloc = details::HostAllocator; using MatrixImplType = nsparse::matrix>; CudaMatrix(size_t nrows, size_t ncols, CudaInstance& instance); ~CudaMatrix() override = default; void setElement(index i, index j) override; - void build(const index *rows, const index *cols, size_t nvals, bool isSorted, bool noDuplicates) override; - void extract(index* rows, index* cols, size_t &nvals) override; - void extractSubMatrix(const MatrixBase &otherBase, index i, index j, index nrows, index ncols, bool checkTime) override; + void build(const index* rows, const index* cols, size_t nvals, bool isSorted, bool noDuplicates) override; + void extract(index* rows, index* cols, size_t& nvals) override; + void extractSubMatrix(const MatrixBase& otherBase, index i, index j, index nrows, index ncols, bool checkTime) override; - void clone(const MatrixBase &other) override; - void transpose(const MatrixBase &other, bool checkTime) override; - void reduce(const MatrixBase &other, bool checkTime) override; + void clone(const MatrixBase& other) override; + void transpose(const MatrixBase& other, bool checkTime) override; + void reduce(const MatrixBase& other, bool checkTime) override; - void multiply(const MatrixBase &a, const MatrixBase &b, bool accumulate, bool checkTime) override; - void kronecker(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; - void eWiseAdd(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; - void eWiseMult(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; - void eWiseMultInverted(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; + void multiply(const MatrixBase& a, const MatrixBase& b, bool accumulate, bool checkTime) override; + void kronecker(const MatrixBase& a, const MatrixBase& b, bool checkTime) override; + void eWiseAdd(const MatrixBase& a, const MatrixBase& b, bool checkTime) override; + void eWiseMult(const MatrixBase& a, const MatrixBase& b, bool checkTime) override; + void eWiseMultInverted(const MatrixBase& a, const MatrixBase& b, bool checkTime) override; index getNrows() const override; index getNcols() const override; @@ -68,16 +68,16 @@ namespace cubool { void resizeStorageToDim() const; void clearAndResizeStorageToDim() const; bool isMatrixEmpty() const; - void transferToDevice(const std::vector &rowOffsets, const std::vector &colIndices) const; - void transferFromDevice(std::vector &rowOffsets, std::vector &colIndices) const; + void transferToDevice(const std::vector& rowOffsets, const std::vector& colIndices) const; + void transferFromDevice(std::vector& rowOffsets, std::vector& colIndices) const; // Uses nsparse csr matrix implementation as a backend mutable MatrixImplType mMatrixImpl; - size_t mNrows = 0; - size_t mNcols = 0; + size_t mNrows = 0; + size_t mNcols = 0; CudaInstance& mInstance; }; -}; +};// namespace cubool -#endif //CUBOOL_CUDA_MATRIX_HPP +#endif//CUBOOL_CUDA_MATRIX_HPP diff --git a/cubool/sources/cuda/cuda_matrix_ewiseadd.cu b/cubool/sources/cuda/cuda_matrix_ewiseadd.cu index 1e4f140..fd819fe 100644 --- a/cubool/sources/cuda/cuda_matrix_ewiseadd.cu +++ b/cubool/sources/cuda/cuda_matrix_ewiseadd.cu @@ -27,7 +27,7 @@ namespace cubool { - void CudaMatrix::eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void CudaMatrix::eWiseAdd(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -58,10 +58,10 @@ namespace cubool { b->resizeStorageToDim(); kernels::SpMergeFunctor> spMergeFunctor; - auto result = spMergeFunctor(a->mMatrixImpl, b->mMatrixImpl); + auto result = spMergeFunctor(a->mMatrixImpl, b->mMatrixImpl); // Assign the actual impl result to this storage this->mMatrixImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_matrix_ewisemult.cu b/cubool/sources/cuda/cuda_matrix_ewisemult.cu index 1708a9c..1ca180f 100644 --- a/cubool/sources/cuda/cuda_matrix_ewisemult.cu +++ b/cubool/sources/cuda/cuda_matrix_ewisemult.cu @@ -27,7 +27,7 @@ namespace cubool { - void CudaMatrix::eWiseMult(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void CudaMatrix::eWiseMult(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -53,10 +53,10 @@ namespace cubool { b->resizeStorageToDim(); kernels::SpMatrixEWiseMult> spFunctor; - auto result = spFunctor(a->mMatrixImpl, b->mMatrixImpl); + auto result = spFunctor(a->mMatrixImpl, b->mMatrixImpl); // Assign the actual impl result to this storage this->mMatrixImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu b/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu index 2e0fa87..e070409 100644 --- a/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu +++ b/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu @@ -27,7 +27,7 @@ namespace cubool { - void CudaMatrix::eWiseMultInverted(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void CudaMatrix::eWiseMultInverted(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -54,10 +54,10 @@ namespace cubool { b->resizeStorageToDim(); kernels::SpVectorEWiseMultInverted> spFunctor; - auto result = spFunctor(a->mMatrixImpl, b->mMatrixImpl); + auto result = spFunctor(a->mMatrixImpl, b->mMatrixImpl); // Assign the actual impl result to this storage this->mMatrixImpl = std::move(result); } -} +}// namespace cubool diff --git a/cubool/sources/cuda/cuda_matrix_extract_sub_matrix.cu b/cubool/sources/cuda/cuda_matrix_extract_sub_matrix.cu index d52f82d..f619fb2 100644 --- a/cubool/sources/cuda/cuda_matrix_extract_sub_matrix.cu +++ b/cubool/sources/cuda/cuda_matrix_extract_sub_matrix.cu @@ -27,7 +27,7 @@ namespace cubool { - void CudaMatrix::extractSubMatrix(const MatrixBase &otherBase, index i, index j, index nrows, index ncols, + void CudaMatrix::extractSubMatrix(const MatrixBase& otherBase, index i, index j, index nrows, index ncols, bool checkTime) { auto other = dynamic_cast(&otherBase); @@ -46,9 +46,9 @@ namespace cubool { other->resizeStorageToDim(); kernels::SpSubMatrix> spSubMatrix; - auto result = spSubMatrix(other->mMatrixImpl, i, j, nrows, ncols); + auto result = spSubMatrix(other->mMatrixImpl, i, j, nrows, ncols); mMatrixImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_matrix_kronecker.cu b/cubool/sources/cuda/cuda_matrix_kronecker.cu index 1627ee1..5e21f2a 100644 --- a/cubool/sources/cuda/cuda_matrix_kronecker.cu +++ b/cubool/sources/cuda/cuda_matrix_kronecker.cu @@ -27,7 +27,7 @@ namespace cubool { - void CudaMatrix::kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void CudaMatrix::kronecker(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -53,10 +53,10 @@ namespace cubool { b->resizeStorageToDim(); kernels::SpKronFunctor> spKronFunctor; - auto result = spKronFunctor(a->mMatrixImpl, b->mMatrixImpl); + auto result = spKronFunctor(a->mMatrixImpl, b->mMatrixImpl); // Assign result to this this->mMatrixImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_matrix_multiply.cu b/cubool/sources/cuda/cuda_matrix_multiply.cu index 55c880e..5401108 100644 --- a/cubool/sources/cuda/cuda_matrix_multiply.cu +++ b/cubool/sources/cuda/cuda_matrix_multiply.cu @@ -27,7 +27,7 @@ namespace cubool { - void CudaMatrix::multiply(const MatrixBase &aBase, const MatrixBase &bBase, bool accumulate, bool checkTime) { + void CudaMatrix::multiply(const MatrixBase& aBase, const MatrixBase& bBase, bool accumulate, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -57,10 +57,10 @@ namespace cubool { // Call backend r = c + a * b implementation, as C this is passed nsparse::spgemm_functor_t> spgemmFunctor; - auto result = spgemmFunctor(mMatrixImpl, a->mMatrixImpl, b->mMatrixImpl); + auto result = spgemmFunctor(mMatrixImpl, a->mMatrixImpl, b->mMatrixImpl); // Assign result to this this->mMatrixImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_matrix_reduce.cu b/cubool/sources/cuda/cuda_matrix_reduce.cu index ade3008..8094487 100644 --- a/cubool/sources/cuda/cuda_matrix_reduce.cu +++ b/cubool/sources/cuda/cuda_matrix_reduce.cu @@ -27,7 +27,7 @@ namespace cubool { - void CudaMatrix::reduce(const MatrixBase &otherBase, bool checkTime) { + void CudaMatrix::reduce(const MatrixBase& otherBase, bool checkTime) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed matrix does not belong to csr matrix class"); @@ -40,9 +40,9 @@ namespace cubool { other->resizeStorageToDim(); kernels::SpReduceFunctor> spReduceFunctor; - auto result = spReduceFunctor(other->mMatrixImpl); + auto result = spReduceFunctor(other->mMatrixImpl); mMatrixImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_matrix_transpose.cu b/cubool/sources/cuda/cuda_matrix_transpose.cu index 3ce4c61..db7d8fc 100644 --- a/cubool/sources/cuda/cuda_matrix_transpose.cu +++ b/cubool/sources/cuda/cuda_matrix_transpose.cu @@ -28,7 +28,7 @@ namespace cubool { - void CudaMatrix::transpose(const MatrixBase &otherBase, bool checkTime) { + void CudaMatrix::transpose(const MatrixBase& otherBase, bool checkTime) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed matrix does not belong to csr matrix class"); @@ -40,10 +40,10 @@ namespace cubool { assert(this->getNcols() == M); kernels::SpTranspose2Functor> spTranspose2Functor; - auto result = spTranspose2Functor(other->mMatrixImpl); + auto result = spTranspose2Functor(other->mMatrixImpl); // Assign the actual impl result to this storage this->mMatrixImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_vector.cu b/cubool/sources/cuda/cuda_vector.cu index f2fa9b0..c7c6ea6 100644 --- a/cubool/sources/cuda/cuda_vector.cu +++ b/cubool/sources/cuda/cuda_vector.cu @@ -22,27 +22,26 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include +#include #include +#include #include -#include -#include #include +#include #include namespace cubool { - CudaVector::CudaVector(size_t nrows, CudaInstance &instance) - : mVectorImpl(nrows), mInstance(instance) { - + CudaVector::CudaVector(size_t nrows, CudaInstance& instance) + : mVectorImpl(nrows), mInstance(instance) { } void CudaVector::setElement(index i) { RAISE_ERROR(NotImplemented, "This function is not supported for this vector class"); } - void CudaVector::build(const index *rows, size_t nvals, bool isSorted, bool noDuplicates) { + void CudaVector::build(const index* rows, size_t nvals, bool isSorted, bool noDuplicates) { if (nvals == 0) { // Empty vector, no values (but preserve dim) mVectorImpl = VectorImplType(getNrows()); @@ -61,7 +60,7 @@ namespace cubool { mVectorImpl = VectorImplType(std::move(deviceData), getNrows(), data.size()); } - void CudaVector::extract(index *rows, size_t &nvals) { + void CudaVector::extract(index* rows, size_t& nvals) { assert(nvals >= getNvals()); nvals = getNvals(); @@ -74,8 +73,8 @@ namespace cubool { } } - void CudaVector::extractSubVector(const VectorBase &otherBase, index i, index nrows, bool checkTime) { - const auto *v = dynamic_cast(&otherBase); + void CudaVector::extractSubVector(const VectorBase& otherBase, index i, index nrows, bool checkTime) { + const auto* v = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(v != nullptr, InvalidArgument, "Passed vector does not belong to cuda vector class"); @@ -96,7 +95,7 @@ namespace cubool { return; } - auto &vec = v->mVectorImpl; + auto& vec = v->mVectorImpl; thrust::device_vector> region(2); thrust::fill_n(region.begin(), 1, std::numeric_limits::max()); @@ -104,8 +103,7 @@ namespace cubool { thrust::for_each(thrust::counting_iterator(0), thrust::counting_iterator(vec.m_vals), [first = region.data(), size = region.data() + 1, - i = i, last = i + nrows, rowIndex = vec.m_rows_index.data()] - __device__(index id) { + i = i, last = i + nrows, rowIndex = vec.m_rows_index.data()] __device__(index id) { auto rowId = rowIndex[id]; if (i <= rowId && rowId < last) { @@ -126,29 +124,29 @@ namespace cubool { index firstToCopy = region.front(); VectorImplType::container_type result(resultSize); - thrust::transform(vec.m_rows_index.begin() + firstToCopy, vec.m_rows_index.begin() + firstToCopy + resultSize,result.begin(), - [i]__device__(index id) { return id - i; }); + thrust::transform(vec.m_rows_index.begin() + firstToCopy, vec.m_rows_index.begin() + firstToCopy + resultSize, result.begin(), + [i] __device__(index id) { return id - i; }); // Update this impl data mVectorImpl = std::move(VectorImplType(std::move(result), nrows, resultSize)); } - void CudaVector::extractRow(const class MatrixBase &matrixBase, index i) { - auto matrix = dynamic_cast(&matrixBase); + void CudaVector::extractRow(const class MatrixBase& matrixBase, index i) { + auto matrix = dynamic_cast(&matrixBase); CHECK_RAISE_ERROR(matrix != nullptr, InvalidArgument, "Provided matrix does not belongs to cuda matrix class"); assert(getNrows() == matrix->getNcols()); assert(i <= matrix->getNrows()); - auto &m = matrix->mMatrixImpl; + auto& m = matrix->mMatrixImpl; index beginOffset = m.m_row_index[i]; - index endOffset = m.m_row_index[i + 1]; + index endOffset = m.m_row_index[i + 1]; - auto size = endOffset - beginOffset; + auto size = endOffset - beginOffset; auto being = m.m_col_index.begin() + beginOffset; - auto end = m.m_col_index.begin() + endOffset; + auto end = m.m_col_index.begin() + endOffset; VectorImplType::container_type result(size); thrust::copy(being, end, result.begin()); @@ -156,61 +154,59 @@ namespace cubool { mVectorImpl = std::move(VectorImplType(std::move(result), m.m_cols, size)); } - void CudaVector::extractCol(const class MatrixBase &matrixBase, index j) { - auto matrix = dynamic_cast(&matrixBase); + void CudaVector::extractCol(const class MatrixBase& matrixBase, index j) { + auto matrix = dynamic_cast(&matrixBase); CHECK_RAISE_ERROR(matrix != nullptr, InvalidArgument, "Provided matrix does not belongs to cuda matrix class"); assert(getNrows() == matrix->getNrows()); assert(j <= matrix->getNcols()); - auto &m = matrix->mMatrixImpl; + auto& m = matrix->mMatrixImpl; VectorImplType::container_type nnz(1); thrust::fill(nnz.begin(), nnz.end(), (index) 0); thrust::for_each(thrust::counting_iterator(0), thrust::counting_iterator(m.m_rows), [rowOffset = m.m_row_index.data(), colIndex = m.m_col_index.data(), - j, nnz = nnz.data()]__device__(index i) { - auto size = rowOffset[i + 1] - rowOffset[i]; + j, nnz = nnz.data()] __device__(index i) { + auto size = rowOffset[i + 1] - rowOffset[i]; auto begin = colIndex + rowOffset[i]; - auto end = colIndex + rowOffset[i + 1]; + auto end = colIndex + rowOffset[i + 1]; - auto r = kernels::find(begin, end, j); + auto r = kernels::find(begin, end, j); - if (r != end && *r == j) - atomicAdd(nnz.get(), 1); - } - ); + if (r != end && *r == j) + atomicAdd(nnz.get(), 1); + }); - index size = nnz.back(); + index size = nnz.back(); VectorImplType::container_type result(size); thrust::fill(nnz.begin(), nnz.end(), (index) 0); thrust::for_each(thrust::counting_iterator(0), thrust::counting_iterator(m.m_rows), [rowOffset = m.m_row_index.data(), colIndex = m.m_col_index.data(), - j, nnz = nnz.data(), result = result.data()]__device__(index i) { - auto size = rowOffset[i + 1] - rowOffset[i]; + j, nnz = nnz.data(), result = result.data()] __device__(index i) { + auto size = rowOffset[i + 1] - rowOffset[i]; auto begin = colIndex + rowOffset[i]; - auto end = colIndex + rowOffset[i + 1]; + auto end = colIndex + rowOffset[i + 1]; auto r = kernels::find(begin, end, j); if (r != end && *r == j) { - auto order = atomicAdd(nnz.get(), 1); + auto order = atomicAdd(nnz.get(), 1); result[order] = i; } - } - ); + }); thrust::sort(result.begin(), result.end()); mVectorImpl = std::move(VectorImplType(std::move(result), m.m_rows, size)); } - void CudaVector::clone(const VectorBase &otherBase) { - auto other = dynamic_cast(&otherBase); + void CudaVector::clone(const VectorBase& otherBase) { + auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Passed vector does not belong to vector class"); CHECK_RAISE_ERROR(other != this, InvalidArgument, "Vectors must differ"); @@ -219,7 +215,7 @@ namespace cubool { this->mVectorImpl = other->mVectorImpl; } - void CudaVector::reduce(index &result, bool checkTime) { + void CudaVector::reduce(index& result, bool checkTime) { result = getNvals(); } @@ -231,4 +227,4 @@ namespace cubool { return mVectorImpl.m_vals; } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_vector.hpp b/cubool/sources/cuda/cuda_vector.hpp index 196dd73..ade6643 100644 --- a/cubool/sources/cuda/cuda_vector.hpp +++ b/cubool/sources/cuda/cuda_vector.hpp @@ -27,44 +27,44 @@ #include #include -#include #include +#include namespace cubool { - class CudaVector final: public VectorBase { + class CudaVector final : public VectorBase { public: template - using DeviceAlloc = details::DeviceAllocator; + using DeviceAlloc = details::DeviceAllocator; using VectorImplType = details::SpVector>; CudaVector(size_t nrows, CudaInstance& instance); ~CudaVector() override = default; void setElement(index i) override; - void build(const index *rows, size_t nvals, bool isSorted, bool noDuplicates) override; - void extract(index *rows, size_t &nvals) override; - void extractSubVector(const VectorBase &otherBase, index i, index nrows, bool checkTime) override; + void build(const index* rows, size_t nvals, bool isSorted, bool noDuplicates) override; + void extract(index* rows, size_t& nvals) override; + void extractSubVector(const VectorBase& otherBase, index i, index nrows, bool checkTime) override; void extractRow(const class MatrixBase& matrixBase, index i) override; void extractCol(const class MatrixBase& matrixBase, index j) override; - void clone(const VectorBase &otherBase) override; - void reduce(index &result, bool checkTime) override; - void reduceMatrix(const struct MatrixBase &matrix, bool transpose, bool checkTime) override; + void clone(const VectorBase& otherBase) override; + void reduce(index& result, bool checkTime) override; + void reduceMatrix(const struct MatrixBase& matrix, bool transpose, bool checkTime) override; - void eWiseMult(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) override; - void eWiseAdd(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) override; - void multiplyVxM(const VectorBase &vBase, const struct MatrixBase &mBase, bool checkTime) override; - void multiplyMxV(const struct MatrixBase &mBase, const VectorBase &vBase, bool checkTime) override; + void eWiseMult(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) override; + void eWiseAdd(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) override; + void multiplyVxM(const VectorBase& vBase, const struct MatrixBase& mBase, bool checkTime) override; + void multiplyMxV(const struct MatrixBase& mBase, const VectorBase& vBase, bool checkTime) override; index getNrows() const override; index getNvals() const override; private: mutable VectorImplType mVectorImpl; - CudaInstance& mInstance; + CudaInstance& mInstance; }; -} +}// namespace cubool -#endif //CUBOOL_CUDA_VECTOR_HPP +#endif//CUBOOL_CUDA_VECTOR_HPP diff --git a/cubool/sources/cuda/cuda_vector_ewiseadd.cu b/cubool/sources/cuda/cuda_vector_ewiseadd.cu index 5401927..d921802 100644 --- a/cubool/sources/cuda/cuda_vector_ewiseadd.cu +++ b/cubool/sources/cuda/cuda_vector_ewiseadd.cu @@ -22,14 +22,14 @@ /* SOFTWARE. */ /**********************************************************************************/ +#include +#include #include #include -#include -#include namespace cubool { - void CudaVector::eWiseAdd(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) { + void CudaVector::eWiseAdd(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) { const auto* a = dynamic_cast(&aBase); const auto* b = dynamic_cast(&bBase); @@ -39,9 +39,9 @@ namespace cubool { assert(a->getNrows() == b->getNrows()); kernels::SpVectorEWiseAdd> functor; - auto result = functor(a->mVectorImpl, b->mVectorImpl); + auto result = functor(a->mVectorImpl, b->mVectorImpl); mVectorImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_vector_ewisemult.cu b/cubool/sources/cuda/cuda_vector_ewisemult.cu index a95910f..8201929 100644 --- a/cubool/sources/cuda/cuda_vector_ewisemult.cu +++ b/cubool/sources/cuda/cuda_vector_ewisemult.cu @@ -22,14 +22,14 @@ /* SOFTWARE. */ /**********************************************************************************/ +#include +#include #include #include -#include -#include namespace cubool { - void CudaVector::eWiseMult(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) { + void CudaVector::eWiseMult(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) { const auto* a = dynamic_cast(&aBase); const auto* b = dynamic_cast(&bBase); @@ -39,8 +39,9 @@ namespace cubool { assert(a->getNrows() == b->getNrows()); kernels::SpVectorEWiseMult> functor; - auto result = functor(a->mVectorImpl, b->mVectorImpl); + auto result = functor(a->mVectorImpl, b->mVectorImpl); - mVectorImpl = std::move(result); } + mVectorImpl = std::move(result); + } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_vector_mxv.cu b/cubool/sources/cuda/cuda_vector_mxv.cu index 36ec1b2..8278b19 100644 --- a/cubool/sources/cuda/cuda_vector_mxv.cu +++ b/cubool/sources/cuda/cuda_vector_mxv.cu @@ -22,15 +22,15 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include +#include +#include #include +#include #include -#include -#include namespace cubool { - void CudaVector::multiplyMxV(const struct MatrixBase &mBase, const VectorBase &vBase, bool checkTime) { + void CudaVector::multiplyMxV(const struct MatrixBase& mBase, const VectorBase& vBase, bool checkTime) { const auto* m = dynamic_cast(&mBase); const auto* v = dynamic_cast(&vBase); @@ -43,9 +43,9 @@ namespace cubool { m->resizeStorageToDim(); kernels::SpGEMV> functor; - auto result = functor(m->mMatrixImpl, v->mVectorImpl); + auto result = functor(m->mMatrixImpl, v->mVectorImpl); mVectorImpl = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_vector_reduce.cu b/cubool/sources/cuda/cuda_vector_reduce.cu index 86b1f04..1149f08 100644 --- a/cubool/sources/cuda/cuda_vector_reduce.cu +++ b/cubool/sources/cuda/cuda_vector_reduce.cu @@ -22,15 +22,15 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include +#include +#include #include +#include #include -#include -#include namespace cubool { - void CudaVector::reduceMatrix(const struct MatrixBase &matrixBase, bool transpose, bool checkTime) { + void CudaVector::reduceMatrix(const struct MatrixBase& matrixBase, bool transpose, bool checkTime) { auto matrix = dynamic_cast(&matrixBase); CHECK_RAISE_ERROR(matrix != nullptr, InvalidArgument, "Provided matrix does not belongs to cuda matrix class"); @@ -42,8 +42,7 @@ namespace cubool { // Reduce to row-vector kernels::SpVectorMatrixTransposedReduceFunctor> functor; mVectorImpl = std::move(functor(matrix->mMatrixImpl)); - } - else { + } else { assert(matrix->getNrows() == this->getNrows()); matrix->resizeStorageToDim(); @@ -53,4 +52,4 @@ namespace cubool { } } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/cuda/cuda_vector_vxm.cu b/cubool/sources/cuda/cuda_vector_vxm.cu index 2996f76..bae2e25 100644 --- a/cubool/sources/cuda/cuda_vector_vxm.cu +++ b/cubool/sources/cuda/cuda_vector_vxm.cu @@ -22,15 +22,15 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include +#include +#include #include +#include #include -#include -#include namespace cubool { - void CudaVector::multiplyVxM(const VectorBase &vBase, const struct MatrixBase &mBase, bool checkTime) { + void CudaVector::multiplyVxM(const VectorBase& vBase, const struct MatrixBase& mBase, bool checkTime) { const auto* v = dynamic_cast(&vBase); const auto* m = dynamic_cast(&mBase); @@ -43,11 +43,9 @@ namespace cubool { m->resizeStorageToDim(); kernels::SpGEMVT> functor; - auto result = functor(v->mVectorImpl, m->mMatrixImpl); + auto result = functor(v->mVectorImpl, m->mMatrixImpl); mVectorImpl = std::move(result); } -} - - +}// namespace cubool diff --git a/cubool/sources/cuda/details/host_allocator.hpp b/cubool/sources/cuda/details/host_allocator.hpp index 115ada2..e1529df 100644 --- a/cubool/sources/cuda/details/host_allocator.hpp +++ b/cubool/sources/cuda/details/host_allocator.hpp @@ -25,44 +25,43 @@ #ifndef CUBOOL_HOST_ALLOCATOR_HPP #define CUBOOL_HOST_ALLOCATOR_HPP -#include #include +#include namespace cubool { namespace details { - template + template class HostAllocator { public: - typedef size_t size_type; - typedef T value_type; - typedef T* pointer; + typedef size_t size_type; + typedef T value_type; + typedef T* pointer; typedef const T* const_pointer; - typedef T& reference; + typedef T& reference; typedef const T& const_reference; - template - struct rebind { typedef HostAllocator other; }; - - explicit HostAllocator(): mInstanceRef(CudaInstance::getInstanceRef()) { + template + struct rebind { + typedef HostAllocator other; + }; + explicit HostAllocator() : mInstanceRef(CudaInstance::getInstanceRef()) { } - HostAllocator(const HostAllocator &other): mInstanceRef(other.mInstanceRef) { - + HostAllocator(const HostAllocator& other) : mInstanceRef(other.mInstanceRef) { } - HostAllocator(HostAllocator &&other) noexcept: mInstanceRef(other.mInstanceRef) { - + HostAllocator(HostAllocator&& other) noexcept : mInstanceRef(other.mInstanceRef) { } ~HostAllocator() = default; - bool operator!=(const HostAllocator &other) const { + bool operator!=(const HostAllocator& other) const { return &mInstanceRef != &other.mInstanceRef; } - HostAllocator& operator=(const HostAllocator &other) { + HostAllocator& operator=(const HostAllocator& other) { this->~HostAllocator(); new (this) HostAllocator(other); return *this; @@ -75,7 +74,7 @@ namespace cubool { } void deallocate(pointer p, size_type n) { - (void)n; + (void) n; mInstanceRef.deallocate(p); } @@ -83,7 +82,7 @@ namespace cubool { CudaInstance& mInstanceRef; }; - } -} + }// namespace details +}// namespace cubool -#endif //CUBOOL_HOST_ALLOCATOR_HPP +#endif//CUBOOL_HOST_ALLOCATOR_HPP diff --git a/cubool/sources/cuda/details/meta.hpp b/cubool/sources/cuda/details/meta.hpp index 18762ae..7310737 100644 --- a/cubool/sources/cuda/details/meta.hpp +++ b/cubool/sources/cuda/details/meta.hpp @@ -25,21 +25,21 @@ #ifndef CUBOOL_META_HPP #define CUBOOL_META_HPP +#include #include #include -#include namespace cubool { - template + template struct StreamsWrapper { StreamsWrapper() { - for (auto& s: streams) + for (auto& s : streams) cudaStreamCreate(&s); } ~StreamsWrapper() { - for (auto& s: streams) + for (auto& s : streams) cudaStreamDestroy(s); } @@ -50,22 +50,21 @@ namespace cubool { struct Bin { static_assert(Threads <= BlocksSize, "Block size must be >= threads in this block"); - static constexpr size_t threads = Threads; - static constexpr size_t blockSize = BlocksSize; + static constexpr size_t threads = Threads; + static constexpr size_t blockSize = BlocksSize; static constexpr size_t dispatchRatio = BlocksSize / Threads; - static constexpr size_t min = Max; - static constexpr size_t max = Min; - static constexpr size_t id = Id; + static constexpr size_t min = Max; + static constexpr size_t max = Min; + static constexpr size_t id = Id; }; - template + template struct Config { public: - static __host__ __device__ size_t selectBin(size_t rowSize) { - static constexpr size_t mins[] = { Bins::min... }; - static constexpr size_t maxs[] = { Bins::max... }; + static constexpr size_t mins[] = {Bins::min...}; + static constexpr size_t maxs[] = {Bins::max...}; for (size_t i = 0; i < binsCount(); i++) { if (mins[i] <= rowSize && rowSize <= maxs[i]) @@ -76,7 +75,7 @@ namespace cubool { } static __host__ __device__ constexpr size_t binBlockSize(size_t id) { - constexpr size_t blockSizes[] = { Bins::blockSize... }; + constexpr size_t blockSizes[] = {Bins::blockSize...}; return blockSizes[id]; } @@ -87,9 +86,8 @@ namespace cubool { static __host__ __device__ constexpr size_t unusedBinId() { return binsCount() + 1; } - }; -} +}// namespace cubool -#endif //CUBOOL_META_HPP +#endif//CUBOOL_META_HPP diff --git a/cubool/sources/cuda/details/sp_vector.hpp b/cubool/sources/cuda/details/sp_vector.hpp index 4720ad0..bd6613f 100644 --- a/cubool/sources/cuda/details/sp_vector.hpp +++ b/cubool/sources/cuda/details/sp_vector.hpp @@ -33,29 +33,29 @@ namespace cubool { template struct SpVector { public: - typedef bool value_type; - typedef IndexType index_type; - typedef AllocType alloc_type; + typedef bool value_type; + typedef IndexType index_type; + typedef AllocType alloc_type; typedef thrust::device_vector container_type; SpVector() : m_rows_index{}, m_rows{0}, m_vals{0} {} SpVector(index_type rows) - : m_rows_index{}, m_rows (rows), m_vals{0} {} + : m_rows_index{}, m_rows(rows), m_vals{0} {} SpVector(thrust::device_vector rows_index, index_type rows, index_type vals) - : m_rows_index{ std::move(rows_index) }, m_rows{ rows }, m_vals{ vals } { + : m_rows_index{std::move(rows_index)}, m_rows{rows}, m_vals{vals} { assert(m_rows > 0); assert(m_rows_index.size() == m_vals); } public: thrust::device_vector m_rows_index; - index_type m_rows; - index_type m_vals; + index_type m_rows; + index_type m_vals; }; - } -} + }// namespace details +}// namespace cubool -#endif //CUBOOL_SP_VECTOR_HPP +#endif//CUBOOL_SP_VECTOR_HPP diff --git a/cubool/sources/io/logger.cpp b/cubool/sources/io/logger.cpp index be5604f..87d08d4 100644 --- a/cubool/sources/io/logger.cpp +++ b/cubool/sources/io/logger.cpp @@ -26,23 +26,23 @@ namespace cubool { - void Logger::logInfo(const std::string &message) { + void Logger::logInfo(const std::string& message) { this->log(Level::Info, message); } - void Logger::logWarning(const std::string &message) { + void Logger::logWarning(const std::string& message) { this->log(Level::Warning, message); } - void Logger::logError(const std::string &message) { + void Logger::logError(const std::string& message) { this->log(Level::Error, message); } - void TextLogger::log(Logger::Level level, const std::string &message) { + void TextLogger::log(Logger::Level level, const std::string& message) { bool pass = true; // If pass all filters - for (const auto& filter: mFilters) { + for (const auto& filter : mFilters) { pass = pass && filter(level, message); } @@ -51,13 +51,13 @@ namespace cubool { Entry entry; entry.message = message; - entry.level = level; - entry.id = id; + entry.level = level; + entry.id = id; mEntries.emplace_back(std::move(entry)); // Notify listeners - for (const auto& action: mOnLogged) { + for (const auto& action : mOnLogged) { action(id, level, message); } } @@ -87,7 +87,7 @@ namespace cubool { mOnLogged.clear(); } - void DummyLogger::log(Logger::Level level, const std::string &message) { + void DummyLogger::log(Logger::Level level, const std::string& message) { // no op. } @@ -98,4 +98,4 @@ namespace cubool { bool DummyLogger::isDummy() const { return true; } -} +}// namespace cubool diff --git a/cubool/sources/io/logger.hpp b/cubool/sources/io/logger.hpp index 2b2fad3..b7198fd 100644 --- a/cubool/sources/io/logger.hpp +++ b/cubool/sources/io/logger.hpp @@ -25,10 +25,10 @@ #ifndef CUBOOL_LOGGER_HPP #define CUBOOL_LOGGER_HPP -#include -#include #include #include +#include +#include namespace cubool { @@ -38,18 +38,18 @@ namespace cubool { class Logger { public: enum class Level { - Info, // Logged basic info (can be ignored) - Warning, // Logged warning (can be ignored) - Error, // Logged error (can be ignored) - Always // Logged always (cannot be ignored) + Info, // Logged basic info (can be ignored) + Warning,// Logged warning (can be ignored) + Error, // Logged error (can be ignored) + Always // Logged always (cannot be ignored) }; - virtual ~Logger() = default; - virtual void log(Level level, const std::string &message) = 0; - virtual void logInfo(const std::string &message); - virtual void logWarning(const std::string &message); - virtual void logError(const std::string &message); - virtual bool isDummy() const = 0; + virtual ~Logger() = default; + virtual void log(Level level, const std::string& message) = 0; + virtual void logInfo(const std::string& message); + virtual void logWarning(const std::string& message); + virtual void logError(const std::string& message); + virtual bool isDummy() const = 0; virtual size_t getMessagesCount() const = 0; }; @@ -60,7 +60,7 @@ namespace cubool { * Allows add filters to ignore some messages. * Allows commit messages to the output log file. */ - class TextLogger final: public Logger { + class TextLogger final : public Logger { public: /** Allows filter logged messages (before they are actually saved inside) */ using Filter = std::function; @@ -68,9 +68,9 @@ namespace cubool { using OnLogged = std::function; ~TextLogger() override = default; - void log(Level level, const std::string &message) override; + void log(Level level, const std::string& message) override; size_t getMessagesCount() const override; - bool isDummy() const override; + bool isDummy() const override; void addFilter(Filter filter); void removeAllFilters(); @@ -80,26 +80,26 @@ namespace cubool { private: struct Entry { std::string message; - Level level; - size_t id; + Level level; + size_t id; }; - std::vector mEntries; - std::vector mFilters; + std::vector mEntries; + std::vector mFilters; std::vector mOnLogged; - size_t mNextMessageId = 0; + size_t mNextMessageId = 0; }; /** * No logging logic. */ - class DummyLogger final: public Logger { + class DummyLogger final : public Logger { public: - DummyLogger() noexcept = default; + DummyLogger() noexcept = default; ~DummyLogger() override = default; - void log(Level level, const std::string &message) override; + void log(Level level, const std::string& message) override; size_t getMessagesCount() const override; - bool isDummy() const override; + bool isDummy() const override; }; /** @@ -112,10 +112,10 @@ namespace cubool { explicit LogStream(Logger& logger) : mLogger(logger), mLevel(Logger::Level::Info) { - }; + }; LogStream(LogStream&& other) noexcept = default; - ~LogStream() = default; + ~LogStream() = default; void commit() { if (!mLogger.isDummy()) { @@ -150,11 +150,11 @@ namespace cubool { } private: - Logger& mLogger; - Logger::Level mLevel; + Logger& mLogger; + Logger::Level mLevel; std::stringstream mStream; }; -} +}// namespace cubool -#endif //CUBOOL_LOGGER_HPP +#endif//CUBOOL_LOGGER_HPP diff --git a/cubool/sources/sequential/sq_backend.cpp b/cubool/sources/sequential/sq_backend.cpp index e99c5cf..53d69f1 100644 --- a/cubool/sources/sequential/sq_backend.cpp +++ b/cubool/sources/sequential/sq_backend.cpp @@ -22,12 +22,12 @@ /* SOFTWARE. */ /**********************************************************************************/ +#include +#include +#include #include #include #include -#include -#include -#include namespace cubool { @@ -56,7 +56,7 @@ namespace cubool { return true; } - MatrixBase *SqBackend::createMatrix(size_t nrows, size_t ncols) { + MatrixBase* SqBackend::createMatrix(size_t nrows, size_t ncols) { mMatCount++; return new SqMatrix(nrows, ncols); } @@ -66,18 +66,18 @@ namespace cubool { return new SqVector(nrows); } - void SqBackend::releaseMatrix(MatrixBase *matrixBase) { + void SqBackend::releaseMatrix(MatrixBase* matrixBase) { mMatCount--; delete matrixBase; } - void SqBackend::releaseVector(VectorBase *vectorBase) { + void SqBackend::releaseVector(VectorBase* vectorBase) { mVecCount--; delete vectorBase; } - void SqBackend::queryCapabilities(cuBool_DeviceCaps &caps) { + void SqBackend::queryCapabilities(cuBool_DeviceCaps& caps) { caps.cudaSupported = false; } -} +}// namespace cubool diff --git a/cubool/sources/sequential/sq_backend.hpp b/cubool/sources/sequential/sq_backend.hpp index b95e51a..1508dfb 100644 --- a/cubool/sources/sequential/sq_backend.hpp +++ b/cubool/sources/sequential/sq_backend.hpp @@ -32,7 +32,7 @@ namespace cubool { /** * Sequential backend for Cpu side computations (fallback). */ - class SqBackend final: public BackendBase { + class SqBackend final : public BackendBase { public: ~SqBackend() override = default; @@ -40,10 +40,10 @@ namespace cubool { void finalize() override; bool isInitialized() const override; - MatrixBase *createMatrix(size_t nrows, size_t ncols) override; + MatrixBase* createMatrix(size_t nrows, size_t ncols) override; VectorBase* createVector(size_t nrows) override; - void releaseMatrix(MatrixBase *matrixBase) override; - void releaseVector(VectorBase* vectorBase) override; + void releaseMatrix(MatrixBase* matrixBase) override; + void releaseVector(VectorBase* vectorBase) override; void queryCapabilities(cuBool_DeviceCaps& caps) override; @@ -52,6 +52,6 @@ namespace cubool { size_t mVecCount = 0; }; -} +}// namespace cubool -#endif //CUBOOL_SQ_BACKEND_HPP +#endif//CUBOOL_SQ_BACKEND_HPP diff --git a/cubool/sources/sequential/sq_data.hpp b/cubool/sources/sequential/sq_data.hpp index 345d707..1e9103c 100644 --- a/cubool/sources/sequential/sq_data.hpp +++ b/cubool/sources/sequential/sq_data.hpp @@ -34,18 +34,18 @@ namespace cubool { public: std::vector rowOffsets; std::vector colIndices; - index nrows = 0; - index ncols = 0; - index nvals = 0; + index nrows = 0; + index ncols = 0; + index nvals = 0; }; class VecData { public: std::vector indices; - index nrows = 0; - index nvals = 0; + index nrows = 0; + index nvals = 0; }; -} +}// namespace cubool -#endif //CUBOOL_SQ_DATA_HPP +#endif//CUBOOL_SQ_DATA_HPP diff --git a/cubool/sources/sequential/sq_ewiseadd.cpp b/cubool/sources/sequential/sq_ewiseadd.cpp index 8613a9a..acf8d69 100644 --- a/cubool/sources/sequential/sq_ewiseadd.cpp +++ b/cubool/sources/sequential/sq_ewiseadd.cpp @@ -34,13 +34,13 @@ namespace cubool { // Count nnz of the result matrix to allocate memory for (index i = 0; i < a.nrows; i++) { - index ak = a.rowOffsets[i]; - index bk = b.rowOffsets[i]; + index ak = a.rowOffsets[i]; + index bk = b.rowOffsets[i]; index asize = a.rowOffsets[i + 1] - ak; index bsize = b.rowOffsets[i + 1] - bk; - const index* ar = &a.colIndices[ak]; - const index* br = &b.colIndices[bk]; + const index* ar = &a.colIndices[ak]; + const index* br = &b.colIndices[bk]; const index* arend = ar + asize; const index* brend = br + bsize; @@ -51,19 +51,17 @@ namespace cubool { nvalsInRow++; ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { nvalsInRow++; ar++; - } - else { + } else { nvalsInRow++; br++; } } - nvalsInRow += (size_t)(arend - ar); - nvalsInRow += (size_t)(brend - br); + nvalsInRow += (size_t) (arend - ar); + nvalsInRow += (size_t) (brend - br); nvals += nvalsInRow; out.rowOffsets[i] = nvalsInRow; @@ -79,8 +77,8 @@ namespace cubool { // Fill sorted column indices size_t k = 0; for (index i = 0; i < a.nrows; i++) { - const index* ar = &a.colIndices[a.rowOffsets[i]]; - const index* br = &b.colIndices[b.rowOffsets[i]]; + const index* ar = &a.colIndices[a.rowOffsets[i]]; + const index* br = &b.colIndices[b.rowOffsets[i]]; const index* arend = &a.colIndices[a.rowOffsets[i + 1]]; const index* brend = &b.colIndices[b.rowOffsets[i + 1]]; @@ -90,13 +88,11 @@ namespace cubool { k++; ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { out.colIndices[k] = *ar; k++; ar++; - } - else { + } else { out.colIndices[k] = *br; k++; br++; @@ -131,11 +127,9 @@ namespace cubool { if (*ar == *br) { ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { ar++; - } - else { + } else { br++; } @@ -166,12 +160,10 @@ namespace cubool { out.indices.push_back(*ar); ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { out.indices.push_back(*ar); ar++; - } - else { + } else { out.indices.push_back(*br); br++; } @@ -188,4 +180,4 @@ namespace cubool { } } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_ewiseadd.hpp b/cubool/sources/sequential/sq_ewiseadd.hpp index 122a2b9..488ae7c 100644 --- a/cubool/sources/sequential/sq_ewiseadd.hpp +++ b/cubool/sources/sequential/sq_ewiseadd.hpp @@ -47,6 +47,6 @@ namespace cubool { */ void sq_ewiseadd(const VecData& a, const VecData& b, VecData& out); -} +}// namespace cubool -#endif //CUBOOL_SQ_EWISEADD_HPP +#endif//CUBOOL_SQ_EWISEADD_HPP diff --git a/cubool/sources/sequential/sq_ewisemult.cpp b/cubool/sources/sequential/sq_ewisemult.cpp index 9ead01a..296059e 100644 --- a/cubool/sources/sequential/sq_ewisemult.cpp +++ b/cubool/sources/sequential/sq_ewisemult.cpp @@ -34,13 +34,13 @@ namespace cubool { // Count nnz of the result matrix to allocate memory for (index i = 0; i < a.nrows; i++) { - index ak = a.rowOffsets[i]; - index bk = b.rowOffsets[i]; + index ak = a.rowOffsets[i]; + index bk = b.rowOffsets[i]; index asize = a.rowOffsets[i + 1] - ak; index bsize = b.rowOffsets[i + 1] - bk; - const index* ar = &a.colIndices[ak]; - const index* br = &b.colIndices[bk]; + const index* ar = &a.colIndices[ak]; + const index* br = &b.colIndices[bk]; const index* arend = ar + asize; const index* brend = br + bsize; @@ -51,11 +51,9 @@ namespace cubool { nvalsInRow++; ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { ar++; - } - else { + } else { br++; } } @@ -74,8 +72,8 @@ namespace cubool { // Fill sorted column indices size_t k = 0; for (index i = 0; i < a.nrows; i++) { - const index* ar = &a.colIndices[a.rowOffsets[i]]; - const index* br = &b.colIndices[b.rowOffsets[i]]; + const index* ar = &a.colIndices[a.rowOffsets[i]]; + const index* br = &b.colIndices[b.rowOffsets[i]]; const index* arend = &a.colIndices[a.rowOffsets[i + 1]]; const index* brend = &b.colIndices[b.rowOffsets[i + 1]]; @@ -85,11 +83,9 @@ namespace cubool { k++; ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { ar++; - } - else { + } else { br++; } } @@ -110,11 +106,9 @@ namespace cubool { out.indices.push_back(*aP); aP++; bP++; - } - else if (*aP < *bP) { + } else if (*aP < *bP) { aP++; - } - else { + } else { bP++; } } @@ -122,4 +116,4 @@ namespace cubool { out.nvals = out.indices.size(); } -} +}// namespace cubool diff --git a/cubool/sources/sequential/sq_ewisemult.hpp b/cubool/sources/sequential/sq_ewisemult.hpp index 13666b4..20e9367 100644 --- a/cubool/sources/sequential/sq_ewisemult.hpp +++ b/cubool/sources/sequential/sq_ewisemult.hpp @@ -47,6 +47,6 @@ namespace cubool { */ void sq_ewisemult(const VecData& a, const VecData& b, VecData& out); -} +}// namespace cubool -#endif //CUBOOL_SQ_EWISEMULT_HPP +#endif//CUBOOL_SQ_EWISEMULT_HPP diff --git a/cubool/sources/sequential/sq_ewisemultinverted.cpp b/cubool/sources/sequential/sq_ewisemultinverted.cpp index ee810c9..1110a88 100644 --- a/cubool/sources/sequential/sq_ewisemultinverted.cpp +++ b/cubool/sources/sequential/sq_ewisemultinverted.cpp @@ -34,13 +34,13 @@ namespace cubool { // Count nnz of the result matrix to allocate memory for (index i = 0; i < a.nrows; i++) { - index ak = a.rowOffsets[i]; - index bk = b.rowOffsets[i]; + index ak = a.rowOffsets[i]; + index bk = b.rowOffsets[i]; index asize = a.rowOffsets[i + 1] - ak; index bsize = b.rowOffsets[i + 1] - bk; - const index* ar = &a.colIndices[ak]; - const index* br = &b.colIndices[bk]; + const index* ar = &a.colIndices[ak]; + const index* br = &b.colIndices[bk]; const index* arend = ar + asize; const index* brend = br + bsize; @@ -50,12 +50,10 @@ namespace cubool { if (*ar == *br) { ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { nvalsInRow++; ar++; - } - else { + } else { br++; } } @@ -75,8 +73,8 @@ namespace cubool { // Fill sorted column indices size_t k = 0; for (index i = 0; i < a.nrows; i++) { - const index* ar = &a.colIndices[a.rowOffsets[i]]; - const index* br = &b.colIndices[b.rowOffsets[i]]; + const index* ar = &a.colIndices[a.rowOffsets[i]]; + const index* br = &b.colIndices[b.rowOffsets[i]]; const index* arend = &a.colIndices[a.rowOffsets[i + 1]]; const index* brend = &b.colIndices[b.rowOffsets[i + 1]]; @@ -84,13 +82,11 @@ namespace cubool { if (*ar == *br) { ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { out.colIndices[k] = *ar; k++; ar++; - } - else { + } else { br++; } } @@ -102,4 +98,4 @@ namespace cubool { } } } -} +}// namespace cubool diff --git a/cubool/sources/sequential/sq_ewisemultinverted.hpp b/cubool/sources/sequential/sq_ewisemultinverted.hpp index 99b2615..6885549 100644 --- a/cubool/sources/sequential/sq_ewisemultinverted.hpp +++ b/cubool/sources/sequential/sq_ewisemultinverted.hpp @@ -37,6 +37,6 @@ namespace cubool { * @param[out] out Where to store the result */ void sq_ewisemultinverted(const CsrData& a, const CsrData& b, CsrData& out); -} +}// namespace cubool -#endif //CUBOOL_SQ_EWISEMULTINVERTED_HPP +#endif//CUBOOL_SQ_EWISEMULTINVERTED_HPP diff --git a/cubool/sources/sequential/sq_kronecker.cpp b/cubool/sources/sequential/sq_kronecker.cpp index f63b959..da66abd 100644 --- a/cubool/sources/sequential/sq_kronecker.cpp +++ b/cubool/sources/sequential/sq_kronecker.cpp @@ -58,4 +58,4 @@ namespace cubool { exclusive_scan(out.rowOffsets.begin(), out.rowOffsets.end(), 0); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_kronecker.hpp b/cubool/sources/sequential/sq_kronecker.hpp index 1eb379e..df2d065 100644 --- a/cubool/sources/sequential/sq_kronecker.hpp +++ b/cubool/sources/sequential/sq_kronecker.hpp @@ -37,6 +37,6 @@ namespace cubool { */ void sq_kronecker(const CsrData& a, const CsrData& b, CsrData& out); -} +}// namespace cubool -#endif //CUBOOL_SP_KRONECKER_HPP +#endif//CUBOOL_SP_KRONECKER_HPP diff --git a/cubool/sources/sequential/sq_matrix.cpp b/cubool/sources/sequential/sq_matrix.cpp index 00473f1..eaad8c8 100644 --- a/cubool/sources/sequential/sq_matrix.cpp +++ b/cubool/sources/sequential/sq_matrix.cpp @@ -22,18 +22,18 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include -#include -#include -#include +#include +#include #include #include #include -#include +#include +#include #include +#include +#include +#include #include -#include -#include namespace cubool { @@ -49,7 +49,7 @@ namespace cubool { RAISE_ERROR(NotImplemented, "This function is not supported for this matrix class"); } - void SqMatrix::build(const index *rows, const index *cols, size_t nvals, bool isSorted, bool noDuplicates) { + void SqMatrix::build(const index* rows, const index* cols, size_t nvals, bool isSorted, bool noDuplicates) { auto nrows = mData.nrows; auto ncols = mData.ncols; @@ -62,7 +62,7 @@ namespace cubool { mData.nvals = mData.colIndices.size(); } - void SqMatrix::extract(index *rows, index *cols, size_t &nvals) { + void SqMatrix::extract(index* rows, index* cols, size_t& nvals) { assert(nvals >= getNvals()); nvals = getNvals(); @@ -71,7 +71,7 @@ namespace cubool { } } - void SqMatrix::extractSubMatrix(const MatrixBase &otherBase, index i, index j, index nrows, index ncols, + void SqMatrix::extractSubMatrix(const MatrixBase& otherBase, index i, index j, index nrows, index ncols, bool checkTime) { auto other = dynamic_cast(&otherBase); @@ -86,7 +86,7 @@ namespace cubool { sq_submatrix(other->mData, this->mData, i, j, nrows, ncols); } - void SqMatrix::clone(const MatrixBase &otherBase) { + void SqMatrix::clone(const MatrixBase& otherBase) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Provided matrix does not belongs to sequential matrix class"); @@ -98,7 +98,7 @@ namespace cubool { this->mData = other->mData; } - void SqMatrix::transpose(const MatrixBase &otherBase, bool checkTime) { + void SqMatrix::transpose(const MatrixBase& otherBase, bool checkTime) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Provided matrix does not belongs to sequential matrix class"); @@ -117,7 +117,7 @@ namespace cubool { this->mData = std::move(out); } - void SqMatrix::reduce(const MatrixBase &otherBase, bool checkTime) { + void SqMatrix::reduce(const MatrixBase& otherBase, bool checkTime) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Provided matrix does not belongs to sequential matrix class"); @@ -136,7 +136,7 @@ namespace cubool { this->mData = std::move(out); } - void SqMatrix::multiply(const MatrixBase &aBase, const MatrixBase &bBase, bool accumulate, bool checkTime) { + void SqMatrix::multiply(const MatrixBase& aBase, const MatrixBase& bBase, bool accumulate, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -169,7 +169,7 @@ namespace cubool { this->mData = std::move(out); } - void SqMatrix::kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void SqMatrix::kronecker(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -190,7 +190,7 @@ namespace cubool { this->mData = std::move(out); } - void SqMatrix::eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void SqMatrix::eWiseAdd(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -213,7 +213,7 @@ namespace cubool { this->mData = std::move(out); } - void SqMatrix::eWiseMult(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void SqMatrix::eWiseMult(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -236,7 +236,7 @@ namespace cubool { this->mData = std::move(out); } - void SqMatrix::eWiseMultInverted(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) { + void SqMatrix::eWiseMultInverted(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -260,7 +260,6 @@ namespace cubool { } - index SqMatrix::getNrows() const { return mData.nrows; } @@ -279,4 +278,4 @@ namespace cubool { mData.rowOffsets.resize(getNrows() + 1, 0); } } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_matrix.hpp b/cubool/sources/sequential/sq_matrix.hpp index d348232..064a1ed 100644 --- a/cubool/sources/sequential/sq_matrix.hpp +++ b/cubool/sources/sequential/sq_matrix.hpp @@ -33,25 +33,25 @@ namespace cubool { /** * Csr matrix for Cpu side operations in sequential backend. */ - class SqMatrix final: public MatrixBase { + class SqMatrix final : public MatrixBase { public: SqMatrix(size_t nrows, size_t ncols); ~SqMatrix() override = default; void setElement(index i, index j) override; - void build(const index *rows, const index *cols, size_t nvals, bool isSorted, bool noDuplicates) override; - void extract(index *rows, index *cols, size_t &nvals) override; - void extractSubMatrix(const MatrixBase &otherBase, index i, index j, index nrows, index ncols, bool checkTime) override; + void build(const index* rows, const index* cols, size_t nvals, bool isSorted, bool noDuplicates) override; + void extract(index* rows, index* cols, size_t& nvals) override; + void extractSubMatrix(const MatrixBase& otherBase, index i, index j, index nrows, index ncols, bool checkTime) override; - void clone(const MatrixBase &otherBase) override; - void transpose(const MatrixBase &otherBase, bool checkTime) override; - void reduce(const MatrixBase &otherBase, bool checkTime) override; + void clone(const MatrixBase& otherBase) override; + void transpose(const MatrixBase& otherBase, bool checkTime) override; + void reduce(const MatrixBase& otherBase, bool checkTime) override; - void multiply(const MatrixBase &aBase, const MatrixBase &bBase, bool accumulate, bool checkTime) override; - void kronecker(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) override; - void eWiseAdd(const MatrixBase &aBase, const MatrixBase &bBase, bool checkTime) override; - void eWiseMult(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; - void eWiseMultInverted(const MatrixBase &a, const MatrixBase &b, bool checkTime) override; + void multiply(const MatrixBase& aBase, const MatrixBase& bBase, bool accumulate, bool checkTime) override; + void kronecker(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) override; + void eWiseAdd(const MatrixBase& aBase, const MatrixBase& bBase, bool checkTime) override; + void eWiseMult(const MatrixBase& a, const MatrixBase& b, bool checkTime) override; + void eWiseMultInverted(const MatrixBase& a, const MatrixBase& b, bool checkTime) override; index getNrows() const override; index getNcols() const override; @@ -64,6 +64,6 @@ namespace cubool { mutable CsrData mData; }; -} +}// namespace cubool -#endif //CUBOOL_SQ_MATRIX_HPP +#endif//CUBOOL_SQ_MATRIX_HPP diff --git a/cubool/sources/sequential/sq_reduce.cpp b/cubool/sources/sequential/sq_reduce.cpp index 0035d4d..2d0de9a 100644 --- a/cubool/sources/sequential/sq_reduce.cpp +++ b/cubool/sources/sequential/sq_reduce.cpp @@ -22,9 +22,9 @@ /* SOFTWARE. */ /**********************************************************************************/ +#include #include #include -#include namespace cubool { @@ -70,15 +70,15 @@ namespace cubool { } void sq_reduce_transposed(const CsrData& a, VecData& out) { - const auto max = std::numeric_limits::max(); + const auto max = std::numeric_limits::max(); std::vector mask(a.ncols, max); - for (auto j: a.colIndices) { + for (auto j : a.colIndices) { mask[j] = j; } size_t size = 0; - for (auto v: mask) { + for (auto v : mask) { if (v != max) { size += 1; } @@ -87,11 +87,11 @@ namespace cubool { out.indices.reserve(size); out.nvals = size; - for (auto v: mask) { + for (auto v : mask) { if (v != max) { out.indices.push_back(v); } } } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_reduce.hpp b/cubool/sources/sequential/sq_reduce.hpp index 02f3534..e029f2d 100644 --- a/cubool/sources/sequential/sq_reduce.hpp +++ b/cubool/sources/sequential/sq_reduce.hpp @@ -52,6 +52,6 @@ namespace cubool { * @param[out] out Where to store result */ void sq_reduce_transposed(const CsrData& a, VecData& out); -} +}// namespace cubool -#endif //CUBOOL_SP_REDUCE_HPP +#endif//CUBOOL_SP_REDUCE_HPP diff --git a/cubool/sources/sequential/sq_spgemm.cpp b/cubool/sources/sequential/sq_spgemm.cpp index db2a821..8406eb7 100644 --- a/cubool/sources/sequential/sq_spgemm.cpp +++ b/cubool/sources/sequential/sq_spgemm.cpp @@ -22,10 +22,10 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include -#include #include #include +#include +#include namespace cubool { @@ -69,9 +69,9 @@ namespace cubool { mask.resize(b.ncols, max); for (index i = 0; i < a.nrows; i++) { - size_t id = 0; + size_t id = 0; size_t first = out.rowOffsets[i]; - size_t last = out.rowOffsets[i + 1]; + size_t last = out.rowOffsets[i + 1]; for (index ak = a.rowOffsets[i]; ak < a.rowOffsets[i + 1]; ak++) { index k = a.colIndices[ak]; @@ -81,7 +81,7 @@ namespace cubool { // Do not compute col nnz twice if (mask[j] != i) { - mask[j] = i; + mask[j] = i; out.colIndices[first + id] = j; id += 1; } @@ -93,4 +93,4 @@ namespace cubool { } } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_spgemm.hpp b/cubool/sources/sequential/sq_spgemm.hpp index 66ce098..b58a8ec 100644 --- a/cubool/sources/sequential/sq_spgemm.hpp +++ b/cubool/sources/sequential/sq_spgemm.hpp @@ -38,6 +38,6 @@ namespace cubool { */ void sq_spgemm(const CsrData& a, const CsrData& b, CsrData& out); -} +}// namespace cubool -#endif //CUBOOL_SQ_SPGEMM_HPP +#endif//CUBOOL_SQ_SPGEMM_HPP diff --git a/cubool/sources/sequential/sq_spgemv.cpp b/cubool/sources/sequential/sq_spgemv.cpp index cb9c3e7..b4cc9bc 100644 --- a/cubool/sources/sequential/sq_spgemv.cpp +++ b/cubool/sources/sequential/sq_spgemv.cpp @@ -42,11 +42,9 @@ namespace cubool { if (*ar == *vr) { nonZero = true; break; - } - else if (*ar < *vr) { + } else if (*ar < *vr) { ar++; - } - else { + } else { vr++; } } @@ -56,14 +54,14 @@ namespace cubool { } } - out.nvals = result.size(); + out.nvals = result.size(); out.indices = std::move(result); } void sq_spgemv_transposed(const CsrData& a, const VecData& b, VecData& out) { std::vector mask(a.ncols, false); - for (index i: b.indices) { + for (index i : b.indices) { for (index k = a.rowOffsets[i]; k < a.rowOffsets[i + 1]; k++) { mask[a.colIndices[k]] = true; } @@ -76,8 +74,8 @@ namespace cubool { result.push_back(i); } - out.nvals = result.size(); + out.nvals = result.size(); out.indices = std::move(result); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_spgemv.hpp b/cubool/sources/sequential/sq_spgemv.hpp index 6975fa9..1c6af0b 100644 --- a/cubool/sources/sequential/sq_spgemv.hpp +++ b/cubool/sources/sequential/sq_spgemv.hpp @@ -47,6 +47,6 @@ namespace cubool { */ void sq_spgemv_transposed(const CsrData& a, const VecData& b, VecData& out); -} +}// namespace cubool -#endif //CUBOOL_SQ_SPGEMV_HPP +#endif//CUBOOL_SQ_SPGEMV_HPP diff --git a/cubool/sources/sequential/sq_submatrix.cpp b/cubool/sources/sequential/sq_submatrix.cpp index 0e28442..5e63362 100644 --- a/cubool/sources/sequential/sq_submatrix.cpp +++ b/cubool/sources/sequential/sq_submatrix.cpp @@ -28,8 +28,8 @@ namespace cubool { void sq_submatrix(const CsrData& a, CsrData& sub, index i, index j, index nrows, index ncols) { - index first = i; - index last = i + nrows; + index first = i; + index last = i + nrows; size_t nvals = 0; for (index ai = first; ai < last; ai++) { @@ -67,4 +67,4 @@ namespace cubool { exclusive_scan(sub.rowOffsets.begin(), sub.rowOffsets.end(), 0); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_submatrix.hpp b/cubool/sources/sequential/sq_submatrix.hpp index d4b6a8e..cd66b4a 100644 --- a/cubool/sources/sequential/sq_submatrix.hpp +++ b/cubool/sources/sequential/sq_submatrix.hpp @@ -41,6 +41,6 @@ namespace cubool { */ void sq_submatrix(const CsrData& a, CsrData& sub, index i, index j, index nrows, index ncols); -} +}// namespace cubool -#endif //CUBOOL_SQ_SUBMATRIX_HPP +#endif//CUBOOL_SQ_SUBMATRIX_HPP diff --git a/cubool/sources/sequential/sq_subvector.cpp b/cubool/sources/sequential/sq_subvector.cpp index 51a4b93..c2f1496 100644 --- a/cubool/sources/sequential/sq_subvector.cpp +++ b/cubool/sources/sequential/sq_subvector.cpp @@ -32,11 +32,11 @@ namespace cubool { } index first = i; - index last = i + nrows; + index last = i + nrows; size_t size = 0; - for (auto v: a.indices) { + for (auto v : a.indices) { if (first <= v && v < last) { size += 1; } @@ -46,11 +46,11 @@ namespace cubool { out.indices.reserve(size); out.nvals = size; - for (auto v: a.indices) { + for (auto v : a.indices) { if (first <= v && v < last) { out.indices.push_back(v - i); } } } -} +}// namespace cubool diff --git a/cubool/sources/sequential/sq_subvector.hpp b/cubool/sources/sequential/sq_subvector.hpp index 9882416..768a3c0 100644 --- a/cubool/sources/sequential/sq_subvector.hpp +++ b/cubool/sources/sequential/sq_subvector.hpp @@ -39,6 +39,6 @@ namespace cubool { */ void sq_subvector(const VecData& a, index i, index nrows, VecData& out); -} +}// namespace cubool -#endif //CUBOOL_SQ_SUBVECTOR_HPP +#endif//CUBOOL_SQ_SUBVECTOR_HPP diff --git a/cubool/sources/sequential/sq_transpose.cpp b/cubool/sources/sequential/sq_transpose.cpp index 1c2540b..75ad13e 100644 --- a/cubool/sources/sequential/sq_transpose.cpp +++ b/cubool/sources/sequential/sq_transpose.cpp @@ -55,4 +55,4 @@ namespace cubool { exclusive_scan(at.rowOffsets.begin(), at.rowOffsets.end(), 0); } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_transpose.hpp b/cubool/sources/sequential/sq_transpose.hpp index bcfee2a..1a05220 100644 --- a/cubool/sources/sequential/sq_transpose.hpp +++ b/cubool/sources/sequential/sq_transpose.hpp @@ -36,6 +36,6 @@ namespace cubool { */ void sq_transpose(const CsrData& a, CsrData& at); -} +}// namespace cubool -#endif //CUBOOL_SQ_TRANSPOSE_HPP +#endif//CUBOOL_SQ_TRANSPOSE_HPP diff --git a/cubool/sources/sequential/sq_vector.cpp b/cubool/sources/sequential/sq_vector.cpp index 4af67e8..2f54a64 100644 --- a/cubool/sources/sequential/sq_vector.cpp +++ b/cubool/sources/sequential/sq_vector.cpp @@ -22,17 +22,17 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include -#include -#include +#include +#include +#include #include #include -#include +#include +#include #include +#include +#include #include -#include -#include -#include namespace cubool { @@ -46,14 +46,14 @@ namespace cubool { RAISE_ERROR(NotImplemented, "This function is not implemented"); } - void SqVector::build(const index *rows, size_t nvals, bool isSorted, bool noDuplicates) { + void SqVector::build(const index* rows, size_t nvals, bool isSorted, bool noDuplicates) { // Utility used to reduce duplicates and sort values if needed DataUtils::buildVectorFromData(mData.nrows, rows, nvals, mData.indices, isSorted, noDuplicates); mData.nvals = mData.indices.size(); } - void SqVector::extract(index *rows, size_t &nvals) { + void SqVector::extract(index* rows, size_t& nvals) { assert(nvals >= getNvals()); nvals = mData.nvals; @@ -62,7 +62,7 @@ namespace cubool { } } - void SqVector::extractSubVector(const VectorBase &otherBase, index i, index nrows, bool checkTime) { + void SqVector::extractSubVector(const VectorBase& otherBase, index i, index nrows, bool checkTime) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Provided vector does not belongs to sequential vector class"); @@ -72,7 +72,7 @@ namespace cubool { sq_subvector(other->mData, i, nrows, this->mData); } - void SqVector::extractRow(const class MatrixBase &matrixBase, index i) { + void SqVector::extractRow(const class MatrixBase& matrixBase, index i) { auto matrix = dynamic_cast(&matrixBase); CHECK_RAISE_ERROR(matrix != nullptr, InvalidArgument, "Provided matrix does not belongs to sequential matrix class"); @@ -83,7 +83,7 @@ namespace cubool { auto& m = matrix->mData; auto begin = m.rowOffsets[i]; - auto end = m.rowOffsets[i + 1]; + auto end = m.rowOffsets[i + 1]; VecData r; r.nrows = m.ncols; @@ -95,7 +95,7 @@ namespace cubool { mData = std::move(r); } - void SqVector::extractCol(const class MatrixBase &matrixBase, index j) { + void SqVector::extractCol(const class MatrixBase& matrixBase, index j) { auto matrix = dynamic_cast(&matrixBase); CHECK_RAISE_ERROR(matrix != nullptr, InvalidArgument, "Provided matrix does not belongs to sequential matrix class"); @@ -110,10 +110,10 @@ namespace cubool { for (index i = 0; i < m.nrows; i++) { auto beginOffset = m.rowOffsets[i]; - auto endOffset = m.rowOffsets[i + 1]; + auto endOffset = m.rowOffsets[i + 1]; auto begin = m.colIndices.begin() + beginOffset; - auto end = m.colIndices.begin() + endOffset; + auto end = m.colIndices.begin() + endOffset; auto res = std::lower_bound(begin, end, j); @@ -126,7 +126,7 @@ namespace cubool { mData = std::move(r); } - void SqVector::clone(const VectorBase &otherBase) { + void SqVector::clone(const VectorBase& otherBase) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Provided vector does not belongs to sequential vector class"); @@ -137,11 +137,11 @@ namespace cubool { mData = other->mData; } - void SqVector::reduce(index &result, bool checkTime) { + void SqVector::reduce(index& result, bool checkTime) { result = getNvals(); } - void SqVector::reduceMatrix(const MatrixBase &otherBase, bool transpose, bool checkTime) { + void SqVector::reduceMatrix(const MatrixBase& otherBase, bool transpose, bool checkTime) { auto other = dynamic_cast(&otherBase); CHECK_RAISE_ERROR(other != nullptr, InvalidArgument, "Provided matrix does not belongs to sequential matrix class"); @@ -164,7 +164,7 @@ namespace cubool { mData = std::move(out); } - void SqVector::eWiseMult(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) { + void SqVector::eWiseMult(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -182,7 +182,7 @@ namespace cubool { mData = std::move(out); } - void SqVector::eWiseAdd(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) { + void SqVector::eWiseAdd(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) { auto a = dynamic_cast(&aBase); auto b = dynamic_cast(&bBase); @@ -200,7 +200,7 @@ namespace cubool { mData = std::move(out); } - void SqVector::multiplyVxM(const VectorBase &vBase, const class MatrixBase &mBase, bool checkTime) { + void SqVector::multiplyVxM(const VectorBase& vBase, const class MatrixBase& mBase, bool checkTime) { auto v = dynamic_cast(&vBase); auto m = dynamic_cast(&mBase); @@ -218,7 +218,7 @@ namespace cubool { mData = std::move(out); } - void SqVector::multiplyMxV(const class MatrixBase &mBase, const VectorBase &vBase, bool checkTime) { + void SqVector::multiplyMxV(const class MatrixBase& mBase, const VectorBase& vBase, bool checkTime) { auto v = dynamic_cast(&vBase); auto m = dynamic_cast(&mBase); @@ -244,4 +244,4 @@ namespace cubool { return mData.nvals; } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/sequential/sq_vector.hpp b/cubool/sources/sequential/sq_vector.hpp index 8f9c5e9..8cad495 100644 --- a/cubool/sources/sequential/sq_vector.hpp +++ b/cubool/sources/sequential/sq_vector.hpp @@ -30,24 +30,24 @@ namespace cubool { - class SqVector final: public VectorBase { + class SqVector final : public VectorBase { public: explicit SqVector(size_t nrows); ~SqVector() override = default; void setElement(index i) override; - void build(const index *rows, size_t nvals, bool isSorted, bool noDuplicates) override; - void extract(index *rows, size_t &nvals) override; - void extractSubVector(const VectorBase &otherBase, index i, index nrows, bool checkTime) override; + void build(const index* rows, size_t nvals, bool isSorted, bool noDuplicates) override; + void extract(index* rows, size_t& nvals) override; + void extractSubVector(const VectorBase& otherBase, index i, index nrows, bool checkTime) override; void extractRow(const class MatrixBase& matrixBase, index i) override; void extractCol(const class MatrixBase& matrixBase, index j) override; - void clone(const VectorBase &otherBase) override; - void reduce(index &result, bool checkTime) override; - void reduceMatrix(const class MatrixBase &matrix, bool transpose, bool checkTime) override; + void clone(const VectorBase& otherBase) override; + void reduce(index& result, bool checkTime) override; + void reduceMatrix(const class MatrixBase& matrix, bool transpose, bool checkTime) override; - void eWiseMult(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) override; - void eWiseAdd(const VectorBase &aBase, const VectorBase &bBase, bool checkTime) override; + void eWiseMult(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) override; + void eWiseAdd(const VectorBase& aBase, const VectorBase& bBase, bool checkTime) override; void multiplyVxM(const VectorBase& vBase, const class MatrixBase& mBase, bool checkTime) override; void multiplyMxV(const class MatrixBase& mBase, const VectorBase& vBase, bool checkTime) override; @@ -55,10 +55,9 @@ namespace cubool { index getNvals() const override; private: - mutable VecData mData; }; -} +}// namespace cubool -#endif //CUBOOL_SQ_VECTOR_HPP +#endif//CUBOOL_SQ_VECTOR_HPP diff --git a/cubool/sources/utils/algo_utils.hpp b/cubool/sources/utils/algo_utils.hpp index ceb7aed..5977867 100644 --- a/cubool/sources/utils/algo_utils.hpp +++ b/cubool/sources/utils/algo_utils.hpp @@ -27,17 +27,17 @@ namespace cubool { - template + template void exclusive_scan(FirstT firstT, LastT lastT, T initial) { T sum = initial; while (firstT != lastT) { - T next = sum + *firstT; + T next = sum + *firstT; *firstT = sum; - sum = next; + sum = next; firstT++; } } -} +}// namespace cubool -#endif //CUBOOL_ALGO_UTILS_HPP +#endif//CUBOOL_ALGO_UTILS_HPP diff --git a/cubool/sources/utils/data_utils.cpp b/cubool/sources/utils/data_utils.cpp index fab1ffa..46a6c8d 100644 --- a/cubool/sources/utils/data_utils.cpp +++ b/cubool/sources/utils/data_utils.cpp @@ -22,17 +22,17 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include -#include -#include #include #include +#include +#include +#include namespace cubool { void DataUtils::buildFromData(size_t nrows, size_t ncols, - const index *rows, const index *cols, size_t nvals, - std::vector &rowOffsets, std::vector &colIndices, + const index* rows, const index* cols, size_t nvals, + std::vector& rowOffsets, std::vector& colIndices, bool isSorted, bool noDuplicates) { rowOffsets.resize(nrows + 1, 0); @@ -70,7 +70,7 @@ namespace cubool { if (!isSorted) { for (size_t i = 0; i < nrows; i++) { auto begin = rowOffsets[i]; - auto end = rowOffsets[i + 1]; + auto end = rowOffsets[i + 1]; // Sort col values within row std::sort(colIndices.begin() + begin, colIndices.begin() + end, [](const index& a, const index& b) { @@ -122,8 +122,8 @@ namespace cubool { } void DataUtils::extractData(size_t nrows, size_t ncols, - index *rows, index *cols, size_t nvals, - const std::vector &rowOffsets, const std::vector &colIndices) { + index* rows, index* cols, size_t nvals, + const std::vector& rowOffsets, const std::vector& colIndices) { assert(rows); assert(cols); @@ -137,15 +137,15 @@ namespace cubool { } } - bool checkBounds(const std::vector &values, index left, index right) { - for (auto v: values) { + bool checkBounds(const std::vector& values, index left, index right) { + for (auto v : values) { CHECK_RAISE_ERROR(left <= v && v < right, InvalidArgument, "Index out of vector bounds"); } return true; } - void DataUtils::buildVectorFromData(size_t nrows, const index *rows, size_t nvals, std::vector &values, + void DataUtils::buildVectorFromData(size_t nrows, const index* rows, size_t nvals, std::vector& values, bool isSorted, bool noDuplicates) { values.resize(nvals); std::copy(rows, rows + nvals, values.begin()); @@ -165,7 +165,7 @@ namespace cubool { if (!noDuplicates) { size_t unique = 0; - index prev = std::numeric_limits::max(); + index prev = std::numeric_limits::max(); for (auto value : values) { if (prev != value) { @@ -191,4 +191,4 @@ namespace cubool { } } -} \ No newline at end of file +}// namespace cubool \ No newline at end of file diff --git a/cubool/sources/utils/data_utils.hpp b/cubool/sources/utils/data_utils.hpp index b7863b3..ccf76fb 100644 --- a/cubool/sources/utils/data_utils.hpp +++ b/cubool/sources/utils/data_utils.hpp @@ -26,8 +26,8 @@ #define CUBOOL_DATA_UTILS_HPP #include -#include #include +#include namespace cubool { @@ -47,6 +47,6 @@ namespace cubool { bool isSorted, bool noDuplicates); }; -} +}// namespace cubool -#endif //CUBOOL_DATA_UTILS_HPP +#endif//CUBOOL_DATA_UTILS_HPP diff --git a/cubool/sources/utils/timer.hpp b/cubool/sources/utils/timer.hpp index e9c8032..90ad673 100644 --- a/cubool/sources/utils/timer.hpp +++ b/cubool/sources/utils/timer.hpp @@ -50,12 +50,12 @@ namespace cubool { } private: - using clock = std::chrono::high_resolution_clock; + using clock = std::chrono::high_resolution_clock; using timepoint = clock::time_point; timepoint mStart; timepoint mEnd; }; -} +}// namespace cubool -#endif //CUBOOL_TIMER_HPP +#endif//CUBOOL_TIMER_HPP diff --git a/cubool/tests/test_library_api.cpp b/cubool/tests/test_library_api.cpp index 084abe3..0701d19 100644 --- a/cubool/tests/test_library_api.cpp +++ b/cubool/tests/test_library_api.cpp @@ -60,16 +60,16 @@ TEST(cuBool, Setup) { * @return Status on this operation */ cuBool_Status TransitiveClosure(cuBool_Matrix A, cuBool_Matrix* T) { - cuBool_Matrix_Duplicate(A, T); /* Duplicate A to result T */ + cuBool_Matrix_Duplicate(A, T); /* Duplicate A to result T */ cuBool_Index total = 0; cuBool_Index current; - cuBool_Matrix_Nvals(*T, ¤t); /* Query current nvals value */ + cuBool_Matrix_Nvals(*T, ¤t); /* Query current nvals value */ - while (current != total) { /* Iterate, while new values are added */ + while (current != total) { /* Iterate, while new values are added */ total = current; - cuBool_MxM(*T, *T, *T, CUBOOL_HINT_ACCUMULATE); /* T += T x T */ + cuBool_MxM(*T, *T, *T, CUBOOL_HINT_ACCUMULATE); /* T += T x T */ cuBool_Matrix_Nvals(*T, ¤t); } @@ -85,22 +85,21 @@ TEST(cuBool, TsExample) { cuBool_Initialize(CUBOOL_HINT_NO); cuBool_Matrix_New(&A, n, n); - testing::Matrix ta = testing::Matrix::generateSparse(n , n, 0.2); + testing::Matrix ta = testing::Matrix::generateSparse(n, n, 0.2); cuBool_Matrix_Build(A, ta.rowsIndex.data(), ta.colsIndex.data(), ta.nvals, CUBOOL_HINT_VALUES_SORTED); TransitiveClosure(A, &T); testing::Matrix tr = ta; - size_t total; + size_t total; do { total = tr.nvals; testing::MatrixMultiplyFunctor functor; tr = std::move(functor(tr, tr, tr, true)); - } - while (tr.nvals != total); + } while (tr.nvals != total); ASSERT_TRUE(tr.areEqual(T)); @@ -128,10 +127,10 @@ TEST(cuBool, DeviceCaps) { ASSERT_EQ(cuBool_GetDeviceCaps(&caps), CUBOOL_STATUS_SUCCESS); std::cout - << "name: " << caps.name << std::endl - << "major: " << caps.major << std::endl - << "minor: " << caps.minor << std::endl - << "cuda supported: " << caps.cudaSupported << std::endl; + << "name: " << caps.name << std::endl + << "major: " << caps.major << std::endl + << "minor: " << caps.minor << std::endl + << "cuda supported: " << caps.cudaSupported << std::endl; ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); } diff --git a/cubool/tests/test_matrix_element.cpp b/cubool/tests/test_matrix_element.cpp index e383b69..e9c3d92 100644 --- a/cubool/tests/test_matrix_element.cpp +++ b/cubool/tests/test_matrix_element.cpp @@ -30,18 +30,18 @@ void testMatrixSetElement(cuBool_Index m, cuBool_Index n, float density) { testing::Matrix tmatrix = std::move(testing::Matrix::generateSparse(m, n, density)); - auto I = tmatrix.rowsIndex; - auto J = tmatrix.colsIndex; + auto I = tmatrix.rowsIndex; + auto J = tmatrix.colsIndex; size_t nvals = tmatrix.nvals; - size_t dups = nvals * 0.10; + size_t dups = nvals * 0.10; std::default_random_engine engine(std::chrono::system_clock::now().time_since_epoch().count()); - auto dist = std::uniform_real_distribution(0.0, 1.0); + auto dist = std::uniform_real_distribution(0.0, 1.0); if (nvals > 0) { for (size_t k = 0; k < dups; k++) { size_t id = std::min(dist(engine) * nvals, nvals - 1); - auto i = I[id], j = J[id]; + auto i = I[id], j = J[id]; I.push_back(i); J.push_back(j); } @@ -71,16 +71,16 @@ void testMatrixAppendElement(cuBool_Index m, cuBool_Index n, float density) { std::vector I; std::vector J; - size_t nvals = tmatrix.nvals; - size_t dups = nvals * 0.20; + size_t nvals = tmatrix.nvals; + size_t dups = nvals * 0.20; std::default_random_engine engine(std::chrono::system_clock::now().time_since_epoch().count()); - auto dist = std::uniform_real_distribution(0.0, 1.0); + auto dist = std::uniform_real_distribution(0.0, 1.0); if (nvals > 0) { for (size_t k = 0; k < dups; k++) { size_t id = std::min(dist(engine) * nvals, nvals - 1); - auto i = tmatrix.rowsIndex[id], j = tmatrix.colsIndex[id]; + auto i = tmatrix.rowsIndex[id], j = tmatrix.colsIndex[id]; I.push_back(i); J.push_back(j); } @@ -99,7 +99,7 @@ void testMatrixAppendElement(cuBool_Index m, cuBool_Index n, float density) { } void testMatrixPostAppendElement(cuBool_Index m, cuBool_Index n, float density) { - cuBool_Matrix matrix = nullptr; + cuBool_Matrix matrix = nullptr; cuBool_Matrix duplicated = nullptr; testing::Matrix tmatrix = std::move(testing::Matrix::generateSparse(m, n, density)); diff --git a/cubool/tests/test_matrix_ewiseadd.cpp b/cubool/tests/test_matrix_ewiseadd.cpp index 1fd9ca7..9bbca0b 100644 --- a/cubool/tests/test_matrix_ewiseadd.cpp +++ b/cubool/tests/test_matrix_ewiseadd.cpp @@ -44,7 +44,7 @@ void testMatrixAdd(cuBool_Index m, cuBool_Index n, float density, cuBool_Hints f // Evaluate naive r += a on the cpu to compare results testing::MatrixEWiseAddFunctor functor; - auto tr = std::move(functor(ta, tb)); + auto tr = std::move(functor(ta, tb)); // Compare results ASSERT_EQ(tr.areEqual(r), true); diff --git a/cubool/tests/test_matrix_ewisemult.cpp b/cubool/tests/test_matrix_ewisemult.cpp index a556d8e..a1479f2 100644 --- a/cubool/tests/test_matrix_ewisemult.cpp +++ b/cubool/tests/test_matrix_ewisemult.cpp @@ -44,7 +44,7 @@ void testMatrixMult(cuBool_Index m, cuBool_Index n, float density, cuBool_Hints // Evaluate naive r += a on the cpu to compare results testing::MatrixEWiseMultFunctor functor; - auto tr = std::move(functor(ta, tb)); + auto tr = std::move(functor(ta, tb)); // Compare results ASSERT_EQ(tr.areEqual(r), true); diff --git a/cubool/tests/test_matrix_ewisemult_inverted.cpp b/cubool/tests/test_matrix_ewisemult_inverted.cpp index 250ba55..f29430b 100644 --- a/cubool/tests/test_matrix_ewisemult_inverted.cpp +++ b/cubool/tests/test_matrix_ewisemult_inverted.cpp @@ -1,19 +1,19 @@ #include "cubool/cubool.h" -#include #include +#include using DataMatrix = std::vector>; -void testApplyNotMask(const DataMatrix &matrix_data, const DataMatrix &mask_data) { +void testApplyNotMask(const DataMatrix& matrix_data, const DataMatrix& mask_data) { cuBool_Index nrows, ncols; - nrows = matrix_data.size(); - ncols = matrix_data[0].size(); + nrows = matrix_data.size(); + ncols = matrix_data[0].size(); testing::Matrix test_matrix = testing::Matrix::generatet(nrows, ncols, - [&matrix_data](cuBool_Index i, cuBool_Index j) { return matrix_data[i][j]; }); - nrows = mask_data.size(); - ncols = mask_data[0].size(); - testing::Matrix test_mask = testing::Matrix::generatet(nrows, ncols, - [&mask_data](cuBool_Index i, cuBool_Index j) { return mask_data[i][j]; }); + [&matrix_data](cuBool_Index i, cuBool_Index j) { return matrix_data[i][j]; }); + nrows = mask_data.size(); + ncols = mask_data[0].size(); + testing::Matrix test_mask = testing::Matrix::generatet(nrows, ncols, + [&mask_data](cuBool_Index i, cuBool_Index j) { return mask_data[i][j]; }); cuBool_Matrix matrix, mask, result; ASSERT_EQ(cuBool_Matrix_New(&matrix, test_matrix.nrows, test_matrix.ncols), CUBOOL_STATUS_SUCCESS); @@ -21,9 +21,11 @@ void testApplyNotMask(const DataMatrix &matrix_data, const DataMatrix &mask_data ASSERT_EQ(cuBool_Matrix_New(&result, test_matrix.nrows, test_matrix.ncols), CUBOOL_STATUS_SUCCESS); ASSERT_EQ(cuBool_Matrix_Build(matrix, test_matrix.rowsIndex.data(), test_matrix.colsIndex.data(), test_matrix.nvals, - CUBOOL_HINT_VALUES_SORTED & CUBOOL_HINT_NO_DUPLICATES), CUBOOL_STATUS_SUCCESS); + CUBOOL_HINT_VALUES_SORTED & CUBOOL_HINT_NO_DUPLICATES), + CUBOOL_STATUS_SUCCESS); ASSERT_EQ(cuBool_Matrix_Build(mask, test_mask.rowsIndex.data(), test_mask.colsIndex.data(), test_mask.nvals, - CUBOOL_HINT_VALUES_SORTED & CUBOOL_HINT_NO_DUPLICATES), CUBOOL_STATUS_SUCCESS); + CUBOOL_HINT_VALUES_SORTED & CUBOOL_HINT_NO_DUPLICATES), + CUBOOL_STATUS_SUCCESS); cuBool_Matrix_EWiseMulInverted(result, matrix, mask, CUBOOL_HINT_NO); @@ -38,8 +40,8 @@ void testApplyNotMask(const DataMatrix &matrix_data, const DataMatrix &mask_data cuBool_Matrix_Free(result); auto mask_data_inverted = mask_data; - for (auto &row : mask_data_inverted) { - for (int &value : row) { + for (auto& row : mask_data_inverted) { + for (int& value : row) { value = !value; } } @@ -54,22 +56,21 @@ void testApplyNotMask(const DataMatrix &matrix_data, const DataMatrix &mask_data ASSERT_EQ(matrix_data[i][j] * mask_data_inverted[i][j], result_data[i][j]); } } - } TEST(cuBool_Matrix, ApplyMatrix) { ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); - DataMatrix matrix { - {1, 0, 0}, - {0, 0, 0}, - {0, 1, 0}, + DataMatrix matrix{ + {1, 0, 0}, + {0, 0, 0}, + {0, 1, 0}, }; - DataMatrix mask { - {0, 1, 1}, - {1, 0, 1}, - {0, 1, 1}, + DataMatrix mask{ + {0, 1, 1}, + {1, 0, 1}, + {0, 1, 1}, }; // iverted is // 1 0 0 @@ -95,7 +96,7 @@ TEST(cuBool_Matrix, ApplyMatrixRandom) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { matrix[i][j] = rand() & 1; - mask[i][j] = rand() & 1; + mask[i][j] = rand() & 1; } } diff --git a/cubool/tests/test_matrix_extract_vector.cpp b/cubool/tests/test_matrix_extract_vector.cpp index c7686d6..1c4891e 100644 --- a/cubool/tests/test_matrix_extract_vector.cpp +++ b/cubool/tests/test_matrix_extract_vector.cpp @@ -50,7 +50,7 @@ void testMatrixExtractRow(cuBool_Index m, cuBool_Index n, float density, cuBool_ void testMatrixExtractCol(cuBool_Index m, cuBool_Index n, float density, cuBool_Hints flags) { cuBool_Matrix a; - auto ta = testing::Matrix::generateSparse(m, n, density); + auto ta = testing::Matrix::generateSparse(m, n, density); auto taT = ta.transpose(); ASSERT_EQ(cuBool_Matrix_New(&a, m, n), CUBOOL_STATUS_SUCCESS); diff --git a/cubool/tests/test_matrix_kronecker.cpp b/cubool/tests/test_matrix_kronecker.cpp index 7ec41cd..974b000 100644 --- a/cubool/tests/test_matrix_kronecker.cpp +++ b/cubool/tests/test_matrix_kronecker.cpp @@ -44,7 +44,7 @@ void testMatrixKronecker(cuBool_Index m, cuBool_Index n, cuBool_Index k, cuBool_ // Evaluate naive r = a `kron` b on the cpu to compare results testing::MatrixKroneckerFunctor functor; - testing::Matrix tr = std::move(functor(ta, tb)); + testing::Matrix tr = std::move(functor(ta, tb)); // Compare results EXPECT_EQ(tr.areEqual(r), true); @@ -70,63 +70,63 @@ void testRun(cuBool_Index m, cuBool_Index n, cuBool_Index k, cuBool_Index t, flo TEST(cuBool_Matrix, KroneckerSmall) { cuBool_Index m = 10, n = 20; cuBool_Index k = 5, t = 15; - float step = 0.05f; + float step = 0.05f; testRun(m, n, k, t, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, KroneckerMedium) { cuBool_Index m = 100, n = 40; cuBool_Index k = 30, t = 80; - float step = 0.02f; + float step = 0.02f; testRun(m, n, k, t, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, KroneckerLarge) { cuBool_Index m = 1000, n = 400; cuBool_Index k = 300, t = 800; - float step = 0.001f; + float step = 0.001f; testRun(m, n, k, t, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, KroneckerSmallFallback) { cuBool_Index m = 10, n = 20; cuBool_Index k = 5, t = 15; - float step = 0.05f; + float step = 0.05f; testRun(m, n, k, t, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, KroneckerMediumFallback) { cuBool_Index m = 100, n = 40; cuBool_Index k = 30, t = 80; - float step = 0.02f; + float step = 0.02f; testRun(m, n, k, t, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, KroneckerLargeFallback) { cuBool_Index m = 1000, n = 400; cuBool_Index k = 300, t = 800; - float step = 0.001f; + float step = 0.001f; testRun(m, n, k, t, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, KroneckerSmallManaged) { cuBool_Index m = 10, n = 20; cuBool_Index k = 5, t = 15; - float step = 0.05f; + float step = 0.05f; testRun(m, n, k, t, step, CUBOOL_HINT_GPU_MEM_MANAGED); } TEST(cuBool_Matrix, KroneckerMediumManaged) { cuBool_Index m = 100, n = 40; cuBool_Index k = 30, t = 80; - float step = 0.02f; + float step = 0.02f; testRun(m, n, k, t, step, CUBOOL_HINT_GPU_MEM_MANAGED); } TEST(cuBool_Matrix, KroneckerLargeManaged) { cuBool_Index m = 1000, n = 400; cuBool_Index k = 300, t = 800; - float step = 0.001f; + float step = 0.001f; testRun(m, n, k, t, step, CUBOOL_HINT_GPU_MEM_MANAGED); } diff --git a/cubool/tests/test_matrix_misc.cpp b/cubool/tests/test_matrix_misc.cpp index cc12f24..a7c3e94 100644 --- a/cubool/tests/test_matrix_misc.cpp +++ b/cubool/tests/test_matrix_misc.cpp @@ -22,13 +22,13 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include #include +#include TEST(cuBool_Matrix, Duplicate) { cuBool_Matrix matrix = nullptr, duplicated = nullptr; - cuBool_Index m = 900, n = 600; - float density = 0.31; + cuBool_Index m = 900, n = 600; + float density = 0.31; testing::Matrix tmatrix = std::move(testing::Matrix::generateSparse(m, n, density)); @@ -49,8 +49,8 @@ TEST(cuBool_Matrix, Duplicate) { TEST(cuBool_Matrix, PropertyQuery) { cuBool_Matrix matrix = nullptr; - cuBool_Index m = 900, n = 600; - float density = 0.21; + cuBool_Index m = 900, n = 600; + float density = 0.21; testing::Matrix tmatrix = std::move(testing::Matrix::generateSparse(m, n, density)); @@ -78,8 +78,8 @@ TEST(cuBool_Matrix, PropertyQuery) { TEST(cuBool_Matrix, ExtractPairs) { cuBool_Matrix matrix = nullptr; - cuBool_Index m = 900, n = 600; - float density = 0.21; + cuBool_Index m = 900, n = 600; + float density = 0.21; testing::Matrix tmatrix = std::move(testing::Matrix::generateSparse(m, n, density)); @@ -88,7 +88,7 @@ TEST(cuBool_Matrix, ExtractPairs) { ASSERT_EQ(cuBool_Matrix_New(&matrix, m, n), CUBOOL_STATUS_SUCCESS); ASSERT_EQ(cuBool_Matrix_Build(matrix, tmatrix.rowsIndex.data(), tmatrix.colsIndex.data(), tmatrix.nvals, CUBOOL_HINT_VALUES_SORTED), CUBOOL_STATUS_SUCCESS); - cuBool_Index nvals = tmatrix.nvals; + cuBool_Index nvals = tmatrix.nvals; std::vector rows(tmatrix.nvals); std::vector cols(tmatrix.nvals); @@ -101,14 +101,14 @@ TEST(cuBool_Matrix, ExtractPairs) { TEST(cuBool_Matrix, Marker) { cuBool_Matrix matrix = nullptr; - cuBool_Index m, n; + cuBool_Index m, n; m = n = 100; const cuBool_Index BUFFER_SIZE = 100; - const char* marker = "Test Matrix Marker"; - cuBool_Index size = 0; - char buffer[BUFFER_SIZE]; + const char* marker = "Test Matrix Marker"; + cuBool_Index size = 0; + char buffer[BUFFER_SIZE]; ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); ASSERT_EQ(cuBool_Matrix_New(&matrix, m, n), CUBOOL_STATUS_SUCCESS); @@ -128,14 +128,14 @@ TEST(cuBool_Matrix, Marker) { TEST(cuBool_Matrix, MarkerShort) { cuBool_Matrix matrix = nullptr; - cuBool_Index m, n; + cuBool_Index m, n; m = n = 100; const cuBool_Index BUFFER_SIZE = 10; - const char* marker = "Test Matrix Marker"; - cuBool_Index size = BUFFER_SIZE; - char buffer[BUFFER_SIZE]; + const char* marker = "Test Matrix Marker"; + cuBool_Index size = BUFFER_SIZE; + char buffer[BUFFER_SIZE]; ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); ASSERT_EQ(cuBool_Matrix_New(&matrix, m, n), CUBOOL_STATUS_SUCCESS); diff --git a/cubool/tests/test_matrix_reduce.cpp b/cubool/tests/test_matrix_reduce.cpp index 4e2e952..63cbb73 100644 --- a/cubool/tests/test_matrix_reduce.cpp +++ b/cubool/tests/test_matrix_reduce.cpp @@ -108,55 +108,55 @@ void testRun(cuBool_Index m, cuBool_Index n, float step, cuBool_Hints setup) { TEST(cuBool_Matrix, ReduceSmall) { cuBool_Index m = 100, n = 200; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, ReduceMedium) { cuBool_Index m = 400, n = 700; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, ReduceLarge) { cuBool_Index m = 2000, n = 4000; - float step = 0.01f; + float step = 0.01f; testRun(m, n, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, ReduceSmallFallback) { cuBool_Index m = 100, n = 200; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, ReduceMediumFallback) { cuBool_Index m = 400, n = 700; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, ReduceLargeFallback) { cuBool_Index m = 2000, n = 4000; - float step = 0.01f; + float step = 0.01f; testRun(m, n, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, ReduceSmallManaged) { cuBool_Index m = 100, n = 200; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_GPU_MEM_MANAGED); } TEST(cuBool_Matrix, ReduceMediumManaged) { cuBool_Index m = 400, n = 700; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_GPU_MEM_MANAGED); } TEST(cuBool_Matrix, ReduceLargeManaged) { cuBool_Index m = 2000, n = 4000; - float step = 0.01f; + float step = 0.01f; testRun(m, n, step, CUBOOL_HINT_GPU_MEM_MANAGED); } diff --git a/cubool/tests/test_matrix_sub_matrix.cpp b/cubool/tests/test_matrix_sub_matrix.cpp index 72bc7d1..e17a5e9 100644 --- a/cubool/tests/test_matrix_sub_matrix.cpp +++ b/cubool/tests/test_matrix_sub_matrix.cpp @@ -66,55 +66,55 @@ void testRun(cuBool_Index m, cuBool_Index n, float step, cuBool_Hints setup) { TEST(cuBool_Matrix, SubMatrixExtractSmall) { cuBool_Index m = 100, n = 200; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, SubMatrixExtractMedium) { cuBool_Index m = 400, n = 700; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, SubMatrixExtractLarge) { cuBool_Index m = 2000, n = 4000; - float step = 0.01f; + float step = 0.01f; testRun(m, n, step, CUBOOL_HINT_NO); } TEST(cuBool_Matrix, SubMatrixExtractSmallFallback) { cuBool_Index m = 100, n = 200; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, SubMatrixExtractMediumFallback) { cuBool_Index m = 400, n = 700; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, SubMatrixExtractLargeFallback) { cuBool_Index m = 2000, n = 4000; - float step = 0.01f; + float step = 0.01f; testRun(m, n, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Matrix, SubMatrixExtractSmallManaged) { cuBool_Index m = 100, n = 200; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_GPU_MEM_MANAGED); } TEST(cuBool_Matrix, SubMatrixExtractMediumManaged) { cuBool_Index m = 400, n = 700; - float step = 0.05f; + float step = 0.05f; testRun(m, n, step, CUBOOL_HINT_GPU_MEM_MANAGED); } TEST(cuBool_Matrix, SubMatrixExtractLargeManaged) { cuBool_Index m = 2000, n = 4000; - float step = 0.01f; + float step = 0.01f; testRun(m, n, step, CUBOOL_HINT_GPU_MEM_MANAGED); } diff --git a/cubool/tests/test_vector_element.cpp b/cubool/tests/test_vector_element.cpp index 7daf3fc..b2f8341 100644 --- a/cubool/tests/test_vector_element.cpp +++ b/cubool/tests/test_vector_element.cpp @@ -30,17 +30,17 @@ void testVectorSetElement(cuBool_Index m, float density) { testing::Vector tvector = testing::Vector::generateSparse(m, density); - auto I = tvector.index; + auto I = tvector.index; size_t nvals = tvector.nvals; - size_t dups = nvals * 0.10; + size_t dups = nvals * 0.10; std::default_random_engine engine(std::chrono::system_clock::now().time_since_epoch().count()); - auto dist = std::uniform_real_distribution(0.0, 1.0); + auto dist = std::uniform_real_distribution(0.0, 1.0); if (nvals > 0) { for (size_t k = 0; k < dups; k++) { size_t id = std::min(dist(engine) * nvals, nvals - 1); - auto i = I[id]; + auto i = I[id]; I.push_back(i); } } @@ -68,16 +68,16 @@ void testVectorAppendElement(cuBool_Index m, float density) { ASSERT_EQ(cuBool_Vector_Build(vector, tvector.index.data(), (cuBool_Index) tvector.nvals, CUBOOL_HINT_VALUES_SORTED | CUBOOL_HINT_NO_DUPLICATES), CUBOOL_STATUS_SUCCESS); std::vector I; - size_t nvals = tvector.nvals; - size_t dups = nvals * 0.20; + size_t nvals = tvector.nvals; + size_t dups = nvals * 0.20; std::default_random_engine engine(std::chrono::system_clock::now().time_since_epoch().count()); - auto dist = std::uniform_real_distribution(0.0, 1.0); + auto dist = std::uniform_real_distribution(0.0, 1.0); if (nvals > 0) { for (size_t k = 0; k < dups; k++) { size_t id = std::min(dist(engine) * nvals, nvals - 1); - auto i = tvector.index[id]; + auto i = tvector.index[id]; I.push_back(i); } } @@ -95,7 +95,7 @@ void testVectorAppendElement(cuBool_Index m, float density) { } void testVectorPostAppendElement(cuBool_Index m, float density) { - cuBool_Vector vector = nullptr; + cuBool_Vector vector = nullptr; cuBool_Vector duplicated = nullptr; testing::Vector tvector = std::move(testing::Vector::generateSparse(m, density)); diff --git a/cubool/tests/test_vector_ewiseadd.cpp b/cubool/tests/test_vector_ewiseadd.cpp index dc671ff..10d0b98 100644 --- a/cubool/tests/test_vector_ewiseadd.cpp +++ b/cubool/tests/test_vector_ewiseadd.cpp @@ -44,7 +44,7 @@ void testVectorAdd(cuBool_Index m, float density, cuBool_Hints flags) { // Evaluate naive r += a on the cpu to compare results testing::VectorEWiseAddFunctor functor; - auto tr = std::move(functor(ta, tb)); + auto tr = std::move(functor(ta, tb)); // Compare results ASSERT_EQ(tr.areEqual(r), true); diff --git a/cubool/tests/test_vector_ewisemult.cpp b/cubool/tests/test_vector_ewisemult.cpp index 2cc7b90..fae1cca 100644 --- a/cubool/tests/test_vector_ewisemult.cpp +++ b/cubool/tests/test_vector_ewisemult.cpp @@ -44,7 +44,7 @@ void testVectorMult(cuBool_Index m, float density, cuBool_Hints flags) { // Evaluate naive r += a on the cpu to compare results testing::VectorEWiseMultFunctor functor; - auto tr = std::move(functor(ta, tb)); + auto tr = std::move(functor(ta, tb)); // Compare results ASSERT_EQ(tr.areEqual(r), true); diff --git a/cubool/tests/test_vector_misc.cpp b/cubool/tests/test_vector_misc.cpp index 5c32723..90a7c2a 100644 --- a/cubool/tests/test_vector_misc.cpp +++ b/cubool/tests/test_vector_misc.cpp @@ -22,13 +22,13 @@ /* SOFTWARE. */ /**********************************************************************************/ -#include #include +#include TEST(cuBool_Vector, Duplicate) { cuBool_Vector vector = nullptr, duplicated = nullptr; - cuBool_Index m = 900; - float density = 0.31; + cuBool_Index m = 900; + float density = 0.31; testing::Vector tvector = testing::Vector::generateSparse(m, density); @@ -48,9 +48,9 @@ TEST(cuBool_Vector, Duplicate) { } TEST(cuBool_Vector, PropertyQuery) { - cuBool_Vector vector = nullptr; - cuBool_Index m = 900; - float density = 0.21; + cuBool_Vector vector = nullptr; + cuBool_Index m = 900; + float density = 0.21; testing::Vector tvector = std::move(testing::Vector::generateSparse(m, density)); @@ -74,9 +74,9 @@ TEST(cuBool_Vector, PropertyQuery) { } TEST(cuBool_Vector, ExtractValues) { - cuBool_Vector vector = nullptr; - cuBool_Index m = 900; - float density = 0.21; + cuBool_Vector vector = nullptr; + cuBool_Index m = 900; + float density = 0.21; testing::Vector tvector = std::move(testing::Vector::generateSparse(m, density)); @@ -85,7 +85,7 @@ TEST(cuBool_Vector, ExtractValues) { ASSERT_EQ(cuBool_Vector_New(&vector, m), CUBOOL_STATUS_SUCCESS); ASSERT_EQ(cuBool_Vector_Build(vector, tvector.index.data(), tvector.nvals, CUBOOL_HINT_VALUES_SORTED), CUBOOL_STATUS_SUCCESS); - cuBool_Index nvals = tvector.nvals; + cuBool_Index nvals = tvector.nvals; std::vector rows(tvector.nvals); ASSERT_EQ(cuBool_Vector_ExtractValues(vector, rows.data(), &nvals), CUBOOL_STATUS_SUCCESS); @@ -98,14 +98,14 @@ TEST(cuBool_Vector, ExtractValues) { TEST(cuBool_Vector, Marker) { cuBool_Vector vector = nullptr; - cuBool_Index m; + cuBool_Index m; m = 100; const cuBool_Index BUFFER_SIZE = 100; - const char* marker = "Test Vector Marker"; - cuBool_Index size = 0; - char buffer[BUFFER_SIZE]; + const char* marker = "Test Vector Marker"; + cuBool_Index size = 0; + char buffer[BUFFER_SIZE]; ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); ASSERT_EQ(cuBool_Vector_New(&vector, m), CUBOOL_STATUS_SUCCESS); @@ -131,14 +131,14 @@ TEST(cuBool_Vector, Marker) { TEST(cuBool_Vector, MarkerShort) { cuBool_Vector vector = nullptr; - cuBool_Index m; + cuBool_Index m; m = 100; const cuBool_Index BUFFER_SIZE = 10; - const char* marker = "Test Vector Marker"; - cuBool_Index size = BUFFER_SIZE; - char buffer[BUFFER_SIZE]; + const char* marker = "Test Vector Marker"; + cuBool_Index size = BUFFER_SIZE; + char buffer[BUFFER_SIZE]; ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); ASSERT_EQ(cuBool_Vector_New(&vector, m), CUBOOL_STATUS_SUCCESS); diff --git a/cubool/tests/test_vector_mxv.cpp b/cubool/tests/test_vector_mxv.cpp index 6386cb2..5c5852f 100644 --- a/cubool/tests/test_vector_mxv.cpp +++ b/cubool/tests/test_vector_mxv.cpp @@ -43,7 +43,7 @@ void testMatrixVectorMultiplyAdd(cuBool_Index m, cuBool_Index n, float density) // Evaluate naive on the cpu to compare results testing::MatrixVectorMultiplyFunctor functor; - testing::Vector tr = functor(ta, tv); + testing::Vector tr = functor(ta, tv); // Evaluate r = M x v ASSERT_EQ(cuBool_MxV(r, a, v, CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); diff --git a/cubool/tests/test_vector_sub_vector.cpp b/cubool/tests/test_vector_sub_vector.cpp index a899618..b5982c5 100644 --- a/cubool/tests/test_vector_sub_vector.cpp +++ b/cubool/tests/test_vector_sub_vector.cpp @@ -62,56 +62,56 @@ void testRun(cuBool_Index m, float step, cuBool_Hints setup) { } TEST(cuBool_Vector, SubVectorExtractSmall) { - cuBool_Index m = 10000; - float step = 0.05f; + cuBool_Index m = 10000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_NO); } TEST(cuBool_Vector, SubVectorExtractMedium) { - cuBool_Index m = 50000; - float step = 0.05f; + cuBool_Index m = 50000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_NO); } TEST(cuBool_Vector, SubVectorExtractLarge) { - cuBool_Index m = 100000; - float step = 0.05f; + cuBool_Index m = 100000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_NO); } TEST(cuBool_Vector, SubVectorExtractSmallFallback) { - cuBool_Index m = 10000; - float step = 0.05f; + cuBool_Index m = 10000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Vector, SubVectorExtractMediumFallback) { - cuBool_Index m = 50000; - float step = 0.05f; + cuBool_Index m = 50000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Vector, SubVectorExtractLargeFallback) { - cuBool_Index m = 100000; - float step = 0.05f; + cuBool_Index m = 100000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_CPU_BACKEND); } TEST(cuBool_Vector, SubVectorExtractSmallManaged) { - cuBool_Index m = 10000; - float step = 0.05f; + cuBool_Index m = 10000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_GPU_MEM_MANAGED); } TEST(cuBool_Vector, SubVectorExtractMediumManaged) { - cuBool_Index m = 50000; - float step = 0.05f; + cuBool_Index m = 50000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_GPU_MEM_MANAGED); } TEST(cuBool_Vector, SubVectorExtractLargeManaged) { - cuBool_Index m = 100000; - float step = 0.05f; + cuBool_Index m = 100000; + float step = 0.05f; testRun(m, step, CUBOOL_HINT_GPU_MEM_MANAGED); } diff --git a/cubool/tests/test_vector_vxm.cpp b/cubool/tests/test_vector_vxm.cpp index 76b2489..e81ca49 100644 --- a/cubool/tests/test_vector_vxm.cpp +++ b/cubool/tests/test_vector_vxm.cpp @@ -43,7 +43,7 @@ void testVectorMatrixMultiplyAdd(cuBool_Index m, cuBool_Index n, float density) // Evaluate naive on the cpu to compare results testing::VectorMatrixMultiplyFunctor functor; - testing::Vector tr = functor(tv, ta); + testing::Vector tr = functor(tv, ta); // Evaluate r = v x M ASSERT_EQ(cuBool_VxM(r, v, a, CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); diff --git a/cubool/utils/testing/matrix.hpp b/cubool/utils/testing/matrix.hpp index 1404a30..121827f 100644 --- a/cubool/utils/testing/matrix.hpp +++ b/cubool/utils/testing/matrix.hpp @@ -25,25 +25,25 @@ #ifndef CUBOOL_TESTING_MATRIX_HPP #define CUBOOL_TESTING_MATRIX_HPP +#include +#include +#include #include +#include #include #include -#include -#include -#include -#include namespace testing { struct Matrix { mutable std::vector rowOffsets; - mutable bool hasRowOffsets = false; + mutable bool hasRowOffsets = false; std::vector rowsIndex; std::vector colsIndex; - size_t nvals = 0; - size_t nrows = 0; - size_t ncols = 0; + size_t nvals = 0; + size_t nrows = 0; + size_t ncols = 0; void computeRowOffsets() const { if (!hasRowOffsets) { @@ -54,10 +54,10 @@ namespace testing { } cuBool_Index sum = 0; - for (auto& rowOffset: rowOffsets) { + for (auto& rowOffset : rowOffsets) { cuBool_Index next = sum + rowOffset; - rowOffset = sum; - sum = next; + rowOffset = sum; + sum = next; } hasRowOffsets = true; @@ -83,7 +83,7 @@ namespace testing { std::sort(vals.begin(), vals.end(), PairCmp{}); - for (auto& p: vals) { + for (auto& p : vals) { result.rowsIndex.push_back(p.i); result.colsIndex.push_back(p.j); } @@ -102,7 +102,7 @@ namespace testing { rows[rowsIndex[i]] |= 0x1u; } - for (auto i: rows) { + for (auto i : rows) { result.nvals += i; } @@ -124,7 +124,7 @@ namespace testing { std::vector mask(nrows, 0); - for (auto r: rowsIndex) { + for (auto r : rowsIndex) { mask[r] |= 0x1u; } @@ -237,7 +237,7 @@ namespace testing { auto dist = std::uniform_real_distribution(0.0, 1.0); - std::unordered_set indices; + std::unordered_set indices; for (size_t id = 0; id < valsToGen; id++) { auto pr = dist(engine); @@ -246,8 +246,8 @@ namespace testing { auto r = (cuBool_Index) (pr * (float) nrows); auto c = (cuBool_Index) (pc * (float) ncols); - r = std::min(r, (cuBool_Index)nrows - 1); - c = std::min(c, (cuBool_Index)ncols - 1); + r = std::min(r, (cuBool_Index) nrows - 1); + c = std::min(c, (cuBool_Index) ncols - 1); indices.emplace(Pair{r, c}); } @@ -260,7 +260,7 @@ namespace testing { matrix.rowsIndex.reserve(matrix.nvals); matrix.colsIndex.reserve(matrix.nvals); - for (auto& p: toSort) { + for (auto& p : toSort) { matrix.rowsIndex.push_back(p.i); matrix.colsIndex.push_back(p.j); } @@ -274,9 +274,8 @@ namespace testing { out.ncols = ncols; return out; } - }; - -} -#endif //CUBOOL_TESTING_MATRIX_HPP \ No newline at end of file +}// namespace testing + +#endif//CUBOOL_TESTING_MATRIX_HPP \ No newline at end of file diff --git a/cubool/utils/testing/matrix_ewiseadd.hpp b/cubool/utils/testing/matrix_ewiseadd.hpp index 5bf6947..1565640 100644 --- a/cubool/utils/testing/matrix_ewiseadd.hpp +++ b/cubool/utils/testing/matrix_ewiseadd.hpp @@ -47,13 +47,13 @@ namespace testing { // Count nnz of the result matrix to allocate memory for (cuBool_Index i = 0; i < a.nrows; i++) { - cuBool_Index ak = a.rowOffsets[i]; - cuBool_Index bk = b.rowOffsets[i]; + cuBool_Index ak = a.rowOffsets[i]; + cuBool_Index bk = b.rowOffsets[i]; cuBool_Index asize = a.rowOffsets[i + 1] - ak; cuBool_Index bsize = b.rowOffsets[i + 1] - bk; - const cuBool_Index* ar = &a.colsIndex[ak]; - const cuBool_Index* br = &b.colsIndex[bk]; + const cuBool_Index* ar = &a.colsIndex[ak]; + const cuBool_Index* br = &b.colsIndex[bk]; const cuBool_Index* arend = ar + asize; const cuBool_Index* brend = br + bsize; @@ -64,19 +64,17 @@ namespace testing { nvalsInRow++; ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { nvalsInRow++; ar++; - } - else { + } else { nvalsInRow++; br++; } } - nvalsInRow += (size_t)(arend - ar); - nvalsInRow += (size_t)(brend - br); + nvalsInRow += (size_t) (arend - ar); + nvalsInRow += (size_t) (brend - br); nvals += nvalsInRow; out.rowOffsets[i] = nvalsInRow; @@ -84,10 +82,10 @@ namespace testing { // Eval row offsets cuBool_Index sum = 0; - for (auto& rowOffset: out.rowOffsets) { + for (auto& rowOffset : out.rowOffsets) { cuBool_Index next = sum + rowOffset; - rowOffset = sum; - sum = next; + rowOffset = sum; + sum = next; } out.hasRowOffsets = true; @@ -99,8 +97,8 @@ namespace testing { // Fill sorted column indices size_t k = 0; for (cuBool_Index i = 0; i < a.nrows; i++) { - const cuBool_Index* ar = &a.colsIndex[a.rowOffsets[i]]; - const cuBool_Index* br = &b.colsIndex[b.rowOffsets[i]]; + const cuBool_Index* ar = &a.colsIndex[a.rowOffsets[i]]; + const cuBool_Index* br = &b.colsIndex[b.rowOffsets[i]]; const cuBool_Index* arend = &a.colsIndex[a.rowOffsets[i + 1]]; const cuBool_Index* brend = &b.colsIndex[b.rowOffsets[i + 1]]; @@ -111,14 +109,12 @@ namespace testing { k++; ar++; br++; - } - else if (*ar < *br) { + } else if (*ar < *br) { out.rowsIndex[k] = i; out.colsIndex[k] = *ar; k++; ar++; - } - else { + } else { out.rowsIndex[k] = i; out.colsIndex[k] = *br; k++; @@ -145,6 +141,6 @@ namespace testing { } }; -} +}// namespace testing -#endif //CUBOOL_TESTING_MATRIXEWISEADD_HPP +#endif//CUBOOL_TESTING_MATRIXEWISEADD_HPP diff --git a/cubool/utils/testing/matrix_ewisemult.hpp b/cubool/utils/testing/matrix_ewisemult.hpp index 4ff39f4..36be443 100644 --- a/cubool/utils/testing/matrix_ewisemult.hpp +++ b/cubool/utils/testing/matrix_ewisemult.hpp @@ -37,8 +37,8 @@ namespace testing { std::unordered_set values; for (size_t i = 0; i < a.nvals; i++) { - uint64_t row = a.rowsIndex[i]; - uint64_t col = a.colsIndex[i]; + uint64_t row = a.rowsIndex[i]; + uint64_t col = a.colsIndex[i]; uint64_t index = row * a.ncols + col; values.insert(index); @@ -49,8 +49,8 @@ namespace testing { out.ncols = a.ncols; for (size_t i = 0; i < b.nvals; i++) { - uint64_t row = b.rowsIndex[i]; - uint64_t col = b.colsIndex[i]; + uint64_t row = b.rowsIndex[i]; + uint64_t col = b.colsIndex[i]; uint64_t index = row * b.ncols + col; if (values.find(index) != values.end()) { @@ -65,6 +65,6 @@ namespace testing { } }; -} +}// namespace testing -#endif //CUBOOL_MATRIX_EWISEMULT_HPP +#endif//CUBOOL_MATRIX_EWISEMULT_HPP diff --git a/cubool/utils/testing/matrix_generator.hpp b/cubool/utils/testing/matrix_generator.hpp index 3ed2a72..38ba559 100644 --- a/cubool/utils/testing/matrix_generator.hpp +++ b/cubool/utils/testing/matrix_generator.hpp @@ -25,10 +25,10 @@ #ifndef CUBOOL_TESTING_MATRIXGENERATOR_HPP #define CUBOOL_TESTING_MATRIXGENERATOR_HPP +#include +#include #include #include -#include -#include namespace testing { @@ -46,19 +46,20 @@ namespace testing { struct Condition3 { public: - explicit Condition3(float density): mDensity(density) { + explicit Condition3(float density) : mDensity(density) { mRandomEngine.seed(std::time(0)); } bool operator()(cuBool_Index i, cuBool_Index j) { return std::uniform_real_distribution(0.0f, 1.0f)(mRandomEngine) <= mDensity; } + private: std::default_random_engine mRandomEngine; - float mDensity = 1.0f; + float mDensity = 1.0f; }; template - static void generateTestData(size_t rows, size_t columns, std::vector &values, Condition&& condition) { + static void generateTestData(size_t rows, size_t columns, std::vector& values, Condition&& condition) { for (cuBool_Index i = 0; i < rows; i++) { for (cuBool_Index j = 0; j < columns; j++) { // is i and j power of two or 0 @@ -70,7 +71,7 @@ namespace testing { } template - static void generateTestData(size_t nrows, size_t ncols, std::vector &rows, std::vector &cols, size_t& nvals, Condition&& condition) { + static void generateTestData(size_t nrows, size_t ncols, std::vector& rows, std::vector& cols, size_t& nvals, Condition&& condition) { nvals = 0; for (cuBool_Index i = 0; i < nrows; i++) { for (cuBool_Index j = 0; j < ncols; j++) { @@ -83,7 +84,7 @@ namespace testing { } } } - -} -#endif //CUBOOL_TESTING_MATRIXGENERATOR_HPP +}// namespace testing + +#endif//CUBOOL_TESTING_MATRIXGENERATOR_HPP diff --git a/cubool/utils/testing/matrix_kronecker.hpp b/cubool/utils/testing/matrix_kronecker.hpp index 96258b9..bf0c592 100644 --- a/cubool/utils/testing/matrix_kronecker.hpp +++ b/cubool/utils/testing/matrix_kronecker.hpp @@ -63,7 +63,7 @@ namespace testing { std::sort(vals.begin(), vals.end(), PairCmp{}); - for (auto& p: vals) { + for (auto& p : vals) { result.rowsIndex.push_back(p.i); result.colsIndex.push_back(p.j); } @@ -72,6 +72,6 @@ namespace testing { } }; -} +}// namespace testing -#endif //CUBOOL_TESTING_MATRIXKRONECKER_HPP +#endif//CUBOOL_TESTING_MATRIXKRONECKER_HPP diff --git a/cubool/utils/testing/matrix_mxm.hpp b/cubool/utils/testing/matrix_mxm.hpp index d92ccfb..3837dd4 100644 --- a/cubool/utils/testing/matrix_mxm.hpp +++ b/cubool/utils/testing/matrix_mxm.hpp @@ -25,10 +25,10 @@ #ifndef CUBOOL_TESTING_MATRIXMXM_HPP #define CUBOOL_TESTING_MATRIXMXM_HPP -#include -#include #include #include +#include +#include namespace testing { @@ -75,10 +75,10 @@ namespace testing { // Row offsets cuBool_Index sum = 0; - for (auto& rowOffset: out.rowOffsets) { + for (auto& rowOffset : out.rowOffsets) { cuBool_Index next = sum + rowOffset; - rowOffset = sum; - sum = next; + rowOffset = sum; + sum = next; } out.hasRowOffsets = true; @@ -91,9 +91,9 @@ namespace testing { mask.resize(b.ncols, max); for (cuBool_Index i = 0; i < a.nrows; i++) { - size_t id = 0; + size_t id = 0; size_t first = out.rowOffsets[i]; - size_t last = out.rowOffsets[i + 1]; + size_t last = out.rowOffsets[i + 1]; for (cuBool_Index ak = a.rowOffsets[i]; ak < a.rowOffsets[i + 1]; ak++) { cuBool_Index k = a.colsIndex[ak]; @@ -103,7 +103,7 @@ namespace testing { // Do not compute col nnz twice if (mask[j] != i) { - mask[j] = i; + mask[j] = i; out.rowsIndex[first + id] = i; out.colsIndex[first + id] = j; id += 1; @@ -124,6 +124,6 @@ namespace testing { } }; -} +}// namespace testing -#endif //CUBOOL_TESTING_MATRIXMXM_HPP +#endif//CUBOOL_TESTING_MATRIXMXM_HPP diff --git a/cubool/utils/testing/matrix_printing.hpp b/cubool/utils/testing/matrix_printing.hpp index d55ba5e..c4dcd77 100644 --- a/cubool/utils/testing/matrix_printing.hpp +++ b/cubool/utils/testing/matrix_printing.hpp @@ -29,11 +29,11 @@ namespace testing { - template + template void printMatrix(Stream& stream, const cuBool_Index* rowsIndex, const cuBool_Index* colsIndex, cuBool_Index nrows, cuBool_Index ncols, cuBool_Index nvals) { cuBool_Index currentRow = 0; cuBool_Index currentCol = 0; - cuBool_Index currentId = 0; + cuBool_Index currentId = 0; while (currentId < nvals) { auto i = rowsIndex[currentId]; @@ -76,8 +76,8 @@ namespace testing { cuBool_Matrix matrix; }; - template - Stream& operator <<(Stream& stream, Print p) { + template + Stream& operator<<(Stream& stream, Print p) { cuBool_Matrix matrix = p.matrix; assert(matrix); @@ -99,12 +99,12 @@ namespace testing { return stream; } - template - Stream& operator <<(Stream& stream, const Matrix& a) { + template + Stream& operator<<(Stream& stream, const Matrix& a) { printMatrix(stream, a.rowsIndex.data(), a.colsIndex.data(), a.nrows, a.ncols, a.nvals); return stream; } - -} -#endif //CUBOOL_TESTING_MATRIXPRINTING_HPP +}// namespace testing + +#endif//CUBOOL_TESTING_MATRIXPRINTING_HPP diff --git a/cubool/utils/testing/pair.hpp b/cubool/utils/testing/pair.hpp index b5fcec9..e7767ed 100644 --- a/cubool/utils/testing/pair.hpp +++ b/cubool/utils/testing/pair.hpp @@ -37,30 +37,30 @@ namespace testing { struct PairHash { public: - std::size_t operator()(const Pair &x) const { + std::size_t operator()(const Pair& x) const { return std::hash()(x.i) ^ std::hash()(x.j); } }; struct PairCmp { public: - bool operator()(const Pair &a, const Pair& b) const { + bool operator()(const Pair& a, const Pair& b) const { return a.i < b.i || (a.i == b.i && a.j < b.j); } }; struct PairEq { public: - bool operator()(const Pair &a, const Pair& b) const { + bool operator()(const Pair& a, const Pair& b) const { return a.i == b.i && a.j == b.j; } }; - bool operator ==(const Pair& a, const Pair& b) { + bool operator==(const Pair& a, const Pair& b) { PairEq pairEq; return pairEq(a, b); } -} +}// namespace testing -#endif //CUBOOL_TESTING_PAIR_HPP +#endif//CUBOOL_TESTING_PAIR_HPP diff --git a/cubool/utils/testing/testing.hpp b/cubool/utils/testing/testing.hpp index c658d65..704d365 100644 --- a/cubool/utils/testing/testing.hpp +++ b/cubool/utils/testing/testing.hpp @@ -26,23 +26,23 @@ #define CUBOOL_TESTING_TESTING_HPP #include -#include -#include #include -#include -#include #include #include -#include +#include #include +#include +#include +#include +#include #include #include // Put in the end of the unit test file -#define CUBOOL_GTEST_MAIN \ - int main(int argc, char *argv[]) { \ - ::testing::InitGoogleTest(&argc, argv); \ - return RUN_ALL_TESTS(); \ +#define CUBOOL_GTEST_MAIN \ + int main(int argc, char* argv[]) { \ + ::testing::InitGoogleTest(&argc, argv); \ + return RUN_ALL_TESTS(); \ } -#endif //CUBOOL_TESTING_TESTING_HPP +#endif//CUBOOL_TESTING_TESTING_HPP diff --git a/cubool/utils/testing/timer.hpp b/cubool/utils/testing/timer.hpp index 6c1d781..33c700d 100644 --- a/cubool/utils/testing/timer.hpp +++ b/cubool/utils/testing/timer.hpp @@ -45,7 +45,7 @@ namespace testing { } private: - using clock = std::chrono::high_resolution_clock; + using clock = std::chrono::high_resolution_clock; using timepoint = clock::time_point; timepoint mStart; timepoint mEnd; @@ -63,13 +63,13 @@ namespace testing { } private: - double mTimeSumMS = 0.0f; - int mSamplesCount = 0; + double mTimeSumMS = 0.0f; + int mSamplesCount = 0; }; struct TimeScope { public: - explicit TimeScope(TimeQuery &query) : mTimeQuery(query) { + explicit TimeScope(TimeQuery& query) : mTimeQuery(query) { mTimer.start(); } @@ -79,10 +79,10 @@ namespace testing { } private: - Timer mTimer; - TimeQuery &mTimeQuery; + Timer mTimer; + TimeQuery& mTimeQuery; }; -} +}// namespace testing -#endif //CUBOOL_TESTING_TIMER_HPP +#endif//CUBOOL_TESTING_TIMER_HPP diff --git a/cubool/utils/testing/vector.hpp b/cubool/utils/testing/vector.hpp index 2d03395..000f543 100644 --- a/cubool/utils/testing/vector.hpp +++ b/cubool/utils/testing/vector.hpp @@ -25,26 +25,26 @@ #ifndef CUBOOL_VECTOR_HPP #define CUBOOL_VECTOR_HPP -#include -#include -#include #include -#include #include +#include +#include +#include +#include namespace testing { struct Vector { std::vector index; - size_t nvals = 0; - size_t nrows = 0; + size_t nvals = 0; + size_t nrows = 0; Vector subVector(cuBool_Index i, cuBool_Index m) const { assert(i + m <= nrows); Vector out; - for (auto v: index) { + for (auto v : index) { if (i <= v && v < (i + m)) out.index.push_back(v - i); } @@ -90,14 +90,14 @@ namespace testing { auto r = (cuBool_Index) (pr * (float) nrows); - r = std::min(r, (cuBool_Index)nrows - 1); + r = std::min(r, (cuBool_Index) nrows - 1); indices.emplace(r); } std::vector toSort(indices.size()); std::copy(indices.begin(), indices.end(), toSort.begin()); - std::sort(toSort.begin(), toSort.end(), [](cuBool_Index a, cuBool_Index b){ return a < b; }); + std::sort(toSort.begin(), toSort.end(), [](cuBool_Index a, cuBool_Index b) { return a < b; }); vec.nvals = toSort.size(); vec.index = std::move(toSort); @@ -112,6 +112,6 @@ namespace testing { } }; -} +}// namespace testing -#endif //CUBOOL_VECTOR_HPP +#endif//CUBOOL_VECTOR_HPP diff --git a/cubool/utils/testing/vector_functors.hpp b/cubool/utils/testing/vector_functors.hpp index d8f59c6..4317a35 100644 --- a/cubool/utils/testing/vector_functors.hpp +++ b/cubool/utils/testing/vector_functors.hpp @@ -25,8 +25,8 @@ #ifndef CUBOOL_VECTOR_FUNCTORS_HPP #define CUBOOL_VECTOR_FUNCTORS_HPP -#include #include +#include namespace testing { @@ -35,10 +35,10 @@ namespace testing { Vector operator()(const Vector& a, const Vector& b) { std::unordered_set values; - for (auto v: a.index) + for (auto v : a.index) values.emplace(v); - for (auto v: b.index) + for (auto v : b.index) values.emplace(v); std::vector sorted(values.size()); @@ -59,12 +59,12 @@ namespace testing { public: Vector operator()(const Vector& a, const Vector& b) { std::unordered_set values; - std::vector result; + std::vector result; - for (auto v: a.index) + for (auto v : a.index) values.emplace(v); - for (auto v: b.index) { + for (auto v : b.index) { if (values.find(v) != values.end()) result.push_back(v); } @@ -85,20 +85,20 @@ namespace testing { std::unordered_set buffer; - for (auto i: v.index) + for (auto i : v.index) buffer.emplace(i); std::vector result; for (cuBool_Index i = 0; i < m.nrows; i++) { - for (cuBool_Index k = m.rowOffsets[i]; k < m.rowOffsets[i + 1]; k++) { - cuBool_Index j = m.colsIndex[k]; - - if (buffer.find(j) != buffer.end()) { - result.push_back(i); - break; - } - } + for (cuBool_Index k = m.rowOffsets[i]; k < m.rowOffsets[i + 1]; k++) { + cuBool_Index j = m.colsIndex[k]; + + if (buffer.find(j) != buffer.end()) { + result.push_back(i); + break; + } + } } Vector r; @@ -116,7 +116,7 @@ namespace testing { std::unordered_set result; - for (cuBool_Index i: v.index) { + for (cuBool_Index i : v.index) { for (cuBool_Index k = m.rowOffsets[i]; k < m.rowOffsets[i + 1]; k++) { result.emplace(m.colsIndex[k]); } @@ -133,6 +133,6 @@ namespace testing { } }; -} +}// namespace testing -#endif //CUBOOL_VECTOR_FUNCTORS_HPP +#endif//CUBOOL_VECTOR_FUNCTORS_HPP From 4a14d4d9f663da3b89537072efc795d6463f2e53 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 26 May 2025 19:13:58 +0300 Subject: [PATCH 72/74] fix: change trigger branch name --- .github/workflows/clang-format.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 858cb9b..7c8171d 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -2,13 +2,13 @@ name: Clang Format on: push: - branches: [ main ] + branches: [ master ] paths: - '.github/**' - 'cubool/**' - '.clang-format' pull_request: - branches: [ main ] + branches: [ master ] jobs: formatting-check: From ad627a9e0e475e64bb15e427a231653e9a50aa1b Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 26 May 2025 22:32:07 +0300 Subject: [PATCH 73/74] fix: change names in docs --- .github/workflows/clang-format.yml | 3 ++- cubool/include/cubool/cubool.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 7c8171d..5b4ca60 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -21,8 +21,9 @@ jobs: - 'cubool' steps: - uses: actions/checkout@v4 + - name: Run clang-format style check uses: jidicula/clang-format-action@v4.15.0 with: clang-format-version: '20' - check-path: ${{ matrix.path }} \ No newline at end of file + check-path: ${{ matrix.path }} diff --git a/cubool/include/cubool/cubool.h b/cubool/include/cubool/cubool.h index a3c3646..6c9a2ae 100644 --- a/cubool/include/cubool/cubool.h +++ b/cubool/include/cubool/cubool.h @@ -882,13 +882,13 @@ CUBOOL_EXPORT CUBOOL_API cuBool_Status cuBool_Kronecker( cuBool_Hints hints); /** - * Performs result = left * ~right, where + * Performs result = matrix * ~mask, where * '*' is boolean semiring 'and' operation * '~' is operation for invert matrix (0 swaps to 1 and 1 to 0) * * @note To perform this operation matrices must be compatible - * dim(left) = M x T - * dim(right) = T x N + * dim(matrix) = M x T + * dim(mask) = T x N * dim(result) = M x N * * @note Pass `CUBOOL_HINT_TIME_CHECK` hint to measure operation time From 3c430c9cac42d3e0be1c209f58f36e9987e5c3d0 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 26 May 2025 22:49:52 +0300 Subject: [PATCH 74/74] ci: delete shell option --- .github/workflows/self-hosted.yml | 2 -- .github/workflows/ubuntu.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 8ca2f69..fdd39fe 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -66,7 +66,6 @@ jobs: working-directory: ${{ env.build_dir }} run: | bash scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} - shell: bash - name: Upload unit tests resutls uses: actions/upload-artifact@v4 @@ -83,7 +82,6 @@ jobs: working-directory: ${{ env.build_dir }}/python run: | bash run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} - shell: bash - name: Upload regression tests resutls uses: actions/upload-artifact@v4 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 26b646f..bf22ee3 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -74,7 +74,6 @@ jobs: working-directory: ${{ env.build_dir }} run: | bash scripts/run_tests_all.sh | tee ${{ env.unit-test-file }} - shell: bash - name: Upload unit tests resutls uses: actions/upload-artifact@v4 @@ -91,7 +90,6 @@ jobs: working-directory: ${{ env.build_dir }}/python run: | bash run_tests.sh 2>&1 | tee ${{ env.regression-test-file }} - shell: bash - name: Upload regression tests resutls uses: actions/upload-artifact@v4