Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-20 02:31:45

0001 #include <cstdlib>
0002 #include <unistd.h>
0003 
0004 #include <alpaka/alpaka.hpp>
0005 
0006 #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h"
0007 #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisHost.h"
0008 #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisSoA.h"
0009 #include "DataFormats/SiPixelDigiSoA/interface/alpaka/SiPixelDigisSoACollection.h"
0010 #include "FWCore/Utilities/interface/stringize.h"
0011 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0012 #include "HeterogeneousCore/AlpakaInterface/interface/devices.h"
0013 #include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
0014 #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h"
0015 
0016 #include "Digis_test.h"
0017 
0018 using namespace ALPAKA_ACCELERATOR_NAMESPACE;
0019 
0020 int main() {
0021   // Get the list of devices on the current platform
0022   auto const& devices = cms::alpakatools::devices<Platform>();
0023   if (devices.empty()) {
0024     std::cerr << "No devices available for the " EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE) " backend, "
0025       "the test will be skipped.\n";
0026     exit(EXIT_FAILURE);
0027   }
0028 
0029   // Run the test on each device
0030   for (const auto& device : devices) {
0031     Queue queue(device);
0032 
0033     // Inner scope to deallocate memory before destroying the stream
0034     {
0035       // Instantiate tracks on device. PortableDeviceCollection allocates
0036       // SoA on device automatically.
0037       SiPixelDigisSoACollection digis_d(1000, queue);
0038       testDigisSoA::runKernels(digis_d.view(), queue);
0039 
0040       // Instantate tracks on host. This is where the data will be
0041       // copied to from device.
0042       SiPixelDigisHost digis_h(digis_d.view().metadata().size(), queue);
0043 
0044       std::cout << digis_h.view().metadata().size() << std::endl;
0045       alpaka::memcpy(queue, digis_h.buffer(), digis_d.const_buffer());
0046       alpaka::wait(queue);
0047     }
0048   }
0049 
0050   return EXIT_SUCCESS;
0051 }