|
9 | 9 | #include "mra/misc/options.h" |
10 | 10 | #include "mra/misc/functiondata.h" |
11 | 11 | #include "mra/misc/functionset.h" |
| 12 | +#include "mra/tensor/sparsitymanager.h" |
12 | 13 | #include "mra/tensor/tensor.h" |
13 | 14 | #include "mra/tensor/tensorview.h" |
14 | 15 | #include "mra/tensor/functionnode.h" |
@@ -87,22 +88,29 @@ namespace mra |
87 | 88 |
|
88 | 89 | /* some inputs are on the device so submit a kernel */ |
89 | 90 |
|
| 91 | + SparsityInfo sparsity(N); |
| 92 | + sparsity.nonzero_if_any(in0, in1, in2, in3, in4, in5, in6, in7); |
| 93 | + //std::cout << name << " " << key << " sparsity: " << sparsity << std::endl; |
| 94 | + |
90 | 95 | // allocate the result |
91 | | - result = mra::FunctionsCompressedNode<T, NDIM>(key, N, K, ttg::scope::Allocate); |
92 | | - auto& d = result.coeffs(); |
| 96 | + result.allocate(sparsity, K, ttg::scope::Allocate); |
| 97 | + |
93 | 98 | // Collect child leaf info |
94 | 99 | mra::apply_leaf_info(result, in0, in1, in2, in3, in4, in5, in6, in7); |
95 | | - p = mra::FunctionsReconstructedNode<T, NDIM>(key, N, K, ttg::scope::Allocate); |
| 100 | + p.allocate(sparsity, K, ttg::scope::Allocate); |
96 | 101 | p.set_all_leaf(false); |
97 | 102 | assert(p.is_all_leaf() == false); |
98 | 103 | FunctionNorms<T, NDIM> norms(name, in0, in1, in2, in3, in4, in5, in6, in7, result); |
99 | 104 |
|
| 105 | + |
100 | 106 | const std::size_t tmp_size = compress_tmp_size<NDIM>(K)*N; |
101 | 107 | ttg::Buffer<T, DeviceAllocator<T>> tmp_scratch(tmp_size, TempScope); |
102 | 108 | const auto& hgT = functiondata.get_hgT(); |
103 | 109 | /* stores sumsq for each child and for result at the end of the kernel */ |
104 | 110 | auto d_sumsq = ttg::Buffer<T, DeviceAllocator<T>>(N, TempScope); |
105 | 111 |
|
| 112 | + auto& d = result.coeffs(); |
| 113 | + |
106 | 114 | #ifndef MRA_ENABLE_HOST |
107 | 115 | auto input = ttg::device::Input(p.coeffs().buffer(), d.buffer(), hgT.buffer(), |
108 | 116 | tmp_scratch, d_sumsq); |
@@ -131,6 +139,9 @@ namespace mra |
131 | 139 | auto input_views = std::array{in0.coeffs().current_view(), in1.coeffs().current_view(), in2.coeffs().current_view(), in3.coeffs().current_view(), |
132 | 140 | in4.coeffs().current_view(), in5.coeffs().current_view(), in6.coeffs().current_view(), in7.coeffs().current_view()}; |
133 | 141 |
|
| 142 | + auto sparseman = make_sparsity_manager(d, p); |
| 143 | + sparseman.populate_device_sparsity(); |
| 144 | + |
134 | 145 | auto coeffs_view = p.coeffs().current_view(); |
135 | 146 | auto rcoeffs_view = d.current_view(); |
136 | 147 | auto hgT_view = hgT.current_view(); |
@@ -176,11 +187,11 @@ namespace mra |
176 | 187 | for (std::size_t i = 0; i < N; ++i) { |
177 | 188 | if (std::abs(p.sum(i) - 1.0) > 1e-12) { |
178 | 189 | all_correct = false; |
179 | | - std::cout << "At root of compressed tree " << key.batch() << " fn " << i << ": total normsq is " << p.sum(i) << std::endl; |
| 190 | + std::cout << name << ": at root of compressed tree " << key.batch() << " fn " << i << ": total normsq is " << p.sum(i) << std::endl; |
180 | 191 | } |
181 | 192 | } |
182 | 193 | if (all_correct) { |
183 | | - std::cout << "At root of compressed tree " << key.batch() << ": all norms are 1.0 with 1e-12 tolerance" << std::endl; |
| 194 | + std::cout << name << ": at root of compressed tree " << key.batch() << ": all norms are 1.0 with 1e-12 tolerance" << std::endl; |
184 | 195 | } |
185 | 196 | #ifndef MRA_ENABLE_HOST |
186 | 197 | co_await ttg::device::forward( |
|
0 commit comments