Skip to content

Increase functionality of try_toolchain#2539

Merged
boegel merged 56 commits intoeasybuilders:developfrom
ocaisa:increase_try_scope
Sep 21, 2018
Merged

Increase functionality of try_toolchain#2539
boegel merged 56 commits intoeasybuilders:developfrom
ocaisa:increase_try_scope

Conversation

@ocaisa
Copy link
Copy Markdown
Member

@ocaisa ocaisa commented Jul 25, 2018

The goal here is to increase the scope of --try-toolchain-* so that it can handle mapping the entire hierarchy of toolchains from the initial to the target toolchain.

  • Add toolchain capabilities to the result of get_toolchain_hierarchy
  • Create a mapping from source hierarchy to target hierarchy
  • Make sure that the entire dep tree is mapped to the new hierarchy
  • Ensure that dep toolchains are also updated if explicitly named
  • Need to handle case where there needs to be a binutils update in an easyconfig that depends on GCCcore

@ocaisa ocaisa changed the base branch from master to develop July 25, 2018 12:28
toolchain['blas_family'] = None
try:
toolchain['lapack_family'] = tc.lapack_family()
except:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do not use bare except'

toolchain['mpi_family'] = None
try:
toolchain['blas_family'] = tc.blas_family()
except:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do not use bare except'

toolchain['compiler_family'] = None
try:
toolchain['mpi_family'] = tc.mpi_family()
except:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do not use bare except'

toolchain['blas_family'] = None
try:
toolchain['lapack_family'] = tc.lapack_family()
except:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do not use bare except'

toolchain['mpi_family'] = None
try:
toolchain['blas_family'] = tc.blas_family()
except:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do not use bare except'

toolchain['compiler_family'] = None
try:
toolchain['mpi_family'] = tc.mpi_family()
except:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do not use bare except'

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
for toolchain_spec in initial_tc_hierarchy:
tc_mapping[toolchain_spec['name']] = match_minimum_tc_specs(toolchain_spec, target_tc_hierarchy)

return tc_mapping No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file

source_tc_spec['compiler_family'], target_compiler_family)


return minimal_matching_toolchain
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)

target_compiler_family = target_tc_spec['compiler_family']


if not minimal_matching_toolchain:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)


return can_map

def match_minimum_tc_specs(source_tc_spec, target_tc_hierarchy):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
"""
can_map = True
# Check they have same capabilities
for key in ['compiler_family', 'mpi_family','blas_family', 'lapack_family', 'cuda']:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing whitespace after ','

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
else:
raise EasyBuildError("No easyconfig found for requested software, and also failed to generate one.")

def compare_toolchain_specs(source_tc_spec, target_tc_spec):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

if 'CUDA_CC' in tc.variables:
toolchain['cuda'] = True
else:
toolchain['cuda'] = None # Useful to have it consistent with the rest
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

at least two spaces before inline comment

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
for toolchain_spec in initial_tc_hierarchy:
tc_mapping[toolchain_spec['name']] = match_minimum_tc_specs(toolchain_spec, target_tc_hierarchy)

return tc_mapping No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file

source_tc_spec['compiler_family'], target_compiler_family)


return minimal_matching_toolchain
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)

target_compiler_family = target_tc_spec['compiler_family']


if not minimal_matching_toolchain:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)


return can_map

def match_minimum_tc_specs(source_tc_spec, target_tc_hierarchy):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
"""
can_map = True
# Check they have same capabilities
for key in ['compiler_family', 'mpi_family','blas_family', 'lapack_family', 'cuda']:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing whitespace after ','

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
else:
raise EasyBuildError("No easyconfig found for requested software, and also failed to generate one.")

def compare_toolchain_specs(source_tc_spec, target_tc_spec):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

if 'CUDA_CC' in tc.variables:
toolchain['cuda'] = True
else:
toolchain['cuda'] = None # Useful to have it consistent with the rest
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

at least two spaces before inline comment

@ocaisa
Copy link
Copy Markdown
Member Author

ocaisa commented Jul 26, 2018

@boegel The last three points will require a major change in how --try-* works, I need to actually parse the easyconfigs so there are no templates and go in and replace values, i.e, we would need to replace the regex.

@ocaisa ocaisa changed the title WIP: Increase try scope WIP: Increase functionality of try_toolchain Jul 26, 2018
Comment thread easybuild/framework/easyconfig/tweak.py Outdated
for target_tc_spec in reversed(target_tc_hierarchy):
if compare_toolchain_specs(source_tc_spec, target_tc_spec):
# GCCcore has compiler capabilities but should only be used if the original toolchain was also GCCcore
if (source_tc_spec['name'] != 'GCCcore' and target_tc_spec['name'] != 'GCCcore')\
Copy link
Copy Markdown
Member Author

@ocaisa ocaisa Jul 26, 2018

Choose a reason for hiding this comment

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

I don't like the hardcoded 'GCCcore' but I also don't know where I can inherit that from

Comment thread easybuild/framework/easyconfig/tweak.py Outdated

# TODO Replace the binutils version (if necessary)

# TODO Determine the name of the modified easyconfig and dump it target_dir No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file


return resolve_dependencies(ec, modtool)

def map_toolchain_hierarchies(source_toolchain, target_toolchain, modtool):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1


return minimal_matching_toolchain

def get_dep_tree_of_toolchain(toolchain_spec, modtool):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

Comment thread test/framework/tweak.py
})
get_toolchain_hierarchy.clear()
gcc_binutils_tc = {'name': 'GCC', 'version': '4.9.3-2.25'}
iccifort_binutils_tc = {'name': 'iccifort', 'version': '2016.1.150-GCC-4.9.3-2.25'}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'iccifort_binutils_tc' is assigned to but never used

Comment thread test/framework/tweak.py Outdated
'robot_path': test_easyconfigs,
})
get_toolchain_hierarchy.clear()
gcc_binutils_tc = {'name': 'GCC', 'version': '4.9.3-2.25'}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'gcc_binutils_tc' is assigned to but never used

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
targetdir = tempfile.gettempdir()
tweaked_spec = os.path.join(target_dir, ec_filename)
parsed_ec.dump(tweaked_spec)
_log.debug("Dumped easyconfig tweaked via --try-toolchain* to %s", tweaked_spec) No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
# easyconfig files for dependencies are also generated but not included, they will be resolved via --robot
# either from existing easyconfigs or, if that fails, from easyconfigs in the appended path

modifying_toolchain = False # TODO Remove this to enable all tests
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

at least two spaces before inline comment

Comment thread test/framework/tweak.py
})
get_toolchain_hierarchy.clear()
gcc_binutils_tc = {'name': 'GCC', 'version': '4.9.3-2.25'}
iccifort_binutils_tc = {'name': 'iccifort', 'version': '2016.1.150-GCC-4.9.3-2.25'}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'iccifort_binutils_tc' is assigned to but never used

Comment thread test/framework/tweak.py Outdated
'robot_path': test_easyconfigs,
})
get_toolchain_hierarchy.clear()
gcc_binutils_tc = {'name': 'GCC', 'version': '4.9.3-2.25'}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'gcc_binutils_tc' is assigned to but never used

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
targetdir = tempfile.gettempdir()
tweaked_spec = os.path.join(target_dir, ec_filename)
parsed_ec.dump(tweaked_spec)
_log.debug("Dumped easyconfig tweaked via --try-toolchain* to %s", tweaked_spec) No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
# easyconfig files for dependencies are also generated but not included, they will be resolved via --robot
# either from existing easyconfigs or, if that fails, from easyconfigs in the appended path

modifying_toolchain = False # TODO Remove this to enable all tests
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

at least two spaces before inline comment

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
parsed_ec['ec'].dump(tweaked_spec)
_log.debug("Dumped easyconfig tweaked via --try-toolchain* to %s", tweaked_spec)

return tweaked_spec No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file

Comment thread easybuild/framework/easyconfig/tweak.py Outdated
parsed_ec['ec'].dump(tweaked_spec)
_log.debug("Dumped easyconfig tweaked via --try-toolchain* to %s", tweaked_spec)

return tweaked_spec No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file

boegel
boegel previously requested changes Sep 11, 2018
Comment thread easybuild/framework/easyconfig/easyconfig.py Outdated
Comment thread easybuild/framework/easyconfig/easyconfig.py Outdated
Comment thread easybuild/framework/easyconfig/easyconfig.py Outdated
Get the dependency tree of a toolchain

:param toolchain_spec: toolchain spec to get the dependencies of
:param modtool: module tool used
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

clarify that this should be an instance of the ModulesTool class?

Comment thread test/framework/tweak.py Outdated
Comment thread easybuild/framework/easyconfig/easyconfig.py Outdated
Comment thread test/framework/toy_build.py Outdated
for modname in ['FFTW', 'OpenBLAS', 'ScaLAPACK']:
regex = re.compile('load.*' + modname, re.M)
self.assertTrue(regex.search(toy_modtxt), "Pattern '%s' found in: %s" % (regex.pattern, toy_modtxt))
self.assertFalse(regex.search(toy_modtxt), "Pattern '%s' not found in: %s" % (regex.pattern, toy_modtxt))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (121 > 120 characters)

@boegelbot

This comment has been minimized.

@boegelbot

This comment has been minimized.

@ocaisa
Copy link
Copy Markdown
Member Author

ocaisa commented Sep 12, 2018

@boegel Ready for re-review.

The one item left is that there is no way to force mapping a toolchain only to the top-level of the target, e.g., for an easyconfig with an iimpi toolchain --try-toolchain=foss,2018a will only map it to gompi and never to full foss (since gompi already has all the capabilities you need). I see this as correct default behaviour (users need to know nothing about subtoolchains, it all just works) but I can also a use case when you have a flat naming scheme. Where that is appropriate to add is up for discussion and I'd prefer to leave it to a different PR.

@ocaisa ocaisa dismissed boegel’s stale review September 13, 2018 09:29

Ready for another pass

@ocaisa
Copy link
Copy Markdown
Member Author

ocaisa commented Sep 20, 2018

@boegel Would really like to see this included in 3.7.0

@ocaisa
Copy link
Copy Markdown
Member Author

ocaisa commented Sep 21, 2018

@boegel still does what it says on the tin

@boegel
Copy link
Copy Markdown
Member

boegel commented Sep 21, 2018

Going in, thanks a lot for your work on this @ocaisa!

@boegel boegel merged commit 44edbc5 into easybuilders:develop Sep 21, 2018
@boegel boegel modified the milestones: next release, 3.7.0 Sep 21, 2018
@ocaisa ocaisa deleted the increase_try_scope branch September 26, 2018 11:21
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.

4 participants