Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
CommonAcceleratorGlobal.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* AcceleratorCoreGlobal.h (C) 2000-2026 */
9/* */
10/* General declarations for accelerator support. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_ACCELERATOR_COMMONACCELERATORCOREGLOBAL_H
13#define ARCCORE_COMMON_ACCELERATOR_COMMONACCELERATORCOREGLOBAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/common/CommonGlobal.h"
18#include "arccore/trace/TraceGlobal.h"
19
20#include <iosfwd>
21
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35namespace Arcane::Accelerator
36{
37
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
40
41class IAcceleratorMng;
42class Runner;
43class RunQueue;
44class RunQueuePool;
45class RunCommand;
46class RunQueueEvent;
49class MemoryCopyArgs;
51class DeviceId;
52class DeviceInfo;
54class ProfileRegion;
55class IDeviceInfoList;
57class ViewBuildInfo;
58class RunnerInternal;
59enum class eMemoryAdvice;
60
61namespace Impl
62{
64 class IRunnerRuntime;
65 // typedef for compatibility with older versions (October 2022)
66 using IRunQueueRuntime = IRunnerRuntime;
67 class IRunQueueStream;
68 class RunCommandImpl;
70 class ReduceMemoryImpl;
71 class RunQueueImpl;
73 class RunnerImpl;
75 class KernelLaunchArgs;
77 class NativeStream;
78 class CudaUtils;
79 class HipUtils;
80 class SyclUtils;
81} // namespace Impl
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
85
104
106extern "C++" ARCCORE_COMMON_EXPORT
107std::ostream&
108operator<<(std::ostream& o, eExecutionPolicy exec_policy);
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
112
119{
126 Atomic ARCCORE_DEPRECATED_REASON("Y2025: Use eDeviceReducePolicy::Grid instead") = 1,
129};
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
133
138enum class eRunQueuePriority : int
139{
143 High = -100,
145 Low = 100
146};
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
153{
154 //NOTE: The values are equivalent to cudaMemoryType. If
155 // these values are changed, the corresponding function
156 // in the runtime (getPointerAttribute()) must be changed.
157 Unregistered = 0,
158 Host = 1,
159 Device = 2,
160 Managed = 3
161};
162
164extern "C++" ARCCORE_COMMON_EXPORT
165std::ostream&
166operator<<(std::ostream& o, ePointerMemoryType mem_type);
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
180{
184 No = 1,
186 Yes = 2
187};
188
189/*---------------------------------------------------------------------------*/
190/*---------------------------------------------------------------------------*/
191
193inline bool
195{
196 return exec_policy == eExecutionPolicy::CUDA || exec_policy == eExecutionPolicy::HIP || exec_policy == eExecutionPolicy::SYCL;
197}
198
199/*---------------------------------------------------------------------------*/
200/*---------------------------------------------------------------------------*/
201
209extern "C++" ARCCORE_COMMON_EXPORT ePointerAccessibility
210getPointerAccessibility(RunQueue* queue, const void* ptr, PointerAttribute* ptr_attr = nullptr);
211
219extern "C++" ARCCORE_COMMON_EXPORT ePointerAccessibility
220getPointerAccessibility(Runner* runner, const void* ptr, PointerAttribute* ptr_attr = nullptr);
221
228extern "C++" ARCCORE_COMMON_EXPORT ePointerAccessibility
229getPointerAccessibility(eExecutionPolicy policy, const void* ptr, PointerAttribute* ptr_attr = nullptr);
230
232template <typename T> inline ePointerAccessibility
233getPointerAccessibility(T& queue_or_runner_or_policy, const void* ptr, PointerAttribute* ptr_attr = nullptr)
234{
235 return getPointerAccessibility(&queue_or_runner_or_policy, ptr, ptr_attr);
236}
237
238/*---------------------------------------------------------------------------*/
239/*---------------------------------------------------------------------------*/
240
241} // namespace Arcane::Accelerator
242
243/*---------------------------------------------------------------------------*/
244/*---------------------------------------------------------------------------*/
245
246namespace Arcane::Accelerator::Impl
247{
248
254extern "C++" ARCCORE_COMMON_EXPORT void
255arcaneCheckPointerIsAccessible(const RunQueue* queue, const void* ptr,
256 const char* name, const TraceInfo& ti);
257
263extern "C++" ARCCORE_COMMON_EXPORT void
264arcaneCheckPointerIsAccessible(const Runner* runner, const void* ptr,
265 const char* name, const TraceInfo& ti);
266
272extern "C++" ARCCORE_COMMON_EXPORT void
273arcaneCheckPointerIsAccessible(eExecutionPolicy policy, const void* ptr,
274 const char* name, const TraceInfo& ti);
275
276inline void
277arcaneCheckPointerIsAccessible(const RunQueue& queue, const void* ptr,
278 const char* name, const TraceInfo& ti)
279{
280 arcaneCheckPointerIsAccessible(&queue, ptr, name, ti);
281}
282
283inline void
284arcaneCheckPointerIsAccessible(const Runner& runner, const void* ptr,
285 const char* name, const TraceInfo& ti)
286{
287 arcaneCheckPointerIsAccessible(&runner, ptr, name, ti);
288}
289
290} // namespace Arcane::Accelerator::Impl
291
292/*---------------------------------------------------------------------------*/
293/*---------------------------------------------------------------------------*/
294
300#define ARCCORE_CHECK_ACCESSIBLE_POINTER_ALWAYS(queue_or_runner_or_policy, ptr) \
301 ::Arcane::Accelerator::Impl::arcaneCheckPointerIsAccessible((queue_or_runner_or_policy), (ptr), #ptr, A_FUNCINFO)
302
303#define ARCANE_CHECK_ACCESSIBLE_POINTER_ALWAYS(queue_or_runner_or_policy, ptr) \
304 ARCANE_CHECK_ACCESSIBLE_POINTER_ALWAYS((queue_or_runner_or_policy), (ptr))
305
306/*---------------------------------------------------------------------------*/
307/*---------------------------------------------------------------------------*/
308
309#if defined(ARCCORE_CHECK)
310
312#define ARCCORE_CHECK_ACCESSIBLE_POINTER(queue_or_runner_or_policy, ptr) \
313 ARCCORE_CHECK_ACCESSIBLE_POINTER_ALWAYS((queue_or_runner_or_policy), (ptr))
314
315#define ARCANE_CHECK_ACCESSIBLE_POINTER(queue_or_runner_or_policy, ptr) \
316 ARCCORE_CHECK_ACCESSIBLE_POINTER((queue_or_runner_or_policy), (ptr))
317
319#else
320
322#define ARCCORE_CHECK_ACCESSIBLE_POINTER(queue_or_runner_or_policy, ptr)
323
324#define ARCANE_CHECK_ACCESSIBLE_POINTER(queue_or_runner_or_policy, ptr)
325
326#endif
327
328/*---------------------------------------------------------------------------*/
329/*---------------------------------------------------------------------------*/
330
331namespace Arcane::Accelerator::impl
332{
333
334// For compatibility with older versions of Arcane.
335// To be deprecated by the end of 2026.
337} // namespace Arcane::Accelerator::impl
338
339/*---------------------------------------------------------------------------*/
340/*---------------------------------------------------------------------------*/
341
342#endif
Interface for event implementation.
Interface of an execution stream for a RunQueue.
Interface of the runtime associated with an accelerator.
Temporary object to store the execution information of a command and group tests.
Static class providing internal functions for Arcane.
ePointerAccessibility getPointerAccessibility(eExecutionPolicy policy, const void *ptr, PointerAttribute *ptr_attr)
Accessibility of address ptr for execution policypolicy.
eDeviceReducePolicy
Reduction operation policy on accelerators.
@ Grid
Uses a compute kernel with synchronization between blocks.
@ Atomic
Uses atomic operations between blocks.
ePointerAccessibility
Accessibility information of a memory address.
ePointerMemoryType
Memory type for a pointer.
eExecutionPolicy
Execution policy for a Runner.
@ SYCL
Execution policy using the SYCL environment.
@ HIP
Execution policy using the HIP environment.
@ CUDA
Execution policy using the CUDA environment.
@ Thread
Multi-threaded execution policy.
eRunQueuePriority
Predefined priority levels for run queues on accelerators.
@ Low
An arbitrary positive value to define a low priority.
@ High
An arbitrary negative value to define a high priority.
bool isAcceleratorPolicy(eExecutionPolicy exec_policy)
Indicates if exec_policy corresponds to an accelerator.