diff --git a/experiments/fpopt-baseline-generator.py b/experiments/fpopt-baseline-generator.py index 7c31750..52c35d8 100644 --- a/experiments/fpopt-baseline-generator.py +++ b/experiments/fpopt-baseline-generator.py @@ -116,7 +116,7 @@ def create_baseline_driver_function(functions, num_samples_per_func): f"WARNING: Bounds not found for {param_name} in function {func_name}, manually specify the bounds." ) dist_name = f"{func_name}_{param_name}_dist" - driver_code.append(f" std::uniform_real_distribution {dist_name}({min_val}, {max_val});") + driver_code.append(f" std::uniform_real_distribution<{return_type}> {dist_name}({min_val}, {max_val});") driver_code.append("") driver_code.append(" double sum = 0.;") diff --git a/experiments/fpopt-golden-driver-generator.py b/experiments/fpopt-golden-driver-generator.py index 253efa1..0e8b4ff 100644 --- a/experiments/fpopt-golden-driver-generator.py +++ b/experiments/fpopt-golden-driver-generator.py @@ -103,7 +103,7 @@ def create_driver_function(functions, num_samples_per_func): f"WARNING: Bounds not found for {param_name} in function {func_name}, manually specify the bounds." ) dist_name = f"{func_name}_{param_name}_dist" - driver_code.append(f" std::uniform_real_distribution {dist_name}({min_val}, {max_val});") + driver_code.append(f" std::uniform_real_distribution<{return_type}> {dist_name}({min_val}, {max_val});") driver_code.append("") driver_code.append(" double sum = 0.;") diff --git a/experiments/fpopt-logged-driver-generator.py b/experiments/fpopt-logged-driver-generator.py index 7c4accb..16a0502 100644 --- a/experiments/fpopt-logged-driver-generator.py +++ b/experiments/fpopt-logged-driver-generator.py @@ -105,7 +105,7 @@ def create_driver_function(functions, num_samples_per_func): f"WARNING: Bounds not found for {param_name} in function {func_name}, manually specify the bounds." ) dist_name = f"{func_name}_{param_name}_dist" - driver_code.append(f" std::uniform_real_distribution {dist_name}({min_val}, {max_val});") + driver_code.append(f" std::uniform_real_distribution<{return_type}> {dist_name}({min_val}, {max_val});") driver_code.append("") driver_code.append(" double sum = 0.;") diff --git a/experiments/fpopt-original-driver-generator.py b/experiments/fpopt-original-driver-generator.py index 97bb07a..0f1ed2d 100644 --- a/experiments/fpopt-original-driver-generator.py +++ b/experiments/fpopt-original-driver-generator.py @@ -103,7 +103,7 @@ def create_driver_function(functions, num_samples_per_func): f"WARNING: Bounds not found for {param_name} in function {func_name}, manually specify the bounds." ) dist_name = f"{func_name}_{param_name}_dist" - driver_code.append(f" std::uniform_real_distribution {dist_name}({min_val}, {max_val});") + driver_code.append(f" std::uniform_real_distribution<{return_type}> {dist_name}({min_val}, {max_val});") driver_code.append("") driver_code.append(" double sum = 0.;") diff --git a/experiments/run-all.py b/experiments/run-all.py index a000be1..40ffad2 100644 --- a/experiments/run-all.py +++ b/experiments/run-all.py @@ -80,7 +80,11 @@ def process_function_task(task): try: subprocess.check_call(["python3", "run.py", "--prefix", prefix]) except subprocess.CalledProcessError as e: - print(f"Error running run.py for function {func_name} in base {base_name}") + print(f"Error running run.py for function {func_name} in base {base_name}. Retrying with --disable-preopt.") + try: + subprocess.check_call(["python3", "run.py", "--prefix", prefix, "--disable-preopt"]) + except subprocess.CalledProcessError as e: + print(f"Error running run.py with --disable-preopt for function {func_name} in base {base_name}") def main(): diff --git a/experiments/run.py b/experiments/run.py index c4da265..7fe2ba9 100755 --- a/experiments/run.py +++ b/experiments/run.py @@ -41,32 +41,6 @@ "-fuse-ld=lld", ] -FPOPTFLAGS_BASE = [ - "-mllvm", - "--enzyme-enable-fpopt", - "-mllvm", - "--enzyme-print-herbie", - "-mllvm", - "--enzyme-print-fpopt", - "-mllvm", - "--fpopt-log-path=example.txt", - "-mllvm", - "--fpopt-target-func-regex=example", - "-mllvm", - "--fpopt-enable-solver", - "-mllvm", - "--fpopt-enable-pt", - "-mllvm", - "--fpopt-comp-cost-budget=0", - "-mllvm", - "--fpopt-num-samples=1000", - "-mllvm", - "--fpopt-cost-model-path=../microbm/cm.csv", - # "-mllvm", - # "--herbie-disable-regime", - # "-mllvm", - # "--herbie-disable-taylor" -] SRC = "example.c" LOGGER = "fp-logger.cpp" @@ -881,8 +855,39 @@ def main(): parser.add_argument("--plot-only", action="store_true", help="Plot results from existing data") parser.add_argument("--output-format", type=str, default="png", help="Output format for plots (e.g., png, pdf)") parser.add_argument("--analytics", action="store_true", help="Run analytics on saved data") + parser.add_argument("--disable-preopt", action="store_true", help="Disable Enzyme preoptimization") args = parser.parse_args() + global FPOPTFLAGS_BASE # Ensure global scope + FPOPTFLAGS_BASE = [ + "-mllvm", + "--enzyme-enable-fpopt", + "-mllvm", + "--enzyme-print-herbie", + "-mllvm", + "--enzyme-print-fpopt", + "-mllvm", + "--fpopt-log-path=example.txt", + "-mllvm", + "--fpopt-target-func-regex=example", + "-mllvm", + "--fpopt-enable-solver", + "-mllvm", + "--fpopt-enable-pt", + "-mllvm", + "--fpopt-comp-cost-budget=0", + "-mllvm", + "--fpopt-num-samples=1000", + "-mllvm", + "--fpopt-cost-model-path=../microbm/cm.csv", + # "-mllvm", + # "--herbie-disable-regime", + # "-mllvm", + # "--herbie-disable-taylor" + ] + if args.disable_preopt: + FPOPTFLAGS_BASE.extend(["-mllvm", "--enzyme-preopt=0"]) + prefix = args.prefix if not prefix.endswith("-"): prefix += "-"