MU Library
call_main.hpp File Reference
#include <cstdint>
#include <cstring>
#include "call_main_template.hpp"
#include "mu/ndarray/ndarray.hpp"
Include dependency graph for call_main.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mu::function_traits< Function >
 

Namespaces

 mu
 
 mu::detail
 

Macros

#define GET_ARG(num)
 
#define PRIMITIVE_CAT(a, ...)   a##__VA_ARGS__
 
#define ARGS(x)   PRIMITIVE_CAT(ARGS_, x)
 
#define ARGS_0
 
#define ARGS_1   GET_ARG(1);
 
#define ARGS_2   ARGS_1 GET_ARG(2);
 
#define ARGS_3   ARGS_2 GET_ARG(3);
 
#define ARGS_4   ARGS_3 GET_ARG(4);
 
#define ARGS_5   ARGS_4 GET_ARG(5);
 
#define ARGS_6   ARGS_5 GET_ARG(6);
 
#define ARGS_7   ARGS_6 GET_ARG(7);
 
#define ARGS_8   ARGS_7 GET_ARG(8);
 
#define ARGS_9   ARGS_8 GET_ARG(9);
 
#define STORE_ARG(num)
 
#define STORES(x)   PRIMITIVE_CAT(STORES_, x)
 
#define STORES_0
 
#define STORES_1   STORE_ARG(1);
 
#define STORES_2   STORES_1 STORE_ARG(2);
 
#define STORES_3   STORES_2 STORE_ARG(3);
 
#define STORES_4   STORES_3 STORE_ARG(4);
 
#define STORES_5   STORES_4 STORE_ARG(5);
 
#define STORES_6   STORES_5 STORE_ARG(6);
 
#define STORES_7   STORES_6 STORE_ARG(7);
 
#define STORES_8   STORES_7 STORE_ARG(8);
 
#define STORES_9   STORES_8 STORE_ARG(9);
 
#define CALL_PARAMS(x)   PRIMITIVE_CAT(CALL_PARAMS_, x)
 
#define CALL_PARAMS_0
 
#define CALL_PARAMS_1   a1
 
#define CALL_PARAMS_2   CALL_PARAMS_1, a2
 
#define CALL_PARAMS_3   CALL_PARAMS_2, a3
 
#define CALL_PARAMS_4   CALL_PARAMS_3, a4
 
#define CALL_PARAMS_5   CALL_PARAMS_4, a5
 
#define CALL_PARAMS_6   CALL_PARAMS_5, a6
 
#define CALL_PARAMS_7   CALL_PARAMS_6, a7
 
#define CALL_PARAMS_8   CALL_PARAMS_7, a8
 
#define CALL_PARAMS_9   CALL_PARAMS_8, a9
 
#define CALL_FUNC(x)   fp(CALL_PARAMS(x))
 
#define CALL_HELPER(_NUM)
 

Functions

bool mu::isNormalMode (uint32_t mode)
 
template<typename T >
T mu::detail::loadArgumentSlot (const void *address)
 
template<typename Pointer >
Pointer mu::detail::unpackKernelPointer (bool isNDArrayValue, const char *buffer)
 
template<typename Pointer >
void mu::detail::storeKernelPointer (bool isNDArrayValue, char *buffer, Pointer value)
 
template<typename Param >
decltype(auto) mu::detail::unpackKernelArgument (uint32_t mode, bool isNDArrayValue, char *buffer)
 
 mu::CALL_HELPER (0)
 
 mu::CALL_HELPER (1)
 
 mu::CALL_HELPER (2)
 
 mu::CALL_HELPER (3)
 
 mu::CALL_HELPER (4)
 
 mu::CALL_HELPER (5)
 
 mu::CALL_HELPER (6)
 
 mu::CALL_HELPER (7)
 
 mu::CALL_HELPER (8)
 
 mu::CALL_HELPER (9)
 
template<typename FP >
void mu::callMain (FP func, uint32_t mode, uint32_t ndarrayValueBit, char *buffer)
 

Macro Definition Documentation

◆ ARGS

#define ARGS (   x)    PRIMITIVE_CAT(ARGS_, x)

Definition at line 114 of file call_main.hpp.

◆ ARGS_0

#define ARGS_0

Definition at line 115 of file call_main.hpp.

◆ ARGS_1

#define ARGS_1   GET_ARG(1);

Definition at line 116 of file call_main.hpp.

◆ ARGS_2

#define ARGS_2   ARGS_1 GET_ARG(2);

Definition at line 117 of file call_main.hpp.

◆ ARGS_3

#define ARGS_3   ARGS_2 GET_ARG(3);

Definition at line 118 of file call_main.hpp.

◆ ARGS_4

#define ARGS_4   ARGS_3 GET_ARG(4);

Definition at line 119 of file call_main.hpp.

◆ ARGS_5

#define ARGS_5   ARGS_4 GET_ARG(5);

Definition at line 120 of file call_main.hpp.

◆ ARGS_6

#define ARGS_6   ARGS_5 GET_ARG(6);

Definition at line 121 of file call_main.hpp.

◆ ARGS_7

#define ARGS_7   ARGS_6 GET_ARG(7);

Definition at line 122 of file call_main.hpp.

◆ ARGS_8

#define ARGS_8   ARGS_7 GET_ARG(8);

Definition at line 123 of file call_main.hpp.

◆ ARGS_9

#define ARGS_9   ARGS_8 GET_ARG(9);

Definition at line 124 of file call_main.hpp.

◆ CALL_FUNC

#define CALL_FUNC (   x)    fp(CALL_PARAMS(x))

Definition at line 158 of file call_main.hpp.

◆ CALL_HELPER

#define CALL_HELPER (   _NUM)
Value:
template <typename F> \
class CallHelper<F, _NUM> \
{ \
public: \
template <typename FP> \
static void invoke(FP fp, [[maybe_unused]] uint32_t mode, [[maybe_unused]] uint32_t ndarrayValueBit, \
[[maybe_unused]] char* buffer) \
{ \
[[maybe_unused]] char* argumentStart = buffer; \
ARGS(_NUM); \
CALL_FUNC(_NUM); \
STORES(_NUM); \
} \
}

Definition at line 160 of file call_main.hpp.

◆ CALL_PARAMS

#define CALL_PARAMS (   x)    PRIMITIVE_CAT(CALL_PARAMS_, x)

Definition at line 147 of file call_main.hpp.

◆ CALL_PARAMS_0

#define CALL_PARAMS_0

Definition at line 148 of file call_main.hpp.

◆ CALL_PARAMS_1

#define CALL_PARAMS_1   a1

Definition at line 149 of file call_main.hpp.

◆ CALL_PARAMS_2

#define CALL_PARAMS_2   CALL_PARAMS_1, a2

Definition at line 150 of file call_main.hpp.

◆ CALL_PARAMS_3

#define CALL_PARAMS_3   CALL_PARAMS_2, a3

Definition at line 151 of file call_main.hpp.

◆ CALL_PARAMS_4

#define CALL_PARAMS_4   CALL_PARAMS_3, a4

Definition at line 152 of file call_main.hpp.

◆ CALL_PARAMS_5

#define CALL_PARAMS_5   CALL_PARAMS_4, a5

Definition at line 153 of file call_main.hpp.

◆ CALL_PARAMS_6

#define CALL_PARAMS_6   CALL_PARAMS_5, a6

Definition at line 154 of file call_main.hpp.

◆ CALL_PARAMS_7

#define CALL_PARAMS_7   CALL_PARAMS_6, a7

Definition at line 155 of file call_main.hpp.

◆ CALL_PARAMS_8

#define CALL_PARAMS_8   CALL_PARAMS_7, a8

Definition at line 156 of file call_main.hpp.

◆ CALL_PARAMS_9

#define CALL_PARAMS_9   CALL_PARAMS_8, a9

Definition at line 157 of file call_main.hpp.

◆ GET_ARG

#define GET_ARG (   num)
Value:
static_assert(detail::supported_directional_parameter_v<typename function_traits<F>::arg##num##_type>, \
"Directional kernel pointer parameters must be passed by value, not by reference"); \
using remove_reference##num##_t = typename remove_reference<typename function_traits<F>::arg##num##_type>::type; \
decltype(auto) a##num = detail::unpackKernelArgument<remove_reference##num##_t>( \
mode, (ndarrayValueBit & (1ull << (num - 1))) != 0, buffer); \
buffer += sizeof(void*);
constexpr bool supported_directional_parameter_v

Definition at line 105 of file call_main.hpp.

◆ PRIMITIVE_CAT

#define PRIMITIVE_CAT (   a,
  ... 
)    a##__VA_ARGS__

Definition at line 113 of file call_main.hpp.

◆ STORE_ARG

#define STORE_ARG (   num)
Value:
if constexpr (std::is_lvalue_reference_v<typename function_traits<F>::arg##num##_type> && \
is_pointer<remove_reference##num##_t>::value && !std::is_const_v<remove_reference##num##_t>) \
{ \
detail::storeKernelPointer((ndarrayValueBit & (1ull << (num - 1))) != 0, \
argumentStart + (num - 1) * sizeof(void*), a##num); \
}
void storeKernelPointer(bool isNDArrayValue, char *buffer, Pointer value)
Definition: call_main.hpp:50

Definition at line 128 of file call_main.hpp.

◆ STORES

#define STORES (   x)    PRIMITIVE_CAT(STORES_, x)

Definition at line 135 of file call_main.hpp.

◆ STORES_0

#define STORES_0

Definition at line 136 of file call_main.hpp.

◆ STORES_1

#define STORES_1   STORE_ARG(1);

Definition at line 137 of file call_main.hpp.

◆ STORES_2

#define STORES_2   STORES_1 STORE_ARG(2);

Definition at line 138 of file call_main.hpp.

◆ STORES_3

#define STORES_3   STORES_2 STORE_ARG(3);

Definition at line 139 of file call_main.hpp.

◆ STORES_4

#define STORES_4   STORES_3 STORE_ARG(4);

Definition at line 140 of file call_main.hpp.

◆ STORES_5

#define STORES_5   STORES_4 STORE_ARG(5);

Definition at line 141 of file call_main.hpp.

◆ STORES_6

#define STORES_6   STORES_5 STORE_ARG(6);

Definition at line 142 of file call_main.hpp.

◆ STORES_7

#define STORES_7   STORES_6 STORE_ARG(7);

Definition at line 143 of file call_main.hpp.

◆ STORES_8

#define STORES_8   STORES_7 STORE_ARG(8);

Definition at line 144 of file call_main.hpp.

◆ STORES_9

#define STORES_9   STORES_8 STORE_ARG(9);

Definition at line 145 of file call_main.hpp.