MU Library
mu::detail Namespace Reference

Classes

struct  input_buffer_direction
 
struct  output_buffer_direction
 
struct  directional_pointer_traits_impl
 
struct  directional_pointer_traits_impl< mu::input_ptr< T > >
 
struct  directional_pointer_traits_impl< mu::output_ptr< T > >
 

Typedefs

template<typename T >
using directional_pointer_traits = directional_pointer_traits_impl< std::remove_cv_t< std::remove_reference_t< T > >>
 

Functions

template<typename T >
T loadArgumentSlot (const void *address)
 
template<typename Pointer >
Pointer unpackKernelPointer (bool isNDArrayValue, const char *buffer)
 
template<typename Pointer >
void storeKernelPointer (bool isNDArrayValue, char *buffer, Pointer value)
 
template<typename Param >
decltype(auto) unpackKernelArgument (uint32_t mode, bool isNDArrayValue, char *buffer)
 

Variables

template<typename T >
constexpr bool supported_directional_parameter_v
 

Typedef Documentation

◆ directional_pointer_traits

template<typename T >
using mu::detail::directional_pointer_traits = typedef directional_pointer_traits_impl<std::remove_cv_t<std::remove_reference_t<T> >>

Definition at line 299 of file call_main_template.hpp.

Function Documentation

◆ loadArgumentSlot()

template<typename T >
T mu::detail::loadArgumentSlot ( const void *  address)

Definition at line 28 of file call_main.hpp.

29 {
30  std::remove_cv_t<T> value;
31  std::memcpy(&value, address, sizeof(value));
32  return value;
33 }

◆ storeKernelPointer()

template<typename Pointer >
void mu::detail::storeKernelPointer ( bool  isNDArrayValue,
char *  buffer,
Pointer  value 
)

Definition at line 50 of file call_main.hpp.

51 {
52  auto parameterSlot = loadArgumentSlot<void*>(buffer);
53  if (isNDArrayValue)
54  {
55  auto ndarray = loadArgumentSlot<mu::NDArray<char>*>(parameterSlot);
56  ndarray->setData(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(value)));
57  }
58  else
59  {
60  std::memcpy(parameterSlot, &value, sizeof(value));
61  }
62 }

◆ unpackKernelArgument()

template<typename Param >
decltype(auto) mu::detail::unpackKernelArgument ( uint32_t  mode,
bool  isNDArrayValue,
char *  buffer 
)

Definition at line 65 of file call_main.hpp.

66 {
67  if constexpr (directional_pointer_traits<Param>::value)
68  {
69  using adapter = directional_pointer_traits<Param>;
70  using wire_type = typename adapter::wire_type;
71  return adapter::fromWire(unpackKernelPointer<wire_type>(isNDArrayValue, buffer));
72  }
73  else if constexpr (is_pointer<Param>::value)
74  {
75  return unpackKernelPointer<Param>(isNDArrayValue, buffer);
76  }
77  else
78  {
79  Param* value = *reinterpret_cast<Param**>(buffer);
80  if constexpr (is_ndarray_v<Param>)
81  {
82  void* argumentAddress = *reinterpret_cast<void**>(buffer);
83  value = *reinterpret_cast<Param**>(argumentAddress);
84  }
85  else if (!isNormalMode(mode))
86  {
87  void* argumentAddress = *reinterpret_cast<void**>(buffer);
88  if (isNDArrayValue)
89  {
90  auto ndarray = reinterpret_cast<mu::NDArray<char>*>(argumentAddress);
91  void* dataPointer = ndarray->data();
92  value = *reinterpret_cast<Param**>(dataPointer);
93  }
94  else
95  {
96  value = *reinterpret_cast<Param**>(argumentAddress);
97  }
98  }
99  return static_cast<Param&>(*value);
100  }
101 }
NDArray is a class that can be used in both host and device code. NDArray is automatically divided in...
Definition: ndarray.hpp:23
T * data()
Definition: ndarray.hpp:79
bool isNormalMode(uint32_t mode)

◆ unpackKernelPointer()

template<typename Pointer >
Pointer mu::detail::unpackKernelPointer ( bool  isNDArrayValue,
const char *  buffer 
)

Definition at line 36 of file call_main.hpp.

37 {
38  // The driver passes &taskCmd.param[i] in each argv slot. For NDArray,
39  // param[i] points to the per-task descriptor, whose data() is the slice.
40  auto parameterSlot = loadArgumentSlot<const void*>(buffer);
41  if (isNDArrayValue)
42  {
43  auto ndarray = loadArgumentSlot<const mu::NDArray<char>*>(parameterSlot);
44  return reinterpret_cast<Pointer>(const_cast<char*>(ndarray->data()));
45  }
46  return loadArgumentSlot<Pointer>(parameterSlot);
47 }

Variable Documentation

◆ supported_directional_parameter_v

template<typename T >
constexpr bool mu::detail::supported_directional_parameter_v
inlineconstexpr
Initial value:
=
!directional_pointer_traits<T>::value || !std::is_reference_v<T>

Definition at line 303 of file call_main_template.hpp.