14#include "arcane/utils/NotImplementedException.h"
15#include "arcane/utils/MemoryView.h"
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/FatalErrorException.h"
20#include "arcane/accelerator/core/internal/IRunnerRuntime.h"
21#include "arcane/accelerator/core/internal/IRunQueueStream.h"
22#include "arcane/accelerator/core/internal/IRunQueueEventImpl.h"
23#include "arcane/accelerator/core/Memory.h"
24#include "arcane/accelerator/core/DeviceInfoList.h"
25#include "arcane/accelerator/core/DeviceMemoryInfo.h"
26#include "arcane/accelerator/core/NativeStream.h"
33namespace Arcane::Accelerator::impl
39class ARCANE_ACCELERATOR_CORE_EXPORT HostRunQueueStream
40:
public IRunQueueStream
44 HostRunQueueStream(IRunnerRuntime* runtime)
50 void notifyBeginLaunchKernel(RunCommandImpl&)
override {
return m_runtime->notifyBeginLaunchKernel(); }
51 void notifyEndLaunchKernel(RunCommandImpl&)
override {
return m_runtime->notifyEndLaunchKernel(); }
52 void barrier()
override {
return m_runtime->barrier(); }
59 bool _barrierNoException()
override {
return false; }
63 IRunnerRuntime* m_runtime;
69class ARCANE_ACCELERATOR_CORE_EXPORT HostRunQueueEvent
70:
public IRunQueueEventImpl
74 explicit HostRunQueueEvent(
bool has_timer)
75 : m_has_timer(has_timer)
80 void recordQueue(IRunQueueStream*)
final
86 void waitForEvent(IRunQueueStream*)
final {}
87 bool hasPendingWork()
final {
return false; }
88 Int64 elapsedTime(IRunQueueEventImpl* start_event)
final
91 auto* true_start_event =
static_cast<HostRunQueueEvent*
>(start_event);
92 if (!m_has_timer || !true_start_event->m_has_timer)
94 double diff_time = m_recorded_time - true_start_event->m_recorded_time;
95 Int64 diff_as_int64 =
static_cast<Int64>(diff_time * 1.0e9);
101 bool m_has_timer =
false;
102 double m_recorded_time = 0.0;
108class ARCANE_ACCELERATOR_CORE_EXPORT CommonRunnerRuntime
109:
public IRunnerRuntime
113 CommonRunnerRuntime()
117 d.setName(
"HostDevice");
118 m_device_info_list.addDevice(d);
123 void notifyBeginLaunchKernel()
final {}
124 void notifyEndLaunchKernel()
final {}
125 void barrier()
final {}
127 IRunQueueEventImpl* createEventImpl()
final {
return new HostRunQueueEvent(
false); }
128 IRunQueueEventImpl* createEventImplWithTimer()
final {
return new HostRunQueueEvent(
true); }
131 void setCurrentDevice(
DeviceId)
final {}
132 const IDeviceInfoList* deviceInfoList()
final {
return &m_device_info_list; }
133 void getPointerAttribute(
PointerAttribute& attribute,
const void* ptr)
final
135 _fillPointerAttribute(attribute, ptr);
152:
public CommonRunnerRuntime
161:
public CommonRunnerRuntime
178extern "C++" ARCANE_ACCELERATOR_CORE_EXPORT IRunnerRuntime*
179getSequentialRunQueueRuntime()
181 return &global_sequential_runqueue_runtime;
185extern "C++" ARCANE_ACCELERATOR_CORE_EXPORT IRunnerRuntime*
186getThreadRunQueueRuntime()
188 return &global_thread_runqueue_runtime;
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Fonctions de gestion mémoire et des allocateurs.
Identifiant d'un composant du système.
Information sur un device.
Information mémoire d'un accélérateur.
Interface d'une liste de devices.
Arguments pour la copie mémoire.
Arguments pour le préfetching mémoire.
Informations sur une adresse mémoire.
Informations pour créer une RunQueue.
Interface d'une liste de devices.
Type opaque pour encapsuler une 'stream' native.
Vue constante sur une zone mémoire contigue contenant des éléments de taille fixe.
eMemoryAdvice
Conseils pour la gestion mémoire.
eExecutionPolicy
Politique d'exécution pour un Runner.
@ Sequential
Politique d'exécution séquentielle.
@ Thread
Politique d'exécution multi-thread.
void copyHost(MutableMemoryView destination, ConstMemoryView source)
Copie dans destination les données de source.
std::int64_t Int64
Type entier signé sur 64 bits.