Arcane  v3.15.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
RunQueueEvent.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/* RunQueueEvent.cc (C) 2000-2025 */
9/* */
10/* Evènement sur une file d'exécution. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/accelerator/core/RunQueueEvent.h"
15
16#include "arcane/utils/FatalErrorException.h"
17
18#include "arcane/accelerator/core/internal/IRunQueueEventImpl.h"
19#include "arcane/accelerator/core/Runner.h"
20#include "arcane/accelerator/core/internal/RunnerImpl.h"
21
22#include <iostream>
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane::Accelerator
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
34{
35 public:
36
38 : m_impl(p)
39 {}
40 ~Impl()
41 {
42 delete m_impl;
43 }
44
45 public:
46
47 void addRef()
48 {
49 ++m_nb_ref;
50 }
51 void removeRef()
52 {
53 Int32 v = std::atomic_fetch_add(&m_nb_ref, -1);
54 if (v == 1)
55 delete this;
56 }
57
58 public:
59
60 impl::IRunQueueEventImpl* m_impl = nullptr;
61
62 private:
63
65 std::atomic<Int32> m_nb_ref = 0;
66};
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
71RunQueueEvent::
72RunQueueEvent()
73{
74}
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
78
79RunQueueEvent::
80RunQueueEvent(const Runner& runner)
81: m_p(new Impl(runner._impl()->_createEvent()))
82{
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88RunQueueEvent::
89RunQueueEvent(const RunQueueEvent& x)
90: m_p(x.m_p)
91{
92}
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97RunQueueEvent::
98RunQueueEvent(RunQueueEvent&& x) noexcept
99: m_p(x.m_p)
100{
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106RunQueueEvent& RunQueueEvent::
107operator=(const RunQueueEvent& x)
108{
109 if (&x != this)
110 m_p = x.m_p;
111 return (*this);
112}
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117RunQueueEvent& RunQueueEvent::
118operator=(RunQueueEvent&& x) noexcept
119{
120 m_p = x.m_p;
121 return (*this);
122}
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
126
127RunQueueEvent::
128~RunQueueEvent()
129{
130}
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
134
136wait()
137{
138 if (m_p)
139 m_p->m_impl->wait();
140}
141
142/*---------------------------------------------------------------------------*/
143/*---------------------------------------------------------------------------*/
144
145impl::IRunQueueEventImpl* RunQueueEvent::
146_internalEventImpl() const
147{
148 if (!m_p)
149 ARCANE_FATAL("Invalid usage of null RunQueueEvent");
150 return m_p->m_impl;
151}
152
153/*---------------------------------------------------------------------------*/
154/*---------------------------------------------------------------------------*/
155
156} // End namespace Arcane::Accelerator
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
std::atomic< Int32 > m_nb_ref
Nombre de références sur l'instance.
Evènement pour une file d'exécution.
void wait()
Bloque tant que les files associées à cet évènement n'ont pas fini leur travail.
Gestionnaire d'exécution pour accélérateur.
Definition core/Runner.h:68
Interface de l'implémentation d'un évènement.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:149
Espace de nom pour l'utilisation des accélérateurs.