|
Ginkgo
Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_LOG_RECORD_HPP_
6 #define GKO_PUBLIC_CORE_LOG_RECORD_HPP_
13 #include <ginkgo/core/log/logger.hpp>
14 #include <ginkgo/core/matrix/dense.hpp>
15 #include <ginkgo/core/stop/criterion.hpp>
32 std::unique_ptr<const LinOp> solver;
33 std::unique_ptr<const LinOp> right_hand_side;
34 std::unique_ptr<const LinOp> solution;
36 std::unique_ptr<const LinOp> residual;
37 std::unique_ptr<const LinOp> residual_norm;
38 std::unique_ptr<const LinOp> implicit_sq_residual_norm;
43 const LinOp* solution,
45 const LinOp* residual =
nullptr,
46 const LinOp* residual_norm =
nullptr,
47 const LinOp* implicit_sq_residual_norm =
nullptr,
49 bool all_stopped =
false)
50 : num_iterations{num_iterations}, all_stopped(all_stopped)
52 this->solver =
solver->clone();
53 this->solution = solution->clone();
54 if (right_hand_side !=
nullptr) {
55 this->right_hand_side = right_hand_side->clone();
57 if (residual !=
nullptr) {
58 this->residual = residual->clone();
60 if (residual_norm !=
nullptr) {
61 this->residual_norm = residual_norm->clone();
63 if (implicit_sq_residual_norm !=
nullptr) {
64 this->implicit_sq_residual_norm =
65 implicit_sq_residual_norm->clone();
67 if (status !=
nullptr) {
68 this->status = *status;
98 std::unique_ptr<const PolymorphicObject> input;
99 std::unique_ptr<const PolymorphicObject> output;
106 this->input = input->
clone();
107 if (output !=
nullptr) {
108 this->output = output->clone();
118 std::unique_ptr<const LinOp> A;
119 std::unique_ptr<const LinOp> alpha;
120 std::unique_ptr<const LinOp> b;
121 std::unique_ptr<const LinOp> beta;
122 std::unique_ptr<const LinOp> x;
127 this->A = A->clone();
128 if (alpha !=
nullptr) {
129 this->alpha = alpha->clone();
131 this->b = b->clone();
132 if (beta !=
nullptr) {
133 this->beta = beta->clone();
135 this->x = x->clone();
145 std::unique_ptr<const LinOp> input;
146 std::unique_ptr<const LinOp> output;
152 this->input = input->clone();
153 if (output !=
nullptr) {
154 this->output = output->clone();
166 std::unique_ptr<const LinOp> residual;
167 std::unique_ptr<const LinOp> residual_norm;
168 std::unique_ptr<const LinOp> solution;
169 const uint8 stopping_id;
170 const bool set_finalized;
172 const bool oneChanged;
173 const bool converged;
177 const LinOp* residual_norm,
const LinOp* solution,
178 const uint8 stopping_id,
const bool set_finalized,
180 const bool oneChanged =
false,
const bool converged =
false)
182 num_iterations{num_iterations},
184 residual_norm{
nullptr},
186 stopping_id{stopping_id},
187 set_finalized{set_finalized},
189 oneChanged{oneChanged},
192 if (residual !=
nullptr) {
193 this->residual = std::unique_ptr<const LinOp>(residual->clone());
195 if (residual_norm !=
nullptr) {
196 this->residual_norm =
197 std::unique_ptr<const LinOp>(residual_norm->clone());
199 if (solution !=
nullptr) {
200 this->solution = std::unique_ptr<const LinOp>(solution->clone());
222 std::deque<std::unique_ptr<executor_data>> allocation_started;
223 std::deque<std::unique_ptr<executor_data>> allocation_completed;
224 std::deque<std::unique_ptr<executor_data>> free_started;
225 std::deque<std::unique_ptr<executor_data>> free_completed;
226 std::deque<std::unique_ptr<std::tuple<executor_data, executor_data>>>
228 std::deque<std::unique_ptr<std::tuple<executor_data, executor_data>>>
231 std::deque<std::unique_ptr<operation_data>> operation_launched;
232 std::deque<std::unique_ptr<operation_data>> operation_completed;
234 std::deque<std::unique_ptr<polymorphic_object_data>>
235 polymorphic_object_create_started;
236 std::deque<std::unique_ptr<polymorphic_object_data>>
237 polymorphic_object_create_completed;
238 std::deque<std::unique_ptr<polymorphic_object_data>>
239 polymorphic_object_copy_started;
240 std::deque<std::unique_ptr<polymorphic_object_data>>
241 polymorphic_object_copy_completed;
242 std::deque<std::unique_ptr<polymorphic_object_data>>
243 polymorphic_object_move_started;
244 std::deque<std::unique_ptr<polymorphic_object_data>>
245 polymorphic_object_move_completed;
246 std::deque<std::unique_ptr<polymorphic_object_data>>
247 polymorphic_object_deleted;
249 std::deque<std::unique_ptr<linop_data>> linop_apply_started;
250 std::deque<std::unique_ptr<linop_data>> linop_apply_completed;
251 std::deque<std::unique_ptr<linop_data>> linop_advanced_apply_started;
252 std::deque<std::unique_ptr<linop_data>> linop_advanced_apply_completed;
253 std::deque<std::unique_ptr<linop_factory_data>>
254 linop_factory_generate_started;
255 std::deque<std::unique_ptr<linop_factory_data>>
256 linop_factory_generate_completed;
258 std::deque<std::unique_ptr<criterion_data>> criterion_check_started;
259 std::deque<std::unique_ptr<criterion_data>> criterion_check_completed;
261 std::deque<std::unique_ptr<iteration_complete_data>>
267 const size_type& num_bytes)
const override;
271 const uintptr& location)
const override;
274 const uintptr& location)
const override;
277 const uintptr& location)
const override;
282 const size_type& num_bytes)
const override;
287 const size_type& num_bytes)
const override;
325 const LinOp* x)
const override;
328 const LinOp* x)
const override;
332 const LinOp* x)
const override;
336 const LinOp* x)
const override;
340 const LinOp* input)
const override;
344 const LinOp* output)
const override;
349 const LinOp* residual,
350 const LinOp* residual_norm,
351 const LinOp* solution,
352 const uint8& stopping_id,
353 const bool& set_finalized)
const override;
357 const LinOp* residual,
const LinOp* residual_norm,
358 const LinOp* implicit_residual_norm_sq,
const LinOp* solution,
359 const uint8& stopping_id,
const bool& set_finalized,
361 const bool& all_converged)
const override;
365 const LinOp* residual,
const LinOp* residual_norm,
366 const LinOp* solution,
const uint8& stopping_id,
368 const bool& one_changed,
const bool& all_converged)
const override;
374 const LinOp* residual_norm,
const LinOp* implicit_resnorm_sq,
378 "Please use the version with the additional stopping "
383 const
LinOp* residual_norm) const override;
386 "Please use the
version with the additional stopping "
391 const
LinOp* residual_norm,
392 const
LinOp* implicit_sq_residual_norm) const override;
408 GKO_DEPRECATED("use two-parameter
create")
410 std::shared_ptr<const
Executor> exec,
414 return std::unique_ptr<Record>(
new Record(enabled_events, max_storage));
435 return std::unique_ptr<Record>(
new Record(enabled_events, max_storage));
462 GKO_DEPRECATED(
"use two-parameter constructor")
466 :
Record(enabled_events, max_storage)
481 : Logger(enabled_events), max_storage_{max_storage}
492 template <
typename deque_type>
493 void append_deque(std::deque<deque_type>& deque, deque_type
object)
const
495 if (this->max_storage_ && deque.size() == this->max_storage_) {
498 deque.push_back(std::move(
object));
502 mutable logged_data data_{};
511 #endif // GKO_PUBLIC_CORE_LOG_RECORD_HPP_
std::uint8_t uint8
8-bit unsigned integral type.
Definition: types.hpp:137
void on_free_completed(const Executor *exec, const uintptr &location) const override
Executor's free completed event.
static std::unique_ptr< Record > create(const mask_type &enabled_events=Logger::all_events_mask, size_type max_storage=1)
Creates a Record logger.
Definition: record.hpp:431
Definition: lin_op.hpp:118
void on_iteration_complete(const LinOp *solver, const LinOp *right_hand_side, 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.
Struct representing LinOp related data.
Definition: record.hpp:117
Struct representing PolymorphicObject related data.
Definition: record.hpp:96
static std::unique_ptr< Record > create(std::shared_ptr< const Executor > exec, const mask_type &enabled_events=Logger::all_events_mask, size_type max_storage=1)
Creates a Record logger.
Definition: record.hpp:409
A PolymorphicObject is the abstract base for all "heavy" objects in Ginkgo that behave polymorphicall...
Definition: polymorphic_object.hpp:44
void on_polymorphic_object_deleted(const Executor *exec, const PolymorphicObject *po) const override
PolymorphicObject's deleted event.
Stopping criterion events.
std::uintptr_t uintptr
Unsigned integer type capable of holding a pointer to void.
Definition: types.hpp:160
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:108
logged_data & get() noexcept
Definition: record.hpp:448
Struct representing Operator related data.
Definition: record.hpp:87
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_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.
void on_polymorphic_object_create_started(const Executor *exec, const PolymorphicObject *po) const override
PolymorphicObject's create started event.
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
void on_operation_launched(const Executor *exec, const Operation *operation) const override
Executor's operation launched event (method run).
std::unique_ptr< PolymorphicObject > clone(std::shared_ptr< const Executor > exec) const
Creates a clone of the object.
Definition: polymorphic_object.hpp:99
void on_criterion_check_completed(const stop::Criterion *criterion, const size_type &num_iterations, const LinOp *residual, const LinOp *residual_norm, const LinOp *implicit_residual_norm_sq, 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.
Struct representing Criterion related data.
Definition: record.hpp:163
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition: array.hpp:27
This structure is used to represent versions of various Ginkgo modules.
Definition: version.hpp:26
static constexpr mask_type all_events_mask
Bitset Mask which activates all events.
Definition: logger.hpp:89
Record is a Logger which logs every event to an object.
Definition: record.hpp:216
Struct representing iteration complete related data.
Definition: record.hpp:31
Struct storing the actually logged data.
Definition: record.hpp:221
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_linop_factory_generate_completed(const LinOpFactory *factory, const LinOp *input, const LinOp *output) const override
LinOp Factory's generate completed event.
Definition: logger.hpp:76
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_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.
Struct representing Executor related data.
Definition: record.hpp:77
The Criterion class is a base class for all stopping criteria.
Definition: criterion.hpp:36
void on_linop_apply_started(const LinOp *A, const LinOp *b, const LinOp *x) const override
LinOp's apply started event.
void on_allocation_completed(const Executor *exec, const size_type &num_bytes, const uintptr &location) const override
Executor's allocation completed event.
void on_free_started(const Executor *exec, const uintptr &location) const override
Executor's free 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_move_completed(const Executor *exec, const PolymorphicObject *from, const PolymorphicObject *to) const override
PolymorphicObject's move completed event.
Kernel execution and data movement.
The first step in using the Ginkgo library consists of creating an executor.
Definition: executor.hpp:616
void on_operation_completed(const Executor *exec, const Operation *operation) const override
Executor's operation completed event (method run).
void on_criterion_check_started(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 override
stop::Criterion's check started event.
Struct representing LinOp factory related data.
Definition: record.hpp:143
void on_linop_factory_generate_started(const LinOpFactory *factory, const LinOp *input) const override
LinOp Factory's generate started event.
void on_polymorphic_object_copy_started(const Executor *exec, const PolymorphicObject *from, const PolymorphicObject *to) const override
PolymorphicObject's copy started event.
A LinOpFactory represents a higher order mapping which transforms one linear operator into another.
Definition: lin_op.hpp:385
void on_linop_apply_completed(const LinOp *A, const LinOp *b, const LinOp *x) const override
LinOp's apply completed event.
Operations can be used to define functionalities whose implementations differ among devices.
Definition: executor.hpp:259
void on_polymorphic_object_move_started(const Executor *exec, const PolymorphicObject *from, const PolymorphicObject *to) const override
PolymorphicObject's move started event.
void on_allocation_started(const Executor *exec, const size_type &num_bytes) const override
Executor's allocation started event.
const logged_data & get() const noexcept
Returns the logged data.
Definition: record.hpp:443