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/SiPixelDigiErrorsDevice.h"
0007 #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsHost.h"
0008 #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigiErrorsSoA.h"
0009 #include "DataFormats/SiPixelDigiSoA/interface/alpaka/SiPixelDigiErrorsSoACollection.h"
0010 #include "FWCore/Utilities/interface/stringize.h"
0011 #include "HeterogeneousCore/AlpakaInterface/interface/devices.h"
0012 #include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
0013 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0014 #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h"
0015 
0016 #include "DigiErrors_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       SiPixelDigiErrorsSoACollection digiErrors_d(1000, queue);
0038       testDigisSoA::runKernels(digiErrors_d.view(), queue);
0039 
0040       // Instantate tracks on host. This is where the data will be
0041       // copied to from device.
0042       SiPixelDigiErrorsHost digiErrors_h(digiErrors_d.view().metadata().size(), queue);
0043       alpaka::memcpy(queue, digiErrors_h.buffer(), digiErrors_d.const_buffer());
0044       std::cout << "digiErrors_h.view().metadata().size(): " << digiErrors_h.view().metadata().size() << std::endl;
0045       std::cout << "digiErrors_h.view()[100].pixelErrors().rawId: " << digiErrors_h.view()[100].pixelErrors().rawId
0046                 << std::endl;
0047       std::cout << "digiErrors_h.view()[100].pixelErrors().word: " << digiErrors_h.view()[100].pixelErrors().word
0048                 << std::endl;
0049       std::cout << "digiErrors_h.view()[100].pixelErrors().errorType: "
0050                 << digiErrors_h.view()[100].pixelErrors().errorType << std::endl;
0051       std::cout << "digiErrors_h.view()[100].pixelErrors().fedId: " << digiErrors_h.view()[100].pixelErrors().fedId
0052                 << std::endl;
0053       alpaka::wait(queue);
0054     }
0055   }
0056 
0057   return EXIT_SUCCESS;
0058 }