Skip to content

Commit

Permalink
Use tbb allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
TLCFEM committed Aug 11, 2023
1 parent fe6d316 commit 0be8d0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 1 addition & 3 deletions Domain/MetaMat/SparseMatFGMRES.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ template<sp_d T> class SparseMatBaseFGMRES : public SparseMat<T> {
SparseMatBaseFGMRES& operator=(const SparseMatBaseFGMRES&) = delete;
SparseMatBaseFGMRES& operator=(SparseMatBaseFGMRES&&) noexcept = delete;

~SparseMatBaseFGMRES() override {
mkl_free_buffers();
}
~SparseMatBaseFGMRES() override = default;
};

template<sp_d T> int SparseMatBaseFGMRES<T>::direct_solve(Mat<T>& X, const Mat<T>& B) {
Expand Down
4 changes: 3 additions & 1 deletion Option.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions suanPan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include <Windows.h>
#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
Expand All @@ -44,5 +48,9 @@ int main(int argc, char** argv) {

lis_finalize();

#ifdef SUANPAN_MKL
std::atexit(mkl_free_buffers);
#endif

return SUANPAN_SUCCESS;
}

0 comments on commit 0be8d0b

Please sign in to comment.