Arcane
v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
MpiLock.h
1
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2
//-----------------------------------------------------------------------------
3
// Copyright 2000-2022 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-2018 */
9
/* */
10
/* Verrou pour les appels MPI. */
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
Arccore::MessagePassing::Mpi
26
{
27
28
/*---------------------------------------------------------------------------*/
29
/*---------------------------------------------------------------------------*/
30
/*!
31
* \brief Verrou pour les appels MPI.
32
*
33
* Ce verrou sert en multi-threading pour sérialiser les appels
34
* MPI en mode MPI_THREAD_SERIALIZED de MPI_Init_thread.
35
*/
36
class
MpiLock
37
{
38
public
:
39
40
// Le spin lock est plus performant mais ne permet pas d'utiliser
41
// valgrind.
42
43
//typedef SpinLock LockType;
44
45
typedef
Mutex
LockType
;
46
47
public
:
48
class
Section
49
{
50
public
:
51
Section
(
MpiLock
* lock) : mpi_lock(lock)
52
{
53
if
(mpi_lock){
54
manual_lock.lock(mpi_lock->m_lock);
55
}
56
}
57
~Section
()
58
{
59
if
(mpi_lock)
60
manual_lock.unlock(mpi_lock->m_lock);
61
}
62
private
:
63
MpiLock
* mpi_lock;
64
LockType::ManualLock
manual_lock;
65
};
66
friend
class
Section
;
67
public
:
68
MpiLock
() {}
69
public
:
70
private
:
71
LockType m_lock;
72
};
73
74
/*---------------------------------------------------------------------------*/
75
/*---------------------------------------------------------------------------*/
76
77
}
// namespace Arccore::MessagePassing::Mpi
78
79
/*---------------------------------------------------------------------------*/
80
/*---------------------------------------------------------------------------*/
81
82
#endif
83
Arccore::MessagePassing::Mpi::MpiLock::Section
Definition
MpiLock.h:49
Arccore::MessagePassing::Mpi::MpiLock
Verrou pour les appels MPI.
Definition
MpiLock.h:37
Arccore::Mutex::ManualLock
Definition
arccore/src/concurrency/arccore/concurrency/Mutex.h:62
Arccore::Mutex
Mutex.
Definition
arccore/src/concurrency/arccore/concurrency/Mutex.h:38
arccore
message_passing_mpi
MpiLock.h
Généré le Lundi 18 Novembre 2024 02:56:57 pour Arcane par
1.9.8