1313#include " HeterogeneousCore/AlpakaInterface/interface/workdivision.h"
1414
1515using namespace ALPAKA_ACCELERATOR_NAMESPACE ;
16+ using namespace Catch ::Matchers;
1617
1718using Vector5f = Eigen::Matrix<float , 5 , 1 >;
1819using Vector15f = Eigen::Matrix<float , 15 , 1 >;
20+ using Matrix6x4d = Eigen::Matrix<double , 6 , 4 >;
1921
2022GENERATE_SOA_LAYOUT (SoATemplate,
2123 SOA_COLUMN (float , quality),
@@ -25,6 +27,7 @@ GENERATE_SOA_LAYOUT(SoATemplate,
2527 SOA_COLUMN(float , pt),
2628 SOA_EIGEN_COLUMN(Vector5f, state),
2729 SOA_EIGEN_COLUMN(Vector15f, covariance),
30+ SOA_EIGEN_COLUMN(Matrix6x4d, matrix),
2831 SOA_SCALAR(int , nTracks),
2932 SOA_COLUMN(uint32_t , hitOffsets))
3033
@@ -81,19 +84,21 @@ TEST_CASE("test merge soa alpaka", "[SoAMerge][Alpaka]") {
8184 h_view1[i].pt () = static_cast <float >(5 );
8285 h_view1[i].state ().setConstant (6 .f );
8386 h_view1[i].covariance ().setConstant (7 .f );
87+ h_view1[i].matrix ().setConstant (8.0 );
8488 h_view1[i].hitOffsets () = static_cast <uint32_t >(9 );
8589 }
8690 h_view1.nTracks () = 8 ;
8791
8892 for (int i = 0 ; i < hostCollection2.size (); i++) {
89- h_view2[i].quality () = static_cast <float >(10 );
90- h_view2[i].chi2 () = static_cast <float >(11 );
91- h_view2[i].nLayers () = static_cast <int8_t >(12 );
92- h_view2[i].eta () = static_cast <float >(13 );
93- h_view2[i].pt () = static_cast <float >(14 );
94- h_view2[i].state ().setConstant (15 .f );
95- h_view2[i].covariance ().setConstant (16 .f );
96- h_view2[i].hitOffsets () = static_cast <uint32_t >(18 );
93+ h_view2[i].quality () = static_cast <float >(11 );
94+ h_view2[i].chi2 () = static_cast <float >(12 );
95+ h_view2[i].nLayers () = static_cast <int8_t >(13 );
96+ h_view2[i].eta () = static_cast <float >(14 );
97+ h_view2[i].pt () = static_cast <float >(15 );
98+ h_view2[i].state ().setConstant (16 .f );
99+ h_view2[i].covariance ().setConstant (17 .f );
100+ h_view2[i].matrix ().setConstant (18.0 );
101+ h_view2[i].hitOffsets () = static_cast <uint32_t >(19 );
97102 }
98103 h_view2.nTracks () = 17 ;
99104
@@ -132,13 +137,13 @@ TEST_CASE("test merge soa alpaka", "[SoAMerge][Alpaka]") {
132137 inCol2.data ());
133138 } else if constexpr (std::get<columnIndex>(outDesc.columnTypes ) == cms::soa::SoAColumnType::eigen) {
134139 using EigenType = std::tuple_element_t <columnIndex, decltype (outDesc.parameterTypes )>::ValueType;
135- constexpr int num_rows = EigenType::RowsAtCompileTime;
140+ constexpr int nRows = EigenType::RowsAtCompileTime * EigenType::ColsAtCompileTime ;
136141
137- const auto strideOutput = std::get<1 >(std::get< columnIndex>(outDesc.parameterTypes ).tupleOrPointer () );
138- const auto strideInput1 = std::get<1 >(std::get< columnIndex>(inDesc1.parameterTypes ).tupleOrPointer () );
139- const auto strideInput2 = std::get<1 >(std::get< columnIndex>(inDesc2.parameterTypes ).tupleOrPointer () );
142+ const auto strideOutput = std::get<columnIndex>(outDesc.parameterTypes ).stride ( );
143+ const auto strideInput1 = std::get<columnIndex>(inDesc1.parameterTypes ).stride ( );
144+ const auto strideInput2 = std::get<columnIndex>(inDesc2.parameterTypes ).stride ( );
140145
141- for (int i = 0 ; i < num_rows ; ++i) {
146+ for (int i = 0 ; i < nRows ; ++i) {
142147 const auto offsetOutput = i * strideOutput;
143148 const auto offsetIn1 = i * strideInput1;
144149 const auto offsetIn2 = i * strideInput2;
@@ -173,23 +178,23 @@ TEST_CASE("test merge soa alpaka", "[SoAMerge][Alpaka]") {
173178
174179 for (int i = 0 ; i < nTk1 + nTk2; i++) {
175180 if (i < nTk1) {
176- REQUIRE (h_viewOut[i].quality () == Catch::Approx ( 1 . 0f ));
177- REQUIRE (h_viewOut[i].chi2 () == Catch::Approx ( 2 . 0f ));
178- REQUIRE (h_viewOut[i].nLayers () == 3 );
179- REQUIRE (h_viewOut[i].eta () == Catch::Approx ( 4 . 0f ));
180- REQUIRE (h_viewOut[i].pt () == Catch::Approx ( 5 . 0f ));
181- REQUIRE (h_viewOut[i].state () == Vector5f ( 6 . f , 6 . f , 6 . f , 6 . f , 6 . f ));
182- REQUIRE (h_viewOut[i].covariance () ==
183- Vector15f ( 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f , 7 . f ));
181+ REQUIRE_THAT (h_viewOut[i].quality (), WithinRel (h_view1[i]. quality () ));
182+ REQUIRE_THAT (h_viewOut[i].chi2 (), WithinRel (h_view1[i]. chi2 () ));
183+ REQUIRE (h_viewOut[i].nLayers () == h_view1[i]. nLayers () );
184+ REQUIRE_THAT (h_viewOut[i].eta (), WithinRel (h_view1[i]. eta () ));
185+ REQUIRE_THAT (h_viewOut[i].pt (), WithinRel (h_view1[i]. pt () ));
186+ REQUIRE (h_viewOut[i].state (). isApprox (h_view1[i]. state () ));
187+ REQUIRE (h_viewOut[i].covariance (). isApprox (h_view1[i]. covariance ()));
188+ REQUIRE (h_viewOut[i]. matrix (). isApprox (h_view1[i]. matrix () ));
184189 } else {
185- REQUIRE (h_viewOut[i].quality () == Catch::Approx ( 10 . 0f ));
186- REQUIRE (h_viewOut[i].chi2 () == Catch::Approx ( 11 . 0f ));
187- REQUIRE (h_viewOut[i].nLayers () == 12 );
188- REQUIRE (h_viewOut[i].eta () == Catch::Approx ( 13 . 0f ));
189- REQUIRE (h_viewOut[i].pt () == Catch::Approx ( 14 . 0f ));
190- REQUIRE (h_viewOut[i].state () == Vector5f ( 15 . f , 15 . f , 15 . f , 15 . f , 15 . f ));
191- REQUIRE (h_viewOut[i].covariance () ==
192- Vector15f ( 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f , 16 . f ));
190+ REQUIRE_THAT (h_viewOut[i].quality (), WithinRel (h_view2[i - nTk1]. quality () ));
191+ REQUIRE_THAT (h_viewOut[i].chi2 (), WithinRel (h_view2[i - nTk1]. chi2 () ));
192+ REQUIRE (h_viewOut[i].nLayers () == h_view2[i - nTk1]. nLayers () );
193+ REQUIRE_THAT (h_viewOut[i].eta (), WithinRel (h_view2[i - nTk1]. eta () ));
194+ REQUIRE_THAT (h_viewOut[i].pt (), WithinRel (h_view2[i - nTk1]. pt () ));
195+ REQUIRE (h_viewOut[i].state (). isApprox (h_view2[i - nTk1]. state () ));
196+ REQUIRE (h_viewOut[i].covariance (). isApprox (h_view2[i - nTk1]. covariance ()));
197+ REQUIRE (h_viewOut[i]. matrix (). isApprox (h_view2[i - nTk1]. matrix () ));
193198 }
194199 }
195200 }
0 commit comments