14#include "arccore/accelerator/internal/Initializer.h"
16#include "arccore/base/String.h"
17#include "arccore/base/PlatformUtils.h"
18#include "arccore/base/CoreArray.h"
20#include "arccore/common/List.h"
21#include "arccore/common/accelerator/internal/AcceleratorCoreGlobalInternal.h"
22#include "arccore/common/accelerator/internal/RuntimeLoader.h"
23#include "arccore/common/accelerator/internal/RunnerInternal.h"
24#include "arccore/common/accelerator/AcceleratorRuntimeInitialisationInfo.h"
36 _stringListToCoreArray(
const StringList& slist)
39 for (
const String& s : slist)
56Initializer(
bool use_accelerator,
Int32 max_allowed_thread)
57: m_trace_mng(arccoreCreateDefaultTraceMng())
59 const bool is_verbose =
false;
61 std::cout <<
"INIT_ACCELERATOR use?=" << use_accelerator <<
"\n";
62 if (use_accelerator) {
63 AcceleratorRuntimeInitialisationInfo init_info;
64 String default_runtime_name;
65#if defined(ARCCORE_HAS_CUDA)
66 default_runtime_name =
"cuda";
67#elif defined(ARCCORE_HAS_HIP)
68 default_runtime_name =
"hip";
69#elif defined(ARCCORE_HAS_SYCL)
70 default_runtime_name =
"sycl";
73 String dll_full_path = Platform::getLoadedSharedLibraryFullPath(
"arccore_accelerator");
75 if (!dll_full_path.null())
76 library_path = Platform::getFileDirName(dll_full_path);
77 if (library_path.null())
78 library_path = Platform::getCurrentDirectory();
81 std::cout <<
"INIT_ACCELERATOR default_runtime=" << default_runtime_name <<
" lib_path=" << library_path <<
"\n";
82 bool has_accelerator =
false;
83 init_info.setIsUsingAcceleratorRuntime(
true);
84 int r = Impl::RuntimeLoader::loadRuntime(init_info, default_runtime_name, library_path, has_accelerator);
86 if (Impl::isUsingCUDARuntime())
87 m_policy = eExecutionPolicy::CUDA;
88 else if (Impl::isUsingHIPRuntime())
89 m_policy = eExecutionPolicy::HIP;
90 else if (Impl::isUsingSYCLRuntime())
91 m_policy = eExecutionPolicy::SYCL;
95 m_concurrency_application.setTraceMng(m_trace_mng);
96 m_application_build_info.setDefaultValues();
97 m_application_build_info.setDefaultServices();
98 if (max_allowed_thread > 1)
99 m_application_build_info.setNbTaskThread(max_allowed_thread);
101 const auto& b = m_application_build_info;
102 auto task_names = _stringListToCoreArray(b.taskImplementationServices());
103 auto thread_names = _stringListToCoreArray(b.threadImplementationServices());
104 Int32 nb_task_thread = b.nbTaskThread();
105 ConcurrencyApplicationBuildInfo c(task_names.constView(), thread_names.constView(), nb_task_thread);
106 m_concurrency_application.setCoreServices(c);
109 if (max_allowed_thread > 1 && m_policy == eExecutionPolicy::Sequential)
110 m_policy = eExecutionPolicy::Thread;
118~Initializer() noexcept(false)
120 Accelerator::RunnerInternal::finalize(
nullptr);
Chaîne de caractères unicode.
Espace de nom pour l'utilisation des accélérateurs.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
List< String > StringList
Tableau de chaînes de caractères unicode.
std::int32_t Int32
Type entier signé sur 32 bits.