14#include "arccore/base/NotImplementedException.h"
15#include "arccore/base/MemoryView.h"
16#include "arccore/base/PlatformUtils.h"
17#include "arccore/base/FatalErrorException.h"
21#include "arccore/common/accelerator/internal/IRunnerRuntime.h"
22#include "arccore/common/accelerator/internal/IRunQueueStream.h"
23#include "arccore/common/accelerator/internal/IRunQueueEventImpl.h"
24#include "arccore/common/accelerator/Memory.h"
25#include "arccore/common/accelerator/DeviceInfoList.h"
26#include "arccore/common/accelerator/DeviceMemoryInfo.h"
27#include "arccore/common/accelerator/NativeStream.h"
32namespace Arcane::Accelerator::Impl
38class ARCCORE_COMMON_EXPORT HostRunQueueStream
39:
public IRunQueueStream
43 explicit HostRunQueueStream(IRunnerRuntime* runtime)
49 void notifyBeginLaunchKernel(RunCommandImpl&)
override {
return m_runtime->notifyBeginLaunchKernel(); }
50 void notifyEndLaunchKernel(RunCommandImpl&)
override {
return m_runtime->notifyEndLaunchKernel(); }
51 void barrier()
override {
return m_runtime->barrier(); }
58 bool _barrierNoException()
override {
return false; }
62 IRunnerRuntime* m_runtime;
68class ARCCORE_COMMON_EXPORT HostRunQueueEvent
69:
public IRunQueueEventImpl
73 explicit HostRunQueueEvent(
bool has_timer)
74 : m_has_timer(has_timer)
79 void recordQueue(IRunQueueStream*)
final
85 void waitForEvent(IRunQueueStream*)
final {}
86 bool hasPendingWork()
final {
return false; }
87 Int64 elapsedTime(IRunQueueEventImpl* start_event)
final
90 auto* true_start_event =
static_cast<HostRunQueueEvent*
>(start_event);
91 if (!m_has_timer || !true_start_event->m_has_timer)
93 double diff_time = m_recorded_time - true_start_event->m_recorded_time;
94 Int64 diff_as_int64 =
static_cast<Int64>(diff_time * 1.0e9);
100 bool m_has_timer =
false;
101 double m_recorded_time = 0.0;
107class ARCCORE_COMMON_EXPORT CommonRunnerRuntime
108:
public IRunnerRuntime
112 CommonRunnerRuntime()
116 d.setName(
"HostDevice");
117 m_device_info_list.addDevice(d);
122 void notifyBeginLaunchKernel()
final {}
123 void notifyEndLaunchKernel()
final {}
124 void barrier()
final {}
126 IRunQueueEventImpl* createEventImpl()
final {
return new HostRunQueueEvent(
false); }
127 IRunQueueEventImpl* createEventImplWithTimer()
final {
return new HostRunQueueEvent(
true); }
130 void setCurrentDevice(
DeviceId)
final {}
131 const IDeviceInfoList* deviceInfoList()
final {
return &m_device_info_list; }
132 void getPointerAttribute(
PointerAttribute& attribute,
const void* ptr)
final
134 _fillPointerAttribute(attribute, ptr);
151:
public CommonRunnerRuntime
160:
public CommonRunnerRuntime
177extern "C++" ARCCORE_COMMON_EXPORT IRunnerRuntime*
178getSequentialRunQueueRuntime()
180 return &global_sequential_runqueue_runtime;
184extern "C++" ARCCORE_COMMON_EXPORT IRunnerRuntime*
185getThreadRunQueueRuntime()
187 return &global_thread_runqueue_runtime;
#define ARCCORE_FATAL(...)
Macro throwing a FatalErrorException.
#define ARCCORE_CHECK_POINTER(ptr)
Macro that returns the pointer ptr if it is not null or throws an exception if it is null.
Memory management utility functions.
Identifier of a system component.
Information about an accelerator.
Accelerator memory information.
Interface of a list of devices.
Interface for a list of devices.
Opaque type to encapsulate a native 'stream'.
Memory prefetching arguments.
Information about a memory address.
Information to create a RunQueue.
Constant view on a contiguous memory region containing fixed-size elements.
eMemoryAdvice
Memory management advice.
eExecutionPolicy
Execution policy for a Runner.
@ Sequential
Sequential execution policy.
@ Thread
Multi-threaded execution policy.
void copyHost(MutableMemoryView destination, ConstMemoryView source)
Copies the data from source into destination.
std::int64_t Int64
Signed integer type of 64 bits.