33#ifndef GKO_PUBLIC_CORE_LOG_PAPI_HPP_
34#define GKO_PUBLIC_CORE_LOG_PAPI_HPP_
37#include <ginkgo/config.hpp>
50#include <ginkgo/core/base/polymorphic_object.hpp>
51#include <ginkgo/core/log/logger.hpp>
59static std::mutex papi_count_mutex;
86template <
typename ValueType = default_precision>
91 const size_type& num_bytes)
const override;
95 const uintptr& location)
const override;
98 const uintptr& location)
const override;
101 const uintptr& location)
const override;
106 const size_type& num_bytes)
const override;
111 const size_type& num_bytes)
const override;
149 const LinOp* x)
const override;
152 const LinOp* x)
const override;
156 const LinOp* x)
const override;
160 const LinOp* x)
const override;
164 const LinOp* input)
const override;
168 const LinOp* output)
const override;
172 const LinOp* residual,
const LinOp* residual_norm,
173 const LinOp* solution,
const uint8& stopping_id,
180 const LinOp* residual,
181 const LinOp* residual_norm,
187 "Please use the version with the additional stopping "
247 GKO_DEPRECATED(
"use single-parameter constructor")
258 std::ostringstream
os;
260 std::lock_guard<std::mutex>
guard(papi_count_mutex);
261 os <<
"ginkgo" << papi_logger_count;
268 template <
typename Po
interType>
272 : handle{handle}, counter_name{counter_name}
277 for (
auto e : data) {
278 std::ostringstream
oss;
279 oss << counter_name <<
"::" <<
e.first;
287 const auto tmp =
reinterpret_cast<uintptr>(ptr);
288 if (data.find(tmp) == data.end()) {
291 auto& value = data[tmp];
293 std::ostringstream
oss;
294 oss << counter_name <<
"::" << tmp;
304 const char* counter_name;
305 std::map<std::uintptr_t, size_type> data;
310 "allocation_started"};
312 "allocation_completed"};
316 "copy_started_from"};
320 "copy_completed_from"};
322 "copy_completed_to"};
325 "operation_launched"};
327 "operation_completed"};
330 &papi_handle,
"polymorphic_object_create_started"};
332 &papi_handle,
"polymorphic_object_create_completed"};
334 &papi_handle,
"polymorphic_object_copy_started"};
336 &papi_handle,
"polymorphic_object_copy_completed"};
338 &papi_handle,
"polymorphic_object_move_started"};
340 &papi_handle,
"polymorphic_object_move_completed"};
342 &papi_handle,
"polymorphic_object_deleted"};
345 &papi_handle,
"linop_factory_generate_started"};
347 &papi_handle,
"linop_factory_generate_completed"};
350 "linop_apply_started"};
352 "linop_apply_completed"};
354 &papi_handle,
"linop_advanced_apply_started"};
356 &papi_handle,
"linop_advanced_apply_completed"};
358 mutable std::map<std::uintptr_t, void*> criterion_check_completed;
361 "iteration_complete"};
364 std::string name{
"ginkgo"};
The first step in using the Ginkgo library consists of creating an executor.
Definition executor.hpp:644
A LinOpFactory represents a higher order mapping which transforms one linear operator into another.
Definition lin_op.hpp:414
Definition lin_op.hpp:146
Operations can be used to define functionalities whose implementations differ among devices.
Definition executor.hpp:287
A PolymorphicObject is the abstract base for all "heavy" objects in Ginkgo that behave polymorphicall...
Definition polymorphic_object.hpp:72
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:187
Definition logger.hpp:104
static constexpr mask_type all_events_mask
Bitset Mask which activates all events.
Definition logger.hpp:117
Papi is a Logger which logs every event to the PAPI software.
Definition papi.hpp:87
void on_polymorphic_object_copy_completed(const Executor *exec, const PolymorphicObject *from, const PolymorphicObject *to) const override
PolymorphicObject's copy completed event.
void on_linop_factory_generate_started(const LinOpFactory *factory, const LinOp *input) const override
LinOp Factory's generate started event.
static std::shared_ptr< Papi > create(std::shared_ptr< const gko::Executor >, const Logger::mask_type &enabled_events=Logger::all_events_mask)
Creates a Papi Logger.
Definition papi.hpp:209
void on_linop_advanced_apply_completed(const LinOp *A, const LinOp *alpha, const LinOp *b, const LinOp *beta, const LinOp *x) const override
LinOp's advanced apply completed event.
void on_iteration_complete(const LinOp *solver, const LinOp *b, const LinOp *x, const size_type &num_iterations, const LinOp *residual, const LinOp *residual_norm, const LinOp *implicit_resnorm_sq, const array< stopping_status > *status, bool stopped) const override
Register the iteration_complete event which logs every completed iterations.
void on_linop_advanced_apply_started(const LinOp *A, const LinOp *alpha, const LinOp *b, const LinOp *beta, const LinOp *x) const override
LinOp's advanced apply started event.
const papi_handle_t get_handle() const
Returns the corresponding papi_handle_t for this logger.
Definition papi.hpp:244
void on_allocation_started(const Executor *exec, const size_type &num_bytes) const override
Executor's allocation started event.
static std::shared_ptr< Papi > create(const Logger::mask_type &enabled_events=Logger::all_events_mask)
Creates a Papi Logger.
Definition papi.hpp:221
void on_allocation_completed(const Executor *exec, const size_type &num_bytes, const uintptr &location) const override
Executor's allocation completed event.
void on_polymorphic_object_move_started(const Executor *exec, const PolymorphicObject *from, const PolymorphicObject *to) const override
PolymorphicObject's move started event.
void on_polymorphic_object_create_completed(const Executor *exec, const PolymorphicObject *input, const PolymorphicObject *output) const override
PolymorphicObject's create completed event.
void on_polymorphic_object_create_started(const Executor *, const PolymorphicObject *po) const override
PolymorphicObject's create started event.
void on_copy_started(const Executor *from, const Executor *to, const uintptr &location_from, const uintptr &location_to, const size_type &num_bytes) const override
Executor's copy started event.
void on_linop_factory_generate_completed(const LinOpFactory *factory, const LinOp *input, const LinOp *output) const override
LinOp Factory's generate completed event.
void on_free_completed(const Executor *exec, const uintptr &location) const override
Executor's free completed event.
void on_operation_completed(const Executor *exec, const Operation *operation) const override
Executor's operation completed event (method run).
void on_polymorphic_object_deleted(const Executor *exec, const PolymorphicObject *po) const override
PolymorphicObject's deleted event.
void on_copy_completed(const Executor *from, const Executor *to, const uintptr &location_from, const uintptr &location_to, const size_type &num_bytes) const override
Executor's copy completed event.
const std::string get_handle_name() const
Returns the unique name of this logger, which can be used in the PAPI_read() call.
Definition papi.hpp:237
void on_criterion_check_completed(const stop::Criterion *criterion, const size_type &num_iterations, const LinOp *residual, const LinOp *residual_norm, const LinOp *solution, const uint8 &stopping_id, const bool &set_finalized, const array< stopping_status > *status, const bool &one_changed, const bool &all_converged) const override
stop::Criterion's check completed event.
void on_linop_apply_started(const LinOp *A, const LinOp *b, const LinOp *x) const override
LinOp's apply started event.
void on_free_started(const Executor *exec, const uintptr &location) const override
Executor's free started event.
void on_polymorphic_object_copy_started(const Executor *exec, const PolymorphicObject *from, const PolymorphicObject *to) const override
PolymorphicObject's copy started event.
void on_polymorphic_object_move_completed(const Executor *exec, const PolymorphicObject *from, const PolymorphicObject *to) const override
PolymorphicObject's move completed event.
void on_operation_launched(const Executor *exec, const Operation *operation) const override
Executor's operation launched event (method run).
void on_linop_apply_completed(const LinOp *A, const LinOp *b, const LinOp *x) const override
LinOp's apply completed event.
The Criterion class is a base class for all stopping criteria.
Definition criterion.hpp:64
@ criterion
Stopping criterion events.
@ factory
LinOpFactory events.
@ operation
Kernel execution and data movement.
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
std::uint8_t uint8
8-bit unsigned integral type.
Definition types.hpp:149
std::uintptr_t uintptr
Unsigned integer type capable of holding a pointer to void.
Definition types.hpp:172
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:120
This structure is used to represent versions of various Ginkgo modules.
Definition version.hpp:54