ツール tbb::parallel_for を使用して、TBB ライブラリ経由でコードを並列化しようとしています。私は Mac OS コンピュータを使用しており、Homebrew で Tbb をダウンロードしてインストールしました。
Tbb は Macintosh HD ▸ opt ▸ intel ▸ compilers_and_libraries_2020.1.216 ▸ mac ▸ tbb ▸ include にあります。
コンパイルしようとすると、次のエラーが表示されます。
"tbb::interface5::internal::task_base::destroy(tbb::task&)", referenced from:
tbb::flow::interface10::graph::~graph() in interface_stokes.cpp.o
"tbb::interface7::internal::task_arena_base::internal_terminate()", referenced from:
tbb::interface7::task_arena::terminate() in interface_stokes.cpp.o
"tbb::interface7::internal::task_arena_base::internal_initialize()", referenced from:
tbb::interface7::task_arena::initialize() in interface_stokes.cpp.o
"tbb::task_group_context::init()", referenced from:
tbb::task_group_context::task_group_context(tbb::internal::string_index) in interface_stokes.cpp.o
"tbb::task_group_context::reset()", referenced from:
tbb::flow::interface10::graph::wait_for_all() in interface_stokes.cpp.o
"tbb::task_group_context::~task_group_context()", referenced from:
tbb::flow::interface10::graph::~graph() in interface_stokes.cpp.o
tbb::interface9::internal::start_for<tbb::blocked_range<unsigned long>, tbb::internal::parallel_for_body<main::$_0, unsigned long>, tbb::auto_partitioner const>::run(tbb::blocked_range<unsigned long> const&, tbb::internal::parallel_for_body<main::$_0, unsigned long> const&, tbb::auto_partitioner const&) in interface_stokes.cpp.o
"tbb::task::note_affinity(unsigned short)", referenced from:
vtable for tbb::interface9::internal::flag_task in interface_stokes.cpp.o
"tbb::internal::throw_exception_v4(tbb::internal::exception_id)", referenced from:
tbb::internal::throw_exception(tbb::internal::exception_id) in interface_stokes.cpp.o
"tbb::internal::get_initial_auto_partitioner_divisor()", referenced from:
tbb::interface9::internal::adaptive_mode<tbb::interface9::internal::auto_partition_type>::adaptive_mode() in interface_stokes.cpp.o
"tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const", referenced from:
void tbb::interface7::task_arena::execute_impl<void, tbb::flow::interface10::graph::wait_functor const>(tbb::flow::interface10::graph::wait_functor const&) in interface_stokes.cpp.o
"tbb::task_group_context::is_group_execution_cancelled() const", referenced from:
tbb::flow::interface10::graph::wait_for_all() in interface_stokes.cpp.o
tbb::task::is_cancelled() const in interface_stokes.cpp.o
"tbb::internal::allocate_child_proxy::allocate(unsigned long) const", referenced from:
tbb::interface9::internal::allocate_sibling(tbb::task*, unsigned long) in interface_stokes.cpp.o
"tbb::internal::allocate_continuation_proxy::free(tbb::task&) const", referenced from:
operator delete(void*, tbb::internal::allocate_continuation_proxy const&) in interface_stokes.cpp.o
"tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const", referenced from:
operator new(unsigned long, tbb::internal::allocate_continuation_proxy const&) in interface_stokes.cpp.o
"tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const", referenced from:
operator delete(void*, tbb::internal::allocate_root_with_context_proxy const&) in interface_stokes.cpp.o
"tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const", referenced from:
operator new(unsigned long, tbb::internal::allocate_root_with_context_proxy const&) in interface_stokes.cpp.o
"typeinfo for tbb::task", referenced from:
typeinfo for tbb::interface9::internal::start_for<tbb::blocked_range<unsigned long>, tbb::internal::parallel_for_body<main::$_0, unsigned long>, tbb::auto_partitioner const> in interface_stokes.cpp.o
typeinfo for tbb::interface9::internal::flag_task in interface_stokes.cpp.o
"vtable for tbb::task", referenced from:
tbb::task::task() in interface_stokes.cpp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [apps/interface_stokes/interface_stokes] Error 1
make[1]: *** [apps/interface_stokes/CMakeFiles/interface_stokes.dir/all] Error 2
make: *** [all] Error 2
自分の作業をコンパイルするには (TBB とは別のフォルダーに保存されます)、Cmakelists を使用します。
#Additional modules path for cmake
set (CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(safeguards)
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++14 -g -fpermissive -fsanitize=address")
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++14 -O3 -mavx -g -fpermissive")
set(CMAKE_CXX_FLAGS_RELEASEASSERT "-std=c++14 -O3 -mavx -g -fpermissive")
find_package(TBB)
if (TBB_FOUND)
include_directories(${TBB_INCLUDE_DIRS})
set(LINK_LIBS ${LINK_LIBS} ${TBB_LIBRARIES})
set(HAVE_INTEL_TBB TRUE)
endif()
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}")
include_directories(src)
include_directories(contrib)
add_subdirectory(apps)
add_subdirectory(tests)
add_subdirectory(output)
私のプログラムには、cmake という名前の別のフォルダーもあり、その中にいくつかのファイル .cmake がありますが、実際にはその目的がわかりません。
私はこのテーマを研究したことがなく、すでに構築されたコードに取り組んでいます。エラーの原因は、私のコードと Tbb ライブラリの不適切なリンクによるものだと思います。誰かがそれを修正する方法を知っていますか? 事前にどうもありがとうステファノ