From 8109dd9fc5c43a145c29f557a441a682ceeeb2b9 Mon Sep 17 00:00:00 2001 From: dpys Date: Mon, 16 Dec 2024 16:10:45 -0500 Subject: [PATCH 1/3] feat: additional teardown handling --- nxbench/benchmarks/benchmark.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nxbench/benchmarks/benchmark.py b/nxbench/benchmarks/benchmark.py index 13de097..370b50c 100644 --- a/nxbench/benchmarks/benchmark.py +++ b/nxbench/benchmarks/benchmark.py @@ -23,6 +23,7 @@ from nxbench.data.loader import BenchmarkDataManager from nxbench.validation.registry import BenchmarkValidator +nx.config.warnings_to_ignore.add("cache") warnings.filterwarnings("ignore") logger = logging.getLogger("nxbench") @@ -184,6 +185,7 @@ def prepare_benchmark( if "cugraph" in backend and is_nx_cugraph_available(): try: + os.environ["NX_CUGRAPH_AUTOCONFIG"] = "True" cugraph = import_module("nx_cugraph") except ImportError: logger.exception("cugraph backend not available") @@ -292,8 +294,14 @@ def teardown_specific(self, backend: str, num_thread: int = 1): os.environ["NUM_THREAD"] = "1" os.environ["OMP_NUM_THREADS"] = "1" - os.environ["MKL_NUM_THREADS"] = "1" os.environ["OPENBLAS_NUM_THREADS"] = "1" + os.environ["MKL_NUM_THREADS"] = "1" + + if "cugraph" in backend: + os.environ["NX_CUGRAPH_AUTOCONFIG"] = "False" + + if "graphblas" in backend: + os.environ["OMP_NUM_THREADS"] = "1" def teardown(self): """ASV teardown method. Called after all benchmarks are run.""" From e76e761794b6104ef07aac2a461f96e679ab9dfa Mon Sep 17 00:00:00 2001 From: dpys Date: Mon, 16 Dec 2024 16:11:54 -0500 Subject: [PATCH 2/3] feat: additional teardown handling --- nxbench/benchmarks/benchmark.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nxbench/benchmarks/benchmark.py b/nxbench/benchmarks/benchmark.py index 370b50c..50aae0f 100644 --- a/nxbench/benchmarks/benchmark.py +++ b/nxbench/benchmarks/benchmark.py @@ -181,6 +181,8 @@ def prepare_benchmark( except ImportError: logger.exception("nx-parallel backend not available") return None + nx.config.backends.parallel.active = True + nx.config.backends.parallel.n_jobs = num_thread return nxp.ParallelGraph(original_graph) if "cugraph" in backend and is_nx_cugraph_available(): From 073952bd07b063497bfcc8b6449d8e9778f7abc6 Mon Sep 17 00:00:00 2001 From: dpys Date: Mon, 16 Dec 2024 16:37:13 -0500 Subject: [PATCH 3/3] feat: additional teardown handling --- nxbench/benchmarks/benchmark.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/nxbench/benchmarks/benchmark.py b/nxbench/benchmarks/benchmark.py index 50aae0f..375c5bc 100644 --- a/nxbench/benchmarks/benchmark.py +++ b/nxbench/benchmarks/benchmark.py @@ -164,6 +164,13 @@ def prepare_benchmark( f"{original_graph.number_of_edges()} edges" ) + # initially clear env completely + if hasattr(nx.config.backends, "parallel"): + if hasattr(nx.config.backends.parallel, "active"): + nx.config.backends.parallel.active = False + nx.config.backends.parallel.n_jobs = 1 + os.environ["NX_CUGRAPH_AUTOCONFIG"] = "False" + for var_name in [ "NUM_THREAD", "OMP_NUM_THREADS", @@ -294,16 +301,13 @@ def teardown_specific(self, backend: str, num_thread: int = 1): nx.config.backends.parallel.active = False nx.config.backends.parallel.n_jobs = 1 - os.environ["NUM_THREAD"] = "1" - os.environ["OMP_NUM_THREADS"] = "1" - os.environ["OPENBLAS_NUM_THREADS"] = "1" - os.environ["MKL_NUM_THREADS"] = "1" - if "cugraph" in backend: os.environ["NX_CUGRAPH_AUTOCONFIG"] = "False" - if "graphblas" in backend: - os.environ["OMP_NUM_THREADS"] = "1" + os.environ["NUM_THREAD"] = "1" + os.environ["OMP_NUM_THREADS"] = "1" + os.environ["OPENBLAS_NUM_THREADS"] = "1" + os.environ["MKL_NUM_THREADS"] = "1" def teardown(self): """ASV teardown method. Called after all benchmarks are run."""