From ccbae9aab22927a94a8cb124a67a135230c09f5e Mon Sep 17 00:00:00 2001 From: Gerard Gorman Date: Wed, 9 Aug 2023 12:04:29 +0100 Subject: [PATCH 1/3] compiler: Use configuration['platform'].isa == 'avx512' to determine whether AVX512 is supported rather than DEVITO_PLATFORM. This adds compiler options for long vectors for Intel Skylake and later generations. --- devito/arch/compiler.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 738f379105..db7a745f30 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -13,7 +13,7 @@ from codepy.toolchain import GCCToolchain, call_capture_output from devito.arch import (AMDGPUX, Cpu64, M1, NVIDIAX, POWER8, POWER9, GRAVITON, - INTELGPUX, IntelSkylake, get_nvidia_cc, check_cuda_runtime, + INTELGPUX, get_nvidia_cc, check_cuda_runtime, get_m1_llvm_path) from devito.exceptions import CompilationError from devito.logger import debug, warning, error @@ -394,7 +394,7 @@ def __init__(self, *args, **kwargs): else: self.cflags.append('-ffast-math') - if isinstance(platform, IntelSkylake): + if platform.isa == 'avx512': # The default is `=256` because avx512 slows down the CPU frequency; # however, we empirically found that stencils generally benefit # from `=512` @@ -698,7 +698,6 @@ class IntelCompiler(Compiler): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - platform = kwargs.pop('platform', configuration['platform']) language = kwargs.pop('language', configuration['language']) self.cflags.append("-xHost") @@ -708,8 +707,8 @@ def __init__(self, *args, **kwargs): else: self.cflags.append('-fp-model=fast') - if isinstance(platform, IntelSkylake): - # Systematically use 512-bit vectors on skylake + if platform.isa == 'avx512': + # Systematically use 512-bit vectors if avx512 is available. self.cflags.append("-qopt-zmm-usage=high") if language == 'openmp': From b85be263b3fc9e0b5ab4b9845fe8ceb4938b2b89 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Wed, 9 Aug 2023 13:46:19 +0000 Subject: [PATCH 2/3] arch: Add SPR codename --- devito/arch/archinfo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/devito/arch/archinfo.py b/devito/arch/archinfo.py index 70c25bcdb8..88a397206f 100644 --- a/devito/arch/archinfo.py +++ b/devito/arch/archinfo.py @@ -20,7 +20,7 @@ 'Device', 'NvidiaDevice', 'AmdDevice', 'IntelDevice', # Intel 'INTEL64', 'SNB', 'IVB', 'HSW', 'BDW', 'KNL', 'KNL7210', - 'SKX', 'KLX', 'CLX', 'CLK', + 'SKX', 'KLX', 'CLX', 'CLK', 'SPR', # ARM 'AMD', 'ARM', 'M1', 'GRAVITON', # Other loosely supported CPU architectures @@ -616,7 +616,7 @@ class IntelSkylake(Intel64): pass -class IntelGoldenCode(Intel64): +class IntelGoldenCove(Intel64): pass @@ -744,6 +744,7 @@ def march(cls): KLX = IntelSkylake('klx') CLX = IntelSkylake('clx') CLK = IntelSkylake('clk') +SPR = IntelGoldenCove('spr') ARM = Arm('arm') GRAVITON = Arm('graviton') @@ -771,6 +772,7 @@ def march(cls): 'klx': KLX, # Kaby Lake 'clx': CLX, # Coffee Lake 'clk': CLK, # Cascade Lake + 'spr': SPR, # Sapphire Rapids 'knl': KNL, 'knl7210': KNL7210, 'arm': ARM, # Generic ARM CPU From c0d920ae5f02ec05318324779d76ee4fe3f71e11 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Wed, 9 Aug 2023 13:48:12 +0000 Subject: [PATCH 3/3] arch: Fixup platform for avx512 jit --- devito/arch/compiler.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index db7a745f30..56f0c7a6e5 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -395,10 +395,14 @@ def __init__(self, *args, **kwargs): self.cflags.append('-ffast-math') if platform.isa == 'avx512': - # The default is `=256` because avx512 slows down the CPU frequency; - # however, we empirically found that stencils generally benefit - # from `=512` - self.cflags.append('-mprefer-vector-width=512') + if self.version >= Version("8.0.0"): + # The default is `=256` because avx512 slows down the CPU frequency; + # however, we empirically found that stencils generally benefit + # from `=512` + self.cflags.append('-mprefer-vector-width=512') + else: + # Unsupported on earlier versions + pass if platform in [POWER8, POWER9]: # -march isn't supported on power architectures, is -mtune needed? @@ -698,6 +702,7 @@ class IntelCompiler(Compiler): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + platform = kwargs.pop('platform', configuration['platform']) language = kwargs.pop('language', configuration['language']) self.cflags.append("-xHost")