From ec8bd38c4e79646af4683659266e1ba2e886e9a9 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Fri, 17 Nov 2023 15:59:04 +0100 Subject: Permit packages that depend on Intel oneAPI packages to access sdk (#41117) * Permit packages that depend on Intel oneAPI packages to access sdk * Implement and use IntelOneapiLibraryPackageWithSdk * Restore libs property to IntelOneapiLibraryPackage * Conform to style * Provide new class to infrastructure * Treat sdk/include as the main include --- lib/spack/spack/build_systems/oneapi.py | 29 ++++++++++++++++++++++ lib/spack/spack/package.py | 1 + .../packages/intel-oneapi-advisor/package.py | 2 +- .../packages/intel-oneapi-inspector/package.py | 2 +- .../builtin/packages/intel-oneapi-vtune/package.py | 2 +- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/build_systems/oneapi.py b/lib/spack/spack/build_systems/oneapi.py index 4c432c0cac..f90312f579 100644 --- a/lib/spack/spack/build_systems/oneapi.py +++ b/lib/spack/spack/build_systems/oneapi.py @@ -179,6 +179,35 @@ class IntelOneApiLibraryPackage(IntelOneApiPackage): return find_libraries("*", root=lib_path, shared=True, recursive=True) +class IntelOneApiLibraryPackageWithSdk(IntelOneApiPackage): + """Base class for Intel oneAPI library packages with SDK components. + + Contains some convenient default implementations for libraries + that expose functionality in sdk subdirectories. + Implement the method directly in the package if something + different is needed. + + """ + + @property + def include(self): + return join_path(self.component_prefix, "sdk", "include") + + @property + def headers(self): + return find_headers("*", self.include, recursive=True) + + @property + def lib(self): + lib_path = join_path(self.component_prefix, "sdk", "lib64") + lib_path = lib_path if isdir(lib_path) else dirname(lib_path) + return lib_path + + @property + def libs(self): + return find_libraries("*", root=self.lib, shared=True, recursive=True) + + class IntelOneApiStaticLibraryList: """Provides ld_flags when static linking is needed diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 79df48cd17..f38ebec299 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -52,6 +52,7 @@ from spack.build_systems.octave import OctavePackage from spack.build_systems.oneapi import ( INTEL_MATH_LIBRARIES, IntelOneApiLibraryPackage, + IntelOneApiLibraryPackageWithSdk, IntelOneApiPackage, IntelOneApiStaticLibraryList, ) diff --git a/var/spack/repos/builtin/packages/intel-oneapi-advisor/package.py b/var/spack/repos/builtin/packages/intel-oneapi-advisor/package.py index fe2b7f3438..01410cd18d 100644 --- a/var/spack/repos/builtin/packages/intel-oneapi-advisor/package.py +++ b/var/spack/repos/builtin/packages/intel-oneapi-advisor/package.py @@ -7,7 +7,7 @@ from spack.package import * @IntelOneApiPackage.update_description -class IntelOneapiAdvisor(IntelOneApiPackage): +class IntelOneapiAdvisor(IntelOneApiLibraryPackageWithSdk): """Intel Advisor is a design and analysis tool for developing performant code. The tool supports C, C++, Fortran, SYCL, OpenMP, OpenCL code, and Python. It helps with the following: Performant diff --git a/var/spack/repos/builtin/packages/intel-oneapi-inspector/package.py b/var/spack/repos/builtin/packages/intel-oneapi-inspector/package.py index 0c1e0f79ab..9f376cffc7 100644 --- a/var/spack/repos/builtin/packages/intel-oneapi-inspector/package.py +++ b/var/spack/repos/builtin/packages/intel-oneapi-inspector/package.py @@ -7,7 +7,7 @@ from spack.package import * @IntelOneApiPackage.update_description -class IntelOneapiInspector(IntelOneApiPackage): +class IntelOneapiInspector(IntelOneApiLibraryPackageWithSdk): """Intel Inspector is a dynamic memory and threading error debugger for C, C++, and Fortran applications that run on Windows and Linux operating systems. Save money: locate the root cause of memory, diff --git a/var/spack/repos/builtin/packages/intel-oneapi-vtune/package.py b/var/spack/repos/builtin/packages/intel-oneapi-vtune/package.py index c2ed3f164e..f9ab11eef7 100644 --- a/var/spack/repos/builtin/packages/intel-oneapi-vtune/package.py +++ b/var/spack/repos/builtin/packages/intel-oneapi-vtune/package.py @@ -7,7 +7,7 @@ from spack.package import * @IntelOneApiPackage.update_description -class IntelOneapiVtune(IntelOneApiPackage): +class IntelOneapiVtune(IntelOneApiLibraryPackageWithSdk): """Intel VTune Profiler is a profiler to optimize application performance, system performance, and system configuration for HPC, cloud, IoT, media, storage, and more. CPU, GPU, and FPGA: Tune -- cgit v1.2.3-60-g2f50