radv/radeonsi: Don't count read-only data when reporting code size
authorConnor Abbott <cwabbott0@gmail.com>
Thu, 29 Aug 2019 15:15:46 +0000 (17:15 +0200)
committerConnor Abbott <cwabbott0@gmail.com>
Thu, 5 Sep 2019 10:21:35 +0000 (12:21 +0200)
We usually use these counts as a simple way to figure out if a change
reduces the number of instructions or shrinks an instruction. However,
since .rodata sections aren't executed, we shouldn't be counting their
size for this analysis. Make the linker return the total executable
size, and use it to report the more useful size in both drivers.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_rtld.c
src/amd/common/ac_rtld.h
src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_shader.c
src/amd/vulkan/radv_shader.h
src/gallium/drivers/radeonsi/si_shader.c

index a1bb51a8a88861cc4e7e8202e6b1777fb46ee155..7c35e72543d2bec6fc407c098efeef9fb7cabf01 100644 (file)
@@ -271,6 +271,7 @@ bool ac_rtld_open(struct ac_rtld_binary *binary,
        uint64_t pasted_text_size = 0;
        uint64_t rx_align = 1;
        uint64_t rx_size = 0;
+       uint64_t exec_size = 0;
 
 #define report_if(cond) \
        do { \
@@ -370,6 +371,8 @@ bool ac_rtld_open(struct ac_rtld_binary *binary,
 
                                        if (!strcmp(s->name, ".text"))
                                                s->is_pasted_text = true;
+
+                                       exec_size += shdr->sh_size;
                                }
 
                                if (s->is_pasted_text) {
@@ -438,6 +441,7 @@ bool ac_rtld_open(struct ac_rtld_binary *binary,
        }
 
        binary->rx_size += rx_size;
+       binary->exec_size = exec_size;
 
        if (i.info->chip_class >= GFX10) {
                /* In gfx10, the SQ fetches up to 3 cache lines of 16 dwords
index 55faaa011db264f38a4979c50b3d9970ca72f7a0..2246cf1208a0d14c91446fb6d64ce569127d5dc3 100644 (file)
@@ -57,6 +57,9 @@ struct ac_rtld_binary {
        /* Required buffer sizes, currently read/executable only. */
        uint64_t rx_size;
 
+       /* Size of executable code, for reporting purposes. */
+       uint64_t exec_size;
+
        uint64_t rx_end_markers;
 
        unsigned num_parts;
index 0897b2d153e31b17fdcff444be1af66fb8611bae..d387e56c60b3730393924cdc5893038389378ad1 100644 (file)
@@ -5025,7 +5025,7 @@ VkResult radv_GetPipelineExecutableStatisticsKHR(
                desc_copy(s->name, "Code size");
                desc_copy(s->description, "Code size in bytes");
                s->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR;
-               s->value.u64 = shader->code_size;
+               s->value.u64 = shader->exec_size;
        }
        ++s;
 
index e907c04863ad9c4197df4b53f5c125b309a42f9a..b6de97deb2443c4f9db24220618d4e77ed9ba536 100644 (file)
@@ -941,10 +941,12 @@ radv_shader_variant_create(struct radv_device *device,
                }
 
                variant->code_size = rtld_binary.rx_size;
+               variant->exec_size = rtld_binary.exec_size;
        } else {
                assert(binary->type == RADV_BINARY_TYPE_LEGACY);
                config = ((struct radv_shader_binary_legacy *)binary)->config;
-               variant->code_size  = radv_get_shader_binary_size(((struct radv_shader_binary_legacy *)binary)->code_size);
+               variant->code_size = radv_get_shader_binary_size(((struct radv_shader_binary_legacy *)binary)->code_size);
+               variant->exec_size = variant->code_size;
        }
 
        variant->info = binary->variant_info;
@@ -1299,7 +1301,7 @@ generate_shader_stats(struct radv_device *device,
                                   "********************\n\n\n",
                                   conf->num_sgprs, conf->num_vgprs,
                                   conf->spilled_sgprs, conf->spilled_vgprs,
-                                  variant->info.private_mem_vgprs, variant->code_size,
+                                  variant->info.private_mem_vgprs, variant->exec_size,
                                   conf->lds_size, conf->scratch_bytes_per_wave,
                                   max_simd_waves);
 }
index 67c45a0f0bdf9c455b72bdc62bfc45f324bd93f5..9d18d4410c185823f9a78f0f1315677d7ac70eb8 100644 (file)
@@ -350,6 +350,7 @@ struct radv_shader_variant {
        uint64_t bo_offset;
        struct ac_shader_config config;
        uint32_t code_size;
+       uint32_t exec_size;
        struct radv_shader_variant_info info;
 
        /* debug only */
index cd75c08404348180c4b8a3e85c0c996a50cbfba4..7636d44bee43584938a0654aff8994493addd026 100644 (file)
@@ -5286,7 +5286,7 @@ static unsigned si_get_shader_binary_size(struct si_screen *screen, struct si_sh
 {
        struct ac_rtld_binary rtld;
        si_shader_binary_open(screen, shader, &rtld);
-       return rtld.rx_size;
+       return rtld.exec_size;
 }
 
 static bool si_get_external_symbol(void *data, const char *name, uint64_t *value)