Arcane  v4.1.2.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Initializer.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* Initializer.h (C) 2000-2025 */
9/* */
10/* Classe pour initialiser le runtime accélérateur. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/accelerator/internal/Initializer.h"
15
16#include "arccore/base/String.h"
17#include "arccore/base/PlatformUtils.h"
18
19#include "arccore/common/accelerator/internal/RuntimeLoader.h"
20#include "arccore/common/accelerator/AcceleratorRuntimeInitialisationInfo.h"
21
22#include <iostream>
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::Accelerator
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32Initializer::
33Initializer(bool use_accelerator, Int32 max_allowed_thread)
34{
35 std::cout << "INIT_ACCELERATOR use?=" << use_accelerator << "\n";
36 if (use_accelerator) {
37 AcceleratorRuntimeInitialisationInfo init_info;
38 String default_runtime_name;
39#if defined(ARCCORE_HAS_CUDA)
40 default_runtime_name = "cuda";
41#elif defined(ARCCORE_HAS_HIP)
42 default_runtime_name = "hip";
43#elif defined(ARCCORE_HAS_SYCL)
44 default_runtime_name = "sycl";
45#endif
46
47 String dll_full_path = Platform::getLoadedSharedLibraryFullPath("arccore_accelerator");
48 String library_path;
49 if (!dll_full_path.null())
50 library_path = Platform::getFileDirName(dll_full_path);
51 if (library_path.null())
52 library_path = Platform::getCurrentDirectory();
53
54 std::cout << "INIT_ACCELERATOR default_runtime=" << default_runtime_name << " lib_path=" << library_path << "\n";
55 bool has_accelerator = false;
56 init_info.setIsUsingAcceleratorRuntime(true);
57 int r = Impl::RuntimeLoader::loadRuntime(init_info, default_runtime_name, library_path, has_accelerator);
58 }
59}
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64} // namespace Arcane::Accelerator
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
static int loadRuntime(AcceleratorRuntimeInitialisationInfo &init_info, const String &default_runtime_name, const String &library_path, bool &has_accelerator)
Détecte et charge la bibliothèque de gestion du runtime des accélérateurs.
Espace de nom pour l'utilisation des accélérateurs.
ARCCORE_BASE_EXPORT String getCurrentDirectory()
Chemin du répertoire courant.
ARCCORE_BASE_EXPORT String getFileDirName(const String &file_name)
Retourne le nom du répertoire d'un fichier.
ARCCORE_BASE_EXPORT String getLoadedSharedLibraryFullPath(const String &dll_name)
Retourne le chemin complet d'une bibliothèque dynamique chargée.
std::int32_t Int32
Type entier signé sur 32 bits.