Skip to content

Conversation

@Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Dec 10, 2019

Current Python versions (3.0+ for unicode, 3.7+ for threads) include the asked features and removed the configure options resulting in configure: WARNING: unrecognized options: --enable-unicode

This PR removes those for the relevant python versions (checked on source checkouts)

Additionally Python 3.5.3 introduced optimized builds employing PGO and LTO for faster runtimes. Users report 5-30% improvement (see deadsnakes/python3.6#1) As EB is HPC centric using an optimized Python-runtime makes sense to me.

On the downside this adds 1h to the build time on our power machine due to the double build and test runs.

I added options to both enable the optimized build as well as --with-lto which does not use profiling to speed up runtime but cross-object-optimizations. That will be easier on build time (expected slight increase) but with less performance benefit. Both can be combined

As a follow-up I'd suggest making output like "WARNING: unrecognized options: " a hard failure to detect changed configure arguments. Imagine this was an important option or e.g. a rename (as happened from --with-optimizations to --enable-optimizations)

@bartoldeman
Copy link
Contributor

Good point about WARNING: unrecognized options, this comes up from time to time (seen it with OpenMPI as well)

@Flamefire
Copy link
Contributor Author

Seems it already exists since v1: #157

extra_vars = {
'ulimit_unlimited': [False, "Ensure stack size limit is set to '%s' during build" % UNLIMITED, CUSTOM],
'ebpythonprefixes': [True, "Create sitecustomize.py and allow use of $EBPYTHONPREFIXES", CUSTOM],
'use_lto': [False, "Build with Link Time Optimization. Potentially unstable on some toolchains", CUSTOM],
Copy link
Member

Choose a reason for hiding this comment

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

@Flamefire Using use_lto = True doesn't do anything at all right now?

Also, can you clarify the "potentially unstable on some toolchains"?

Is it worth using None as a default here, and auto-enabling LTO for blessed toolchains (e.g. when a sufficiently recent version of GCC or Intel compiler is used as toolchain compiler)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ups, rebase conflict gone wrong. Thanks

From https://docs.python.org/3.7/whatsnew/changelog.html#python-3-7-5-final

A –with-lto configure option has been added that will enable link time optimizations at build time during a make profile-opt. Some compilers and toolchains are known to not produce stable code when using LTO, be sure to test things thoroughly before relying on it. It can provide a few % speed up over profile-opt alone.

The suggestion with None==auto-detect is good. https://bugs.python.org/issue25702 seems to state that GCC>=4.8 is fine and apparently "Ubuntu" might have same kind of whitelist or blacklist when to enable this for Python. Not sure where to look for that though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I guess the question is how to determine if the resulting build is stable, and how to "test things thoroughly".

If it's only a few %, I'm not sure it's worth taking the risk to auto-enable it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Python devs seem to be quite confident and if Ubuntu does it... But maybe we can at least do it in the ECS where we know the compilers, so no surprises

Copy link
Member

Choose a reason for hiding this comment

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

How about this:

  • use None as default, so people can opt-in (True) or opt-out (False) in the Python easyconfig easily
  • auto-enable if None is used, but only if a sufficiently recent GCC is used as compiler (probably not worth the auto-enable when Intel compilers are used in toolchain for installing Python, so we pulled down Python to using GCCcore as toolchain a while ago)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. What would you deem "sufficiently recent GCC"? GCC 6+? 8+?
Do you have a snipped how to check for the used compiler and version?

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer being conservative here, so why not go with GCC 8+.

Should be something like this:

if self.cfg['uselto'] is None and self.toolchain.comp_family() == toolchain.GCC:
    gcc_ver = get_software_version('GCCcore') or get_software_version('GCC')
    if LooseVersion(gcc_ver) >= LooseVersion('8.0'):
        self.log.info("Auto-enabling --with-lto since GCC >= v8.0 is used as toolchain compiler")
        self.cfg['uselto']  = True

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Slightly adapted and removed get_software_version('GCCcore'). If I got it right the if-check already ensures we have GCC

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, it seems GCCcore is needed because it does not load the GCC module. This is an annoying pitfall and I'm not the only one:

easybuild-easyblocks/easybuild/easyblocks/l/libsmm.py: gccVersion = LooseVersion(get_software_version('GCC'))

There are probably more... Maybe make get_software_version('GCC) also check `GCCcore'?

@boegel
Copy link
Member

boegel commented Dec 10, 2019

FWIW: version checks look OK to me based on this:

$ ls -d /software/Python/*
/software/Python/2.7.12-foss-2016b
/software/Python/2.7.13-foss-2017a
/software/Python/2.7.14-foss-2018a
/software/Python/2.7.14-GCCcore-6.4.0-bare
/software/Python/2.7.14-intel-2018a
/software/Python/2.7.15-foss-2018b
/software/Python/2.7.15-foss-2019b
/software/Python/2.7.15-fosscuda-2018b
/software/Python/2.7.15-GCCcore-7.3.0-bare
/software/Python/2.7.15-GCCcore-8.2.0
/software/Python/2.7.15-GCCcore-8.3.0-bare
/software/Python/2.7.16-GCCcore-8.3.0
/software/Python/3.5.2-foss-2016b
/software/Python/3.6.4-foss-2018a
/software/Python/3.6.6-foss-2018b
/software/Python/3.6.6-foss-2019b
/software/Python/3.6.6-fosscuda-2018b
/software/Python/3.7.0-foss-2018b
/software/Python/3.7.0-foss-2019b
/software/Python/3.7.2-GCCcore-8.2.0
/software/Python/3.7.4-GCCcore-8.3.0
$ bzgrep "configure: WARNING: unrecognized options" /software/Python/*/easybuild/*log*
/software/Python/3.5.2-foss-2016b/easybuild/easybuild-Python-3.5.2-20191119.123533.log.bz2:configure: WARNING: unrecognized options: --enable-unicode
/software/Python/3.5.2-foss-2016b/easybuild/easybuild-Python-3.5.2-20191119.123533.log.bz2:configure: WARNING: unrecognized options: --enable-unicode
/software/Python/3.6.4-foss-2018a/easybuild/easybuild-Python-3.6.4-20191104.200920.log.bz2:configure: WARNING: unrecognized options: --enable-unicode
/software/Python/3.6.4-foss-2018a/easybuild/easybuild-Python-3.6.4-20191104.200920.log.bz2:configure: WARNING: unrecognized options: --enable-unicode
/software/Python/3.6.6-foss-2018b/easybuild/easybuild-Python-3.6.6-20190828.231037.log.bz2:configure: WARNING: unrecognized options: --enable-unicode
/software/Python/3.6.6-foss-2018b/easybuild/easybuild-Python-3.6.6-20190828.231037.log.bz2:configure: WARNING: unrecognized options: --enable-unicode
/software/Python/3.6.6-foss-2019b/easybuild/easybuild-Python-3.6.6-20190912.165329.log.bz2:configure: WARNING: unrecognized options: --enable-unicode
/software/Python/3.6.6-foss-2019b/easybuild/easybuild-Python-3.6.6-20190912.165329.log.bz2:configure: WARNING: unrecognized options: --enable-unicode
/software/Python/3.7.0-foss-2018b/easybuild/easybuild-Python-3.7.0-20190828.195437.log.bz2:configure: WARNING: unrecognized options: --with-threads, --enable-unicode
/software/Python/3.7.0-foss-2018b/easybuild/easybuild-Python-3.7.0-20190828.195437.log.bz2:configure: WARNING: unrecognized options: --with-threads, --enable-unicode
/software/Python/3.7.0-foss-2019b/easybuild/easybuild-Python-3.7.0-20190914.112033.log.bz2:configure: WARNING: unrecognized options: --with-threads, --enable-unicode
/software/Python/3.7.0-foss-2019b/easybuild/easybuild-Python-3.7.0-20190914.112033.log.bz2:configure: WARNING: unrecognized options: --with-threads, --enable-unicode
/software/Python/3.7.2-GCCcore-8.2.0/easybuild/easybuild-Python-3.7.2-20191121.112113.log.bz2:configure: WARNING: unrecognized options: --with-threads, --enable-unicode
/software/Python/3.7.2-GCCcore-8.2.0/easybuild/easybuild-Python-3.7.2-20191121.112113.log.bz2:configure: WARNING: unrecognized options: --with-threads, --enable-unicode
/software/Python/3.7.4-GCCcore-8.3.0/easybuild/easybuild-Python-3.7.4-20191121.113430.log.bz2:configure: WARNING: unrecognized options: --with-threads, --enable-unicode
/software/Python/3.7.4-GCCcore-8.3.0/easybuild/easybuild-Python-3.7.4-20191121.113430.log.bz2:configure: WARNING: unrecognized options: --with-threads, --enable-unicode

@boegel boegel changed the title [Python] Remove obsolete configure args and enable optimizations [Python] Remove obsolete configure args, build with optimizations + build with LTO for GCC >= 8.0 Jan 2, 2020
improve doc for 'optimized' and 'use_lto' custom easyconfig parameter for Python
@boegel
Copy link
Member

boegel commented Jan 4, 2020

Tested by rebuilding various Python 3.6 & 3.7 + 2.7.16 versions with this updated easyblock, and various Python packages on top (SciPy-bundle, TensorFlow).

No problems encounered, so good to go... Thanks @Flamefire!

@boegel boegel merged commit 853d24e into easybuilders:develop Jan 4, 2020
@Flamefire Flamefire deleted the python branch January 5, 2020 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants