Arcane  v4.1.7.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ProfilingInternal.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/* ProfilingInternal.h (C) 2000-2026 */
9/* */
10/* Classes internes pour gérer le profilage. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_BASE_INTERNAL_PROFILINGINTERNAL_H
13#define ARCCORE_BASE_INTERNAL_PROFILINGINTERNAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17// Note: ce fichier n'est pas disponible pour les utilisateurs de Arcane.
18// Il ne faut donc pas l'inclure dans un fichier d'en-tête public.
19
20#include "arccore/base/String.h"
21#include "arccore/base/FixedArray.h"
22#include "arccore/base/Profiling.h"
23
24#include <map>
25#include <atomic>
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arcane::Impl
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
38struct ARCCORE_BASE_EXPORT ForLoopProfilingStat
39{
40 public:
41
43 void add(const ForLoopOneExecStat& s);
44
45 Int64 nbCall() const { return m_nb_call; }
46 Int64 nbChunk() const { return m_nb_chunk; }
47 Int64 execTime() const { return m_exec_time; }
48
49 private:
50
51 Int64 m_nb_call = 0;
52 Int64 m_nb_chunk = 0;
53 Int64 m_exec_time = 0;
54};
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
59class ARCCORE_BASE_EXPORT ForLoopStatInfoListImpl
60{
61 public:
62
63 void print(std::ostream& o);
64
65 public:
66
67 // TODO Utiliser un hash pour le map plutôt qu'une String pour accélérer les comparaisons
68 std::map<String, ForLoopProfilingStat> m_stat_map;
69};
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
76class ARCCORE_BASE_EXPORT ForLoopCumulativeStat
77{
78 public:
79
80 void merge(const ForLoopOneExecStat& s)
81 {
82 ++m_nb_loop_parallel_for;
83 m_nb_chunk_parallel_for += s.nbChunk();
84 m_total_time += s.execTime();
85 }
86
87 public:
88
89 Int64 nbLoopParallelFor() const { return m_nb_loop_parallel_for.load(); }
90 Int64 nbChunkParallelFor() const { return m_nb_chunk_parallel_for.load(); }
91 Int64 totalTime() const { return m_total_time.load(); }
92
93 private:
94
95 std::atomic<Int64> m_nb_loop_parallel_for = 0;
96 std::atomic<Int64> m_nb_chunk_parallel_for = 0;
97 std::atomic<Int64> m_total_time = 0;
98};
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
108class ARCCORE_BASE_EXPORT AcceleratorStatInfoList
109{
110 public:
111
114 {
115 public:
116
117 void merge(const MemoryTransferInfo& mem_info)
118 {
119 m_nb_byte += mem_info.m_nb_byte;
120 m_nb_call += mem_info.m_nb_call;
121 }
122
123 public:
124
125 Int64 m_nb_byte = 0;
126 Int64 m_nb_call = 0;
127 };
128
131 {
132 public:
133
134 void merge(const MemoryPageFaultInfo& mem_info)
135 {
136 m_nb_fault += mem_info.m_nb_fault;
137 m_nb_call += mem_info.m_nb_call;
138 }
139
140 public:
141
142 Int64 m_nb_fault = 0;
143 Int64 m_nb_call = 0;
144 };
145
146 enum class eMemoryTransferType
147 {
148 HostToDevice = 0,
149 DeviceToHost = 1
150 };
151 enum class eMemoryPageFaultType
152 {
153 Gpu = 0,
154 Cpu = 1
155 };
156
157 public:
158
159 void addMemoryTransfer(eMemoryTransferType type, Int64 nb_byte)
160 {
161 MemoryTransferInfo mem_info{ nb_byte, 1 };
162 m_managed_memory_transfer_list[(int)type].merge(mem_info);
163 }
164 const MemoryTransferInfo& memoryTransfer(eMemoryTransferType type) const
165 {
166 return m_managed_memory_transfer_list[(int)type];
167 }
168 void addMemoryPageFault(eMemoryPageFaultType type, Int64 nb_byte)
169 {
170 MemoryPageFaultInfo mem_info{ nb_byte, 1 };
171 m_managed_memory_page_fault_list[(int)type].merge(mem_info);
172 }
173 const MemoryPageFaultInfo& memoryPageFault(eMemoryPageFaultType type) const
174 {
175 return m_managed_memory_page_fault_list[(int)type];
176 }
177
178 public:
179
180 void print(std::ostream& ostr) const;
181
182 private:
183
184 // Doit avoir le même nombre d'éléments que 'eMemoryTransfertType'
185 FixedArray<MemoryTransferInfo, 2> m_managed_memory_transfer_list;
186
187 // Doit avoir le même nombre d'éléments que 'eMemoryPageFaultType'
188 FixedArray<MemoryPageFaultInfo, 2> m_managed_memory_page_fault_list;
189};
190
191/*---------------------------------------------------------------------------*/
192/*---------------------------------------------------------------------------*/
193
197extern "C++" ARCCORE_BASE_EXPORT void
198dumpProfilingStatistics(std::ostream& o);
199
200/*---------------------------------------------------------------------------*/
201/*---------------------------------------------------------------------------*/
202
203} // namespace Arcane::Impl
204
205/*---------------------------------------------------------------------------*/
206/*---------------------------------------------------------------------------*/
207
208#endif
ARCCORE_COMMON_EXPORT Int32 print(ITraceMng *tm, bool is_no_continue=true)
Imprime un message pour une exception inconnue.
Informations sur les défauts de page sur CPU ou GPU.
Informations sur les transferts mémoire entre CPU et GPU.
Classe pour gérer le profiling d'une seule exécution d'une boucle.
Int64 execTime() const
Temps d'exécution (en nanoseconde).
Statistiques pour les accélérateurs.
Statistiques cumulées sur le nombre de boucles exécutées.
std::int64_t Int64
Type entier signé sur 64 bits.
Statistiques d'exécution d'une boucle.
void add(const ForLoopOneExecStat &s)
Ajoute les infos de l'exécution s.
Definition Profiling.cc:330