Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
PapiPerformanceService.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/* PapiPerformanceService.h (C) 2000-2023 */
9/* */
10/* Performance information using PAPI. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_STD_PAPIPERFORMANCESERVICE_H
13#define ARCANE_STD_PAPIPERFORMANCESERVICE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/IProfilingService.h"
18
19#include "arcane/core/AbstractService.h"
20
21#include <papi.h>
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
35class PapiPerformanceService
36: public AbstractService
37, public IProfilingService
38{
39 public:
40
41 explicit PapiPerformanceService(const ServiceBuildInfo& sbi);
42 ~PapiPerformanceService() override;
43
44 public:
45
46 void initialize() override;
47 bool isInitialized() const override { return m_is_initialized; }
48 void startProfiling() override;
49 void switchEvent() override;
50 void stopProfiling() override;
51 void printInfos(bool dump_file) override;
52 void getInfos(Int64Array&) override;
53 void dumpJSON(JSONWriter& writer) override;
54 void reset() override;
55 ITimerMng* timerMng() override;
56
57 private:
58
59 int m_period = 0;
60 int m_event_set = 0;
61 bool m_only_flops = false;
62 bool m_is_running = false;
63 bool m_is_initialized = false;
64 ITimerMng* m_timer_mng = nullptr;
65 IApplication* m_application = nullptr;
66
67 private:
68
69 void _printFlops();
70 bool _addEvent(int event_code, int event_index);
71 static void arcane_papi_handler(int EventSet, void* address,
72 long_long overflow_vector, void* context);
73};
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78} // End namespace Arcane
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83#endif
AbstractService(const ServiceBuildInfo &)
Constructor from a ServiceBuildInfo.
Application interface.
Interface of a profiling service.
Interface of a timer manager.
Definition ITimerMng.h:50
void printInfos(bool dump_file) override
Displays profiling information.
void stopProfiling() override
Stops profiling.
void dumpJSON(JSONWriter &writer) override
Writes the profiling information to the writer writer.
void reset() override
Resets the counters.
void initialize() override
Initializes the profiling service.
void startProfiling() override
Starts profiling.
bool isInitialized() const override
Indicates if initialize() has already been called.
ITimerMng * timerMng() override
Timer using the features of this service if they exist. Can be null.
Structure containing the information to create a service.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Int64 > Int64Array
Dynamic one-dimensional array of 64-bit integers.
Definition UtilsTypes.h:125