 |
Ginkgo
Generated from pipelines/2662685947 branch based on develop. Ginkgo version 2.0.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_
12 #include <ginkgo/core/log/logger.hpp>
13 #include <ginkgo/core/matrix/dense.hpp>
14 #include <ginkgo/core/stop/criterion.hpp>
29 std::unique_ptr<T> clone_or_nullptr(T* input)
32 if (
auto tmp = dynamic_cast<const Cloneable*>(input)) {
33 return as<T>(tmp->clone());
46 std::unique_ptr<const LinOp> solver;
47 std::unique_ptr<const LinOp> right_hand_side;
48 std::unique_ptr<const LinOp> solution;
50 std::unique_ptr<const LinOp> residual;
51 std::unique_ptr<const LinOp> residual_norm;
52 std::unique_ptr<const LinOp> implicit_sq_residual_norm;
57 const LinOp* solution,
59 const LinOp* residual =
nullptr,
60 const LinOp* residual_norm =
nullptr,
61 const LinOp* implicit_sq_residual_norm =
nullptr,
63 bool all_stopped =
false)
64 : num_iterations{num_iterations}, all_stopped(all_stopped)
66 this->solver = detail::clone_or_nullptr(
solver);
67 this->solution = detail::clone_or_nullptr(solution);
68 if (right_hand_side !=
nullptr) {
69 this->right_hand_side = detail::clone_or_nullptr(right_hand_side);
71 if (residual !=
nullptr) {
72 this->residual = detail::clone_or_nullptr(residual);
74 if (residual_norm !=
nullptr) {
75 this->residual_norm = detail::clone_or_nullptr(residual_norm);
77 if (implicit_sq_residual_norm !=
nullptr) {
78 this->implicit_sq_residual_norm =
79 detail::clone_or_nullptr(implicit_sq_residual_norm);
81 if (status !=
nullptr) {
82 this->status = *status;
112 std::unique_ptr<const PolymorphicObject> input;
113 std::unique_ptr<const PolymorphicObject> output;
120 this->input = detail::clone_or_nullptr(input);
121 if (output !=
nullptr) {
122 this->output = detail::clone_or_nullptr(output);
132 std::unique_ptr<const LinOp> A;
133 std::unique_ptr<const LinOp> alpha;
134 std::unique_ptr<const LinOp> b;
135 std::unique_ptr<const LinOp> beta;
136 std::unique_ptr<const LinOp> x;
141 this->A = detail::clone_or_nullptr(A);
142 if (alpha !=
nullptr) {
143 this->alpha = detail::clone_or_nullptr(alpha);
145 this->b = detail::clone_or_nullptr(b);
146 if (beta !=
nullptr) {
147 this->beta = detail::clone_or_nullptr(beta);
149 this->x = detail::clone_or_nullptr(x);
159 std::unique_ptr<const LinOp> input;
160 std::unique_ptr<const LinOp> output;
166 this->input = detail::clone_or_nullptr(input);
167 if (output !=
nullptr) {
168 this->output = detail::clone_or_nullptr(output);
180 std::unique_ptr<const LinOp> residual;
181 std::unique_ptr<const LinOp> residual_norm;
182 std::unique_ptr<const LinOp> solution;
183 const uint8 stopping_id;
184 const bool set_finalized;
186 const bool oneChanged;
187 const bool converged;
191 const LinOp* residual_norm,
const LinOp* solution,
192 const uint8 stopping_id,
const bool set_finalized,
194 const bool oneChanged =
false,
const bool converged =
false)
196 num_iterations{num_iterations},
198 residual_norm{
nullptr},
200 stopping_id{stopping_id},
201 set_finalized{set_finalized},
203 oneChanged{oneChanged},
206 if (residual !=
nullptr) {
207 this->residual = detail::clone_or_nullptr(residual);
209 if (residual_norm !=
nullptr) {
210 this->residual_norm = detail::clone_or_nullptr(residual_norm);
212 if (solution !=
nullptr) {
213 this->solution = detail::clone_or_nullptr(solution);
235 std::deque<std::unique_ptr<executor_data>> allocation_started;
236 std::deque<std::unique_ptr<executor_data>> allocation_completed;
237 std::deque<std::unique_ptr<executor_data>> free_started;
238 std::deque<std::unique_ptr<executor_data>> free_completed;
239 std::deque<std::unique_ptr<std::tuple<executor_data, executor_data>>>
241 std::deque<std::unique_ptr<std::tuple<executor_data, executor_data>>>
244 std::deque<std::unique_ptr<operation_data>> operation_launched;
245 std::deque<std::unique_ptr<operation_data>> operation_completed;
247 std::deque<std::unique_ptr<polymorphic_object_data>>
248 polymorphic_object_create_started;
249 std::deque<std::unique_ptr<polymorphic_object_data>>
250 polymorphic_object_create_completed;
251 std::deque<std::unique_ptr<polymorphic_object_data>>
252 polymorphic_object_copy_started;
253 std::deque<std::unique_ptr<polymorphic_object_data>>
254 polymorphic_object_copy_completed;
255 std::deque<std::unique_ptr<polymorphic_object_data>>
256 polymorphic_object_move_started;
257 std::deque<std::unique_ptr<polymorphic_object_data>>
258 polymorphic_object_move_completed;
259 std::deque<std::unique_ptr<polymorphic_object_data>>
260 polymorphic_object_deleted;
262 std::deque<std::unique_ptr<linop_data>> linop_apply_started;
263 std::deque<std::unique_ptr<linop_data>> linop_apply_completed;
264 std::deque<std::unique_ptr<linop_data>> linop_advanced_apply_started;
265 std::deque<std::unique_ptr<linop_data>> linop_advanced_apply_completed;
266 std::deque<std::unique_ptr<linop_factory_data>>
267 linop_factory_generate_started;
268 std::deque<std::unique_ptr<linop_factory_data>>
269 linop_factory_generate_completed;
271 std::deque<std::unique_ptr<criterion_data>> criterion_check_started;
272 std::deque<std::unique_ptr<criterion_data>> criterion_check_completed;
274 std::deque<std::unique_ptr<iteration_complete_data>>
280 const size_type& num_bytes)
const override;
284 const uintptr& location)
const override;
287 const uintptr& location)
const override;
290 const uintptr& location)
const override;
295 const size_type& num_bytes)
const override;
300 const size_type& num_bytes)
const override;
338 const LinOp* x)
const override;
341 const LinOp* x)
const override;
345 const LinOp* x)
const override;
349 const LinOp* x)
const override;
353 const LinOp* input)
const override;
357 const LinOp* output)
const override;
362 const LinOp* residual,
363 const LinOp* residual_norm,
364 const LinOp* solution,
365 const uint8& stopping_id,
366 const bool& set_finalized)
const override;
370 const LinOp* residual,
const LinOp* residual_norm,
371 const LinOp* implicit_residual_norm_sq,
const LinOp* solution,
372 const uint8& stopping_id,
const bool& set_finalized,
374 const bool& all_converged)
const override;
378 const LinOp* residual,
const LinOp* residual_norm,
379 const LinOp* solution,
const uint8& stopping_id,
381 const bool& one_changed,
const bool& all_converged)
const override;
387 const LinOp* residual_norm,
const LinOp* implicit_resnorm_sq,
391 "Please use the version with the additional stopping "
396 const
LinOp* residual_norm) const override;
399 "Please use the
version with the additional stopping "
404 const
LinOp* residual_norm,
405 const
LinOp* implicit_sq_residual_norm) const override;
421 GKO_DEPRECATED("use two-parameter
create")
423 std::shared_ptr<const
Executor> exec,
427 return std::unique_ptr<Record>(
new Record(enabled_events, max_storage));
448 return std::unique_ptr<Record>(
new Record(enabled_events, max_storage));
475 GKO_DEPRECATED(
"use two-parameter constructor")
479 :
Record(enabled_events, max_storage)
494 : Logger(enabled_events), max_storage_{max_storage}
505 template <
typename deque_type>
506 void append_deque(std::deque<deque_type>& deque, deque_type
object)
const
508 if (this->max_storage_ && deque.size() == this->max_storage_) {
511 deque.push_back(std::move(
object));
515 mutable logged_data data_{};
524 #endif // GKO_PUBLIC_CORE_LOG_RECORD_HPP_
std::uint8_t uint8
8-bit unsigned integral type.
Definition: types.hpp:119
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:444
Definition: lin_op.hpp:117
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:131
Struct representing PolymorphicObject related data.
Definition: record.hpp:110
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:422
A PolymorphicObject is the abstract base for all "heavy" objects in Ginkgo that behave polymorphicall...
Definition: polymorphic_object.hpp:46
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:142
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:90
logged_data & get() noexcept
Definition: record.hpp:461
Struct representing Operator related data.
Definition: record.hpp:101
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).
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:177
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition: array.hpp:26
This structure is used to represent versions of various Ginkgo modules.
Definition: version.hpp:25
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:229
Struct representing iteration complete related data.
Definition: record.hpp:45
Struct storing the actually logged data.
Definition: record.hpp:234
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:91
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:157
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:343
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:258
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:456