summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGaneshPrasadMA <72124920+GaneshPrasadMA@users.noreply.github.com>2020-10-20 21:20:09 +0530
committerGitHub <noreply@github.com>2020-10-20 10:50:09 -0500
commit0253f0af29b97f107715d74f5b694f53ca4b7476 (patch)
treef6299c7ceae3ac7e527fac8c66c5511901d2780f /lib
parentf68287afe97623b0a0e09c8625fcb79148b64f33 (diff)
downloadspack-0253f0af29b97f107715d74f5b694f53ca4b7476.tar.gz
spack-0253f0af29b97f107715d74f5b694f53ca4b7476.tar.bz2
spack-0253f0af29b97f107715d74f5b694f53ca4b7476.tar.xz
spack-0253f0af29b97f107715d74f5b694f53ca4b7476.zip
Adding AOCC compiler to SPACK community (#19345)
* Adding AOCC compiler to SPACK community The AOCC compiler system offers a high level of advanced optimizations, multi-threading and processor support that includes global optimization, vectorization, inter-procedural analyses, loop transformations, and code generation. AMD also provides highly optimized libraries, which extract the optimal performance from each x86 processor core when utilized. The AOCC Compiler Suite simplifies and accelerates development and tuning for x86 applications. * Added unit tests for detection and flags for AOCC * Addressed reviewers comments w.r.t version checks and url,checksum related line lengths Co-authored-by: Test User <spack@example.com>
Diffstat (limited to 'lib')
l---------lib/spack/env/aocc/clang1
l---------lib/spack/env/aocc/clang++1
l---------lib/spack/env/aocc/flang1
-rwxr-xr-xlib/spack/env/cc2
-rw-r--r--lib/spack/spack/compilers/__init__.py2
-rw-r--r--lib/spack/spack/compilers/aocc.py116
-rw-r--r--lib/spack/spack/compilers/clang.py2
-rw-r--r--lib/spack/spack/test/compilers/basics.py24
-rw-r--r--lib/spack/spack/test/compilers/detection.py16
9 files changed, 162 insertions, 3 deletions
diff --git a/lib/spack/env/aocc/clang b/lib/spack/env/aocc/clang
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/aocc/clang
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/env/aocc/clang++ b/lib/spack/env/aocc/clang++
new file mode 120000
index 0000000000..abf4cd45c7
--- /dev/null
+++ b/lib/spack/env/aocc/clang++
@@ -0,0 +1 @@
+../cpp \ No newline at end of file
diff --git a/lib/spack/env/aocc/flang b/lib/spack/env/aocc/flang
new file mode 120000
index 0000000000..b6c64233b0
--- /dev/null
+++ b/lib/spack/env/aocc/flang
@@ -0,0 +1 @@
+../fc \ No newline at end of file
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index 6de7df3576..e826cabca4 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -125,7 +125,7 @@ case "$command" in
comp="FC"
lang_flags=F
;;
- f77|xlf|xlf_r|pgf77|frt)
+ f77|xlf|xlf_r|pgf77|frt|flang)
command="$SPACK_F77"
language="Fortran 77"
comp="F77"
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index c11bafe47d..452dc384a5 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -739,7 +739,7 @@ def is_mixed_toolchain(compiler):
toolchains.add(compiler_cls.__name__)
if len(toolchains) > 1:
- if toolchains == set(['Clang', 'AppleClang']):
+ if toolchains == set(['Clang', 'AppleClang', 'Aocc']):
return False
tty.debug("[TOOLCHAINS] {0}".format(toolchains))
return True
diff --git a/lib/spack/spack/compilers/aocc.py b/lib/spack/spack/compilers/aocc.py
new file mode 100644
index 0000000000..5c9e885490
--- /dev/null
+++ b/lib/spack/spack/compilers/aocc.py
@@ -0,0 +1,116 @@
+# Copyright 2013-2020 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 sys
+
+import llnl.util.lang
+
+from spack.compiler import Compiler
+
+
+class Aocc(Compiler):
+ # Subclasses use possible names of C compiler
+ cc_names = ['clang']
+
+ # Subclasses use possible names of C++ compiler
+ cxx_names = ['clang++']
+
+ # Subclasses use possible names of Fortran 77 compiler
+ f77_names = ['flang']
+
+ # Subclasses use possible names of Fortran 90 compiler
+ fc_names = ['flang']
+
+ version_argument = '--version'
+
+ @property
+ def debug_flags(self):
+ return ['-gcodeview', '-gdwarf-2', '-gdwarf-3', '-gdwarf-4',
+ '-gdwarf-5', '-gline-tables-only', '-gmodules', '-gz', '-g']
+
+ @property
+ def opt_flags(self):
+ return ['-O0', '-O1', '-O2', '-O3', '-Ofast', '-Os', '-Oz', '-Og',
+ '-O', '-O4']
+
+ @property
+ def link_paths(self):
+ link_paths = {'cc': 'aocc/clang',
+ 'cxx': 'aocc/clang++',
+ 'f77': 'aocc/flang',
+ 'fc': 'aocc/flang'}
+
+ return link_paths
+
+ @property
+ def verbose_flag(self):
+ return "-v"
+
+ @property
+ def openmp_flag(self):
+ return "-fopenmp"
+
+ @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"
+
+ @property
+ def cc_pic_flag(self):
+ return "-fPIC"
+
+ @property
+ def cxx_pic_flag(self):
+ return "-fPIC"
+
+ @property
+ def f77_pic_flag(self):
+ return "-fPIC"
+
+ @property
+ def fc_pic_flag(self):
+ return "-fPIC"
+
+ required_libs = ['libclang']
+
+ @classmethod
+ @llnl.util.lang.memoized
+ def extract_version_from_output(cls, output):
+ loc_ver = 'unknown'
+
+ match = re.search(
+ r'AMD clang version ([^ )]+)',
+ output
+ )
+ if match:
+ loc_ver = output.split('AOCC_')[1].split('-')[0]
+ return loc_ver
+
+ @classmethod
+ def fc_version(cls, fortran_compiler):
+ if sys.platform == 'darwin':
+ return cls.default_version('clang')
+
+ return cls.default_version(fortran_compiler)
+
+ @classmethod
+ def f77_version(cls, f77):
+ return cls.fc_version(f77)
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index 2f8c7d43e3..5eb08cbf0a 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -154,7 +154,7 @@ class Clang(Compiler):
@llnl.util.lang.memoized
def extract_version_from_output(cls, output):
ver = 'unknown'
- if 'Apple' in output:
+ if ('Apple' in output) or ('AMD' in output):
return ver
match = re.search(
diff --git a/lib/spack/spack/test/compilers/basics.py b/lib/spack/spack/test/compilers/basics.py
index 9af416dd7b..22099bdb63 100644
--- a/lib/spack/spack/test/compilers/basics.py
+++ b/lib/spack/spack/test/compilers/basics.py
@@ -442,6 +442,30 @@ def test_clang_flags():
'clang@3.3')
+def test_aocc_flags():
+ supported_flag_test("debug_flags",
+ ['-gcodeview', '-gdwarf-2', '-gdwarf-3',
+ '-gdwarf-4', '-gdwarf-5', '-gline-tables-only',
+ '-gmodules', '-gz', '-g'],
+ 'aocc@2.2.0')
+ supported_flag_test("opt_flags",
+ ['-O0', '-O1', '-O2', '-O3', '-Ofast',
+ '-Os', '-Oz', '-Og',
+ '-O', '-O4'],
+ 'aocc@2.2.0')
+ supported_flag_test("openmp_flag", "-fopenmp", "aocc@2.2.0")
+ supported_flag_test("cxx11_flag", "-std=c++11", "aocc@2.2.0")
+ supported_flag_test("cxx14_flag", "-std=c++14", "aocc@2.2.0")
+ supported_flag_test("cxx17_flag", "-std=c++17", "aocc@2.2.0")
+ supported_flag_test("c99_flag", "-std=c99", "aocc@2.2.0")
+ supported_flag_test("c11_flag", "-std=c11", "aocc@2.2.0")
+ supported_flag_test("cc_pic_flag", "-fPIC", "aocc@2.2.0")
+ supported_flag_test("cxx_pic_flag", "-fPIC", "aocc@2.2.0")
+ supported_flag_test("f77_pic_flag", "-fPIC", "aocc@2.2.0")
+ supported_flag_test("fc_pic_flag", "-fPIC", "aocc@2.2.0")
+ supported_flag_test("version_argument", "--version", "aocc@2.2.0")
+
+
def test_fj_flags():
supported_flag_test("openmp_flag", "-Kopenmp", "fj@4.0.0")
supported_flag_test("cxx98_flag", "-std=c++98", "fj@4.0.0")
diff --git a/lib/spack/spack/test/compilers/detection.py b/lib/spack/spack/test/compilers/detection.py
index 4cb80090b5..cf2f7a057a 100644
--- a/lib/spack/spack/test/compilers/detection.py
+++ b/lib/spack/spack/test/compilers/detection.py
@@ -19,6 +19,7 @@ import spack.compilers.nvhpc
import spack.compilers.pgi
import spack.compilers.xl
import spack.compilers.xl_r
+import spack.compilers.aocc
from spack.operating_systems.cray_frontend import CrayFrontend
import spack.util.module_cmd
@@ -288,3 +289,18 @@ def test_cray_frontend_compiler_detection(
paths = cray_fe_os.compiler_search_paths
assert paths == [str(compiler_dir)]
+
+
+@pytest.mark.parametrize('version_str,expected_version', [
+ # This applies to C,C++ and FORTRAN compiler
+ ('AMD clang version 10.0.0 (CLANG: AOCC_2.2.0-Build#93 2020_06_25)'
+ '(based on LLVM Mirror.Version.10.0.0)\n'
+ 'Target: x86_64-unknown-linux-gnu\n'
+ 'Thread model: posix\n', '2.2.0'
+ )
+])
+def test_aocc_version_detection(version_str, expected_version):
+ version = spack.compilers.aocc.Aocc.extract_version_from_output(
+ version_str
+ )
+ assert version == expected_version