From 884a03c4fbdd6db61968a34b4558e26401dfb806 Mon Sep 17 00:00:00 2001 From: Martin Bauer <martin.bauer@fau.de> Date: Fri, 1 Feb 2019 16:20:49 +0100 Subject: [PATCH] Adapted tests to changes in walberla sweep generation --- cmake_integration.py | 25 ++++++++++++++++++++++++- codegen.py | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cmake_integration.py b/cmake_integration.py index 2ce021d..fba134d 100644 --- a/cmake_integration.py +++ b/cmake_integration.py @@ -14,7 +14,8 @@ import sys import os import warnings -__all__ = ['CodeGeneration'] +__all__ = ['CodeGeneration', 'ManualCodeGenerationContext'] + class CodeGeneration: def __init__(self): @@ -76,3 +77,25 @@ class CodeGenerationContext: self.files_written.append(os.path.abspath(name)) with open(name, 'w') as f: f.write(content) + + +class ManualCodeGenerationContext: + """Context for testing - does not actually write files but puts them into a public dict + Environment parameters like if OpenMP, MPI or CPU-specific optimization should be used can be explicitly passed + to constructor instead of getting them from CMake + """ + def __init__(self, openmp=False, optimize_for_localhost=False, mpi=True, double_accuracy=True): + self.openmp = openmp + self.optimize_for_localhost = optimize_for_localhost + self.mpi = mpi + self.double_accuracy = double_accuracy + self.files = dict() + + def write_file(self, name, content): + self.files[name] = content + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + pass diff --git a/codegen.py b/codegen.py index 6bad99b..8f8e248 100644 --- a/codegen.py +++ b/codegen.py @@ -20,7 +20,7 @@ def generate_sweep(generation_context, class_name, assignments, if hasattr(assignments, 'all_assignments'): assignments = assignments.all_assignments - create_kernel_params = default_create_kernel_parameters(generation_context, create_kernel_params) + create_kernel_params = default_create_kernel_parameters(generation_context, create_kernel_params) if not staggered: ast = create_kernel(assignments, **create_kernel_params) -- GitLab