rocmcc compiler: initial commit based on aocc and clang (#28575)

* rocmcc compiler: initial commit based on aocc and clang

Co-authored-by: luker <luke.roskop@hpe.com>
Co-authored-by: Tom Scogland <scogland1@llnl.gov>
This commit is contained in:
Greg Becker 2022-03-03 13:34:22 -08:00 committed by GitHub
parent 96c1fb7b0b
commit e2b87ade06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 91 additions and 5 deletions

8
lib/spack/env/cc vendored
View file

@ -241,28 +241,28 @@ case "$command" in
mode=cpp mode=cpp
debug_flags="-g" debug_flags="-g"
;; ;;
cc|c89|c99|gcc|clang|armclang|icc|icx|pgcc|nvc|xlc|xlc_r|fcc) cc|c89|c99|gcc|clang|armclang|icc|icx|pgcc|nvc|xlc|xlc_r|fcc|amdclang)
command="$SPACK_CC" command="$SPACK_CC"
language="C" language="C"
comp="CC" comp="CC"
lang_flags=C lang_flags=C
debug_flags="-g" debug_flags="-g"
;; ;;
c++|CC|g++|clang++|armclang++|icpc|icpx|dpcpp|pgc++|nvc++|xlc++|xlc++_r|FCC) c++|CC|g++|clang++|armclang++|icpc|icpx|dpcpp|pgc++|nvc++|xlc++|xlc++_r|FCC|amdclang++)
command="$SPACK_CXX" command="$SPACK_CXX"
language="C++" language="C++"
comp="CXX" comp="CXX"
lang_flags=CXX lang_flags=CXX
debug_flags="-g" debug_flags="-g"
;; ;;
ftn|f90|fc|f95|gfortran|flang|armflang|ifort|ifx|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt) ftn|f90|fc|f95|gfortran|flang|armflang|ifort|ifx|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt|amdflang)
command="$SPACK_FC" command="$SPACK_FC"
language="Fortran 90" language="Fortran 90"
comp="FC" comp="FC"
lang_flags=F lang_flags=F
debug_flags="-g" debug_flags="-g"
;; ;;
f77|xlf|xlf_r|pgf77) f77|xlf|xlf_r|pgf77|amdflang)
command="$SPACK_F77" command="$SPACK_F77"
language="Fortran 77" language="Fortran 77"
comp="F77" comp="F77"

1
lib/spack/env/rocmcc/amdclang vendored Symbolic link
View file

@ -0,0 +1 @@
../cc

1
lib/spack/env/rocmcc/amdclang++ vendored Symbolic link
View file

@ -0,0 +1 @@
../cpp

1
lib/spack/env/rocmcc/amdflang vendored Symbolic link
View file

@ -0,0 +1 @@
../fc

View file

@ -42,7 +42,8 @@
_compiler_to_pkg = { _compiler_to_pkg = {
'clang': 'llvm+clang', 'clang': 'llvm+clang',
'oneapi': 'intel-oneapi-compilers' 'oneapi': 'intel-oneapi-compilers',
'rocmcc': 'llvm-amdgpu'
} }

View file

@ -0,0 +1,78 @@
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
import llnl.util.lang
import spack.compilers.clang
class Rocmcc(spack.compilers.clang.Clang):
# Subclasses use possible names of C compiler
cc_names = ['amdclang']
# Subclasses use possible names of C++ compiler
cxx_names = ['amdclang++']
# Subclasses use possible names of Fortran 77 compiler
f77_names = ['amdflang']
# Subclasses use possible names of Fortran 90 compiler
fc_names = ['amdflang']
PrgEnv = 'PrgEnv-amd'
PrgEnv_compiler = 'amd'
@property
def link_paths(self):
link_paths = {'cc': 'rocmcc/amdclang',
'cxx': 'rocmcc/amdclang++',
'f77': 'rocmcc/amdflang',
'fc': 'rocmcc/amdflang'}
return link_paths
@property
def cxx11_flag(self):
return "-std=c++11"
@property
def cxx14_flag(self):
return "-std=c++14"
@property
def cxx17_flag(self):
return "-std=c++17"
@property
def c99_flag(self):
return '-std=c99'
@property
def c11_flag(self):
return "-std=c11"
@classmethod
@llnl.util.lang.memoized
def extract_version_from_output(cls, output):
match = re.search(
r'llvm-project roc-(\d+)[._](\d+)[._](\d+)',
output
)
if match:
return '.'.join(match.groups())
@classmethod
def fc_version(cls, fortran_compiler):
return cls.default_version(fortran_compiler)
@classmethod
def f77_version(cls, f77):
return cls.fc_version(f77)
@property
def stdcxx_libs(self):
return ('-lstdc++', )

View file

@ -188,6 +188,10 @@ def provides(self):
if self.spec.name == 'llvm': if self.spec.name == 'llvm':
provides['compiler'] = spack.spec.CompilerSpec(str(self.spec)) provides['compiler'] = spack.spec.CompilerSpec(str(self.spec))
provides['compiler'].name = 'clang' provides['compiler'].name = 'clang'
# Special case for llvm-amdgpu
if self.spec.name == 'llvm-amdgpu':
provides['compiler'] = spack.spec.CompilerSpec(str(self.spec))
provides['compiler'].name = 'rocmcc'
# All the other tokens in the hierarchy must be virtual dependencies # All the other tokens in the hierarchy must be virtual dependencies
for x in self.hierarchy_tokens: for x in self.hierarchy_tokens: