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>
This commit is contained in:
GaneshPrasadMA 2020-10-20 21:20:09 +05:30 committed by GitHub
parent f68287afe9
commit 0253f0af29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 229 additions and 4 deletions

View file

@ -15,7 +15,7 @@
# -------------------------------------------------------------------------
packages:
all:
compiler: [gcc, intel, pgi, clang, xl, nag, fj]
compiler: [gcc, intel, pgi, clang, xl, nag, fj, aocc]
providers:
D: [ldc]
awk: [gawk]

1
lib/spack/env/aocc/clang vendored Symbolic link
View file

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

1
lib/spack/env/aocc/clang++ vendored Symbolic link
View file

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

1
lib/spack/env/aocc/flang vendored Symbolic link
View file

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

2
lib/spack/env/cc vendored
View file

@ -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"

View file

@ -739,7 +739,7 @@ def name_matches(name, name_list):
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

View file

@ -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)

View file

@ -154,7 +154,7 @@ def fc_pic_flag(self):
@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(

View file

@ -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")

View file

@ -19,6 +19,7 @@
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 _module(cmd, *args):
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

View file

@ -0,0 +1,66 @@
# 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)
from spack import *
class Aocc(Package):
'''
The AOCC compiler system is a high performance,
production quality code generation tool.
The AOCC environment provides various options to developers when
building and optimizing C, C++, and Fortran applications
targeting 32-bit and 64-bit Linux platforms.
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.
Please install only if you agree to terms and conditions depicted
under : http://developer.amd.com/wordpress/media/files/AOCC_EULA.pdf
Example for installation: \'spack install aocc +license-agreed\'
'''
family = 'compiler'
homepage = "https://developer.amd.com/amd-aocc/"
version(ver="2.2.0", sha256='500940ce36c19297dfba3aa56dcef33b6145867a1f34890945172ac2be83b286',
url='http://developer.amd.com/wordpress/media/files/aocc-compiler-2.2.0.tar')
# Licensing
license_required = True
license_comment = '#'
license_files = ['AOCC_EULA.pdf']
license_url = 'http://developer.amd.com/wordpress/media/files/AOCC_EULA.pdf'
install_example = "spack install aocc +license-agreed"
depends_on('libxml2')
depends_on('zlib')
depends_on('ncurses')
depends_on('libtool')
depends_on('texinfo')
variant('license-agreed', default=False,
description='Agree to terms and conditions depicted under : {0}'
.format(license_url))
@run_before('install')
def abort_without_license_agreed(self):
license_url = 'http://developer.amd.com/wordpress/media/files/AOCC_EULA.pdf'
install_example = "spack install aocc +license-agreed"
if not self.spec.variants['license-agreed'].value:
raise InstallError("\n\n\nNOTE:\nUse +license-agreed " +
"during installation " +
"to accept terms and conditions " +
"depicted under following link \n" +
" {0}\n".format(license_url) +
"Example: \'{0}\' \n".format(install_example))
def install(self, spec, prefix):
print("Installing AOCC Compiler ... ")
install_tree('.', prefix)