2022-01-13 03:21:41 +08:00
|
|
|
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
|
2021-03-17 05:34:25 +08:00
|
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2022-05-29 00:55:44 +08:00
|
|
|
from spack.package import *
|
2021-07-09 06:12:30 +08:00
|
|
|
|
2021-03-17 05:34:25 +08:00
|
|
|
|
|
|
|
class AoclSparse(CMakePackage):
|
|
|
|
"""AOCL-Sparse is a library that contains basic linear algebra subroutines
|
|
|
|
for sparse matrices and vectors optimized for AMD EPYC family of processors.
|
|
|
|
It is designed to be used with C and C++. Current functionality of sparse
|
|
|
|
library supports SPMV function with CSR and ELLPACK formats."""
|
|
|
|
|
|
|
|
homepage = "https://developer.amd.com/amd-aocl/aocl-sparse/"
|
2021-03-23 00:30:08 +08:00
|
|
|
url = "https://github.com/amd/aocl-sparse/archive/3.0.tar.gz"
|
2021-03-17 05:34:25 +08:00
|
|
|
git = "https://github.com/amd/aocl-sparse.git"
|
|
|
|
|
|
|
|
maintainers = ['amd-toolchain-support']
|
|
|
|
|
2021-12-18 01:28:41 +08:00
|
|
|
version('3.1', sha256='8536f06095c95074d4297a3d2910654085dd91bce82e116c10368a9f87e9c7b9')
|
2021-03-23 00:30:08 +08:00
|
|
|
version('3.0', sha256='1d04ba16e04c065051af916b1ed9afce50296edfa9b1513211a7378e1d6b952e')
|
2021-03-17 05:34:25 +08:00
|
|
|
version('2.2', sha256='33c2ed6622cda61d2613ee63ff12c116a6cd209c62e54307b8fde986cd65f664')
|
|
|
|
|
2021-10-03 21:09:02 +08:00
|
|
|
conflicts("%gcc@:9.1", msg="Minimum required GCC version is 9.2.0")
|
2021-03-17 05:34:25 +08:00
|
|
|
|
|
|
|
variant('build_type', default='Release',
|
|
|
|
description='CMake build type',
|
|
|
|
values=('Debug', 'Release'))
|
|
|
|
variant('shared', default=True,
|
|
|
|
description='Build shared library')
|
2021-03-23 00:30:08 +08:00
|
|
|
variant('ilp64', default=False,
|
|
|
|
description='Build with ILP64 support')
|
2021-03-17 05:34:25 +08:00
|
|
|
|
2021-03-23 00:30:08 +08:00
|
|
|
depends_on('boost', when='@2.2')
|
2021-12-18 01:28:41 +08:00
|
|
|
depends_on('cmake@3.5:', type='build')
|
2021-03-17 05:34:25 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def build_directory(self):
|
|
|
|
"""Returns the directory to use when building the package
|
|
|
|
|
|
|
|
:return: directory where to build the package
|
|
|
|
"""
|
|
|
|
|
2021-03-23 00:30:08 +08:00
|
|
|
build_directory = self.stage.source_path
|
2021-03-17 05:34:25 +08:00
|
|
|
|
|
|
|
if self.spec.variants['build_type'].value == 'Debug':
|
2021-03-23 00:30:08 +08:00
|
|
|
build_directory = join_path(build_directory, 'build', 'debug')
|
2021-03-17 05:34:25 +08:00
|
|
|
else:
|
2021-03-23 00:30:08 +08:00
|
|
|
build_directory = join_path(build_directory, 'build', 'release')
|
2021-03-17 05:34:25 +08:00
|
|
|
|
2021-03-23 00:30:08 +08:00
|
|
|
return build_directory
|
2021-03-17 05:34:25 +08:00
|
|
|
|
2021-03-23 00:30:08 +08:00
|
|
|
def cmake_args(self):
|
2021-03-17 05:34:25 +08:00
|
|
|
"""Runs ``cmake`` in the build directory"""
|
2021-03-23 00:30:08 +08:00
|
|
|
spec = self.spec
|
|
|
|
|
2021-03-17 05:34:25 +08:00
|
|
|
args = [
|
|
|
|
"../..",
|
|
|
|
"-DCMAKE_INSTALL_PREFIX:PATH={0}".format(spec.prefix),
|
|
|
|
"-DCMAKE_CXX_COMPILER={0}".format(os.path.basename(spack_cxx))
|
|
|
|
]
|
|
|
|
|
|
|
|
if spec.variants['build_type'].value == 'Debug':
|
|
|
|
args.append("-DCMAKE_BUILD_TYPE=Debug")
|
|
|
|
else:
|
|
|
|
args.append("-DCMAKE_BUILD_TYPE=Release")
|
|
|
|
|
|
|
|
args.extend([
|
2021-05-19 18:59:06 +08:00
|
|
|
self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
|
2021-03-17 05:34:25 +08:00
|
|
|
|
|
|
|
"-DBUILD_CLIENTS_BENCHMARKS:BOOL=%s" % (
|
2021-03-23 00:30:08 +08:00
|
|
|
'ON' if self.run_tests else 'OFF')
|
2021-03-17 05:34:25 +08:00
|
|
|
])
|
|
|
|
|
2021-03-23 00:30:08 +08:00
|
|
|
if spec.satisfies('@3.0:'):
|
|
|
|
args.extend([
|
2021-05-19 18:59:06 +08:00
|
|
|
self.define_from_variant('BUILD_ILP64', 'ilp64')
|
2021-03-23 00:30:08 +08:00
|
|
|
])
|
|
|
|
|
|
|
|
return args
|
2021-03-17 05:34:25 +08:00
|
|
|
|
|
|
|
@run_after('build')
|
|
|
|
@on_package_attributes(run_tests=True)
|
|
|
|
def check(self):
|
2021-03-23 00:30:08 +08:00
|
|
|
""" Simple test to test the built library by running
|
2021-03-17 05:34:25 +08:00
|
|
|
one of the aocl-sparse examples, after compiling the
|
|
|
|
library with benchmarks.
|
|
|
|
"""
|
|
|
|
dso_suffix = 'so' if '+shared' in self.spec else 'a'
|
|
|
|
|
|
|
|
if self.spec.variants['build_type'].value == 'Debug':
|
2021-03-23 00:30:08 +08:00
|
|
|
lib_path = join_path(self.build_directory,
|
2021-03-17 05:34:25 +08:00
|
|
|
'library',
|
|
|
|
'libaoclsparse-d.{0}'.format(dso_suffix))
|
|
|
|
else:
|
2021-03-23 00:30:08 +08:00
|
|
|
lib_path = join_path(self.build_directory,
|
2021-03-17 05:34:25 +08:00
|
|
|
'library',
|
|
|
|
'libaoclsparse.{0}'.format(dso_suffix))
|
|
|
|
|
2021-03-23 00:30:08 +08:00
|
|
|
test_bench_bin = join_path(self.build_directory, 'tests',
|
|
|
|
'staging', 'aoclsparse-bench')
|
|
|
|
test_args = " --function=csrmv --precision=d "
|
|
|
|
test_args += "--sizem=1000 --sizen=1000 --sizennz=4000 --verify=1 "
|
|
|
|
os.system(test_bench_bin + test_args + lib_path)
|