Skip to content

Commit 6f7fad1

Browse files
Merge pull request #1207 from arcaneframework/dev/gg-add-internal-barrier-no-exception
Add method to synchronize stream without launching exception in case of error
2 parents 84fac7d + 5303b38 commit 6f7fad1

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

arcane/src/arcane/accelerator/core/IRunQueueStream.h

+5-2
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-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 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-
/* IRunQueueStream.h (C) 2000-2022 */
8+
/* IRunQueueStream.h (C) 2000-2024 */
99
/* */
1010
/* Interface d'un flux d'exécution pour une RunQueue. */
1111
/*---------------------------------------------------------------------------*/
@@ -65,6 +65,9 @@ class ARCANE_ACCELERATOR_CORE_EXPORT IRunQueueStream
6565

6666
//! Pointeur sur la structure interne dépendante de l'implémentation
6767
virtual void* _internalImpl() = 0;
68+
69+
//! Barrière sans exception. Retourne \a true en cas d'erreur
70+
virtual bool _barrierNoException() = 0;
6871
};
6972

7073
/*---------------------------------------------------------------------------*/

arcane/src/arcane/accelerator/core/RunQueueImpl.cc

+9-4
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-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 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-
/* RunQueueImpl.cc (C) 2000-2023 */
8+
/* RunQueueImpl.cc (C) 2000-2024 */
99
/* */
1010
/* Gestion d'une file d'exécution sur accélérateur. */
1111
/*---------------------------------------------------------------------------*/
@@ -68,8 +68,13 @@ _release()
6868
// les commandes ne seront pas désallouées.
6969
// TODO: Regarder s'il ne faudrait pas plutôt indiquer cela à l'utilisateur
7070
// ou faire une erreur fatale.
71-
if (!m_active_run_command_list.empty())
72-
_internalBarrier();
71+
if (!m_active_run_command_list.empty()){
72+
if (!_internalStream()->_barrierNoException()){
73+
_internalFreeRunningCommands();
74+
}
75+
else
76+
std::cerr << "WARNING: Error in internal accelerator barrier\n";
77+
}
7378
if (_isInPool())
7479
m_runner->_internalPutRunQueueImplInPool(this);
7580
else

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

+3-2
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-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 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-2022 */
8+
/* RunQueueRuntime.cc (C) 2000-2024 */
99
/* */
1010
/* Implémentation d'un RunQueue pour une cible donnée. */
1111
/*---------------------------------------------------------------------------*/
@@ -53,6 +53,7 @@ class ARCANE_ACCELERATOR_CORE_EXPORT HostRunQueueStream
5353
}
5454
void prefetchMemory(const MemoryPrefetchArgs&) override {}
5555
void* _internalImpl() override { return nullptr; }
56+
bool _barrierNoException() override { return false; }
5657

5758
private:
5859

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

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ class CudaRunQueueStream
148148
if (global_cupti_flush > 0)
149149
flushCupti();
150150
}
151+
bool _barrierNoException() override
152+
{
153+
return (cudaStreamSynchronize(m_cuda_stream)!=CUDA_SUCCESS);
154+
}
151155
void copyMemory(const MemoryCopyArgs& args) override
152156
{
153157
auto source_bytes = args.source().bytes();

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

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ class HipRunQueueStream
9090
{
9191
ARCANE_CHECK_HIP(hipStreamSynchronize(m_hip_stream));
9292
}
93+
bool _barrierNoException() override
94+
{
95+
return hipStreamSynchronize(m_hip_stream) != HIP_SUCCESS;
96+
}
9397
void copyMemory(const MemoryCopyArgs& args) override
9498
{
9599
auto r = hipMemcpyAsync(args.destination().data(), args.source().data(),

arcane/src/arcane/core/materials/ComponentItemInternal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ _superItemBase(ConstituentItemIndex id) const
437437
return m_super_component_item_shared_info->_item(super_local_id);
438438
}
439439

440-
inline matimpl::ConstituentItemBase ComponentItemSharedInfo::
440+
inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase ComponentItemSharedInfo::
441441
_subItemBase(ConstituentItemIndex id,Int32 sub_index) const
442442
{
443443
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);

0 commit comments

Comments
 (0)