File indexing completed on 2022-11-24 00:02:10
0001 #ifndef DataFormats_Portable_interface_alpaka_PortableDeviceCollection_h
0002 #define DataFormats_Portable_interface_alpaka_PortableDeviceCollection_h
0003
0004 #include <optional>
0005
0006 #include <alpaka/alpaka.hpp>
0007
0008 #include "DataFormats/Portable/interface/PortableCollection.h"
0009 #include "DataFormats/Portable/interface/PortableHostCollection.h"
0010 #include "DataFormats/Portable/interface/PortableDeviceCollection.h"
0011 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0012 #include "HeterogeneousCore/AlpakaInterface/interface/TransferToHost.h"
0013
0014 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0015
0016 #if defined ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
0017
0018
0019
0020 template <typename T>
0021 using PortableCollection = ::PortableHostCollection<T>;
0022
0023 #else
0024
0025
0026 template <typename T>
0027 using PortableCollection = ::PortableDeviceCollection<T, Device>;
0028
0029 #endif
0030
0031 }
0032
0033 namespace traits {
0034
0035
0036 template <typename T>
0037 class PortableCollectionTrait<T, ALPAKA_ACCELERATOR_NAMESPACE::Device> {
0038 using CollectionType = ALPAKA_ACCELERATOR_NAMESPACE::PortableCollection<T>;
0039 };
0040
0041 }
0042
0043 namespace cms::alpakatools {
0044
0045 template <typename T>
0046 struct TransferToHost<ALPAKA_ACCELERATOR_NAMESPACE::PortableCollection<T>> {
0047 using HostDataType = ::PortableHostCollection<T>;
0048
0049 template <typename TQueue>
0050 static HostDataType transferAsync(TQueue& queue,
0051 ALPAKA_ACCELERATOR_NAMESPACE::PortableCollection<T> const& deviceData) {
0052 HostDataType hostData(deviceData->metadata().size(), queue);
0053 alpaka::memcpy(queue, hostData.buffer(), deviceData.buffer());
0054 return hostData;
0055 }
0056 };
0057 }
0058
0059 #endif