DataFormats
Portable
interface
alpaka
PortableCollection.h
Go to the documentation of this file.
1
#ifndef DataFormats_Portable_interface_alpaka_PortableDeviceCollection_h
2
#define DataFormats_Portable_interface_alpaka_PortableDeviceCollection_h
3
4
#include <optional>
5
6
#include <alpaka/alpaka.hpp>
7
8
#include "
DataFormats/Portable/interface/PortableCollection.h
"
9
#include "
DataFormats/Portable/interface/PortableHostCollection.h
"
10
#include "
DataFormats/Portable/interface/PortableDeviceCollection.h
"
11
#include "
HeterogeneousCore/AlpakaInterface/interface/config.h
"
12
#include "
HeterogeneousCore/AlpakaInterface/interface/TransferToHost.h
"
13
14
namespace
ALPAKA_ACCELERATOR_NAMESPACE
{
15
16
#if defined ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
17
// ... or any other CPU-based accelerators
18
19
// generic SoA-based product in host memory
20
template
<
typename
T>
21
using
PortableCollection
=
::PortableHostCollection<T>
;
22
23
#else
24
25
// generic SoA-based product in device memory
26
template
<
typename
T>
27
using
PortableCollection
=
::PortableDeviceCollection<T, Device>
;
28
29
#endif // ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
30
31
}
// namespace ALPAKA_ACCELERATOR_NAMESPACE
32
33
namespace
traits
{
34
35
// specialise the trait for the device provided by the ALPAKA_ACCELERATOR_NAMESPACE
36
template
<
typename
T>
37
class
PortableCollectionTrait
<
T
,
ALPAKA_ACCELERATOR_NAMESPACE
::Device> {
38
using
CollectionType
=
ALPAKA_ACCELERATOR_NAMESPACE::PortableCollection<T>
;
39
};
40
41
}
// namespace traits
42
43
namespace
cms::alpakatools
{
44
// TODO: Is this the right place for the specialization? Or should it be in PortableDeviceProduct?
45
template
<
typename
T>
46
struct
TransferToHost
<
ALPAKA_ACCELERATOR_NAMESPACE
::
PortableCollection
<T>> {
47
using
HostDataType
=
::PortableHostCollection<T>
;
48
49
template
<
typename
TQueue>
50
static
HostDataType
transferAsync
(TQueue&
queue
,
51
ALPAKA_ACCELERATOR_NAMESPACE::PortableCollection<T>
const
& deviceData) {
52
HostDataType
hostData(deviceData->metadata().size(),
queue
);
53
alpaka::memcpy(
queue
, hostData.buffer(), deviceData.
buffer
());
54
return
hostData;
55
}
56
};
57
}
// namespace cms::alpakatools
58
59
#endif // DataFormats_Portable_interface_alpaka_PortableDeviceCollection_h
PortableHostCollection.h
PortableCollection.h
PortableDeviceCollection.h
traits::PortableCollectionTrait
Definition:
PortableCollection.h:10
createBeamHaloJobs.queue
queue
Definition:
createBeamHaloJobs.py:343
cms::alpakatools
Definition:
PortableCollection.h:43
cms::alpakatools::TransferToHost
Definition:
TransferToHost.h:9
ALPAKA_ACCELERATOR_NAMESPACE
Definition:
PortableCollection.h:14
PortableDeviceCollection::buffer
Buffer buffer()
Definition:
PortableDeviceCollection.h:67
PortableHostCollection
Definition:
PortableHostCollection.h:14
traits
Definition:
PortableCollection.h:33
cms::alpakatools::TransferToHost< ALPAKA_ACCELERATOR_NAMESPACE::PortableCollection< T > >::transferAsync
static HostDataType transferAsync(TQueue &queue, ALPAKA_ACCELERATOR_NAMESPACE::PortableCollection< T > const &deviceData)
Definition:
PortableCollection.h:50
TransferToHost.h
PortableDeviceCollection
Definition:
PortableDeviceCollection.h:14
PortableCollection
typename traits::PortableCollectionTrait< T, TDev >::CollectionType PortableCollection
Definition:
PortableCollection.h:16
config.h
T
long double T
Definition:
Basic3DVectorLD.h:48
Generated for CMSSW Reference Manual by
1.8.14