Skip to content

Commit

Permalink
x64: brgemm conv: heuristic for big convolution on avx2
Browse files Browse the repository at this point in the history
  • Loading branch information
ankalinin committed Jan 31, 2025
1 parent 7db5b55 commit 8e28c6f
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/cpu/x64/jit_brgemm_conv_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1970,13 +1970,17 @@ status_t init_conf(jit_brgemm_conv_conf_t &jcp, cpu_isa_t isa,

using namespace data_type;
// ======================= blocking =================================

auto bcast_amount
= static_cast<size_t>(jcp.id) * jcp.ih * jcp.iw * jcp.src_dsz;
auto bcast_amount = static_cast<size_t>(jcp.id) * jcp.ih * jcp.iw
* jcp.src_dsz * jcp.ic;
auto wei_amount = static_cast<size_t>(jcp.oc) * jcp.kd * jcp.kh * jcp.kw
* jcp.wei_dsz;

jcp.loop_order = (bcast_amount < wei_amount) ? loop_ngcdhw : loop_ndhwgc;
* jcp.wei_dsz * jcp.ic;

jcp.loop_order
= (one_of(isa, avx2, avx2_vnni, avx2_vnni_2) && jcp.mb > jcp.nthr
&& bcast_amount > brg_blocking_t::L2
&& wei_amount > brg_blocking_t::L2)
? loop_gcndhw
: ((bcast_amount < wei_amount) ? loop_ngcdhw : loop_ndhwgc);
jcp.brgemm_kernel_loop_order
= brgemm_kernel_loop_order_t::brgemm_lo_default;

Expand All @@ -1994,6 +1998,13 @@ status_t init_conf(jit_brgemm_conv_conf_t &jcp, cpu_isa_t isa,
const bool small_amx_job = est_amx_job < 64 || jcp.oc < 256;
auto start_ocb
= (is_amx(isa) && jcp.is_os_blocking && small_amx_job) ? 2 : 4;
if (one_of(isa, avx2, avx2_vnni, avx2_vnni_2)
&& jcp.loop_order == loop_gcndhw)
start_ocb = 2;
if (one_of(isa, avx2, avx2_vnni, avx2_vnni_2)
&& jcp.oh * jcp.ow >= 150 * 150)
start_ocb = 2;

start_ocb = nstl::min(div_up(jcp.oc, jcp.acc_simd_w), start_ocb);

auto finish_ocb = 1;
Expand Down Expand Up @@ -2248,7 +2259,6 @@ status_t init_conf(jit_brgemm_conv_conf_t &jcp, cpu_isa_t isa,
#endif

// ============ end blocking ===========================================

jcp.brg_type
= (jcp.use_uker && one_of(jcp.exec_type, exec_base, exec_trans))
? brgemm_static_offs
Expand Down

0 comments on commit 8e28c6f

Please sign in to comment.