3 #include "DataFormats/PortableTestObjects/interface/TestHostCollection.h" 22 void print(std::ostream&
out)
const {
29 buffer <<
", " << data_[1];
32 buffer <<
", " << data_[2];
47 std::ostream& operator<<(std::ostream& out, Column<T>
const&
column) {
53 void checkViewAddresses(
T const&
view) {
77 assert(
view.metadata().addressOf_m() == &
view.m(0).coeffRef(0, 0));
78 assert(
view.metadata().addressOf_m() == &
view[0].m().coeffRef(0, 0));
82 void checkViewAddresses2(
T const&
view) {
96 assert(
view.metadata().addressOf_m2() == &
view.m2(0).coeffRef(0, 0));
97 assert(
view.metadata().addressOf_m2() == &
view[0].m2().coeffRef(0, 0));
103 template <
typename T>
104 void checkViewAddresses3(
T const&
view) {
118 assert(
view.metadata().addressOf_m3() == &
view.m3(0).coeffRef(0, 0));
119 assert(
view.metadata().addressOf_m3() == &
view[0].m3().coeffRef(0, 0));
146 auto& mview = product.
view();
147 auto const& cmview = product.
view();
151 <<
view.metadata().size();
157 msg <<
" data @ " << product.
buffer().data() <<
",\n" 158 <<
" x @ " <<
view.metadata().addressOf_x() <<
" = " << Column(
view.x(),
view.metadata().size()) <<
",\n" 159 <<
" y @ " <<
view.metadata().addressOf_y() <<
" = " << Column(
view.y(),
view.metadata().size()) <<
",\n" 160 <<
" z @ " <<
view.metadata().addressOf_z() <<
" = " << Column(
view.z(),
view.metadata().size()) <<
",\n" 161 <<
" id @ " <<
view.metadata().addressOf_id() <<
" = " << Column(
view.id(),
view.metadata().size())
163 <<
" r @ " <<
view.metadata().addressOf_r() <<
" = " <<
view.r() <<
'\n' 164 <<
" flags @ " <<
view.metadata().addressOf_flags() <<
" = " << Column(
view.flags(),
view.metadata().size())
168 msg << std::hex <<
" [y - x] = 0x" 169 <<
reinterpret_cast<intptr_t
>(
view.metadata().addressOf_y()) -
170 reinterpret_cast<intptr_t>(
view.metadata().addressOf_x())
172 << reinterpret_cast<intptr_t>(
view.metadata().addressOf_z()) -
173 reinterpret_cast<intptr_t>(
view.metadata().addressOf_y())
175 << reinterpret_cast<intptr_t>(
view.metadata().addressOf_id()) -
176 reinterpret_cast<intptr_t>(
view.metadata().addressOf_z())
178 << reinterpret_cast<intptr_t>(
view.metadata().addressOf_r()) -
179 reinterpret_cast<intptr_t>(
view.metadata().addressOf_id())
180 <<
" [flags - r] = 0x" 181 << reinterpret_cast<intptr_t>(
view.metadata().addressOf_flags()) -
182 reinterpret_cast<intptr_t>(
view.metadata().addressOf_r())
183 <<
" [m - flags] = 0x" 184 << reinterpret_cast<intptr_t>(
view.metadata().addressOf_m()) -
185 reinterpret_cast<intptr_t>(
view.metadata().addressOf_flags());
188 checkViewAddresses(
view);
189 checkViewAddresses(mview);
190 checkViewAddresses(cmview);
192 const portabletest::Matrix matrix{{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, 10, 12}, {3, 6, 9, 12, 15, 18}};
195 for (int32_t
i = 0;
i <
view.metadata().size(); ++
i) {
225 auto const& viewMulti2_0 = productMulti2.
const_view<0>();
226 auto& mviewMulti2_0 = productMulti2.
view<0>();
227 auto const& cmviewMulti2_0 = productMulti2.
view<0>();
228 auto const& viewMulti2_1 = productMulti2.
const_view<1>();
229 auto& mviewMulti2_1 = productMulti2.
view<1>();
230 auto const& cmviewMulti2_1 = productMulti2.
view<1>();
232 checkViewAddresses(viewMulti2_0);
233 checkViewAddresses(mviewMulti2_0);
234 checkViewAddresses(cmviewMulti2_0);
235 checkViewAddresses2(viewMulti2_1);
236 checkViewAddresses2(mviewMulti2_1);
237 checkViewAddresses2(cmviewMulti2_1);
239 assert(viewMulti2_0.r() == 1.);
240 for (int32_t
i = 0;
i < viewMulti2_0.metadata().size(); ++
i) {
241 auto vi = viewMulti2_0[
i];
255 assert(viewMulti2_1.r2() == 2.);
256 for (int32_t
i = 0;
i < viewMulti2_1.metadata().size(); ++
i) {
257 auto vi = viewMulti2_1[
i];
269 auto const& viewMulti3_0 = productMulti3.
const_view<0>();
270 auto& mviewMulti3_0 = productMulti3.
view<0>();
271 auto const& cmviewMulti3_0 = productMulti3.
view<0>();
272 auto const& viewMulti3_1 = productMulti3.
const_view<1>();
273 auto& mviewMulti3_1 = productMulti3.
view<1>();
274 auto const& cmviewMulti3_1 = productMulti3.
view<1>();
275 auto const& viewMulti3_2 = productMulti3.
const_view<2>();
276 auto& mviewMulti3_2 = productMulti3.
view<2>();
277 auto const& cmviewMulti3_2 = productMulti3.
view<2>();
279 checkViewAddresses(viewMulti3_0);
280 checkViewAddresses(mviewMulti3_0);
281 checkViewAddresses(cmviewMulti3_0);
282 checkViewAddresses2(viewMulti3_1);
283 checkViewAddresses2(mviewMulti3_1);
284 checkViewAddresses2(cmviewMulti3_1);
285 checkViewAddresses3(viewMulti3_2);
286 checkViewAddresses3(mviewMulti3_2);
287 checkViewAddresses3(cmviewMulti3_2);
289 assert(viewMulti3_0.r() == 1.);
290 for (int32_t
i = 0;
i < viewMulti3_0.metadata().size(); ++
i) {
291 auto vi = viewMulti3_0[
i];
301 assert(viewMulti3_1.r2() == 2.);
302 for (int32_t
i = 0;
i < viewMulti3_1.metadata().size(); ++
i) {
303 auto vi = viewMulti3_1[
i];
314 assert(viewMulti3_2.r3() == 3.);
315 for (int32_t
i = 0;
i < viewMulti3_2.metadata().size(); ++
i) {
316 auto vi = viewMulti3_2[
i];
331 desc.add<
int>(
"expectSize", -1)
332 ->setComment(
"Expected size of the input collection. Values < 0 mean the check is not performed. Default: -1");
333 desc.add<std::vector<double>>(
"expectXvalues", std::vector<double>(0.))
335 "Expected values of the 'x' field in the input collection. Empty value means to not perform the check. If " 336 "input collection has more elements than this parameter, the parameter values are looped over. Default: " 340 "Expected backend of the input collection. Empty value means to not perform the check. Default: empty "
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< portabletest::TestHostCollection > token_
Eigen::Matrix< double, 3, 6 > Matrix
void analyze(edm::StreamID sid, edm::Event const &event, edm::EventSetup const &) const override
std::optional< cms::alpakatools::Backend > expectBackend_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConstView const & const_view() const
const edm::InputTag source_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< portabletest::TestHostMultiCollection2 > tokenMulti2_
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
edm::EDGetTokenT< unsigned short > backendToken_
#define DEFINE_FWK_MODULE(type)
const std::vector< double > expectXvalues_
char data[epos_bytes_allocation]
const edm::EDGetTokenT< portabletest::TestHostMultiCollection3 > tokenMulti3_
TestAlpakaAnalyzer(edm::ParameterSet const &config)
ConstView< Idx > const & const_view() const