Skip to content

Commit b3efd3a

Browse files
[arcane,accelerator] Ajoute méthode 'RunQueueEvent::hasPendingWork()' pour savoir si les RunQueue associées à un évènement ont du travail.
Cette méthode encapsule 'cudaQueryEvent()' ou 'hipQueryEvent()'.
1 parent e001132 commit b3efd3a

File tree

7 files changed

+54
-8
lines changed

7 files changed

+54
-8
lines changed

arcane/src/arcane/accelerator/core/RunQueueEvent.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ wait()
142142
/*---------------------------------------------------------------------------*/
143143
/*---------------------------------------------------------------------------*/
144144

145+
bool RunQueueEvent::
146+
hasPendingWork() const
147+
{
148+
if (m_p)
149+
return m_p->m_impl->hasPendingWork();
150+
return false;
151+
}
152+
153+
/*---------------------------------------------------------------------------*/
154+
/*---------------------------------------------------------------------------*/
155+
145156
impl::IRunQueueEventImpl* RunQueueEvent::
146157
_internalEventImpl() const
147158
{

arcane/src/arcane/accelerator/core/RunQueueEvent.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ class ARCANE_ACCELERATOR_CORE_EXPORT RunQueueEvent
7474
//! Bloque tant que les files associées à cet évènement n'ont pas fini leur travail.
7575
void wait();
7676

77+
/*!
78+
* \brief Indique si les RunQueue associées à cet évènement ont fini leur travail.
79+
*
80+
* Retourne \a false si les RunQueue enregistrées via RunQueue::recordEvent() ont
81+
* fini leur travail. Retourn \a true sinon.
82+
*/
83+
bool hasPendingWork() const;
84+
7785
private:
7886

7987
impl::IRunQueueEventImpl* _internalEventImpl() const;

arcane/src/arcane/accelerator/core/RunQueueRuntime.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* RunQueueRuntime.cc (C) 2000-2024 */
8+
/* RunQueueRuntime.cc (C) 2000-2025 */
99
/* */
1010
/* Implémentation d'un RunQueue pour une cible donnée. */
1111
/*---------------------------------------------------------------------------*/
@@ -83,6 +83,7 @@ class ARCANE_ACCELERATOR_CORE_EXPORT HostRunQueueEvent
8383
}
8484
void wait() final {}
8585
void waitForEvent(IRunQueueStream*) final {}
86+
bool hasPendingWork() final { return false; }
8687
Int64 elapsedTime(IRunQueueEventImpl* start_event) final
8788
{
8889
ARCANE_CHECK_POINTER(start_event);

arcane/src/arcane/accelerator/core/internal/IRunQueueEventImpl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* IRunQueueEventImpl.h (C) 2000-2024 */
8+
/* IRunQueueEventImpl.h (C) 2000-2025 */
99
/* */
1010
/* Interface de l'implémentation d'un évènement. */
1111
/*---------------------------------------------------------------------------*/
@@ -42,6 +42,8 @@ class ARCANE_ACCELERATOR_CORE_EXPORT IRunQueueEventImpl
4242

4343
//! Temps écoulé (en nanoseconde) entre l'évènement \a from_event et cet évènement.
4444
virtual Int64 elapsedTime(IRunQueueEventImpl* from_event) = 0;
45+
46+
virtual bool hasPendingWork() =0;
4547
};
4648

4749
/*---------------------------------------------------------------------------*/

arcane/src/arcane/accelerator/cuda/runtime/CudaAcceleratorRuntime.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,15 @@ class CudaRunQueueEvent
232232
return nano_time;
233233
}
234234

235+
bool hasPendingWork() final
236+
{
237+
cudaError_t v = cudaEventQuery(m_cuda_event);
238+
if (v == cudaErrorNotReady)
239+
return true;
240+
ARCANE_CHECK_CUDA(v);
241+
return false;
242+
}
243+
235244
private:
236245

237246
cudaEvent_t m_cuda_event;

arcane/src/arcane/accelerator/hip/runtime/HipAcceleratorRuntime.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* HipAcceleratorRuntime.cc (C) 2000-2024 */
8+
/* HipAcceleratorRuntime.cc (C) 2000-2025 */
99
/* */
1010
/* Runtime pour 'HIP'. */
1111
/*---------------------------------------------------------------------------*/
@@ -187,6 +187,15 @@ class HipRunQueueEvent
187187
return nano_time;
188188
}
189189

190+
bool hasPendingWork() final
191+
{
192+
hipError_t v = hipEventQuery(m_hip_event);
193+
if (v == hipErrorNotReady)
194+
return true;
195+
ARCANE_CHECK_HIP(v);
196+
return false;
197+
}
198+
190199
private:
191200

192201
hipEvent_t m_hip_event;

arcane/src/arcane/accelerator/sycl/runtime/SyclAcceleratorRuntime.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* SyclAcceleratorRuntime.cc (C) 2000-2024 */
8+
/* SyclAcceleratorRuntime.cc (C) 2000-2025 */
99
/* */
1010
/* Runtime pour 'SYCL'. */
1111
/*---------------------------------------------------------------------------*/
@@ -16,6 +16,7 @@
1616

1717
#include "arcane/utils/PlatformUtils.h"
1818
#include "arcane/utils/NotSupportedException.h"
19+
#include "arcane/utils/NotImplementedException.h"
1920
#include "arcane/utils/FatalErrorException.h"
2021
#include "arcane/utils/IMemoryRessourceMng.h"
2122
#include "arcane/utils/internal/IMemoryRessourceMngInternal.h"
@@ -216,6 +217,11 @@ class SyclRunQueueEvent
216217
return (end - start);
217218
}
218219

220+
bool hasPendingWork() final
221+
{
222+
ARCANE_THROW(NotImplementedException,"hasPendingWork()");
223+
}
224+
219225
private:
220226

221227
sycl::event m_sycl_event;

0 commit comments

Comments
 (0)