XeTLA v0.3.6
IntelĀ® Xe Templates for Linear Algebra - API Definition Document
 
Loading...
Searching...
No Matches
tile_op_xe.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
25
26namespace gpu::xetla::group {
27
30
32template <typename tile_op_t_, typename tile_shape_, typename mem_desc_c_t_,
33 gpu_arch arch_tag_>
34class epilogue_t<epilogue_policy_tile_op<tile_op_t_, arch_tag_>, tile_shape_,
35 mem_desc_c_t_, std::enable_if_t<(arch_tag_ == gpu_arch::Xe)>> {
36public:
39 using tile_shape = tile_shape_;
40 using mem_desc_c_t = mem_desc_c_t_;
41 static constexpr gpu_arch arch_tag = arch_tag_;
42 static constexpr uint32_t barrier_count = 0;
43 static constexpr uint32_t slm_size = mem_desc_c_t::is_local
44 ? tile_shape::wg_tile_size_x * tile_shape::wg_tile_size_y
45 : 0;
46
48 struct arguments_t {
51 typename tile_op_t::arguments_t tile_op_args;
52
54 inline arguments_t() = default;
55
59 inline arguments_t(typename tile_op_t::arguments_t tile_op_args_)
60 : tile_op_args(tile_op_args_) {}
61 // Be aware of the risks: Rule of three (copy constructor, copy assignment, destructor)
62 // Please check if you need to add self-define destructor
63 // inline ~arguments_t(){}
64 inline arguments_t(const arguments_t &args)
65 : tile_op_args(args.tile_op_args) {}
66
67 inline arguments_t &operator=(const arguments_t &args) {
68 this->tile_op_args = args.tile_op_args;
69 return *this;
70 }
71
75 inline void init(typename tile_op_t::arguments_t tile_op_args_) {
76 tile_op_args = tile_op_args_;
77 }
78 };
79
80private:
81 using work_group_t = typename tile_shape::work_group_t;
82 static constexpr uint32_t sg_tile_m = tile_shape::sg_tile_size_y;
83 static constexpr uint32_t sg_tile_n = tile_shape::sg_tile_size_x;
84 static constexpr uint32_t wg_size_x = tile_shape::wg_size_x;
85 static constexpr uint32_t wg_size_y = tile_shape::wg_size_y;
86 using dtype_c = typename mem_desc_c_t::dtype;
87 static constexpr mem_layout mem_layout_c = mem_desc_c_t::layout;
88 static constexpr mem_space mem_space_c = mem_desc_c_t::space;
89
91 __XETLA_API static void update_sg_tile_tdesc(
92 work_group_t &g, mem_desc_c_t &mem_desc_c) {
93 int32_t sg_idx = g.get_id() % wg_size_x;
94 int32_t sg_idy = g.get_id() / wg_size_x;
95 int32_t tile_offset_n = sg_idx * sg_tile_n;
96 int32_t tile_offset_m = sg_idy * sg_tile_m;
97 mem_desc_c.update_coord(tile_offset_n, tile_offset_m);
98 }
99
100public:
101 static constexpr msg_type msg_type_c
102 = (mem_space_c == mem_space::global ? msg_type::block_2d
104
115 template <typename matAcc_t>
116 __XETLA_API KERNEL_FUNC void operator()(work_group_t &g, matAcc_t &matAcc,
117 mem_desc_c_t mem_desc_c, arguments_t args = {},
118 uint32_t slm_base = 0, uint32_t nbarrier_base = 0) {
119 using mat_tile_desc = typename matAcc_t::tile_desc;
121 using matC_payload_t = subgroup::mem_payload_t<mem_desc_c_t,
122 mat_tile_desc, msg_type_c, arch_tag>;
123 update_sg_tile_tdesc(g, mem_desc_c);
124 tile_op_t tile_op;
125 tile_op(matAcc, mem_desc_c.coord, args.tile_op_args, slm_base,
126 nbarrier_base);
127 matC_t matC;
128 matC_payload_t matC_payload(mem_desc_c);
129 subgroup::elemwise_cvt(matC, matAcc);
130 subgroup::tile_store<cache_hint::streaming, cache_hint::write_back>(
131 matC, matC_payload);
132 }
133};
134
136
137} // namespace gpu::xetla::group
__XETLA_API KERNEL_FUNC void operator()(work_group_t &g, matAcc_t &matAcc, mem_desc_c_t mem_desc_c, arguments_t args={}, uint32_t slm_base=0, uint32_t nbarrier_base=0)
Default epilogue.
Definition tile_op_xe.hpp:116
Is the epilogue functor.
Definition api.hpp:35
#define __XETLA_API
Definition common.hpp:43
C++ API.
C++ API.
#define KERNEL_FUNC
KERNEL_FUNC macro.
Definition common.hpp:39
Definition limitation.hpp:607
__XETLA_API std::enable_if_t<(T_src::register_layout !=reg_layout::linear) &&(T_dst::register_layout !=reg_layout::linear) &&is_same_layout< T_dst, T_src >::value &&(!is_floating_to_integer< T_dst, T_src >::value)> elemwise_cvt(T_dst &dst, T_src &src)
Is the element wise data conversion, the src and dst tile should have the same layout.
Definition op_function.hpp:40
mem_space
Definition common.hpp:77
gpu_arch
Definition common.hpp:73
msg_type
Definition common.hpp:78
mem_layout
Definition common.hpp:76
Epilogue policy for tile_op + store C fusion.
Definition epilogue_policy.hpp:40
tile_op_t_ tile_op_t
Definition epilogue_policy.hpp:41
tile_op_t::arguments_t tile_op_args
Is tile_op arguments, could be a single tile_op argument or chained_tile_op_args.
Definition tile_op_xe.hpp:51
void init(typename tile_op_t::arguments_t tile_op_args_)
Explicit initialization function.
Definition tile_op_xe.hpp:75
arguments_t(typename tile_op_t::arguments_t tile_op_args_)
Constructs a new arguments t object.
Definition tile_op_xe.hpp:59
Is to illustrate the memory information.
Definition api.hpp:44
Is a struct contains some register file.
Definition api.hpp:99
Define a workgroup scope for a specific problem shape.
Definition work_group.hpp:34
__XETLA_API uint32_t get_id()
Definition work_group.hpp:41