Skip to content
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 20 commits into from
Mar 23, 2020
Merged
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions easybuild/easyblocks/m/mesa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
##
# 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)
"""

from easybuild.easyblocks.generic.mesonninja import MesonNinja
from easybuild.tools.systemtools import POWER, X86_64, get_cpu_architecture, get_cpu_features


class EB_Mesa(MesonNinja):
def configure_step(self, cmd_prefix=''):
edmondac marked this conversation as resolved.
Show resolved Hide resolved
"""
Customise the configopts based on the platform
"""
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 'swr-arches' not in self.cfg['configopts']:
# Set cpu features of SWR for current architecture
cpu_features = set(get_cpu_features())
swr_arches = []
if arch == X86_64:
# avx512f: AVX-512 Foundation - introduced in Skylake
# avx512er: AVX-512 Exponential and Reciprocal Instructions implemented in Knights Landing
x86_features = {'avx': 'avx', 'avx1.0': 'avx', 'avx2': 'avx2', 'avx512f': 'skx', 'avx512er': 'knl'}
swr_arches = [farch for fname, farch in x86_features.items() if fname in cpu_features]
lexming marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So after finding that Mesa < 19.3.7 bug, suggested code would be:

if arch == X86_64:
  x86_features = {'avx': 'avx', 'avx1.0': 'avx', 'avx2': 'avx2', 'avx512f': 'skx', 'avx512er': 'knl'}
  if LooseVersion(self.version) < LooaseVersion('19.3.7'):
    swr_arches = [farch for fname, farch in x86_features.items() if fname in cpu_features]
  else:
    swr_arches = [farch for fname, farch in x86_features.items() ]

Or something similar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @lexming here that including this version check is not a good idea, especially since there's a patch available to fix the problem you're dancing around here.

if swr_arches:
self.cfg.update('configopts', "-Dswr-arches=%s" % ','.join(swr_arches))

return super(EB_Mesa, self).configure_step(cmd_prefix=cmd_prefix)