From 8bfb94d291b3267843448015111df65e6b6f55f7 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Fri, 29 Nov 2024 14:02:11 +0000 Subject: [PATCH] Various loopy fixes --- .github/workflows/build.yml | 2 +- pyop2/codegen/rep2loopy.py | 6 ++++-- pyop2/compilation.py | 2 +- pyop2/local_kernel.py | 8 +++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 694c2de408..d19a307708 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,7 +83,7 @@ jobs: --install defcon \ --install gadopt \ --install asQ \ - --package-branch loopy connorjward/merge-upstream \ + --package-branch loopy connorjward/revert-hack-for-firedrake \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | diff --git a/pyop2/codegen/rep2loopy.py b/pyop2/codegen/rep2loopy.py index f13e94622d..b3cd55c3ba 100644 --- a/pyop2/codegen/rep2loopy.py +++ b/pyop2/codegen/rep2loopy.py @@ -113,10 +113,12 @@ def __init__(self, name=None, arg_id_to_dtype=None, arg_id_to_descr=None, name_in_target=None): if name is not None: assert name == self.name + + name_in_target = name_in_target if name_in_target else self.name super(LACallable, self).__init__(self.name, arg_id_to_dtype=arg_id_to_dtype, - arg_id_to_descr=arg_id_to_descr) - self.name_in_target = name_in_target if name_in_target else self.name + arg_id_to_descr=arg_id_to_descr, + name_in_target=name_in_target) @abc.abstractproperty def name(self): diff --git a/pyop2/compilation.py b/pyop2/compilation.py index 76ccbb38a7..d28c945188 100644 --- a/pyop2/compilation.py +++ b/pyop2/compilation.py @@ -547,7 +547,7 @@ def check_source_hashes(compiler, jitmodule, extension, comm): output = Path(configuration["cache_dir"]).joinpath("mismatching-kernels") srcfile = output.joinpath(f"src-rank{icomm.rank}.{extension}") if icomm.rank == 0: - output.mkdir(exist_ok=True) + output.mkdir(parents=True, exist_ok=True) icomm.barrier() with open(srcfile, "w") as fh: fh.write(jitmodule.code_to_compile) diff --git a/pyop2/local_kernel.py b/pyop2/local_kernel.py index da82f6ecad..21e06ab043 100644 --- a/pyop2/local_kernel.py +++ b/pyop2/local_kernel.py @@ -120,13 +120,11 @@ def cache_key(self): def _immutable_cache_key(self): # We need this function because self.accesses is mutable due to legacy support if isinstance(self.code, lp.TranslationUnit): - key_hash = hashlib.sha256() - self.code.update_persistent_hash(key_hash, LoopyKeyBuilder()) - code = key_hash.hexdigest() + code_key = LoopyKeyBuilder()(self.code) else: - code = self.code + code_key = self.code - key = (code, self.name, self.cpp, self.flop_count, + key = (code_key, self.name, self.cpp, self.flop_count, self.headers, self.include_dirs, self.ldargs, sorted(self.opts.items()), self.requires_zeroed_output_arguments, self.user_code, version.__version__) return hashlib.md5(str(key).encode()).hexdigest()