From f3360d2ba24a83aa5df13b431a981182d6b122c7 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Thu, 12 Dec 2024 04:39:28 +0000 Subject: [PATCH] Merge branch 'fixbishopcache' into 'master' Fix Bishop Cache Registration See merge request StanfordLegion/legion!1576 (cherry picked from commit e91888a41200b5282afd08c18a6a7debce9be3ac) 959541f9 bishop: another fix for handled cache clean-up when there is a race for... Co-authored-by: Mike Bauer --- language/src/bishop/codegen.t | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/language/src/bishop/codegen.t b/language/src/bishop/codegen.t index 1fbd618ce1..4e4e404627 100644 --- a/language/src/bishop/codegen.t +++ b/language/src/bishop/codegen.t @@ -928,11 +928,24 @@ function codegen.map_task(rules, automata, state_id, signature, mapper_state_typ c.bishop_logger_debug( "[map_task] initialize instance cache for region %d", [idx - 1]) end - c.legion_map_task_output_chosen_instances_add([map_task_output_var], - [inst_var], 1) if not[cache_success_var] then + -- Failed to cache which means something else beat us to the cache + -- Free up our allocation and get the new cached values + -- This should happen very rarely and only really at start-up c.free([inst_var]) + [inst_var] = c.bishop_instance_cache_get_cached_instances( + [instance_cache_var], [idx - 1], [region_var], [target.value]) + -- This better have succeeded now + std.assert([inst_var] ~= [&c.legion_physical_instance_t](nil), "must hit in cache") + -- Probably don't need to acquire again but since this happens + -- rarely let's just do it to be safe + var success = + c.legion_mapper_runtime_acquire_instances([rt_var], [ctx_var], + [inst_var], 1) + std.assert(success, "instance acquire must succeed") end + c.legion_map_task_output_chosen_instances_add([map_task_output_var], + [inst_var], 1) end end end