XeTLA v0.3.6
IntelĀ® Xe Templates for Linear Algebra - API Definition Document
 
Loading...
Searching...
No Matches
chained_tile_op.hpp
Go to the documentation of this file.
1/*******************************************************************************
2* Copyright (c) 2022-2023 Intel Corporation
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*******************************************************************************/
16
19
20#pragma once
21
23
24namespace gpu::xetla::subgroup {
25
26template <int idx, typename tile_op_args_t>
28 tile_op_args_t args;
29 inline tile_op_arg_helper_t(tile_op_args_t args_) : args(args_) {}
30 // Be aware of the risks: Rule of three (copy constructor, copy assignment, destructor)
31 // Please check if you need to add self-define destructor
32 // ~tile_op_arg_helper_t(){}
35 : args(args_helper.args) {}
36 // Be aware of the risks: Rule of three (copy constructor, copy assignment, destructor)
37 // Please check if you need to add self-define destructor
38 // inline ~tile_op_arg_helper_t(){}
41 this->args = args_helper.args;
42 return *this;
43 }
44 inline tile_op_arg_helper_t() = default;
45 // Be aware of the risks: Rule of three (copy constructor, copy assignment, destructor)
46 // Please check if you need to add self-define destructor
47 // ~tile_op_arg_helper_t(){}
48
49 inline tile_op_args_t get_args() const { return args; }
50 inline void set_args(const tile_op_args_t &new_args) { args = new_args; }
51};
52
53template <int idx, typename... tile_op_args_t>
55
56template <int idx, typename curr_args_t, typename... remain_args_t>
57struct chained_tile_op_arg_t<idx, curr_args_t, remain_args_t...>
58 : public tile_op_arg_helper_t<idx, curr_args_t>,
59 public chained_tile_op_arg_t<idx + 1, remain_args_t...> {
60 inline chained_tile_op_arg_t() = default;
62 curr_args_t curr_args, remain_args_t... remain_args)
63 : tile_op_arg_helper_t<idx, curr_args_t>(curr_args)
64 , chained_tile_op_arg_t<idx + 1, remain_args_t...>(remain_args...) {}
65
68 &args)
69 = default;
70
71 template <int idx_, typename T>
72 inline T get() const {
74 }
75 template <int idx_, typename T>
76 inline void set(T new_args) {
78 }
79};
80
81template <typename... tile_op_t>
84 = chained_tile_op_arg_t<0, typename tile_op_t::arguments_t...>;
85 static constexpr int list_size = sizeof...(tile_op_t);
86 template <typename matAcc_t, typename coord_t>
87 __XETLA_API KERNEL_FUNC void operator()(matAcc_t &matAcc,
88 const coord_t &coord, const arguments_t &args_helper,
89 uint32_t slm_base = 0, uint32_t nbarrier_base = 0) {
90 if constexpr (list_size == 0) {
91 return;
92 } else {
93 chained_tile_op_helper<tile_op_t...> chained_tile_op;
94 chained_tile_op(
95 matAcc, coord, args_helper, slm_base, nbarrier_base);
96 }
97 }
98
99private:
100 template <typename... total_tile_op_t>
101 struct chained_tile_op_helper {};
102
103 template <typename curr_tile_op_t, typename... remain_tile_op_t>
104 struct chained_tile_op_helper<curr_tile_op_t, remain_tile_op_t...> {
105 using curr_tile_op_args_t = typename curr_tile_op_t::arguments_t;
106 static constexpr int curr_idx
107 = list_size - sizeof...(remain_tile_op_t) - 1;
108 template <typename matAcc_t, typename coord_t>
109 __XETLA_API KERNEL_FUNC void operator()(matAcc_t &matAcc,
110 const coord_t &coord, const arguments_t &args_helper,
111 uint32_t slm_base = 0, uint32_t nbarrier_base = 0) {
112 curr_tile_op_t curr_tile_op;
113 //call the actual tile op
114 curr_tile_op(matAcc, coord,
115 args_helper.template get<curr_idx, curr_tile_op_args_t>(),
116 slm_base, nbarrier_base);
117 if constexpr (sizeof...(remain_tile_op_t) > 0) {
118 chained_tile_op_helper<remain_tile_op_t...> remain_tile_op;
119 remain_tile_op(
120 matAcc, coord, args_helper, slm_base, nbarrier_base);
121 }
122 }
123 };
124};
125
126} // namespace gpu::xetla::subgroup
#define __XETLA_API
Definition common.hpp:43
#define KERNEL_FUNC
KERNEL_FUNC macro.
Definition common.hpp:39
Definition limitation.hpp:457
chained_tile_op_arg_t(curr_args_t curr_args, remain_args_t... remain_args)
Definition chained_tile_op.hpp:61
chained_tile_op_arg_t(chained_tile_op_arg_t< idx, curr_args_t, remain_args_t... > const &args)=default
Definition chained_tile_op.hpp:54
Definition chained_tile_op.hpp:82
chained_tile_op_arg_t< 0, typename tile_op_t::arguments_t... > arguments_t
Definition chained_tile_op.hpp:84
__XETLA_API KERNEL_FUNC void operator()(matAcc_t &matAcc, const coord_t &coord, const arguments_t &args_helper, uint32_t slm_base=0, uint32_t nbarrier_base=0)
Definition chained_tile_op.hpp:87
static constexpr int list_size
Definition chained_tile_op.hpp:85
Definition chained_tile_op.hpp:27
tile_op_args_t args
Definition chained_tile_op.hpp:28
void set_args(const tile_op_args_t &new_args)
Definition chained_tile_op.hpp:50
tile_op_arg_helper_t & operator=(const tile_op_arg_helper_t< idx, tile_op_args_t > &args_helper)
Definition chained_tile_op.hpp:39
tile_op_arg_helper_t(tile_op_args_t args_)
Definition chained_tile_op.hpp:29
tile_op_arg_helper_t(const tile_op_arg_helper_t< idx, tile_op_args_t > &args_helper)
Definition chained_tile_op.hpp:33
tile_op_args_t get_args() const
Definition chained_tile_op.hpp:49
C++ API.