|
22 | 22 | from devito.tools import (as_list, change_directory, filter_ordered, |
23 | 23 | memoized_func, make_tempdir) |
24 | 24 |
|
25 | | -__all__ = ['sniff_mpi_distro', 'compiler_registry'] |
| 25 | +__all__ = ['compiler_registry', 'sniff_mpi_distro'] |
26 | 26 |
|
27 | 27 |
|
28 | 28 | @memoized_func |
@@ -50,11 +50,7 @@ def sniff_compiler_version(cc, allow_fail=False): |
50 | 50 | ver = ver.strip() |
51 | 51 | if ver.startswith("gcc"): |
52 | 52 | compiler = "gcc" |
53 | | - elif ver.startswith("clang"): |
54 | | - compiler = "clang" |
55 | | - elif ver.startswith("Apple LLVM"): |
56 | | - compiler = "clang" |
57 | | - elif ver.startswith("Homebrew clang"): |
| 53 | + elif ver.startswith("clang") or ver.startswith("Apple LLVM") or ver.startswith("Homebrew clang"): |
58 | 54 | compiler = "clang" |
59 | 55 | elif ver.startswith("Intel"): |
60 | 56 | compiler = "icx" |
@@ -334,22 +330,21 @@ def make(self, loc, args): |
334 | 330 | logfile = path.join(self.get_jit_dir(), f"{hash_key}.log") |
335 | 331 | errfile = path.join(self.get_jit_dir(), f"{hash_key}.err") |
336 | 332 |
|
337 | | - with change_directory(loc): |
338 | | - with open(logfile, "w") as lf: |
339 | | - with open(errfile, "w") as ef: |
340 | | - |
341 | | - command = ['make'] + args |
342 | | - lf.write("Compilation command:\n") |
343 | | - lf.write(" ".join(command)) |
344 | | - lf.write("\n\n") |
345 | | - try: |
346 | | - check_call(command, stderr=ef, stdout=lf) |
347 | | - except CalledProcessError as e: |
348 | | - raise CompilationError(f'Command "{e.cmd}" return error status' |
349 | | - f'{e.returncode}. ' |
350 | | - f'Unable to compile code.\n' |
351 | | - f'Compile log in {logfile}\n' |
352 | | - f'Compile errors in {errfile}\n') |
| 333 | + with change_directory(loc), open(logfile, "w") as lf: |
| 334 | + with open(errfile, "w") as ef: |
| 335 | + |
| 336 | + command = ['make'] + args |
| 337 | + lf.write("Compilation command:\n") |
| 338 | + lf.write(" ".join(command)) |
| 339 | + lf.write("\n\n") |
| 340 | + try: |
| 341 | + check_call(command, stderr=ef, stdout=lf) |
| 342 | + except CalledProcessError as e: |
| 343 | + raise CompilationError(f'Command "{e.cmd}" return error status' |
| 344 | + f'{e.returncode}. ' |
| 345 | + f'Unable to compile code.\n' |
| 346 | + f'Compile log in {logfile}\n' |
| 347 | + f'Compile errors in {errfile}\n') |
353 | 348 | debug(f"Make <{' '.join(args)}>") |
354 | 349 |
|
355 | 350 | def _cmdline(self, files, object=False): |
@@ -387,7 +382,7 @@ def jit_compile(self, soname, code): |
387 | 382 | # Warning: dropping `code` on the floor in favor to whatever is written |
388 | 383 | # within `src_file` |
389 | 384 | try: |
390 | | - with open(src_file, 'r') as f: |
| 385 | + with open(src_file) as f: |
391 | 386 | code = f.read() |
392 | 387 | code = f'{code}/* Backdoor edit at {time.ctime()}*/ \n' |
393 | 388 | # Bypass the devito JIT cache |
|
0 commit comments