14#include "arcane/utils/IPerformanceCounterService.h"
15#include "arcane/utils/TraceAccessor.h"
16#include "arcane/utils/FatalErrorException.h"
18#include "arcane/FactoryService.h"
20#include <linux/perf_event.h>
21#include <linux/hw_breakpoint.h>
64 memset(&attr, 0,
sizeof(attr));
69 attr.exclude_kernel = 1;
76 unsigned long flags = 0;
78 info(4) <<
"AddEvent type=" << attr.type <<
" id=" << attr.config <<
" fd=" <<
long_fd;
85 m_events_file_descriptor.
add(
fd);
94 info(4) <<
"LinuxPerf: Start";
95 for (
int fd : m_events_file_descriptor) {
106 info(4) <<
"LinuxPerf: Stop";
107 for (
int fd : m_events_file_descriptor) {
112 m_is_started =
false;
122 for (Int32 index = 0, n = m_events_file_descriptor.
size(); index < n; ++index) {
123 Int64 value = _getOneCounter(index);
132 return _getOneCounter(0);
138 bool m_is_started =
false;
139 bool m_is_init =
false;
140 pid_t m_process_id = -1;
146 for (
int fd : m_events_file_descriptor) {
150 m_events_file_descriptor.clear();
155 int fd = m_events_file_descriptor[index];
156 uint64_t value[1] = { 0 };
157 const size_t s =
sizeof(uint64_t);
158 size_t nb_read = ::read(fd, value, s);
164 void _checkInitialize()
169 info() <<
"Initialize LinuxPerfPerformanceCounterService";
170 m_process_id = ::getpid();
172 _addEvent(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES);
174 _addEvent(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS);
182 const bool is_optional =
true;
185 int cache_access = (PERF_COUNT_HW_CACHE_OP_READ << 8) | (PERF_COUNT_HW_CACHE_RESULT_MISS << 16);
186 is_bad =
_addEvent(PERF_TYPE_HW_CACHE, PERF_COUNT_HW_CACHE_LL | cache_access, is_optional);
189 is_bad =
_addEvent(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, is_optional);
191 _addEvent(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES, is_optional);
201 ServiceProperty(
"LinuxPerfPerformanceCounterService",
ST_Application),
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro pour déclarer une interface lors de l'enregistrement d'un service.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Structure contenant les informations pour créer un service.
Integer size() const
Nombre d'éléments du vecteur.
Vue modifiable d'un tableau d'un type T.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Classe d'accès aux traces.
ITraceMng * traceMng() const
Gestionnaire de trace.
TraceMessage info() const
Flot pour un message d'information.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro pour enregistrer un service.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
@ ST_Application
Le service s'utilise au niveau de l'application.