Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-04 04:35:00

0001 /* Simple test for the copyFromDense and copyToDense utilities from DataFormats/TrackSoA/interface/alpaka/TrackUtilities.h .
0002  *
0003  * Creates an instance of TracksSoACollection<pixelTopology::Phase1> (automatically allocates memory on device),
0004  * passes the view of the SoA data to the kernel that:
0005  *   - fill the SoA with covariance data;
0006  *   - copy the covariance data to the dense representation, and back to the matrix representation;
0007  *   - verify that the data is copied back and forth correctly.
0008  */
0009 
0010 #include <cstdlib>
0011 #include <iostream>
0012 
0013 #include <alpaka/alpaka.hpp>
0014 
0015 #include "DataFormats/TrackSoA/interface/TracksSoA.h"
0016 #include "DataFormats/TrackSoA/interface/alpaka/TracksSoACollection.h"
0017 #include "FWCore/Utilities/interface/stringize.h"
0018 #include "Geometry/CommonTopologies/interface/SimplePixelTopology.h"
0019 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0020 #include "HeterogeneousCore/AlpakaInterface/interface/devices.h"
0021 
0022 #include "TrajectoryStateSoA_t.h"
0023 
0024 // Each test binary is built for a single Alpaka backend.
0025 using namespace ALPAKA_ACCELERATOR_NAMESPACE;
0026 
0027 int main() {
0028   // Get the list of devices on the current platform.
0029   auto const& devices = cms::alpakatools::devices<Platform>();
0030   if (devices.empty()) {
0031     std::cerr << "No devices available for the " EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE) " backend, "
0032       "the test will be skipped.\n";
0033     exit(EXIT_FAILURE);
0034   }
0035 
0036   // Run the test on each device.
0037   for (const auto& device : devices) {
0038     Queue queue(device);
0039 
0040     // Inner scope to deallocate memory before destroying the stream.
0041     {
0042       TracksSoACollection<pixelTopology::Phase1> tracks_d(queue);
0043 
0044       test::testTrackSoA<pixelTopology::Phase1>(queue, tracks_d.view());
0045 
0046       // Wait for the tests to complete.
0047       alpaka::wait(queue);
0048     }
0049   }
0050 
0051   return EXIT_SUCCESS;
0052 }