Skip to content

Commit a204c4b

Browse files
committed
ukernel: x64: initialize amx palette once in finalize
1 parent dac23cd commit a204c4b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/cpu/x64/ukernel/brgemm.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ status_t brgemm_t::finalize() {
122122
// compensation on their own as a binary post-op.
123123
brgemm_desc_.req_s8s8_compensation = false;
124124

125+
// Precompute the pallette
126+
// If status isn't successful, it means tiles configuration is not required.
127+
status = brgemm_init_tiles(brgemm_desc_, palette_);
128+
palette_initialized_ = (status == status::success);
129+
125130
return status::success;
126131
}
127132

@@ -153,11 +158,8 @@ bool brgemm_t::is_execute_postops_valid() const {
153158
}
154159

155160
status_t brgemm_t::set_hw_context() const {
156-
char palette[AMX_PALETTE_SIZE] = {};
157-
auto status = brgemm_init_tiles(brgemm_desc_, palette);
158-
// If status isn't successful, it means tiles configuration is not required.
159-
if (status == status::success) {
160-
status = amx_tile_lazy_configure(palette);
161+
if (palette_initialized_) {
162+
auto status = amx_tile_lazy_configure(palette_);
161163
VCHECK_BRGEMM_STATUS(
162164
status, status == status::success, "amx_tile_configure failed");
163165
}

src/cpu/x64/ukernel/brgemm.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "cpu/ukernel/c_types_map.hpp"
2121

22+
#include "cpu/x64/amx_tile_configure.hpp"
2223
#include "cpu/x64/brgemm/brgemm_types.hpp"
2324

2425
#include "cpu/x64/ukernel/attr_params.hpp"
@@ -95,6 +96,9 @@ struct dnnl_brgemm : public dnnl::impl::c_compatible {
9596
// it during execute(). This is done to avoid string re-creation.
9697
dnnl::impl::status_t create_verbose_info();
9798
std::string verbose_info_;
99+
100+
bool palette_initialized_ = false;
101+
char palette_[dnnl::impl::cpu::x64::AMX_PALETTE_SIZE] = {};
98102
};
99103

100104
namespace dnnl {

0 commit comments

Comments
 (0)