|
Ginkgo
Generated from pipelines/1554403166 branch based on develop. Ginkgo version 1.9.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>
31 std::unique_ptr<const LinOp> solver;
32 std::unique_ptr<const LinOp> right_hand_side;
33 std::unique_ptr<const LinOp> solution;
35 std::unique_ptr<const LinOp> residual;
36 std::unique_ptr<const LinOp> residual_norm;
37 std::unique_ptr<const LinOp> implicit_sq_residual_norm;
42 const LinOp* solution,
44 const LinOp* residual =
nullptr,
45 const LinOp* residual_norm =
nullptr,
46 const LinOp* implicit_sq_residual_norm =
nullptr,
48 bool all_stopped =
false)
49 : num_iterations{num_iterations}, all_stopped(all_stopped)
51 this->solver =
solver->clone();
52 this->solution = solution->clone();
53 if (right_hand_side !=
nullptr) {
54 this->right_hand_side = right_hand_side->clone();
56 if (residual !=
nullptr) {
57 this->residual = residual->clone();
59 if (residual_norm !=
nullptr) {
60 this->residual_norm = residual_norm->clone();
62 if (implicit_sq_residual_norm !=
nullptr) {
63 this->implicit_sq_residual_norm =
64 implicit_sq_residual_norm->clone();
66 if (status !=
nullptr) {
67 this->status = *status;
97 std::unique_ptr<const PolymorphicObject> input;
98 std::unique_ptr<const PolymorphicObject> output;
105 this->input = input->
clone();
106 if (output !=
nullptr) {
107 this->output = output->clone();
117 std::unique_ptr<const LinOp> A;
118 std::unique_ptr<const LinOp> alpha;
119 std::unique_ptr<const LinOp> b;
120 std::unique_ptr<const LinOp> beta;
121 std::unique_ptr<const LinOp> x;
126 this->A = A->clone();
127 if (alpha !=
nullptr) {
128 this->alpha = alpha->clone();
130 this->b = b->clone();
131 if (beta !=
nullptr) {
132 this->beta = beta->clone();
134 this->x = x->clone();
144 std::unique_ptr<const LinOp> input;
145 std::unique_ptr<const LinOp> output;
151 this->input = input->clone();
152 if (output !=
nullptr) {
153 this->output = output->clone();
165 std::unique_ptr<const LinOp> residual;
166 std::unique_ptr<const LinOp> residual_norm;
167 std::unique_ptr<const LinOp> solution;
168 const uint8 stopping_id;
169 const bool set_finalized;
171 const bool oneChanged;
172 const bool converged;
176 const LinOp* residual_norm,
const LinOp* solution,
177 const uint8 stopping_id,
const bool set_finalized,
179 const bool oneChanged =
false,
const bool converged =
false)
181 num_iterations{num_iterations},
183 residual_norm{
nullptr},
185 stopping_id{stopping_id},
186 set_finalized{set_finalized},
188 oneChanged{oneChanged},
191 if (residual !=
nullptr) {
192 this->residual = std::unique_ptr<const LinOp>(residual->clone());
194 if (residual_norm !=
nullptr) {
195 this->residual_norm =
196 std::unique_ptr<const LinOp>(residual_norm->clone());
198 if (solution !=
nullptr) {
199 this->solution = std::unique_ptr<const LinOp>(solution->clone());
221 std::deque<std::unique_ptr<executor_data>> allocation_started;
222 std::deque<std::unique_ptr<executor_data>> allocation_completed;
223 std::deque<std::unique_ptr<executor_data>> free_started;
224 std::deque<std::unique_ptr<executor_data>> free_completed;
225 std::deque<std::unique_ptr<std::tuple<executor_data, executor_data>>>
227 std::deque<std::unique_ptr<std::tuple<executor_data, executor_data>>>
230 std::deque<std::unique_ptr<operation_data>> operation_launched;
231 std::deque<std::unique_ptr<operation_data>> operation_completed;
233 std::deque<std::unique_ptr<polymorphic_object_data>>
234 polymorphic_object_create_started;
235 std::deque<std::unique_ptr<polymorphic_object_data>>
236 polymorphic_object_create_completed;
237 std::deque<std::unique_ptr<polymorphic_object_data>>
238 polymorphic_object_copy_started;
239 std::deque<std::unique_ptr<polymorphic_object_data>>
240 polymorphic_object_copy_completed;
241 std::deque<std::unique_ptr<polymorphic_object_data>>
242 polymorphic_object_move_started;
243 std::deque<std::unique_ptr<polymorphic_object_data>>
244 polymorphic_object_move_completed;
245 std::deque<std::unique_ptr<polymorphic_object_data>>
246 polymorphic_object_deleted;
248 std::deque<std::unique_ptr<linop_data>> linop_apply_started;
249 std::deque<std::unique_ptr<linop_data>> linop_apply_completed;
250 std::deque<std::unique_ptr<linop_data>> linop_advanced_apply_started;
251 std::deque<std::unique_ptr<linop_data>> linop_advanced_apply_completed;
252 std::deque<std::unique_ptr<linop_factory_data>>
253 linop_factory_generate_started;
254 std::deque<std::unique_ptr<linop_factory_data>>
255 linop_factory_generate_completed;
257 std::deque<std::unique_ptr<criterion_data>> criterion_check_started;
258 std::deque<std::unique_ptr<criterion_data>> criterion_check_completed;
260 std::deque<std::unique_ptr<iteration_complete_data>>
266 const size_type& num_bytes)
const override;
270 const uintptr& location)
const override;
273 const uintptr& location)
const override;
276 const uintptr& location)
const override;
281 const size_type& num_bytes)
const override;
286 const size_type& num_bytes)
const override;
324 const LinOp* x)
const override;
327 const LinOp* x)
const override;
331 const LinOp* x)
const override;
335 const LinOp* x)
const override;
339 const LinOp* input)
const override;
343 const LinOp* output)
const override;
348 const LinOp* residual,
349 const LinOp* residual_norm,
350 const LinOp* solution,
351 const uint8& stopping_id,
352 const bool& set_finalized)
const override;
356 const LinOp* residual,
const LinOp* residual_norm,
357 const LinOp* implicit_residual_norm_sq,
const LinOp* solution,
358 const uint8& stopping_id,
const bool& set_finalized,
360 const bool& all_converged)
const override;
364 const LinOp* residual,
const LinOp* residual_norm,
365 const LinOp* solution,
const uint8& stopping_id,
367 const bool& one_changed,
const bool& all_converged)
const override;
373 const LinOp* residual_norm,
const LinOp* implicit_resnorm_sq,
377 "Please use the version with the additional stopping "
382 const
LinOp* residual_norm) const override;
385 "Please use the
version with the additional stopping "
390 const
LinOp* residual_norm,
391 const
LinOp* implicit_sq_residual_norm) const override;
407 GKO_DEPRECATED("use two-parameter
create")
409 std::shared_ptr<const
Executor> exec,
413 return std::unique_ptr<Record>(
new Record(enabled_events, max_storage));
434 return std::unique_ptr<Record>(
new Record(enabled_events, max_storage));
461 GKO_DEPRECATED(
"use two-parameter constructor")
465 :
Record(enabled_events, max_storage)
480 : Logger(enabled_events), max_storage_{max_storage}
491 template <
typename deque_type>
492 void append_deque(std::deque<deque_type>& deque, deque_type
object)
const
494 if (this->max_storage_ && deque.size() == this->max_storage_) {
497 deque.push_back(std::move(
object));
501 mutable logged_data data_{};
510 #endif // GKO_PUBLIC_CORE_LOG_RECORD_HPP_
std::uint8_t uint8
8-bit unsigned integral type.
Definition: types.hpp:115
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:430
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:116
Struct representing PolymorphicObject related data.
Definition: record.hpp:95
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:408
A PolymorphicObject is the abstract base for all "heavy" objects in Ginkgo that behave polymorphicall...
Definition: polymorphic_object.hpp:43
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:138
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:86
logged_data & get() noexcept
Definition: record.hpp:447
Struct representing Operator related data.
Definition: record.hpp:86
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:98
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:162
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:88
Record is a Logger which logs every event to an object.
Definition: record.hpp:215
Struct representing iteration complete related data.
Definition: record.hpp:30
Struct storing the actually logged data.
Definition: record.hpp:220
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:75
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:76
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:615
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:142
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:384
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:442