Arcane
4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MpiLock.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
/* MpiLock.h (C) 2000-2025 */
9
/* */
10
/* Lock for MPI calls. */
11
/*---------------------------------------------------------------------------*/
12
#ifndef ARCANE_PARALLEL_MPI_MPILOCK_H
13
#define ARCANE_PARALLEL_MPI_MPILOCK_H
14
/*---------------------------------------------------------------------------*/
15
/*---------------------------------------------------------------------------*/
16
17
#include "arccore/concurrency/SpinLock.h"
18
#include "arccore/concurrency/Mutex.h"
19
20
#include "arccore/message_passing_mpi/MessagePassingMpiGlobal.h"
21
22
/*---------------------------------------------------------------------------*/
23
/*---------------------------------------------------------------------------*/
24
25
namespace
Arcane::MessagePassing::Mpi
26
{
27
28
/*---------------------------------------------------------------------------*/
29
/*---------------------------------------------------------------------------*/
30
37
class
MpiLock
38
{
39
public
:
40
41
// The spin lock is more performant but does not allow using valgrind.
42
43
//typedef SpinLock LockType;
44
45
typedef
Mutex
LockType;
46
47
public
:
48
49
class
Section
50
{
51
public
:
52
53
Section(MpiLock* lock)
54
: mpi_lock(lock)
55
{
56
if
(mpi_lock) {
57
manual_lock.lock(mpi_lock->m_lock);
58
}
59
}
60
~Section()
61
{
62
if
(mpi_lock)
63
manual_lock.unlock(mpi_lock->m_lock);
64
}
65
66
private
:
67
68
MpiLock* mpi_lock;
69
LockType::ManualLock
manual_lock;
70
};
71
friend
class
Section
;
72
73
public
:
74
75
MpiLock() {}
76
77
public
:
78
private
:
79
80
LockType m_lock;
81
};
82
83
/*---------------------------------------------------------------------------*/
84
/*---------------------------------------------------------------------------*/
85
86
}
// namespace Arcane::MessagePassing::Mpi
87
88
/*---------------------------------------------------------------------------*/
89
/*---------------------------------------------------------------------------*/
90
91
#endif
Arcane::MessagePassing::Mpi::MpiLock::Section
Definition
MpiLock.h:50
Arcane::Mutex::ManualLock
Definition
arccore/src/concurrency/arccore/concurrency/Mutex.h:61
Arcane::Mutex
Mutex.
Definition
arccore/src/concurrency/arccore/concurrency/Mutex.h:33
arccore
src
message_passing_mpi
arccore
message_passing_mpi
internal
MpiLock.h
Generated on
for Arcane by
1.16.1