File indexing completed on 2024-04-06 12:05:11
0001 #ifndef DataFormats_SiPixelClusterSoA_interface_alpaka_SiPixelClustersSoACollection_h
0002 #define DataFormats_SiPixelClusterSoA_interface_alpaka_SiPixelClustersSoACollection_h
0003
0004 #include <alpaka/alpaka.hpp>
0005
0006 #include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
0007 #include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersDevice.h"
0008 #include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersHost.h"
0009 #include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersSoA.h"
0010 #include "HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h"
0011 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0012
0013 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0014 using SiPixelClustersSoACollection =
0015 std::conditional_t<std::is_same_v<Device, alpaka::DevCpu>, SiPixelClustersHost, SiPixelClustersDevice<Device>>;
0016 }
0017
0018 namespace cms::alpakatools {
0019 template <typename TDevice>
0020 struct CopyToHost<SiPixelClustersDevice<TDevice>> {
0021 template <typename TQueue>
0022 static auto copyAsync(TQueue &queue, SiPixelClustersDevice<TDevice> const &srcData) {
0023
0024 SiPixelClustersHost dstData(srcData->metadata().size() - 1, queue);
0025 alpaka::memcpy(queue, dstData.buffer(), srcData.buffer());
0026 dstData.setNClusters(srcData.nClusters(), srcData.offsetBPIX2());
0027 #ifdef GPU_DEBUG
0028 printf("SiPixelClustersSoACollection: I'm copying to host.\n");
0029 #endif
0030 return dstData;
0031 }
0032 };
0033 }
0034
0035 ASSERT_DEVICE_MATCHES_HOST_COLLECTION(SiPixelClustersSoACollection, SiPixelClustersHost);
0036 #endif