From 671f2686c0e33f6667dc96aedfe3e25a54aaebf4 Mon Sep 17 00:00:00 2001 From: Johannes Graner Date: Tue, 21 Oct 2025 09:35:04 +0200 Subject: [PATCH] Fix race conditions in ck_tile remod (#3061) [ROCm/composable_kernel commit: 4043401db186ee006f14fb00842af29c194ba209] --- example/ck_tile/remod.py | 19 ++++++++++--------- include/ck_tile/remod.py | 21 +++++++++++---------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/example/ck_tile/remod.py b/example/ck_tile/remod.py index 4fa3a4e430..94b51c2a9a 100644 --- a/example/ck_tile/remod.py +++ b/example/ck_tile/remod.py @@ -10,15 +10,16 @@ for p in sorted(Path("./").rglob("*")): # formatting +format_procs = [] for x in all_files: - subprocess.Popen( - f"python -m dos2unix {str(x)} {str(x)}", - shell=True, - stdout=open(os.devnull, "wb"), + dos2unix = f"python -m dos2unix {str(x)} {str(x)}" + clang_format = f"clang-format -style=file -i {str(x)}" + # One process to avoid race conditions. + cmd = f"{dos2unix} && {clang_format}" + format_procs.append( + subprocess.Popen(cmd, shell=True, stdout=open(os.devnull, "wb")) ) - cmd = f"clang-format -style=file -i {str(x)}" - # for xp in x.parents: - # print(get_file_base(x)) - subprocess.Popen(cmd, shell=True) -# print(all_files) +# Wait for formatting to complete. +for p in format_procs: + p.wait() diff --git a/include/ck_tile/remod.py b/include/ck_tile/remod.py index a8ff2defe5..2ff707e9d3 100644 --- a/include/ck_tile/remod.py +++ b/include/ck_tile/remod.py @@ -85,18 +85,19 @@ class submodule_t: submodule = submodule_t() # formatting +format_procs = [] for x in all_files: - subprocess.Popen( - f"python -m dos2unix {str(x)} {str(x)}", - shell=True, - stdout=open(os.devnull, "wb"), + dos2unix = f"python -m dos2unix {str(x)} {str(x)}" + clang_format = f"clang-format -style=file -i {str(x)}" + # One process to avoid race conditions. + cmd = f"{dos2unix} && {clang_format}" + format_procs.append( + subprocess.Popen(cmd, shell=True, stdout=open(os.devnull, "wb")) ) - cmd = f"clang-format -style=file -i {str(x)}" - # for xp in x.parents: - # print(get_file_base(x)) - subprocess.Popen(cmd, shell=True) submodule.push(x) -submodule.gen() +# Wait for formatting to complete before generating headers. +for p in format_procs: + p.wait() -# print(all_files) +submodule.gen()