Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
AcceleratorUtils.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* AcceleratorUtils.h (C) 2000-2024 */
9/* */
10/* Fonctions utilitaires communes à tous les runtimes. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_ACCELERATOR_ACCELERATORUTILS_H
13#define ARCANE_ACCELERATOR_ACCELERATORUTILS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.h"
18
19#include "arcane/accelerator/AcceleratorGlobal.h"
20#include "arcane/accelerator/core/RunQueue.h"
21
22#if defined(ARCANE_COMPILING_HIP)
23#include "arcane/accelerator/hip/HipAccelerator.h"
24#include <hip/hip_runtime.h>
25#include <rocprim/rocprim.hpp>
26#endif
27#if defined(ARCANE_COMPILING_CUDA)
28#include "arcane/accelerator/cuda/CudaAccelerator.h"
29#include <cub/cub.cuh>
30#endif
31#if defined(ARCANE_COMPILING_SYCL)
32#include "arcane/accelerator/sycl/SyclAccelerator.h"
33#include <sycl/sycl.hpp>
34#if defined(__INTEL_LLVM_COMPILER)
35#include <oneapi/dpl/execution>
36#include <oneapi/dpl/algorithm>
37#endif
38#endif
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
43namespace Arcane::Accelerator::impl
44{
45
46/*---------------------------------------------------------------------------*/
47/*---------------------------------------------------------------------------*/
48
49#if defined(ARCANE_COMPILING_CUDA)
50class ARCANE_ACCELERATOR_EXPORT CudaUtils
51{
52 public:
53
54 static cudaStream_t toNativeStream(const RunQueue* queue);
55 static cudaStream_t toNativeStream(const RunQueue& queue);
56};
57#endif
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62#if defined(ARCANE_COMPILING_HIP)
63class ARCANE_ACCELERATOR_EXPORT HipUtils
64{
65 public:
66
67 static hipStream_t toNativeStream(const RunQueue* queue);
68 static hipStream_t toNativeStream(const RunQueue& queue);
69};
70#endif
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75#if defined(ARCANE_COMPILING_SYCL)
76class ARCANE_ACCELERATOR_EXPORT SyclUtils
77{
78 public:
79
80 static sycl::queue toNativeStream(const RunQueue* queue);
81 static sycl::queue toNativeStream(const RunQueue& queue);
82};
83#endif
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88} // namespace Arcane::Accelerator::impl
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93namespace Arcane::Accelerator::AcceleratorUtils
94{
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99#if defined(ARCANE_COMPILING_CUDA)
105inline cudaStream_t
106toCudaNativeStream(const RunQueue& queue)
107{
108 return impl::CudaUtils::toNativeStream(queue);
109}
110#endif
111
112#if defined(ARCANE_COMPILING_HIP)
118inline hipStream_t
119toHipNativeStream(const RunQueue& queue)
120{
121 return impl::HipUtils::toNativeStream(queue);
122}
123#endif
124
125#if defined(ARCANE_COMPILING_SYCL)
131inline sycl::queue
132toSyclNativeStream(const RunQueue& queue)
133{
134 return impl::SyclUtils::toNativeStream(queue);
135}
136#endif
137
138/*---------------------------------------------------------------------------*/
139/*---------------------------------------------------------------------------*/
140
141} // namespace Arcane::Accelerator::AcceleratorUtils
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
146#endif
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/