Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into kmp5/feature/cp-bcd
Browse files Browse the repository at this point in the history
  • Loading branch information
kmp5VT committed Jan 24, 2024
2 parents fdb1b8d + a54b414 commit b9490ec
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 128 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions btas/generic/cp_als.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@ namespace btas {
double lambda = 0) {
Tensor temp(A[n].extent(0), rank);
Tensor an(A[n].range());

// Testing the code to see if pivoted QR can help
if (false) {
// First create a Pivot matrix from the flattened tensor_ref
Expand Down Expand Up @@ -795,10 +794,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){
Expand Down
39 changes: 1 addition & 38 deletions cmake/btas-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 0 additions & 25 deletions cmake/modules/FindOrFetchBoost.cmake

This file was deleted.

84 changes: 30 additions & 54 deletions external/boost.cmake
Original file line number Diff line number Diff line change
@@ -1,63 +1,39 @@
# -*- 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)
# 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()

# 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)
else()
set(Boost_USE_CONFIG TRUE)
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)
Expand Down
2 changes: 1 addition & 1 deletion external/versions.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(BTAS_TRACKED_VGCMAKEKIT_TAG d6746098e63deab4032309c4455bb084a17ff51a)
set(BTAS_TRACKED_VGCMAKEKIT_TAG 45e7d0d8d7f994a88c5af5fc082332db7bd0d6b3)

# likely can use earlier, but
# - as of oct 2023 tested with 1.71 and up only
Expand Down
4 changes: 2 additions & 2 deletions unittest/ztensor_cp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ TEST_CASE("ZCP") {
SECTION("RALS MODE = 4, Finite rank") {
CP_RALS<ztensor, zconv_class> 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<ztensor, zconv_class> 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, 67, true, 65);
CHECK(std::abs(diff) <= epsilon);
}
#if BTAS_ENABLE_TUCKER_CP_UT
Expand Down

0 comments on commit b9490ec

Please sign in to comment.