Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
NodeAXPYThreeVectors.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
18
19#include "shambase/string.hpp"
24
25namespace shamrock::solvergraph {
26
27 template<class T>
29 auto edges = get_edges();
30
31 edges.spans_x.check_sizes(edges.sizes.indexes);
32 edges.spans_y.check_sizes(edges.sizes.indexes);
33 edges.spans_z.check_sizes(edges.sizes.indexes);
34
35 Tscal alpha = edges.alpha.data;
36 Tscal beta = edges.beta.data;
37
39 = edges.sizes.indexes.template map<u32>([&](u64 id, u32 obj_cnt) {
40 return obj_cnt * nvar;
41 });
42
44 shamsys::instance::get_compute_scheduler_ptr(),
45 sham::DDMultiRef{edges.spans_x.get_spans(), edges.spans_y.get_spans()},
46 sham::DDMultiRef{edges.spans_z.get_spans()},
47 val_cnts,
48 [alpha, beta](u32 i, const T *__restrict x, const T *__restrict y, T *__restrict z) {
49 z[i] = z[i] + alpha * x[i] + beta * y[i];
50 });
51 }
52
53 template<class T>
55 std::string tex = R"tex(
56 AXPY update with two vectors
57 \begin{equation}
58 {spans_z}_i \leftarrow {spans_z}_i + {alpha} \, {spans_x}_i + {beta} \, {spans_y}_i
59 \end{equation}
60 )tex";
61
62 replace_edges_tex_symbols(tex);
63
64 return tex;
65 }
66
67} // namespace shamrock::solvergraph
68
Node computing the in place update z <- z + alpha * x + beta * y on fields.
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Represents a collection of objects distributed across patches identified by a u64 id.
Compute z <- z + alpha * x + beta * y on every value of every patch.
virtual std::string _impl_get_tex() const
get the tex of the node
void distributed_data_kernel_call(sham::DeviceScheduler_ptr dev_sched, RefIn in, RefOut in_out, const shambase::DistributedData< index_t > &thread_counts, Functor &&func)
A variant of sham::kernel_call for distributed data.
A variant of sham::MultiRef for distributed data.