|
1 |
| -// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors |
| 1 | +// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors |
2 | 2 | //
|
3 | 3 | // SPDX-License-Identifier: BSD-3-Clause
|
4 | 4 |
|
|
10 | 10 |
|
11 | 11 | #include <ginkgo/core/base/math.hpp>
|
12 | 12 | #include <ginkgo/core/base/types.hpp>
|
| 13 | +#include <ginkgo/core/base/work_estimate.hpp> |
13 | 14 | #include <ginkgo/core/matrix/dense.hpp>
|
14 | 15 | #include <ginkgo/core/matrix/diagonal.hpp>
|
15 | 16 |
|
@@ -476,6 +477,53 @@ GKO_DECLARE_FOR_ALL_EXECUTOR_NAMESPACES(dense, GKO_DECLARE_ALL_AS_TEMPLATES);
|
476 | 477 | #undef GKO_DECLARE_ALL_AS_TEMPLATES
|
477 | 478 |
|
478 | 479 |
|
| 480 | +namespace work_estimate { |
| 481 | +namespace dense { |
| 482 | + |
| 483 | + |
| 484 | +template <typename ValueType> |
| 485 | +kernel_work_estimate simple_apply(const matrix::Dense<ValueType>* a, |
| 486 | + const matrix::Dense<ValueType>* b, |
| 487 | + matrix::Dense<ValueType>* c) |
| 488 | +{ |
| 489 | + const auto a_rows = a->get_size()[0]; |
| 490 | + const auto a_cols = a->get_size()[1]; |
| 491 | + const auto b_cols = b->get_size()[1]; |
| 492 | + return compute_bound_work_estimate{2 * a_rows * a_cols * b_cols}; |
| 493 | +} |
| 494 | + |
| 495 | + |
| 496 | +template <typename InValueType, typename OutValueType> |
| 497 | +kernel_work_estimate copy(const matrix::Dense<InValueType>* input, |
| 498 | + matrix::Dense<OutValueType>* output) |
| 499 | +{ |
| 500 | + const auto memsize = input->get_size()[0] * input->get_size()[1]; |
| 501 | + return memory_bound_work_estimate{memsize * sizeof(InValueType), |
| 502 | + memsize * sizeof(OutValueType)}; |
| 503 | +} |
| 504 | + |
| 505 | + |
| 506 | +template <typename ValueType> |
| 507 | +kernel_work_estimate fill(matrix::Dense<ValueType>* mat, ValueType value) |
| 508 | +{ |
| 509 | + return memory_bound_work_estimate{ |
| 510 | + 0, mat->get_size()[0] * mat->get_size()[1] * sizeof(ValueType)}; |
| 511 | +} |
| 512 | + |
| 513 | + |
| 514 | +template <typename ValueType> |
| 515 | +kernel_work_estimate compute_dot_dispatch(const matrix::Dense<ValueType>* x, |
| 516 | + const matrix::Dense<ValueType>* y, |
| 517 | + matrix::Dense<ValueType>* result, |
| 518 | + array<char>& tmp) |
| 519 | +{ |
| 520 | + const auto num_elements = x->get_size()[0] * x->get_size()[1]; |
| 521 | + return memory_bound_work_estimate{2 * num_elements * sizeof(ValueType), 0}; |
| 522 | +} |
| 523 | + |
| 524 | + |
| 525 | +} // namespace dense |
| 526 | +} // namespace work_estimate |
479 | 527 | } // namespace kernels
|
480 | 528 | } // namespace gko
|
481 | 529 |
|
|
0 commit comments