|
12 | 12 | from codepy.jit import compile_from_string |
13 | 13 | from codepy.toolchain import GCCToolchain |
14 | 14 |
|
15 | | -from devito.arch import (AMDGPUX, Cpu64, M1, NVIDIAX, SKX, POWER8, POWER9, |
16 | | - get_nvidia_cc, check_cuda_runtime, get_m1_llvm_path) |
| 15 | +from devito.arch import (AMDGPUX, NVIDIAX, M1, SKX, POWER8, POWER9, INTELGPUX, |
| 16 | + Cpu64, get_nvidia_cc, check_cuda_runtime, get_m1_llvm_path) |
17 | 17 | from devito.exceptions import CompilationError |
18 | 18 | from devito.logger import debug, warning, error |
19 | 19 | from devito.parameters import configuration |
@@ -515,6 +515,58 @@ def __lookup_cmds__(self): |
515 | 515 | self.MPICXX = 'mpicxx' |
516 | 516 |
|
517 | 517 |
|
| 518 | +class OneapiCompiler(Compiler): |
| 519 | + |
| 520 | + def __init__(self, *args, **kwargs): |
| 521 | + super().__init__(*args, **kwargs) |
| 522 | + |
| 523 | + language = kwargs.pop('language', configuration['language']) |
| 524 | + platform = kwargs.pop('platform', configuration['platform']) |
| 525 | + |
| 526 | + self.cflags.append("-xHost") |
| 527 | + self.cflags.append("-qopt-zmm-usage=high") |
| 528 | + |
| 529 | + if configuration['safe-math']: |
| 530 | + self.cflags.append("-fp-model=strict") |
| 531 | + else: |
| 532 | + self.cflags.append('-fast') |
| 533 | + |
| 534 | + if language == 'sycl': |
| 535 | + self.cflags.append('-fsycl') |
| 536 | + if platform is NVIDIAX: |
| 537 | + self.cflags.append('-fsycl-targets=nvptx64-cuda') |
| 538 | + else: |
| 539 | + self.cflags.append('-fsycl-targets=spir64') |
| 540 | + |
| 541 | + if language == 'openmp': |
| 542 | + self.cflags.append('-qopenmp') |
| 543 | + if platform is NVIDIAX: |
| 544 | + self.cflags.append('-fopenmp-targets=nvptx64-cuda') |
| 545 | + if platform is INTELGPUX: |
| 546 | + self.cflags.append('-fopenmp-targets=spir64') |
| 547 | + self.cflags.append('-fopenmp-target-simd') |
| 548 | + |
| 549 | + if platform is INTELGPUX: |
| 550 | + self.cflags.remove('-g') # -g disables some optimizations in IGC |
| 551 | + self.cflags.append('-gline-tables-only') |
| 552 | + self.cflags.append('-fdebug-info-for-profiling') |
| 553 | + |
| 554 | + # Make sure the MPI compiler uses `icx` underneath -- whatever the MPI distro is |
| 555 | + if kwargs.get('mpi'): |
| 556 | + ver = check_output([self.MPICC, "--version"]).decode("utf-8") |
| 557 | + if not ver.startswith("Intel(R) oneAPI"): |
| 558 | + warning("The MPI compiler `%s` doesn't use the Intel(R) oneAPI " |
| 559 | + "DPC++/C++ compiler underneath" % self.MPICC) |
| 560 | + |
| 561 | + def __lookup_cmds__(self): |
| 562 | + # OneAPI HPC ToolKit comes with icpx, which is clang++, |
| 563 | + # and icx, which is clang |
| 564 | + self.CC = 'icx' |
| 565 | + self.CXX = 'icpx' |
| 566 | + self.MPICC = 'mpicc' |
| 567 | + self.MPICXX = 'mpicxx' |
| 568 | + |
| 569 | + |
518 | 570 | class PGICompiler(Compiler): |
519 | 571 |
|
520 | 572 | def __init__(self, *args, **kwargs): |
@@ -779,6 +831,8 @@ def __lookup_cmds__(self): |
779 | 831 | 'intel': IntelCompiler, |
780 | 832 | 'icpc': IntelCompiler, |
781 | 833 | 'icc': IntelCompiler, |
| 834 | + 'icx': OneapiCompiler, |
| 835 | + 'icpx': OneapiCompiler, |
782 | 836 | 'intel-knl': IntelKNLCompiler, |
783 | 837 | 'knl': IntelKNLCompiler, |
784 | 838 | 'dpcpp': DPCPPCompiler, |
|
0 commit comments