From 78bd3ddecea5f4aac95e26eeebe5cc019e3dfc74 Mon Sep 17 00:00:00 2001 From: Sreelakshmi Haridas Maruthur Date: Tue, 1 Apr 2025 10:53:21 -0600 Subject: [PATCH] allocations: Scale number of work-items in relation to input size (#2336) Make the number of work-items proportional to size of the allocation so we launch more work-items and do less work per work-item as buffer sizes go up with device capabilities. To test: test_allocations multiple 5 buffer test_allocations single 5 buffer --- test_conformance/allocations/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test_conformance/allocations/main.cpp b/test_conformance/allocations/main.cpp index e0310bb8..b62c2a54 100644 --- a/test_conformance/allocations/main.cpp +++ b/test_conformance/allocations/main.cpp @@ -26,6 +26,8 @@ typedef long long unsigned llu; #define REDUCTION_PERCENTAGE_DEFAULT 50 +#define BYTES_PER_WORK_ITEM 2048ULL + int g_repetition_count = 1; int g_reduction_percentage = REDUCTION_PERCENTAGE_DEFAULT; int g_write_allocations = 1; @@ -125,7 +127,7 @@ int doTest(cl_device_id device, cl_context context, cl_command_queue queue, int number_of_mems_used; cl_ulong max_individual_allocation_size = g_max_individual_allocation_size; cl_ulong global_mem_size = g_global_mem_size; - unsigned int number_of_work_items = 8192 * 32; + unsigned int number_of_work_items; const bool allocate_image = (alloc_type != BUFFER) && (alloc_type != BUFFER_NON_BLOCKING); @@ -183,12 +185,16 @@ int doTest(cl_device_id device, cl_context context, cl_command_queue queue, g_reduction_percentage); g_max_size = (size_t)((double)g_max_size * (double)g_reduction_percentage / 100.0); - number_of_work_items = 8192 * 2; } // Round to nearest MB. g_max_size &= (size_t)(0xFFFFFFFFFF00000ULL); + // Scales the number of work-items to keep the amount of bytes processed + // per work-item the same. + number_of_work_items = + std::max(g_max_size / BYTES_PER_WORK_ITEM, 8192ULL * 2ULL); + log_info("** Target allocation size (rounded to nearest MB) is: %llu bytes " "(%gMB).\n", llu(g_max_size), toMB(g_max_size));