1/*******************************************************************************
2* Copyright 2020-2021 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
17#include "cpu/x64/amx_tile_configure.hpp"
18#include "cpu/x64/jit_generator.hpp"
19
20namespace dnnl {
21namespace impl {
22namespace cpu {
23namespace x64 {
24
25struct jit_amx_tilecfg_t : public jit_generator {
26 DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_amx_tilecfg_t)
27
28 // TODO: Need to check status
29 jit_amx_tilecfg_t()
30 : jit_generator(
31 jit_name(), nullptr, MAX_CODE_SIZE, true, avx512_core_amx) {
32 create_kernel();
33 }
34
35 void tile_configure(const char *palette) const { (*this)(palette); }
36
37private:
38 void generate() override {
39 ldtilecfg(ptr[abi_param1]);
40 ret();
41 }
42};
43
44struct jit_amx_tilerelease_t : public jit_generator {
45 DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_amx_tilerelease_t)
46
47 // TODO: Need to check status
48 jit_amx_tilerelease_t()
49 : jit_generator(
50 jit_name(), nullptr, MAX_CODE_SIZE, true, avx512_core_amx) {
51 create_kernel();
52 }
53
54 void tile_release() const { (*this)(); }
55
56private:
57 void generate() override {
58 tilerelease();
59 ret();
60 }
61};
62
63status_t amx_tile_configure(const char palette[AMX_PALETTE_SIZE]) {
64 static const jit_amx_tilecfg_t tilecfg;
65 tilecfg.tile_configure(palette);
66 return status::success;
67};
68
69status_t amx_tile_release() {
70 static const jit_amx_tilerelease_t tilerls;
71 tilerls.tile_release();
72 return status::success;
73};
74
75} // namespace x64
76} // namespace cpu
77} // namespace impl
78} // namespace dnnl
79