From 0be8d0bff4be486712fe08842d5ccaf2fdbdf290 Mon Sep 17 00:00:00 2001 From: Theodore Chang Date: Sat, 12 Aug 2023 00:01:12 +0200 Subject: [PATCH] Use tbb allocator --- Domain/MetaMat/SparseMatFGMRES.hpp | 4 +--- Option.cmake | 4 +++- suanPan.cpp | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Domain/MetaMat/SparseMatFGMRES.hpp b/Domain/MetaMat/SparseMatFGMRES.hpp index c73cefc62..42a84a094 100644 --- a/Domain/MetaMat/SparseMatFGMRES.hpp +++ b/Domain/MetaMat/SparseMatFGMRES.hpp @@ -61,9 +61,7 @@ template class SparseMatBaseFGMRES : public SparseMat { SparseMatBaseFGMRES& operator=(const SparseMatBaseFGMRES&) = delete; SparseMatBaseFGMRES& operator=(SparseMatBaseFGMRES&&) noexcept = delete; - ~SparseMatBaseFGMRES() override { - mkl_free_buffers(); - } + ~SparseMatBaseFGMRES() override = default; }; template int SparseMatBaseFGMRES::direct_solve(Mat& X, const Mat& B) { diff --git a/Option.cmake b/Option.cmake index 3a37385f8..2ae6dec1a 100644 --- a/Option.cmake +++ b/Option.cmake @@ -97,7 +97,7 @@ if (USE_MKL) message(FATAL_ERROR "The mkl.h is not found under the path: ${MKLROOT}/include") endif () add_compile_definitions(SUANPAN_MKL) - add_compile_definitions(ARMA_USE_MKL_ALLOC) + # add_compile_definitions(ARMA_USE_MKL_ALLOC) include_directories(${MKLROOT}/include) link_directories(${MKLROOT}/lib/intel64) if (USE_MPI) @@ -202,11 +202,13 @@ endif () if (BUILD_MULTITHREAD) message("USING TBB LIBRARY") add_compile_definitions(SUANPAN_MT) + add_compile_definitions(ARMA_USE_TBB_ALLOC) if (COMPILER_IDENTIFIER MATCHES "gcc-win") link_libraries(tbb12) else () link_libraries(tbb) endif () + link_libraries(tbbmalloc tbbmalloc_proxy) endif () if (BUILD_SHARED) diff --git a/suanPan.cpp b/suanPan.cpp index ba6fa06c6..3c9d5742c 100644 --- a/suanPan.cpp +++ b/suanPan.cpp @@ -23,6 +23,10 @@ #include #endif +#ifdef SUANPAN_MKL +extern "C" void mkl_free_buffers(void); +#endif + // ReSharper disable once CppParameterMayBeConst int main(int argc, char** argv) { #ifdef SUANPAN_WIN @@ -44,5 +48,9 @@ int main(int argc, char** argv) { lis_finalize(); +#ifdef SUANPAN_MKL + std::atexit(mkl_free_buffers); +#endif + return SUANPAN_SUCCESS; }