33 #ifndef GKO_CORE_LOG_RECORD_HPP_ 34 #define GKO_CORE_LOG_RECORD_HPP_ 37 #include <ginkgo/core/log/logger.hpp> 44 #include <ginkgo/core/matrix/dense.hpp> 45 #include <ginkgo/core/stop/criterion.hpp> 62 std::unique_ptr<const LinOp> solver;
64 std::unique_ptr<const LinOp> residual;
65 std::unique_ptr<const LinOp> solution;
66 std::unique_ptr<const LinOp> residual_norm;
69 const LinOp *residual =
nullptr,
70 const LinOp *solution =
nullptr,
71 const LinOp *residual_norm =
nullptr)
73 num_iterations{num_iterations},
76 residual_norm{
nullptr}
78 this->solver = solver->clone();
79 if (residual !=
nullptr) {
80 this->residual = residual->clone();
82 if (solution !=
nullptr) {
83 this->solution = solution->clone();
85 if (residual_norm !=
nullptr) {
86 this->residual_norm = residual_norm->clone();
98 const uintptr location;
116 std::unique_ptr<const PolymorphicObject> input;
117 std::unique_ptr<const PolymorphicObject> output;
124 this->input = input->
clone();
125 if (output !=
nullptr) {
126 this->output = output->clone();
136 std::unique_ptr<const LinOp> A;
137 std::unique_ptr<const LinOp> alpha;
138 std::unique_ptr<const LinOp> b;
139 std::unique_ptr<const LinOp> beta;
140 std::unique_ptr<const LinOp> x;
145 this->A = A->clone();
146 if (alpha !=
nullptr) {
147 this->alpha = alpha->clone();
149 this->b = b->clone();
150 if (beta !=
nullptr) {
151 this->beta = beta->clone();
153 this->x = x->clone();
163 std::unique_ptr<const LinOp> input;
164 std::unique_ptr<const LinOp> output;
170 this->input = input->clone();
171 if (output !=
nullptr) {
172 this->output = output->clone();
184 std::unique_ptr<const LinOp> residual;
185 std::unique_ptr<const LinOp> residual_norm;
186 std::unique_ptr<const LinOp> solution;
187 const uint8 stopping_id;
188 const bool set_finalized;
190 const bool oneChanged;
191 const bool converged;
195 const LinOp *residual_norm,
const LinOp *solution,
196 const uint8 stopping_id,
const bool set_finalized,
198 const bool oneChanged =
false,
const bool converged =
false)
199 : criterion{criterion},
200 num_iterations{num_iterations},
202 residual_norm{
nullptr},
204 stopping_id{stopping_id},
205 set_finalized{set_finalized},
207 oneChanged{oneChanged},
210 if (residual !=
nullptr) {
211 this->residual = std::unique_ptr<const LinOp>(residual->clone());
213 if (residual_norm !=
nullptr) {
214 this->residual_norm =
215 std::unique_ptr<const LinOp>(residual_norm->clone());
217 if (solution !=
nullptr) {
218 this->solution = std::unique_ptr<const LinOp>(solution->clone());
240 std::deque<std::unique_ptr<executor_data>> allocation_started;
241 std::deque<std::unique_ptr<executor_data>> allocation_completed;
242 std::deque<std::unique_ptr<executor_data>> free_started;
243 std::deque<std::unique_ptr<executor_data>> free_completed;
244 std::deque<std::unique_ptr<std::tuple<executor_data, executor_data>>>
246 std::deque<std::unique_ptr<std::tuple<executor_data, executor_data>>>
249 std::deque<std::unique_ptr<operation_data>> operation_launched;
250 std::deque<std::unique_ptr<operation_data>> operation_completed;
252 std::deque<std::unique_ptr<polymorphic_object_data>>
253 polymorphic_object_create_started;
254 std::deque<std::unique_ptr<polymorphic_object_data>>
255 polymorphic_object_create_completed;
256 std::deque<std::unique_ptr<polymorphic_object_data>>
257 polymorphic_object_copy_started;
258 std::deque<std::unique_ptr<polymorphic_object_data>>
259 polymorphic_object_copy_completed;
260 std::deque<std::unique_ptr<polymorphic_object_data>>
261 polymorphic_object_deleted;
263 std::deque<std::unique_ptr<linop_data>> linop_apply_started;
264 std::deque<std::unique_ptr<linop_data>> linop_apply_completed;
265 std::deque<std::unique_ptr<linop_data>> linop_advanced_apply_started;
266 std::deque<std::unique_ptr<linop_data>> linop_advanced_apply_completed;
267 std::deque<std::unique_ptr<linop_factory_data>>
268 linop_factory_generate_started;
269 std::deque<std::unique_ptr<linop_factory_data>>
270 linop_factory_generate_completed;
272 std::deque<std::unique_ptr<criterion_data>> criterion_check_started;
273 std::deque<std::unique_ptr<criterion_data>> criterion_check_completed;
275 std::deque<std::unique_ptr<iteration_complete_data>>
280 void on_allocation_started(
const Executor *exec,
281 const size_type &num_bytes)
const override;
283 void on_allocation_completed(
const Executor *exec,
285 const uintptr &location)
const override;
287 void on_free_started(
const Executor *exec,
288 const uintptr &location)
const override;
290 void on_free_completed(
const Executor *exec,
291 const uintptr &location)
const override;
294 const uintptr &location_from,
295 const uintptr &location_to,
296 const size_type &num_bytes)
const override;
299 const uintptr &location_from,
300 const uintptr &location_to,
301 const size_type &num_bytes)
const override;
304 void on_operation_launched(
const Executor *exec,
305 const Operation *operation)
const override;
307 void on_operation_completed(
const Executor *exec,
308 const Operation *operation)
const override;
311 void on_polymorphic_object_create_started(
314 void on_polymorphic_object_create_completed(
318 void on_polymorphic_object_copy_started(
322 void on_polymorphic_object_copy_completed(
326 void on_polymorphic_object_deleted(
330 void on_linop_apply_started(
const LinOp *A,
const LinOp *b,
331 const LinOp *x)
const override;
333 void on_linop_apply_completed(
const LinOp *A,
const LinOp *b,
334 const LinOp *x)
const override;
336 void on_linop_advanced_apply_started(
const LinOp *A,
const LinOp *alpha,
338 const LinOp *x)
const override;
340 void on_linop_advanced_apply_completed(
const LinOp *A,
const LinOp *alpha,
342 const LinOp *x)
const override;
345 void on_linop_factory_generate_started(
const LinOpFactory *factory,
346 const LinOp *input)
const override;
348 void on_linop_factory_generate_completed(
350 const LinOp *output)
const override;
355 const LinOp *residual,
356 const LinOp *residual_norm,
357 const LinOp *solution,
358 const uint8 &stopping_id,
359 const bool &set_finalized)
const override;
361 void on_criterion_check_completed(
363 const LinOp *residual,
const LinOp *residual_norm,
364 const LinOp *solution,
const uint8 &stopping_id,
366 const bool &one_changed,
const bool &all_converged)
const override;
369 void on_iteration_complete(
371 const LinOp *residual,
const LinOp *solution =
nullptr,
372 const LinOp *residual_norm =
nullptr)
const override;
394 std::shared_ptr<const Executor> exec,
398 return std::unique_ptr<Record>(
399 new Record(exec, enabled_events, max_storage));
426 explicit Record(std::shared_ptr<const gko::Executor> exec,
429 :
Logger(exec, enabled_events), max_storage_{max_storage}
440 template <
typename deque_type>
441 void append_deque(std::deque<deque_type> &deque, deque_type
object)
const 443 if (this->max_storage_ && deque.size() == this->max_storage_) {
446 deque.push_back(std::move(
object));
459 #endif // GKO_CORE_LOG_RECORD_HPP_ Struct representing Operator related data.
Definition: record.hpp:105
Definition: logger.hpp:90
std::unique_ptr< PolymorphicObject > clone(std::shared_ptr< const Executor > exec) const
Creates a clone of the object.
Definition: polymorphic_object.hpp:122
Struct representing iteration complete related data.
Definition: record.hpp:61
Struct representing LinOp factory related data.
Definition: record.hpp:161
A LinOpFactory represents a higher order mapping which transforms one linear operator into another...
Definition: lin_op.hpp:356
Struct representing PolymorphicObject related data.
Definition: record.hpp:114
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:94
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
A PolymorphicObject is the abstract base for all "heavy" objects in Ginkgo that behave polymorphicall...
Definition: polymorphic_object.hpp:67
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:393
Definition: lin_op.hpp:134
std::uint8_t uint8
8-bit unsigned integral type.
Definition: types.hpp:123
Operations can be used to define functionalities whose implementations differ among devices...
Definition: executor.hpp:173
Struct storing the actually logged data.
Definition: record.hpp:239
An Array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the Arr...
Definition: array.hpp:63
Struct representing Executor related data.
Definition: record.hpp:95
static constexpr mask_type all_events_mask
Bitset Mask which activates all events.
Definition: logger.hpp:103
The Criterion class is a base class for all stopping criteria.
Definition: criterion.hpp:63
Struct representing Criterion related data.
Definition: record.hpp:181
The first step in using the Ginkgo library consists of creating an executor.
Definition: executor.hpp:410
Record is a Logger which logs every event to an object.
Definition: record.hpp:234
Struct representing LinOp related data.
Definition: record.hpp:135