From fbe430fae98ea3b5dbba064bbf8709390d4ff8e5 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 4 Jul 2022 16:43:59 -0400 Subject: [PATCH] panfrost: Move bifrost_lanes_per_warp to common Whereas the compiler needs to know the warp size for lowering divergent indirects, the driver needs to know it to report the subgroup size. Move the Bifrost-specific helper to common and add the trivial implementation for Midgard. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_quirks.h | 13 ------------- src/panfrost/bifrost/bifrost_compile.c | 2 +- src/panfrost/util/pan_ir.h | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/panfrost/bifrost/bi_quirks.h b/src/panfrost/bifrost/bi_quirks.h index ec21da0d2ca..5dd75dd1db6 100644 --- a/src/panfrost/bifrost/bi_quirks.h +++ b/src/panfrost/bifrost/bi_quirks.h @@ -55,17 +55,4 @@ bifrost_get_quirks(unsigned product_id) } } -/* How many lanes per architectural warp (subgroup)? Used to lower divergent - * indirects. */ - -static inline unsigned -bifrost_lanes_per_warp(unsigned product_id) -{ - switch (product_id >> 12) { - case 6: return 4; - case 7: return 8; - default: return 16; - } -} - #endif diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index e6c97f3f369..431f4031959 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -4566,7 +4566,7 @@ bi_optimize_nir(nir_shader *nir, unsigned gpu_id, bool is_blend) nir_convert_to_lcssa(nir, true, true); NIR_PASS_V(nir, nir_divergence_analysis); NIR_PASS_V(nir, bi_lower_divergent_indirects, - bifrost_lanes_per_warp(gpu_id)); + pan_subgroup_size(gpu_id >> 12)); NIR_PASS_V(nir, nir_shader_instructions_pass, nir_invalidate_divergence, nir_metadata_all, NULL); } diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h index 5a910c7cdd4..820a6e61455 100644 --- a/src/panfrost/util/pan_ir.h +++ b/src/panfrost/util/pan_ir.h @@ -502,4 +502,22 @@ bool pan_nir_lower_64bit_intrin(nir_shader *shader); bool pan_lower_helper_invocation(nir_shader *shader); bool pan_lower_sample_pos(nir_shader *shader); +/* + * Helper returning the subgroup size. Generally, this is equal to the number of + * threads in a warp. For Midgard (including warping models), this returns 1, as + * subgroups are not supported. + */ +static inline unsigned +pan_subgroup_size(unsigned arch) +{ + if (arch >= 9) + return 16; + else if (arch >= 7) + return 8; + else if (arch >= 6) + return 4; + else + return 1; +} + #endif