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 std::cout <<
"INIT_ACCELERATOR use?=" << use_accelerator <<
"\n";
60 if (use_accelerator) {
61 AcceleratorRuntimeInitialisationInfo init_info;
62 String default_runtime_name;
63#if defined(ARCCORE_HAS_CUDA)
64 default_runtime_name =
"cuda";
65#elif defined(ARCCORE_HAS_HIP)
66 default_runtime_name =
"hip";
67#elif defined(ARCCORE_HAS_SYCL)
68 default_runtime_name =
"sycl";
71 String dll_full_path = Platform::getLoadedSharedLibraryFullPath(
"arccore_accelerator");
73 if (!dll_full_path.null())
74 library_path = Platform::getFileDirName(dll_full_path);
75 if (library_path.null())
76 library_path = Platform::getCurrentDirectory();
78 std::cout <<
"INIT_ACCELERATOR default_runtime=" << default_runtime_name <<
" lib_path=" << library_path <<
"\n";
79 bool has_accelerator =
false;
80 init_info.setIsUsingAcceleratorRuntime(
true);
81 int r = Impl::RuntimeLoader::loadRuntime(init_info, default_runtime_name, library_path, has_accelerator);
83 if (Impl::isUsingCUDARuntime())
84 m_policy = eExecutionPolicy::CUDA;
85 else if (Impl::isUsingHIPRuntime())
86 m_policy = eExecutionPolicy::HIP;
87 else if (Impl::isUsingSYCLRuntime())
88 m_policy = eExecutionPolicy::SYCL;
92 m_concurrency_application.setTraceMng(m_trace_mng);
93 m_application_build_info.setDefaultValues();
94 m_application_build_info.setDefaultServices();
95 if (max_allowed_thread > 1)
96 m_application_build_info.setNbTaskThread(max_allowed_thread);
98 const auto& b = m_application_build_info;
99 auto task_names = _stringListToCoreArray(b.taskImplementationServices());
100 auto thread_names = _stringListToCoreArray(b.threadImplementationServices());
101 Int32 nb_task_thread = b.nbTaskThread();
102 ConcurrencyApplicationBuildInfo c(task_names.constView(), thread_names.constView(), nb_task_thread);
103 m_concurrency_application.setCoreServices(c);
105 if (max_allowed_thread > 1)
106 m_policy = eExecutionPolicy::Thread;
114~Initializer() noexcept(false)
116 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.