From faa4d6e7f385d9e89dca4dca5c2fdb45bdb3257d Mon Sep 17 00:00:00 2001
From: "Hadrien G." <knights_of_ni@gmx.com>
Date: Wed, 24 Jul 2024 20:33:14 +0200
Subject: [PATCH] Only release tiles when that can be useful

---
 exercises/src/gpu/grayscott.comp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/exercises/src/gpu/grayscott.comp b/exercises/src/gpu/grayscott.comp
index 6ae5c03..3733e20 100644
--- a/exercises/src/gpu/grayscott.comp
+++ b/exercises/src/gpu/grayscott.comp
@@ -320,8 +320,8 @@ void run_simulation() {
         #endif
     }
 
-    // Liberate any acquired tile
-    if (s_acquired_tile && is_leader()) {
+    // Liberate any acquired tile that was dropped due to an early exit
+    if (is_leader() && s_acquired_tile && work_group_finished()) {
         leader_release_tile();
         #if DEBUG || PROFILE
             atomicAdd(g_metadata.final_release, 1);
-- 
GitLab