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