10 #include "hc_defines.h" 11 #include "kalmar_runtime.h" 12 #include "kalmar_serialize.h" 17 template <
typename Kernel>
18 static void append_kernel(
const std::shared_ptr<KalmarQueue>& pQueue,
const Kernel& f,
void* kernel)
20 Kalmar::BufferArgumentsAppender vis(pQueue, kernel);
21 Kalmar::Serialize s(&vis);
22 f.__cxxamp_serialize(s);
25 template <
typename Kernel>
26 static inline std::shared_ptr<KalmarQueue> get_availabe_que(
const Kernel& f)
28 Kalmar::QueueSearcher ser;
29 Kalmar::Serialize s(&ser);
30 f.__cxxamp_serialize(s);
34 return getContext()->auto_select();
37 #pragma clang diagnostic push 38 #pragma clang diagnostic ignored "-Wunused-variable" 39 template<
typename Kernel,
int dim_ext>
40 inline std::shared_ptr<KalmarAsyncOp>
41 mcw_cxxamp_launch_kernel_async(
const std::shared_ptr<KalmarQueue>& pQueue,
size_t *ext,
42 size_t *local_size,
const Kernel& f) restrict(cpu,amp) {
43 #if __KALMAR_ACCELERATOR__ != 1 48 int* foo =
reinterpret_cast<int*
>(&Kernel::__cxxamp_trampoline);
51 std::string kernel_name(f.__cxxamp_trampoline_name());
52 kernel = CLAMP::CreateKernel(kernel_name, pQueue.get());
54 append_kernel(pQueue, f, kernel);
55 return pQueue->LaunchKernelAsync(kernel, dim_ext, ext, local_size);
58 #pragma clang diagnostic pop 60 #pragma clang diagnostic push 61 #pragma clang diagnostic ignored "-Wunused-variable" 62 template<
typename Kernel,
int dim_ext>
64 void mcw_cxxamp_launch_kernel(
const std::shared_ptr<KalmarQueue>& pQueue,
size_t *ext,
65 size_t *local_size,
const Kernel& f) restrict(cpu,amp) {
66 #if __KALMAR_ACCELERATOR__ != 1 71 int* foo =
reinterpret_cast<int*
>(&Kernel::__cxxamp_trampoline);
74 std::string kernel_name(f.__cxxamp_trampoline_name());
75 kernel = CLAMP::CreateKernel(kernel_name, pQueue.get());
77 append_kernel(pQueue, f, kernel);
78 pQueue->LaunchKernel(kernel, dim_ext, ext, local_size);
79 #endif // __KALMAR_ACCELERATOR__ 81 #pragma clang diagnostic pop 83 #pragma clang diagnostic push 84 #pragma clang diagnostic ignored "-Wunused-variable" 85 template<
typename Kernel>
86 inline void* mcw_cxxamp_get_kernel(
const std::shared_ptr<KalmarQueue>& pQueue,
const Kernel& f) restrict(cpu,amp) {
87 #if __KALMAR_ACCELERATOR__ != 1 92 int* foo =
reinterpret_cast<int*
>(&Kernel::__cxxamp_trampoline);
94 std::string kernel_name (f.__cxxamp_trampoline_name());
95 kernel = CLAMP::CreateKernel(kernel_name, pQueue.get());
101 #pragma clang diagnostic pop 103 template<
typename Kernel,
int dim_ext>
105 void mcw_cxxamp_execute_kernel_with_dynamic_group_memory(
106 const std::shared_ptr<KalmarQueue>& pQueue,
size_t *ext,
size_t *local_size,
107 const Kernel& f,
void *kernel,
size_t dynamic_group_memory_size) restrict(cpu,amp) {
108 #if __KALMAR_ACCELERATOR__ != 1 109 append_kernel(pQueue, f, kernel);
110 pQueue->LaunchKernelWithDynamicGroupMemory(kernel, dim_ext, ext, local_size, dynamic_group_memory_size);
111 #endif // __KALMAR_ACCELERATOR__ 114 template<
typename Kernel,
int dim_ext>
115 inline std::shared_ptr<KalmarAsyncOp>
116 mcw_cxxamp_execute_kernel_with_dynamic_group_memory_async(
117 const std::shared_ptr<KalmarQueue>& pQueue,
size_t *ext,
size_t *local_size,
118 const Kernel& f,
void *kernel,
size_t dynamic_group_memory_size) restrict(cpu,amp) {
119 #if __KALMAR_ACCELERATOR__ != 1 120 append_kernel(pQueue, f, kernel);
121 return pQueue->LaunchKernelWithDynamicGroupMemoryAsync(kernel, dim_ext, ext, local_size, dynamic_group_memory_size);
122 #endif // __KALMAR_ACCELERATOR__ namespace for internal classes of Kalmar compiler / runtime
Definition: hc.hpp:42