From 245a95dc6bdc3252b0e9c87a51bc9cefb7d812ef Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 9 Feb 2018 14:06:18 -0500 Subject: [PATCH 1/4] catch missing toolchain error from codepy --- loopy/target/c/c_execution.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/loopy/target/c/c_execution.py b/loopy/target/c/c_execution.py index d8b76d32a..b959ccdd8 100644 --- a/loopy/target/c/c_execution.py +++ b/loopy/target/c/c_execution.py @@ -29,7 +29,7 @@ from loopy.target.execution import (KernelExecutorBase, _KernelInfo, ExecutionWrapperGeneratorBase, get_highlighted_code) from pytools import memoize_method from pytools.py_codegen import (Indentation) -from codepy.toolchain import guess_toolchain +from codepy.toolchain import guess_toolchain, ToolchainGuessError, GCCToolchain from codepy.jit import compile_from_string import six import ctypes @@ -216,7 +216,18 @@ class CCompiler(object): source_suffix='c'): # try to get a default toolchain # or subclass supplied version if available - self.toolchain = guess_toolchain() if toolchain is None else toolchain + self.toolchain = toolchain + if toolchain is None: + try: + self.toolchain = guess_toolchain() + except ToolchainGuessError: + # missing compiler python was built with (likely, Conda) + # use a default GCCToolchain + logger = logging.getLogger(__name__) + logger.info('Default toolchain guessed from python config ' + 'not found, replacing with default GCCToolchain.') + self.toolchain = GCCToolchain() + self.source_suffix = source_suffix if toolchain is None: # copy in all differing values -- GitLab From 9375de0df7f0a9db52894015f59e7b5c97beca5f Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 9 Feb 2018 14:09:49 -0500 Subject: [PATCH 2/4] catch ExecError for bwards compat --- loopy/target/c/c_execution.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopy/target/c/c_execution.py b/loopy/target/c/c_execution.py index b959ccdd8..46f382cd1 100644 --- a/loopy/target/c/c_execution.py +++ b/loopy/target/c/c_execution.py @@ -29,6 +29,7 @@ from loopy.target.execution import (KernelExecutorBase, _KernelInfo, ExecutionWrapperGeneratorBase, get_highlighted_code) from pytools import memoize_method from pytools.py_codegen import (Indentation) +from pytools.prefork import ExecError from codepy.toolchain import guess_toolchain, ToolchainGuessError, GCCToolchain from codepy.jit import compile_from_string import six @@ -220,7 +221,7 @@ class CCompiler(object): if toolchain is None: try: self.toolchain = guess_toolchain() - except ToolchainGuessError: + except (ToolchainGuessError, ExecError): # missing compiler python was built with (likely, Conda) # use a default GCCToolchain logger = logging.getLogger(__name__) -- GitLab From e8e28832c9d41d88d80cf35c12aaf653b675d30a Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 9 Feb 2018 14:32:50 -0500 Subject: [PATCH 3/4] change to warn --- loopy/target/c/c_execution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopy/target/c/c_execution.py b/loopy/target/c/c_execution.py index 46f382cd1..4628595ff 100644 --- a/loopy/target/c/c_execution.py +++ b/loopy/target/c/c_execution.py @@ -225,7 +225,7 @@ class CCompiler(object): # missing compiler python was built with (likely, Conda) # use a default GCCToolchain logger = logging.getLogger(__name__) - logger.info('Default toolchain guessed from python config ' + logger.warn('Default toolchain guessed from python config ' 'not found, replacing with default GCCToolchain.') self.toolchain = GCCToolchain() -- GitLab From dcf2eb784781eb271fe43d5cde8a5348847f479e Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 9 Feb 2018 14:33:04 -0500 Subject: [PATCH 4/4] move init into func to avoid running at import --- loopy/target/c/c_execution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loopy/target/c/c_execution.py b/loopy/target/c/c_execution.py index 4628595ff..2c8ab16f2 100644 --- a/loopy/target/c/c_execution.py +++ b/loopy/target/c/c_execution.py @@ -324,14 +324,14 @@ class CompiledCKernel(object): to automatically map argument types. """ - def __init__(self, knl, idi, dev_code, target, comp=CCompiler()): + def __init__(self, knl, idi, dev_code, target, comp=None): from loopy.target.c import ExecutableCTarget assert isinstance(target, ExecutableCTarget) self.target = target self.name = knl.name # get code and build self.code = dev_code - self.comp = comp + self.comp = comp if comp is not None else CCompiler() self.dll = self.comp.build(self.name, self.code) # get the function declaration for interface with ctypes -- GitLab