|
| 1 | +## |
| 2 | +# Copyright 2009-2025 Ghent University |
| 3 | +# |
| 4 | +# This file is part of EasyBuild, |
| 5 | +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), |
| 6 | +# with support of Ghent University (http://ugent.be/hpc), |
| 7 | +# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), |
| 8 | +# Flemish Research Foundation (FWO) (http://www.fwo.be/en) |
| 9 | +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). |
| 10 | +# |
| 11 | +# https://github.com/easybuilders/easybuild |
| 12 | +# |
| 13 | +# EasyBuild is free software: you can redistribute it and/or modify |
| 14 | +# it under the terms of the GNU General Public License as published by |
| 15 | +# the Free Software Foundation v2. |
| 16 | +# |
| 17 | +# EasyBuild is distributed in the hope that it will be useful, |
| 18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | +# GNU General Public License for more details. |
| 21 | +# |
| 22 | +# You should have received a copy of the GNU General Public License |
| 23 | +# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. |
| 24 | +## |
| 25 | +""" |
| 26 | +EasyBuild support for installing the Intel Performance Primitives (IPP) library, implemented as an easyblock |
| 27 | +
|
| 28 | +@author: Stijn De Weirdt (Ghent University) |
| 29 | +@author: Dries Verdegem (Ghent University) |
| 30 | +@author: Kenneth Hoste (Ghent University) |
| 31 | +@author: Pieter De Baets (Ghent University) |
| 32 | +@author: Jens Timmerman (Ghent University) |
| 33 | +@author: Lumir Jasiok (IT4Innovations) |
| 34 | +@author: Damian Alvarez (Forschungszentrum Juelich GmbH) |
| 35 | +@author: Jan Andre Reuter (Forschungszentrum Juelich GmbH) |
| 36 | +""" |
| 37 | + |
| 38 | +from easybuild.tools import LooseVersion |
| 39 | +import os |
| 40 | + |
| 41 | +from easybuild.easyblocks.generic.intelbase import IntelBase |
| 42 | +from easybuild.tools.build_log import EasyBuildError |
| 43 | +from easybuild.tools.modules import MODULE_LOAD_ENV_HEADERS |
| 44 | +from easybuild.tools.systemtools import get_platform_name |
| 45 | +from easybuild.tools.systemtools import get_shared_lib_ext |
| 46 | + |
| 47 | + |
| 48 | +class EB_ipp(IntelBase): |
| 49 | + """ |
| 50 | + Support for installing Intel Integrated Performance Primitives library |
| 51 | + """ |
| 52 | + def __init__(self, *args, **kwargs): |
| 53 | + super().__init__(*args, **kwargs) |
| 54 | + |
| 55 | + if LooseVersion(self.version) < '2021': |
| 56 | + raise EasyBuildError( |
| 57 | + f"Version {self.version} of {self.name} is unsupported. Mininum supported version is 2021.0." |
| 58 | + ) |
| 59 | + |
| 60 | + platform_name = get_platform_name() |
| 61 | + if platform_name.startswith('x86_64'): |
| 62 | + self.arch = "intel64" |
| 63 | + elif platform_name.startswith('i386') or platform_name.startswith('i686'): |
| 64 | + if LooseVersion(self.version) >= '2022.0': |
| 65 | + raise EasyBuildError(f"ipp is not supported on {platform_name} starting with 2022.0.0") |
| 66 | + self.arch = 'ia32' |
| 67 | + else: |
| 68 | + raise EasyBuildError("Failed to determine system architecture based on %s", platform_name) |
| 69 | + |
| 70 | + def prepare_step(self, *args, **kwargs): |
| 71 | + kwargs['requires_runtime_license'] = False |
| 72 | + super().prepare_step(*args, **kwargs) |
| 73 | + |
| 74 | + def install_step(self): |
| 75 | + """ |
| 76 | + Actual installation |
| 77 | + - create silent cfg file |
| 78 | + - execute command |
| 79 | + """ |
| 80 | + silent_cfg_names_map = None |
| 81 | + silent_cfg_extras = { |
| 82 | + 'ARCH_SELECTED': self.arch.upper() |
| 83 | + } |
| 84 | + |
| 85 | + super(EB_ipp, self).install_step(silent_cfg_names_map=silent_cfg_names_map, silent_cfg_extras=silent_cfg_extras) |
| 86 | + |
| 87 | + def sanity_check_step(self): |
| 88 | + """Custom sanity check paths for IPP.""" |
| 89 | + shlib_ext = get_shared_lib_ext() |
| 90 | + |
| 91 | + dirs = [os.path.join('ipp', x) for x in ['bin', 'include', os.path.join('tools', 'intel64')]] |
| 92 | + ipp_libs = ['cc', 'ch', 'core', 'cv', 'dc', 'i', 's', 'vm'] |
| 93 | + |
| 94 | + custom_paths = { |
| 95 | + 'files': [ |
| 96 | + os.path.join('ipp', 'lib', 'intel64', 'libipp%s') % y for x in ipp_libs |
| 97 | + for y in ['%s.a' % x, '%s.%s' % (x, shlib_ext)] |
| 98 | + ], |
| 99 | + 'dirs': dirs, |
| 100 | + } |
| 101 | + |
| 102 | + super(EB_ipp, self).sanity_check_step(custom_paths=custom_paths) |
| 103 | + |
| 104 | + def make_module_step(self, *args, **kwargs): |
| 105 | + """ |
| 106 | + Set paths for module load environment based on the actual installation files |
| 107 | + """ |
| 108 | + major_minor_version = '.'.join(self.version.split('.')[:2]) |
| 109 | + if LooseVersion(major_minor_version) >= '2022.0': |
| 110 | + include_path = os.path.join('ipp', major_minor_version, 'include') |
| 111 | + lib_path = os.path.join('ipp', major_minor_version, 'lib') |
| 112 | + cmake_prefix_path = os.path.join('ipp', major_minor_version) |
| 113 | + cmake_module_path = os.path.join('ipp', major_minor_version, 'lib', 'cmake') |
| 114 | + else: |
| 115 | + include_path = os.path.join('ipp', self.version, 'include') |
| 116 | + lib_path = os.path.join('ipp', self.version, 'lib', self.arch) |
| 117 | + cmake_prefix_path = os.path.join('ipp', self.version) |
| 118 | + cmake_module_path = os.path.join('ipp', self.version, 'lib', 'cmake') |
| 119 | + |
| 120 | + self.module_load_environment.PATH = [] |
| 121 | + self.module_load_environment.LD_LIBRARY_PATH = [lib_path] |
| 122 | + self.module_load_environment.LIBRARY_PATH = self.module_load_environment.LD_LIBRARY_PATH |
| 123 | + self.module_load_environment.CMAKE_PREFIX_PATH = os.path.join(cmake_prefix_path) |
| 124 | + self.module_load_environment.CMAKE_MODULE_PATH = os.path.join(cmake_module_path) |
| 125 | + self.module_load_environment.set_alias_vars(MODULE_LOAD_ENV_HEADERS, include_path) |
| 126 | + |
| 127 | + return super().make_module_step(*args, **kwargs) |
| 128 | + |
| 129 | + def make_module_extra(self): |
| 130 | + """Overwritten from Application to add extra txt""" |
| 131 | + major_minor_version = '.'.join(self.version.split('.')[:2]) |
| 132 | + |
| 133 | + txt = super().make_module_extra() |
| 134 | + |
| 135 | + ipproot = os.path.join(self.installdir, 'ipp', major_minor_version) |
| 136 | + txt += self.module_generator.set_environment('IPPROOT', ipproot) |
| 137 | + txt += self.module_generator.set_environment('IPP_TARGET_ARCH', self.arch) |
| 138 | + |
| 139 | + return txt |
0 commit comments