CMS 3D CMS Logo

Classes | Functions
ALPAKA_ACCELERATOR_NAMESPACE::test Namespace Reference

Classes

struct  KernelAddVectorsD
 
struct  KernelAddVectorsF
 

Functions

ALPAKA_FN_ACC void add_vectors_d (Acc1D const &acc, double const *__restrict__ in1, double const *__restrict__ in2, double *__restrict__ out, uint32_t size)
 
ALPAKA_FN_ACC void add_vectors_f (Acc1D const &acc, float const *__restrict__ in1, float const *__restrict__ in2, float *__restrict__ out, uint32_t size)
 
void opaque_add_vectors_d (const double *in1, const double *in2, double *out, uint32_t size)
 
void opaque_add_vectors_f (const float *in1, const float *in2, float *out, uint32_t size)
 
void wrapper_add_vectors_d (Queue &queue, const double *__restrict__ in1, const double *__restrict__ in2, double *__restrict__ out, uint32_t size)
 
void wrapper_add_vectors_f (Queue &queue, const float *__restrict__ in1, const float *__restrict__ in2, float *__restrict__ out, uint32_t size)
 

Function Documentation

◆ add_vectors_d()

ALPAKA_FN_ACC void ALPAKA_ACCELERATOR_NAMESPACE::test::add_vectors_d ( Acc1D const &  acc,
double const *__restrict__  in1,
double const *__restrict__  in2,
double *__restrict__  out,
uint32_t  size 
)
inline

Definition at line 23 of file DeviceAddition.h.

References mps_fire::i, MillePedeFileConverter_cfg::out, and cms::alpakatools::uniform_elements().

Referenced by ALPAKA_ACCELERATOR_NAMESPACE::test::KernelAddVectorsD::operator()().

27  {
28  for (auto i : cms::alpakatools::uniform_elements(acc, size)) {
29  out[i] = in1[i] + in2[i];
30  }
31  }
size
Write out results.
ALPAKA_FN_ACC auto uniform_elements(TAcc const &acc, TArgs... args)
Definition: workdivision.h:311

◆ add_vectors_f()

ALPAKA_FN_ACC void ALPAKA_ACCELERATOR_NAMESPACE::test::add_vectors_f ( Acc1D const &  acc,
float const *__restrict__  in1,
float const *__restrict__  in2,
float *__restrict__  out,
uint32_t  size 
)
inline

◆ opaque_add_vectors_d()

void ALPAKA_ACCELERATOR_NAMESPACE::test::opaque_add_vectors_d ( const double *  in1,
const double *  in2,
double *  out,
uint32_t  size 
)

Definition at line 49 of file DeviceAdditionOpaque.cc.

References MillePedeFileConverter_cfg::out, createBeamHaloJobs::queue, SequenceTypes::wait(), and wrapper_add_vectors_d().

49  {
50  // run on the first available devices
51  auto const& device = cms::alpakatools::devices<Platform>()[0];
52  Queue queue{device};
53 
54  // wrap the input and output data in views
55  auto in1_h = cms::alpakatools::make_host_view<const double>(in1, size);
56  auto in2_h = cms::alpakatools::make_host_view<const double>(in2, size);
57  auto out_h = cms::alpakatools::make_host_view<double>(out, size);
58 
59  // allocate input and output buffers on the device
60  auto in1_d = cms::alpakatools::make_device_buffer<double[]>(queue, size);
61  auto in2_d = cms::alpakatools::make_device_buffer<double[]>(queue, size);
62  auto out_d = cms::alpakatools::make_device_buffer<double[]>(queue, size);
63 
64  // copy the input data to the device
65  // FIXME: pass the explicit size of type uint32_t to avoid compilation error
66  // The destination view and the extent are required to have compatible index types!
67  alpaka::memcpy(queue, in1_d, in1_h, size);
68  alpaka::memcpy(queue, in2_d, in2_h, size);
69 
70  // fill the output buffer with zeros
71  alpaka::memset(queue, out_d, 0);
72 
73  // launch the 1-dimensional kernel for vector addition
74  test::wrapper_add_vectors_d(queue, in1_d.data(), in2_d.data(), out_d.data(), size);
75 
76  // copy the results from the device to the host
77  alpaka::memcpy(queue, out_h, out_d);
78 
79  // wait for all the operations to complete
81 
82  // the device buffers are freed automatically
83  }
size
Write out results.
void wrapper_add_vectors_d(Queue &queue, const double *__restrict__ in1, const double *__restrict__ in2, double *__restrict__ out, uint32_t size)

◆ opaque_add_vectors_f()

void ALPAKA_ACCELERATOR_NAMESPACE::test::opaque_add_vectors_f ( const float *  in1,
const float *  in2,
float *  out,
uint32_t  size 
)

Definition at line 13 of file DeviceAdditionOpaque.cc.

References MillePedeFileConverter_cfg::out, createBeamHaloJobs::queue, SequenceTypes::wait(), and wrapper_add_vectors_f().

Referenced by ALPAKA_ACCELERATOR_NAMESPACE::AlpakaTestOpaqueAdditionModule::analyze().

13  {
14  // run on the first available devices
15  auto const& device = cms::alpakatools::devices<Platform>()[0];
16  Queue queue{device};
17 
18  // wrap the input and output data in views
19  auto in1_h = cms::alpakatools::make_host_view<const float>(in1, size);
20  auto in2_h = cms::alpakatools::make_host_view<const float>(in2, size);
21  auto out_h = cms::alpakatools::make_host_view<float>(out, size);
22 
23  // allocate input and output buffers on the device
24  auto in1_d = cms::alpakatools::make_device_buffer<float[]>(queue, size);
25  auto in2_d = cms::alpakatools::make_device_buffer<float[]>(queue, size);
26  auto out_d = cms::alpakatools::make_device_buffer<float[]>(queue, size);
27 
28  // copy the input data to the device
29  // FIXME: pass the explicit size of type uint32_t to avoid compilation error
30  // The destination view and the extent are required to have compatible index types!
31  alpaka::memcpy(queue, in1_d, in1_h, size);
32  alpaka::memcpy(queue, in2_d, in2_h, size);
33 
34  // fill the output buffer with zeros
35  alpaka::memset(queue, out_d, 0);
36 
37  // launch the 1-dimensional kernel for vector addition
38  test::wrapper_add_vectors_f(queue, in1_d.data(), in2_d.data(), out_d.data(), size);
39 
40  // copy the results from the device to the host
41  alpaka::memcpy(queue, out_h, out_d);
42 
43  // wait for all the operations to complete
45 
46  // the device buffers are freed automatically
47  }
size
Write out results.
void wrapper_add_vectors_f(Queue &queue, const float *__restrict__ in1, const float *__restrict__ in2, float *__restrict__ out, uint32_t size)

◆ wrapper_add_vectors_d()

void ALPAKA_ACCELERATOR_NAMESPACE::test::wrapper_add_vectors_d ( Queue &  queue,
const double *__restrict__  in1,
const double *__restrict__  in2,
double *__restrict__  out,
uint32_t  size 
)

Definition at line 20 of file DeviceAdditionWrapper.dev.cc.

References MillePedeFileConverter_cfg::out, and createBeamHaloJobs::queue.

Referenced by opaque_add_vectors_d().

24  {
25  alpaka::exec<Acc1D>(queue, cms::alpakatools::make_workdiv<Acc1D>(32, 32), KernelAddVectorsD{}, in1, in2, out, size);
26  }
size
Write out results.

◆ wrapper_add_vectors_f()

void ALPAKA_ACCELERATOR_NAMESPACE::test::wrapper_add_vectors_f ( Queue &  queue,
const float *__restrict__  in1,
const float *__restrict__  in2,
float *__restrict__  out,
uint32_t  size 
)

Definition at line 12 of file DeviceAdditionWrapper.dev.cc.

References MillePedeFileConverter_cfg::out, and createBeamHaloJobs::queue.

Referenced by ALPAKA_ACCELERATOR_NAMESPACE::AlpakaTestWrapperAdditionModule::analyze(), and opaque_add_vectors_f().

16  {
17  alpaka::exec<Acc1D>(queue, cms::alpakatools::make_workdiv<Acc1D>(32, 32), KernelAddVectorsF{}, in1, in2, out, size);
18  }
size
Write out results.