-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change options based on arch for Mesa #1892
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3c02f75
Change options based on arch for Mesa
edmondac 4e42c52
Update mesa.py
edmondac 725459c
Update mesa.py
edmondac dfca214
Merge branch 'develop' of github.com:easybuilders/easybuild-easyblock…
edmondac c229253
Copyright notice
edmondac f486204
Missing quotes
edmondac 7b92a99
Merge branch 'develop' of github.com:easybuilders/easybuild-easyblock…
edmondac e0cf7ac
Set the swr-arches based on the available CPU features
edmondac 82538ab
Update easybuild/easyblocks/m/mesa.py
edmondac 8aee552
Update easybuild/easyblocks/m/mesa.py
edmondac ecdfec6
Update easybuild/easyblocks/m/mesa.py
edmondac cac0c0c
Update easybuild/easyblocks/m/mesa.py
edmondac 54826ec
minor style cleanup in configure step of Mesa easyblock
boegel 99d9f80
always copy include/GL/internal headers + implement custom sanity che…
boegel 1904d14
also check for libswr*.so libraries in sanity check for Mesa
boegel bc18448
only copy include/GL/internal if it's missing in Mesa easyblock
boegel 3986f0f
appease the Hound
boegel 61f5389
use .items() to compose self.swr_arches in Mesa easyblock
boegel 4255b23
make Mesa sanity check compatible with Mesa 20.x
boegel b1418e9
Merge pull request #17 from boegel/mesa-for-power9
edmondac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
## | ||
# Copyright 2009-2020 Ghent University | ||
# | ||
# This file is part of EasyBuild, | ||
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), | ||
# with support of Ghent University (http://ugent.be/hpc), | ||
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), | ||
# Flemish Research Foundation (FWO) (http://www.fwo.be/en) | ||
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). | ||
# | ||
# https://github.com/easybuilders/easybuild | ||
# | ||
# EasyBuild is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation v2. | ||
# | ||
# EasyBuild is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. | ||
## | ||
""" | ||
EasyBuild support for installing Mesa, implemented as an easyblock | ||
|
||
@author: Andrew Edmondson (University of Birmingham) | ||
@author: Kenneth Hoste (HPC-UGent) | ||
""" | ||
import os | ||
from distutils.version import LooseVersion | ||
|
||
from easybuild.easyblocks.generic.mesonninja import MesonNinja | ||
from easybuild.tools.filetools import copy_dir | ||
from easybuild.tools.systemtools import POWER, X86_64, get_cpu_architecture, get_cpu_features, get_shared_lib_ext | ||
|
||
|
||
class EB_Mesa(MesonNinja): | ||
"""Custom easyblock for building and installing Mesa.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Constructor for custom Mesa easyblock: figure out which vales to pass to swr-arches configuration option.""" | ||
|
||
super(EB_Mesa, self).__init__(*args, **kwargs) | ||
|
||
self.swr_arches = [] | ||
|
||
if 'swr-arches' not in self.cfg['configopts']: | ||
# set cpu features of SWR for current architecture (only on x86_64) | ||
if get_cpu_architecture() == X86_64: | ||
feat_to_swrarch = { | ||
'avx': 'avx', | ||
'avx1.0': 'avx', # on macOS, AVX is indicated with 'avx1.0' rather than 'avx' | ||
'avx2': 'avx2', | ||
'avx512f': 'skx', # AVX-512 Foundation - introduced in Skylake | ||
'avx512er': 'knl', # AVX-512 Exponential and Reciprocal Instructions implemented in Knights Landing | ||
} | ||
# determine list of values to pass to swr-arches configuration option | ||
cpu_features = get_cpu_features() | ||
self.swr_arches = sorted([swrarch for feat, swrarch in feat_to_swrarch.items() if feat in cpu_features]) | ||
|
||
def configure_step(self): | ||
""" | ||
Customise the configure options based on the processor architecture of the host | ||
(x86_64 or not, CPU features, ...) | ||
""" | ||
|
||
arch = get_cpu_architecture() | ||
if 'gallium-drivers' not in self.cfg['configopts']: | ||
# Install appropriate Gallium drivers for current architecture | ||
if arch == X86_64: | ||
self.cfg.update('configopts', "-Dgallium-drivers='swrast,swr'") | ||
elif arch == POWER: | ||
self.cfg.update('configopts', "-Dgallium-drivers='swrast'") | ||
|
||
if self.swr_arches: | ||
self.cfg.update('configopts', '-Dswr-arches=' + ','.join(self.swr_arches)) | ||
|
||
return super(EB_Mesa, self).configure_step() | ||
|
||
def install_step(self): | ||
"""Also copy additional header files after installing Mesa.""" | ||
|
||
super(EB_Mesa, self).install_step() | ||
|
||
# also install header files located in include/GL/internal, unless they're available already; | ||
# we can't enable both DRI and Gallium drivers, | ||
# but we can provide the DRI header file (GL/internal/dri_interface.h) | ||
target_inc_GL_internal = os.path.join(self.installdir, 'include', 'GL', 'internal') | ||
if not os.path.exists(target_inc_GL_internal): | ||
src_inc_GL_internal = os.path.join(self.start_dir, 'include', 'GL', 'internal') | ||
copy_dir(src_inc_GL_internal, target_inc_GL_internal) | ||
self.log.info("Copied %s to %s" % (src_inc_GL_internal, target_inc_GL_internal)) | ||
|
||
def sanity_check_step(self): | ||
"""Custom sanity check for Mesa.""" | ||
|
||
shlib_ext = get_shared_lib_ext() | ||
|
||
if LooseVersion(self.version) >= LooseVersion('20.0'): | ||
header_files = [os.path.join('include', 'EGL', x) for x in ['eglmesaext.h', 'eglextchromium.h']] | ||
header_files.extend([ | ||
os.path.join('include', 'GL', 'osmesa.h'), | ||
os.path.join('include', 'GL', 'internal', 'dri_interface.h'), | ||
]) | ||
else: | ||
gl_inc_files = ['glext.h', 'gl_mangle.h', 'glx.h', 'osmesa.h', 'gl.h', 'glxext.h', 'glx_mangle.h'] | ||
gles_inc_files = [('GLES', 'gl.h'), ('GLES2', 'gl2.h'), ('GLES3', 'gl3.h')] | ||
header_files = [os.path.join('include', 'GL', x) for x in gl_inc_files] | ||
header_files.extend([os.path.join('include', x, y) for (x, y) in gles_inc_files]) | ||
|
||
custom_paths = { | ||
'files': [os.path.join('lib', 'libOSMesa.%s' % shlib_ext)] + header_files, | ||
'dirs': [os.path.join('include', 'GL', 'internal')], | ||
} | ||
|
||
if self.swr_arches: | ||
swr_arch_libs = [os.path.join('lib', 'libswr%s.%s' % (a.upper(), shlib_ext)) for a in self.swr_arches] | ||
custom_paths['files'].extend(swr_arch_libs) | ||
|
||
super(EB_Mesa, self).sanity_check_step(custom_paths=custom_paths) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, this is indeed wrong: It expects swr to be build without checking the configopts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Flamefire Did this get fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it was in #2006...