From 85eea7796651de1bcb4781b0081a352b32bf91d5 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Wed, 17 Jan 2024 00:07:25 -0500 Subject: [PATCH 01/12] use modularized FindOrFetchBoost.cmake from VG Cmake kit --- CMakeLists.txt | 7 ++- cmake/btas-config.cmake.in | 39 +------------ cmake/modules/FindOrFetchBoost.cmake | 25 --------- external/boost.cmake | 84 ++++++++++------------------ external/versions.cmake | 2 +- 5 files changed, 38 insertions(+), 119 deletions(-) delete mode 100644 cmake/modules/FindOrFetchBoost.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a367abb9..fb714ec9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,8 +225,11 @@ add_custom_target_subproject(btas install-config COMMAND ${CMAKE_COMMAND} -DCOMPONENT=btas-config -P ${PROJECT_BINARY_DIR}/cmake_install.cmake COMMENT "Installing BTAS config components") -feature_summary(WHAT ALL - DESCRIPTION "=== BTAS Package/Feature Info ===") +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + feature_summary(WHAT ALL + DESCRIPTION "=== BTAS Package/Feature Info ===") + feature_summary(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/features.log WHAT ALL) +endif() ############################################################################### # appendix: misc details diff --git a/cmake/btas-config.cmake.in b/cmake/btas-config.cmake.in index 2259b169..26a4db67 100644 --- a/cmake/btas-config.cmake.in +++ b/cmake/btas-config.cmake.in @@ -16,44 +16,7 @@ set(BTAS_EXT_VERSION "@BTAS_EXT_VERSION@") @PACKAGE_INIT@ -# import boost components, if any missing -set(Boost_BTAS_DEPS_LIBRARIES @Boost_BTAS_DEPS_LIBRARIES@) -foreach(_deplib ${Boost_BTAS_DEPS_LIBRARIES}) - if (DEFINED Boost_BTAS_DEPS_LIBRARIES_NOT_FOUND_CHECK) - list(APPEND Boost_BTAS_DEPS_LIBRARIES_NOT_FOUND_CHECK OR) - endif() - list(APPEND Boost_BTAS_DEPS_LIBRARIES_NOT_FOUND_CHECK "NOT;TARGET;Boost::${_deplib}") -endforeach(_deplib) -if (NOT DEFINED Boost_BTAS_DEPS_LIBRARIES_NOT_FOUND_CHECK) - list(APPEND Boost_BTAS_DEPS_LIBRARIES_NOT_FOUND_CHECK "NOT;TARGET;Boost::boost") -endif (NOT DEFINED Boost_BTAS_DEPS_LIBRARIES_NOT_FOUND_CHECK) - -if(${Boost_BTAS_DEPS_LIBRARIES_NOT_FOUND_CHECK}) - set(Boost_USE_CONFIG @Boost_USE_CONFIG@) - # OPTIONAL_COMPONENTS in FindBoost available since 3.11 - cmake_minimum_required(VERSION 3.11.0) - if (Boost_USE_CONFIG) - set(Boost_CONFIG @Boost_CONFIG@) - if (NOT Boost_CONFIG OR NOT EXISTS ${Boost_CONFIG}) - message(FATAL_ERROR "Expected Boost config file at ${Boost_CONFIG}; directory moved since BTAS configuration?") - endif() - get_filename_component(Boost_DIR ${Boost_CONFIG} DIRECTORY) - find_package(Boost CONFIG QUIET REQUIRED OPTIONAL_COMPONENTS ${Boost_BTAS_DEPS_LIBRARIES} PATHS ${Boost_DIR} NO_DEFAULT_PATH) - else (Boost_USE_CONFIG) - set(BOOST_INCLUDEDIR @Boost_INCLUDE_DIR@) - set(BOOST_LIBRARYDIR @Boost_LIBRARY_DIR_RELEASE@) - if (NOT BOOST_LIBRARYDIR OR NOT EXISTS ${BOOST_LIBRARYDIR}) - set(BOOST_LIBRARYDIR @Boost_LIBRARY_DIR_DEBUG@) - endif() - set(Boost_NO_SYSTEM_PATHS OFF) - if (BOOST_LIBRARYDIR AND BOOST_INCLUDEDIR) - if (EXISTS ${BOOST_LIBRARYDIR} AND EXISTS ${BOOST_INCLUDEDIR}) - set(Boost_NO_SYSTEM_PATHS ON) - endif() - endif() - find_package(Boost QUIET REQUIRED OPTIONAL_COMPONENTS ${Boost_BTAS_DEPS_LIBRARIES}) - endif (Boost_USE_CONFIG) -endif(${Boost_BTAS_DEPS_LIBRARIES_NOT_FOUND_CHECK}) +@Boost_CONFIG_FILE_CONTENTS@ # find linalgpp dependencies if(NOT TARGET blaspp) diff --git a/cmake/modules/FindOrFetchBoost.cmake b/cmake/modules/FindOrFetchBoost.cmake deleted file mode 100644 index c0b24b5f..00000000 --- a/cmake/modules/FindOrFetchBoost.cmake +++ /dev/null @@ -1,25 +0,0 @@ -if (NOT TARGET Boost::boost) - include (FetchContent) - cmake_minimum_required (VERSION 3.14.0) # for FetchContent_MakeAvailable - - FetchContent_Declare( - CMAKEBOOST - GIT_REPOSITORY https://github.com/Orphis/boost-cmake - ) - FetchContent_MakeAvailable(CMAKEBOOST) - FetchContent_GetProperties(CMAKEBOOST - SOURCE_DIR CMAKEBOOST_SOURCE_DIR - BINARY_DIR CMAKEBOOST_BINARY_DIR - ) - - # current boost-cmake/master does not install boost correctly, so warn that installed BTAS will not be usable - # boost-cmake/install_rules https://github.com/Orphis/boost-cmake/pull/45 is supposed to fix it but is inactive - message(WARNING "Building Boost from source makes BTAS unusable from the install location! Install Boost using package manager or manually and reconfigure/reinstall BTAS to fix this") - install(TARGETS Boost_serialization EXPORT btas COMPONENT boost-libs) - -endif(NOT TARGET Boost::boost) - -# postcond check -if (NOT TARGET Boost::boost) - message(FATAL_ERROR "FindOrFetchBoost could not make Boost::boost target available") -endif(NOT TARGET Boost::boost) diff --git a/external/boost.cmake b/external/boost.cmake index 9570bb53..40487334 100644 --- a/external/boost.cmake +++ b/external/boost.cmake @@ -1,63 +1,41 @@ # -*- mode: cmake -*- -# Limit scope of the search if BOOST_ROOT or BOOST_INCLUDEDIR is provided. -if (BOOST_ROOT OR BOOST_INCLUDEDIR) - set(Boost_NO_SYSTEM_PATHS TRUE) -endif() - -# make sure Boost::boost is available, and look for optional serialization component -if (NOT TARGET Boost::boost OR NOT TARGET Boost::serialization) - list(APPEND Boost_BTAS_DEPS_LIBRARIES serialization) - - # detect which Boost targets I already have - foreach(tgt boost;headers;${Boost_BTAS_DEPS_LIBRARIES}) - if (TARGET Boost::${tgt}) - set(btas_imported_boost_${tgt} 0) - else() - set(btas_imported_boost_${tgt} 1) - endif() - endforeach() - - # try config first - # OPTIONAL_COMPONENTS in FindBoost available since 3.11 - cmake_minimum_required(VERSION 3.11.0) - find_package(Boost ${BTAS_TRACKED_BOOST_VERSION} CONFIG OPTIONAL_COMPONENTS ${Boost_BTAS_DEPS_LIBRARIES}) - if (NOT TARGET Boost::boost) - find_package(Boost ${BTAS_TRACKED_BOOST_VERSION} OPTIONAL_COMPONENTS ${Boost_BTAS_DEPS_LIBRARIES}) - if (TARGET Boost::boost) - set(Boost_USE_CONFIG FALSE) - endif(TARGET Boost::boost) +# Boost can be discovered by every (sub)package but only the top package can build it ... +# if we are the top package need to include the list of Boost components to be built +if("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}") + set(required_components + headers # BTAS + container # BTAS + iterator # BTAS + random # BTAS + ) + if (DEFINED Boost_REQUIRED_COMPONENTS) + list(APPEND Boost_REQUIRED_COMPONENTS ${required_components}) + list(REMOVE_DUPLICATES Boost_REQUIRED_COMPONENTS) else() - set(Boost_USE_CONFIG TRUE) + set(Boost_REQUIRED_COMPONENTS "${required_components}" CACHE STRING "Required components of Boost to discovered or built") endif() + set(optional_components + serialization # BTAS + ) + if (DEFINED Boost_OPTIONAL_COMPONENTS) + list(APPEND Boost_OPTIONAL_COMPONENTS ${optional_components}) + list(REMOVE_DUPLICATES Boost_OPTIONAL_COMPONENTS) + else() + set(Boost_OPTIONAL_COMPONENTS "${optional_components}" CACHE STRING "Optional components of Boost to discovered or built") + endif() +endif() - # Boost::* targets by default are not GLOBAL, so to allow users of LINALG_LIBRARIES to safely use them we need to make them global - # more discussion here: https://gitlab.kitware.com/cmake/cmake/-/issues/17256 - foreach(tgt boost;headers;${Boost_BTAS_DEPS_LIBRARIES}) - if (TARGET Boost::${tgt} AND btas_imported_boost_${tgt}) - get_target_property(_boost_tgt_${tgt}_is_imported_global Boost::${tgt} IMPORTED_GLOBAL) - if (NOT _boost_tgt_${tgt}_is_imported_global) - set_target_properties(Boost::${tgt} PROPERTIES IMPORTED_GLOBAL TRUE) - endif() - unset(_boost_tgt_${tgt}_is_imported_global) - endif() - endforeach() - -endif (NOT TARGET Boost::boost OR NOT TARGET Boost::serialization) - -# if Boost not found, and BTAS_BUILD_DEPS_FROM_SOURCE=ON, use FetchContent to build it -set(BTAS_BUILT_BOOST_FROM_SOURCE 0) -if (NOT TARGET Boost::boost) - if (BTAS_BUILD_DEPS_FROM_SOURCE) - include(${PROJECT_SOURCE_DIR}/cmake/modules/FindOrFetchBoost.cmake) - set(BTAS_BUILT_BOOST_FROM_SOURCE 1) - else(BTAS_BUILD_DEPS_FROM_SOURCE) - message(FATAL_ERROR "Boost is a required prerequisite of BTAS, but not found; install Boost or set BTAS_BUILD_DEPS_FROM_SOURCE=ON to obtain from source") - endif(BTAS_BUILD_DEPS_FROM_SOURCE) -endif (NOT TARGET Boost::boost) +if (BTAS_BUILD_DEPS_FROM_SOURCE AND NOT DEFINED Boost_FETCH_IF_MISSING) + set(Boost_FETCH_IF_MISSING 1) +endif() +include(${vg_cmake_kit_SOURCE_DIR}/modules/FindOrFetchBoost.cmake) +if (DEFINED Boost_SOURCE_DIR) + set(BTAS_BUILT_BOOST_FROM_SOURCE 1) +endif() # make BTAS depend on Boost -set(Boost_LIBRARIES Boost::boost) +set(Boost_LIBRARIES Boost::headers;Boost::random) if (TARGET Boost::serialization) list(APPEND Boost_LIBRARIES Boost::serialization) target_compile_definitions(BTAS INTERFACE -DBTAS_HAS_BOOST_SERIALIZATION=1) diff --git a/external/versions.cmake b/external/versions.cmake index 2c955352..2c5257b5 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -1,4 +1,4 @@ -set(BTAS_TRACKED_VGCMAKEKIT_TAG d6746098e63deab4032309c4455bb084a17ff51a) +set(BTAS_TRACKED_VGCMAKEKIT_TAG 8713beb71ff6b7d4b1c758e9e1c7d814bd97b0af) # likely can use earlier, but # - as of oct 2023 tested with 1.71 and up only From 960dd07126f66039ac4dcc1411433263ba550644 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Wed, 17 Jan 2024 01:08:07 -0500 Subject: [PATCH 02/12] [ci] ubuntu needs to install libboost-random --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index e732ed5d..a6a70bf1 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -58,7 +58,7 @@ jobs: if: ${{ matrix.os == 'ubuntu-20.04' }} run: | sudo apt-get update - sudo apt-get install ninja-build g++-9 liblapack-dev libboost-dev libboost-serialization-dev libeigen3-dev openmpi-bin libopenmpi-dev libtbb-dev ccache + sudo apt-get install ninja-build g++-9 liblapack-dev libboost-dev libboost-serialization-dev libboost-random-dev libeigen3-dev openmpi-bin libopenmpi-dev libtbb-dev ccache if [ "${{matrix.build_type}}" = "Release" ]; then sudo apt-get install libclang1-9 libclang-cpp9 graphviz fonts-liberation cd ${{github.workspace}}/build From b2c18c797122b149eb088ae494dbd12f2f5ff81b Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 22 Jan 2024 01:08:36 -0500 Subject: [PATCH 03/12] upgrade FindOrFetchBoost via https://github.com/ValeevGroup/kit-cmake/pull/6/commits/45e7d0d8d7f994a88c5af5fc082332db7bd0d6b3 and support BTAS loading if Boost already partially discovered --- external/boost.cmake | 46 ++++++++++++++++++++--------------------- external/versions.cmake | 2 +- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/external/boost.cmake b/external/boost.cmake index 40487334..1611011c 100644 --- a/external/boost.cmake +++ b/external/boost.cmake @@ -1,29 +1,27 @@ # -*- mode: cmake -*- -# Boost can be discovered by every (sub)package but only the top package can build it ... -# if we are the top package need to include the list of Boost components to be built -if("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}") - set(required_components - headers # BTAS - container # BTAS - iterator # BTAS - random # BTAS - ) - if (DEFINED Boost_REQUIRED_COMPONENTS) - list(APPEND Boost_REQUIRED_COMPONENTS ${required_components}) - list(REMOVE_DUPLICATES Boost_REQUIRED_COMPONENTS) - else() - set(Boost_REQUIRED_COMPONENTS "${required_components}" CACHE STRING "Required components of Boost to discovered or built") - endif() - set(optional_components - serialization # BTAS - ) - if (DEFINED Boost_OPTIONAL_COMPONENTS) - list(APPEND Boost_OPTIONAL_COMPONENTS ${optional_components}) - list(REMOVE_DUPLICATES Boost_OPTIONAL_COMPONENTS) - else() - set(Boost_OPTIONAL_COMPONENTS "${optional_components}" CACHE STRING "Optional components of Boost to discovered or built") - endif() +# Boost can be discovered by every (sub)package but only the top package can *build* it ... +# in either case must declare the components used by BTAS +set(required_components + headers # BTAS + container # BTAS + iterator # BTAS + random # BTAS +) +if (DEFINED Boost_REQUIRED_COMPONENTS) + list(APPEND Boost_REQUIRED_COMPONENTS ${required_components}) + list(REMOVE_DUPLICATES Boost_REQUIRED_COMPONENTS) +else() + set(Boost_REQUIRED_COMPONENTS "${required_components}" CACHE STRING "Required components of Boost to discovered or built") +endif() +set(optional_components + serialization # BTAS +) +if (DEFINED Boost_OPTIONAL_COMPONENTS) + list(APPEND Boost_OPTIONAL_COMPONENTS ${optional_components}) + list(REMOVE_DUPLICATES Boost_OPTIONAL_COMPONENTS) +else() + set(Boost_OPTIONAL_COMPONENTS "${optional_components}" CACHE STRING "Optional components of Boost to discovered or built") endif() if (BTAS_BUILD_DEPS_FROM_SOURCE AND NOT DEFINED Boost_FETCH_IF_MISSING) diff --git a/external/versions.cmake b/external/versions.cmake index 2c5257b5..cf7f8470 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -1,4 +1,4 @@ -set(BTAS_TRACKED_VGCMAKEKIT_TAG 8713beb71ff6b7d4b1c758e9e1c7d814bd97b0af) +set(BTAS_TRACKED_VGCMAKEKIT_TAG 45e7d0d8d7f994a88c5af5fc082332db7bd0d6b3) # likely can use earlier, but # - as of oct 2023 tested with 1.71 and up only From c956bea321688c8266bde9d73e916208a915040a Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 22 Jan 2024 14:07:17 -0500 Subject: [PATCH 04/12] Try making the converge tighter --- unittest/ztensor_cp_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/ztensor_cp_test.cc b/unittest/ztensor_cp_test.cc index f7c26732..a2d947b4 100644 --- a/unittest/ztensor_cp_test.cc +++ b/unittest/ztensor_cp_test.cc @@ -72,7 +72,7 @@ TEST_CASE("ZCP") { std::complex norm3 = sqrt(dot(Z3, Z3)); std::complex norm32 = sqrt(dot(Z33, Z33)); - zconv_class conv(1e-3); + zconv_class conv(1e-4); // ALS tests { From a7af4d0ff5e3c0e2cd826d02d91f2b82b0c52b35 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 22 Jan 2024 14:36:24 -0500 Subject: [PATCH 05/12] [ci] try setting MKL_NUM_THREADS=1 to see if stochastic CI failures of CP tests subside --- .github/workflows/cmake.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a6a70bf1..58452528 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -80,6 +80,7 @@ jobs: sudo apt-get install intel-oneapi-mkl-devel echo "BLAS_PREFERENCE_LIST=IntelMKL" >> $GITHUB_ENV echo "MKLROOT=/opt/intel/oneapi/mkl/latest" >> $GITHUB_ENV + echo "MKL_NUM_THREADS=1" >> $GITHUB_ENV else echo "BLAS_PREFERENCE_LIST=ReferenceBLAS" >> $GITHUB_ENV fi From b6de17125f99a81bfa7682189197086c0783a9ec Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 22 Jan 2024 15:29:20 -0500 Subject: [PATCH 06/12] change conv back and try to get tests working --- unittest/ztensor_cp_test.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/unittest/ztensor_cp_test.cc b/unittest/ztensor_cp_test.cc index a2d947b4..e68368b0 100644 --- a/unittest/ztensor_cp_test.cc +++ b/unittest/ztensor_cp_test.cc @@ -72,7 +72,7 @@ TEST_CASE("ZCP") { std::complex norm3 = sqrt(dot(Z3, Z3)); std::complex norm32 = sqrt(dot(Z33, Z33)); - zconv_class conv(1e-4); + zconv_class conv(1e-3); // ALS tests { @@ -98,16 +98,19 @@ TEST_CASE("ZCP") { conv.verbose(false); } #endif + std::cout.precision(16); SECTION("ALS MODE = 4, Finite error") { CP_ALS A1(Z4); conv.set_norm(norm4.real()); - double diff = A1.compute_error(conv, 1e-2, 1, 100, true, 57); + double diff = A1.compute_error(conv, 1e-5, 1, 100, true, 57); + std::cout << diff << std::endl; + std::cout << epsilon << std::endl; CHECK(std::abs(diff) <= epsilon); } SECTION("ALS MODE = 4, Finite rank") { CP_ALS A1(Z4); conv.set_norm(norm4.real()); - double diff = A1.compute_rank(57, conv, 1, true, 57); + double diff = A1.compute_rank(70, conv, 1, true, 70); CHECK(std::abs(diff) <= epsilon); } #if BTAS_ENABLE_TUCKER_CP_UT From d21ee08da09633b5d83d48c066bea3cfca9166d2 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 22 Jan 2024 15:37:56 -0500 Subject: [PATCH 07/12] Print the rank to see when `compute_error` finishes --- unittest/ztensor_cp_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unittest/ztensor_cp_test.cc b/unittest/ztensor_cp_test.cc index e68368b0..f5760001 100644 --- a/unittest/ztensor_cp_test.cc +++ b/unittest/ztensor_cp_test.cc @@ -105,12 +105,13 @@ TEST_CASE("ZCP") { double diff = A1.compute_error(conv, 1e-5, 1, 100, true, 57); std::cout << diff << std::endl; std::cout << epsilon << std::endl; + std::cout << A1.get_factor_matrices()[1].extent(1) << std::endl; CHECK(std::abs(diff) <= epsilon); } SECTION("ALS MODE = 4, Finite rank") { CP_ALS A1(Z4); conv.set_norm(norm4.real()); - double diff = A1.compute_rank(70, conv, 1, true, 70); + double diff = A1.compute_rank(80, conv, 1, true, 80); CHECK(std::abs(diff) <= epsilon); } #if BTAS_ENABLE_TUCKER_CP_UT From fd015d57951678aa34c5d02d8b01d541f21f2d72 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 22 Jan 2024 15:43:20 -0500 Subject: [PATCH 08/12] I was testing the wrong function on accident --- unittest/ztensor_cp_test.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/unittest/ztensor_cp_test.cc b/unittest/ztensor_cp_test.cc index f5760001..d01d77a5 100644 --- a/unittest/ztensor_cp_test.cc +++ b/unittest/ztensor_cp_test.cc @@ -98,20 +98,16 @@ TEST_CASE("ZCP") { conv.verbose(false); } #endif - std::cout.precision(16); SECTION("ALS MODE = 4, Finite error") { CP_ALS A1(Z4); conv.set_norm(norm4.real()); - double diff = A1.compute_error(conv, 1e-5, 1, 100, true, 57); - std::cout << diff << std::endl; - std::cout << epsilon << std::endl; - std::cout << A1.get_factor_matrices()[1].extent(1) << std::endl; + double diff = A1.compute_error(conv, 1e-2, 1, 100, true, 57); CHECK(std::abs(diff) <= epsilon); } SECTION("ALS MODE = 4, Finite rank") { CP_ALS A1(Z4); conv.set_norm(norm4.real()); - double diff = A1.compute_rank(80, conv, 1, true, 80); + double diff = A1.compute_rank(57, conv, 1, true, 57); CHECK(std::abs(diff) <= epsilon); } #if BTAS_ENABLE_TUCKER_CP_UT @@ -156,7 +152,11 @@ TEST_CASE("ZCP") { SECTION("RALS MODE = 4, Finite error"){ CP_RALS A1(Z4); conv.set_norm(norm4.real()); - double diff = A1.compute_error(conv, 1e-2, 1, 67, true, 65); + double diff = A1.compute_error(conv, 1e-5, 1, 100, true, 65); + std::cout.precision(16); + std::cout << diff << std::endl; + std::cout << epsilon << std::endl; + std::cout << A1.get_factor_matrices()[1].extent(1) << std::endl; CHECK(std::abs(diff) <= epsilon); } #if BTAS_ENABLE_TUCKER_CP_UT From 0c66507cef2c721af4045191988627565f43bad3 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 22 Jan 2024 15:49:44 -0500 Subject: [PATCH 09/12] Try to get RALS working --- btas/generic/cp_als.h | 1 + unittest/ztensor_cp_test.cc | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/btas/generic/cp_als.h b/btas/generic/cp_als.h index 7335e723..52866628 100644 --- a/btas/generic/cp_als.h +++ b/btas/generic/cp_als.h @@ -659,6 +659,7 @@ namespace btas { Tensor temp(A[n].extent(0), rank); Tensor an(A[n].range()); + } #ifdef BTAS_HAS_INTEL_MKL // Computes the Khatri-Rao product intermediate diff --git a/unittest/ztensor_cp_test.cc b/unittest/ztensor_cp_test.cc index d01d77a5..66ea12c6 100644 --- a/unittest/ztensor_cp_test.cc +++ b/unittest/ztensor_cp_test.cc @@ -146,17 +146,14 @@ TEST_CASE("ZCP") { SECTION("RALS MODE = 4, Finite rank") { CP_RALS A1(Z4); conv.set_norm(norm4.real()); - double diff = A1.compute_rank(65, conv, 1, true, 65); + double diff = A1.compute_rank(67, conv, 1, true, 65); CHECK(std::abs(diff) <= epsilon); } SECTION("RALS MODE = 4, Finite error"){ CP_RALS A1(Z4); conv.set_norm(norm4.real()); - double diff = A1.compute_error(conv, 1e-5, 1, 100, true, 65); - std::cout.precision(16); - std::cout << diff << std::endl; - std::cout << epsilon << std::endl; - std::cout << A1.get_factor_matrices()[1].extent(1) << std::endl; + conv.verbose(true); + double diff = A1.compute_error(conv, 1e-5, 1, 67, true, 65); CHECK(std::abs(diff) <= epsilon); } #if BTAS_ENABLE_TUCKER_CP_UT From d6fd0e6e5f15f71b10478c18b5c2e037dc2e4903 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 22 Jan 2024 15:55:42 -0500 Subject: [PATCH 10/12] remove extraneous curly brace --- btas/generic/cp_als.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/btas/generic/cp_als.h b/btas/generic/cp_als.h index 52866628..1944d510 100644 --- a/btas/generic/cp_als.h +++ b/btas/generic/cp_als.h @@ -658,8 +658,7 @@ namespace btas { double lambda = 0) { Tensor temp(A[n].extent(0), rank); Tensor an(A[n].range()); - - } + #ifdef BTAS_HAS_INTEL_MKL // Computes the Khatri-Rao product intermediate From 41a491c3ed037f272bd743be4e4cdf463ab214bf Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 22 Jan 2024 16:00:49 -0500 Subject: [PATCH 11/12] remove verbose statement [no ci] --- unittest/ztensor_cp_test.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/unittest/ztensor_cp_test.cc b/unittest/ztensor_cp_test.cc index 66ea12c6..d523b0f9 100644 --- a/unittest/ztensor_cp_test.cc +++ b/unittest/ztensor_cp_test.cc @@ -152,7 +152,6 @@ TEST_CASE("ZCP") { SECTION("RALS MODE = 4, Finite error"){ CP_RALS A1(Z4); conv.set_norm(norm4.real()); - conv.verbose(true); double diff = A1.compute_error(conv, 1e-5, 1, 67, true, 65); CHECK(std::abs(diff) <= epsilon); } From bc22242babb6858906f1cc31f16c6c22e2e26c9a Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 22 Jan 2024 17:27:59 -0500 Subject: [PATCH 12/12] Remove unnecessary comments [no ci] --- btas/generic/cp_als.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/btas/generic/cp_als.h b/btas/generic/cp_als.h index 1944d510..39698e2d 100644 --- a/btas/generic/cp_als.h +++ b/btas/generic/cp_als.h @@ -718,10 +718,6 @@ namespace btas { } KRP_dims.push_back(ndim); contract(this->one, tensor_ref, tref_indices, KhatriRao, KRP_dims, this->zero, temp, An_indices); - - // without MKL program cannot perform the swapping algorithm, must compute - // flattened intermediate -// gemm(blas::Op::NoTrans, blas::Op::NoTrans, this->one, new_flatten(tensor_ref, n), this->generate_KRP(n, rank, true), this->zero, temp); #endif if(lambda != 0){