Skip to content

Commit

Permalink
Merge pull request #1836 from reguly/feature/intelGPU
Browse files Browse the repository at this point in the history
gpu: Adding DPCPP compiler support
  • Loading branch information
FabioLuporini authored Feb 16, 2022
2 parents 8eebfc2 + 23db4f9 commit 7f15c89
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
15 changes: 12 additions & 3 deletions devito/arch/archinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
__all__ = ['platform_registry', 'get_cpu_info', 'get_gpu_info', 'get_nvidia_cc',
'check_cuda_runtime',
'Platform', 'Cpu64', 'Intel64', 'Amd', 'Arm', 'Power', 'Device',
'NvidiaDevice', 'AmdDevice',
'NvidiaDevice', 'AmdDevice', 'IntelDevice',
'INTEL64', 'SNB', 'IVB', 'HSW', 'BDW', 'SKX', 'KNL', 'KNL7210', # Intel
'AMD', 'ARM', 'M1', # ARM
'POWER8', 'POWER9', # Other loosely supported CPU architectures
'AMDGPUX', 'NVIDIAX'] # GPUs
'AMDGPUX', 'NVIDIAX', 'INTELGPUX'] # GPUs


@memoized_func
Expand Down Expand Up @@ -600,6 +600,13 @@ def memavail(self, deviceid=0):
return None


class IntelDevice(Device):

@cached_property
def march(self):
return ''


class NvidiaDevice(Device):

@cached_property
Expand Down Expand Up @@ -665,6 +672,7 @@ def march(cls):
# Devices
NVIDIAX = NvidiaDevice('nvidiaX')
AMDGPUX = AmdDevice('amdgpuX')
INTELGPUX = IntelDevice('intelgpuX')


platform_registry = {
Expand All @@ -685,7 +693,8 @@ def march(cls):
'power8': POWER8,
'power9': POWER9,
'nvidiaX': NVIDIAX, # Generic NVidia GPU
'amdgpuX': AMDGPUX # Generic AMD GPU
'amdgpuX': AMDGPUX, # Generic AMD GPU
'intelgpuX': INTELGPUX # Generic Intel GPU
}
"""
Registry dict for deriving Platform classes according to the environment variable
Expand Down
17 changes: 17 additions & 0 deletions devito/arch/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,22 @@ def __lookup_cmds__(self):
self.MPICXX = 'mpicxx'


class DPCPPCompiler(Compiler):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.cflags += ['-qopenmp', '-fopenmp-targets=spir64']

def __lookup_cmds__(self):
# OneAPI Base Kit comes with dpcpp/icpx, both are clang++,
# and icx, which is clang
self.CC = 'icx'
self.CXX = 'icpx'
self.MPICC = 'mpic++'
self.MPICXX = 'mpicxx'


class PGICompiler(Compiler):

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -641,6 +657,7 @@ def __lookup_cmds__(self):
'icc': IntelCompiler,
'intel-knl': IntelKNLCompiler,
'knl': IntelKNLCompiler,
'dpcpp': DPCPPCompiler,
}
"""
Registry dict for deriving Compiler classes according to the environment variable
Expand Down
3 changes: 2 additions & 1 deletion devito/passes/iet/languages/openmp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cgen as c
from sympy import Not

from devito.arch import AMDGPUX, NVIDIAX
from devito.arch import AMDGPUX, NVIDIAX, INTELGPUX
from devito.ir import (Call, Conditional, List, Prodder, ParallelIteration,
ParallelBlock, PointerCast, While, FindSymbols)
from devito.passes.iet.definitions import DataManager, DeviceAwareDataManager
Expand Down Expand Up @@ -122,6 +122,7 @@ class OmpBB(PragmaLangBB):
# Platform mapping
AMDGPUX: None,
NVIDIAX: None,
INTELGPUX: None,
# Runtime library
'init': None,
'thread-num': lambda retobj=None:
Expand Down

0 comments on commit 7f15c89

Please sign in to comment.