File indexing completed on 2024-12-06 02:45:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <cstdlib>
0017 #include <unistd.h>
0018
0019 #include <alpaka/alpaka.hpp>
0020
0021 #include "DataFormats/VertexSoA/interface/ZVertexHost.h"
0022 #include "DataFormats/VertexSoA/interface/alpaka/ZVertexSoACollection.h"
0023 #include "FWCore/Utilities/interface/stringize.h"
0024 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0025 #include "HeterogeneousCore/AlpakaInterface/interface/devices.h"
0026 #include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
0027 #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h"
0028
0029 #include "ZVertexSoA_test.h"
0030
0031 using namespace ALPAKA_ACCELERATOR_NAMESPACE;
0032
0033
0034 constexpr uint32_t maxTracks = 32 * 1024;
0035 constexpr uint32_t maxVertices = 1024;
0036
0037 int main() {
0038
0039 auto const& devices = cms::alpakatools::devices<Platform>();
0040 if (devices.empty()) {
0041 std::cerr << "No devices available for the " EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE) " backend, "
0042 "the test will be skipped.\n";
0043 exit(EXIT_FAILURE);
0044 }
0045
0046
0047 for (const auto& device : devices) {
0048 Queue queue(device);
0049
0050
0051 {
0052
0053
0054 ZVertexSoACollection zvertex_d({{maxTracks, maxVertices}}, queue);
0055 testZVertexSoAT::runKernels(zvertex_d.view(), zvertex_d.view<reco::ZVertexTracksSoA>(), queue);
0056
0057
0058
0059 #ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
0060 ZVertexHost zvertex_h = std::move(zvertex_d);
0061 #else
0062 ZVertexHost zvertex_h = cms::alpakatools::CopyToHost<ZVertexSoACollection>::copyAsync(queue, zvertex_d);
0063 #endif
0064 alpaka::wait(queue);
0065 std::cout << zvertex_h.view().metadata().size() << std::endl;
0066
0067
0068 std::cout << "idv\t"
0069 << "zv\t"
0070 << "wv\t"
0071 << "chi2\t"
0072 << "ptv2\t"
0073 << "ndof\t"
0074 << "sortInd\t"
0075 << "nvFinal\n";
0076
0077 auto vtx_v = zvertex_h.view<reco::ZVertexSoA>();
0078 auto trk_v = zvertex_h.view<reco::ZVertexTracksSoA>();
0079 for (int i = 0; i < 10; ++i) {
0080 auto vi = vtx_v[i];
0081 auto ti = trk_v[i];
0082 std::cout << (int)ti.idv() << "\t" << vi.zv() << "\t" << vi.wv() << "\t" << vi.chi2() << "\t" << vi.ptv2()
0083 << "\t" << (int)ti.ndof() << "\t" << vi.sortInd() << "\t" << (int)vtx_v.nvFinal() << std::endl;
0084 }
0085 }
0086 }
0087
0088 return EXIT_SUCCESS;
0089 }