src
DataFormats
Portable
interface
PortableObject.h
Go to the documentation of this file.
1
#ifndef DataFormats_Portable_interface_PortableObject_h
2
#define DataFormats_Portable_interface_PortableObject_h
3
4
#include <type_traits>
5
6
#include <alpaka/alpaka.hpp>
7
8
#include "
DataFormats/Portable/interface/PortableHostObject.h
"
9
#include "
DataFormats/Portable/interface/PortableDeviceObject.h
"
10
#include "
HeterogeneousCore/AlpakaInterface/interface/CopyToDevice.h
"
11
#include "
HeterogeneousCore/AlpakaInterface/interface/CopyToHost.h
"
12
13
namespace
traits
{
14
15
// trait for a generic struct-based product
16
template
<
typename
T,
typename
TDev,
typename
= std::enable_if_t<alpaka::isDevice<TDev>>>
17
struct
PortableObjectTrait
{
18
using
ProductType
=
PortableDeviceObject<T, TDev>
;
19
};
20
21
// specialise for host device
22
template
<
typename
T>
23
struct
PortableObjectTrait
<
T
,
alpaka_common
::
DevHost
> {
24
using
ProductType
=
PortableHostObject<T>
;
25
};
26
27
}
// namespace traits
28
29
// type alias for a generic struct-based product
30
template
<
typename
T,
typename
TDev,
typename
= std::enable_if_t<alpaka::isDevice<TDev>>>
31
using
PortableObject
=
typename
traits::PortableObjectTrait<T, TDev>::ProductType
;
32
33
// define how to copy PortableObject between host and device
34
namespace
cms::alpakatools
{
35
template
<
typename
TProduct,
typename
TDevice>
36
struct
CopyToHost
<
PortableDeviceObject
<TProduct, TDevice>> {
37
template
<
typename
TQueue>
38
static
auto
copyAsync
(TQueue&
queue
,
PortableDeviceObject<TProduct, TDevice>
const
& srcData) {
39
PortableHostObject<TProduct>
dstData(
queue
);
40
alpaka::memcpy(
queue
, dstData.
buffer
(), srcData.
buffer
());
41
return
dstData;
42
}
43
};
44
45
template
<
typename
TProduct>
46
struct
CopyToDevice
<
PortableHostObject
<TProduct>> {
47
template
<
typename
TQueue>
48
static
auto
copyAsync
(TQueue&
queue
,
PortableHostObject<TProduct>
const
& srcData) {
49
using
TDevice =
typename
alpaka::trait::DevType<TQueue>::type
;
50
PortableDeviceObject<TProduct, TDevice>
dstData(
queue
);
51
alpaka::memcpy(
queue
, dstData.
buffer
(), srcData.
buffer
());
52
return
dstData;
53
}
54
};
55
}
// namespace cms::alpakatools
56
57
#endif // DataFormats_Portable_interface_PortableObject_h
PortableObject
typename traits::PortableObjectTrait< T, TDev >::ProductType PortableObject
Definition:
PortableObject.h:31
PortableDeviceObject
Definition:
PortableDeviceObject.h:15
PortableDeviceObject.h
PortableDeviceObject::buffer
Buffer buffer()
Definition:
PortableDeviceObject.h:64
cms::alpakatools::CopyToDevice< PortableHostObject< TProduct > >::copyAsync
static auto copyAsync(TQueue &queue, PortableHostObject< TProduct > const &srcData)
Definition:
PortableObject.h:48
cms::alpakatools::CopyToHost
Definition:
CopyToHost.h:33
cms::alpakatools::CopyToHost< PortableDeviceObject< TProduct, TDevice > >::copyAsync
static auto copyAsync(TQueue &queue, PortableDeviceObject< TProduct, TDevice > const &srcData)
Definition:
PortableObject.h:38
cms::alpakatools::CopyToDevice
Definition:
CopyToDevice.h:32
alpaka_common
Definition:
config.h:11
createBeamHaloJobs.queue
queue
Definition:
createBeamHaloJobs.py:343
cms::alpakatools
Definition:
PortableCollection.h:48
CopyToDevice.h
gainCalibHelper::gainCalibPI::type
type
Definition:
SiPixelGainCalibHelper.h:40
PortableHostObject.h
traits
Definition:
PortableCollection.h:11
traits::PortableObjectTrait
Definition:
PortableObject.h:17
PortableHostObject::buffer
Buffer buffer()
Definition:
PortableHostObject.h:62
CopyToHost.h
PortableHostObject
Definition:
PortableHostObject.h:16
alpaka_common::DevHost
alpaka::DevCpu DevHost
Definition:
config.h:37
T
long double T
Definition:
Basic3DVectorLD.h:48
Generated for CMSSW Reference Manual by
1.8.14