/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/common/array_wrapper.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/common/array_wrapper.hpp Source File#

2 min read time

Applies to Linux

rocCV: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/common/array_wrapper.hpp Source File
array_wrapper.hpp
Go to the documentation of this file.
1 
22 #pragma once
23 
24 #include <hip/hip_runtime.h>
25 
32 template <typename T, size_t N>
33 class ArrayWrapper {
34  public:
40  ArrayWrapper(const T *data) {
41  if (data == nullptr) {
42  return;
43  }
44 
45 #pragma unroll
46  for (size_t i = 0; i < N; i++) {
47  this->data_[i] = data[i];
48  }
49  }
50 
51  __device__ __host__ T &operator[](size_t i) { return this->data_[i]; }
52 
53  __device__ __host__ const T &operator[](size_t i) const {
54  return this->data_[i];
55  }
56 
57  private:
58  T data_[N];
59 };
A helper class to transfer fixed size arrays to device.
Definition: array_wrapper.hpp:33
__device__ __host__ const T & operator[](size_t i) const
Definition: array_wrapper.hpp:53
__device__ __host__ T & operator[](size_t i)
Definition: array_wrapper.hpp:51
ArrayWrapper(const T *data)
Construct a new Array Wrapper object.
Definition: array_wrapper.hpp:40