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

Increase functionality of try_toolchain #2539

Merged
merged 56 commits into from
Sep 21, 2018

Conversation

ocaisa
Copy link
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:

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:

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:

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:

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:

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:

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'

for toolchain_spec in initial_tc_hierarchy:
tc_mapping[toolchain_spec['name']] = match_minimum_tc_specs(toolchain_spec, target_tc_hierarchy)

return tc_mapping

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

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:

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):

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

"""
can_map = True
# Check they have same capabilities
for key in ['compiler_family', 'mpi_family','blas_family', 'lapack_family', 'cuda']:

Choose a reason for hiding this comment

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

missing whitespace after ','

@@ -615,3 +616,64 @@ def obtain_ec_for(specs, paths, fp=None):
return res
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):

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

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

for toolchain_spec in initial_tc_hierarchy:
tc_mapping[toolchain_spec['name']] = match_minimum_tc_specs(toolchain_spec, target_tc_hierarchy)

return tc_mapping

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

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:

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):

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

"""
can_map = True
# Check they have same capabilities
for key in ['compiler_family', 'mpi_family','blas_family', 'lapack_family', 'cuda']:

Choose a reason for hiding this comment

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

missing whitespace after ','

@@ -615,3 +616,64 @@ def obtain_ec_for(specs, paths, fp=None):
return res
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):

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

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
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
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
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


# TODO Replace the binutils version (if necessary)

# TODO Determine the name of the modified easyconfig and dump it target_dir

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):

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):

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

})
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'}

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

'robot_path': test_easyconfigs,
})
get_toolchain_hierarchy.clear()
gcc_binutils_tc = {'name': 'GCC', 'version': '4.9.3-2.25'}

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

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)

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

@@ -114,13 +136,23 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
# prepended path so that they are found first).
# 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

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

})
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'}

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

'robot_path': test_easyconfigs,
})
get_toolchain_hierarchy.clear()
gcc_binutils_tc = {'name': 'GCC', 'version': '4.9.3-2.25'}

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

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)

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

@@ -114,13 +136,23 @@ def tweak(easyconfigs, build_specs, modtool, targetdirs=None):
# prepended path so that they are found first).
# 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

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

parsed_ec['ec'].dump(tweaked_spec)
_log.debug("Dumped easyconfig tweaked via --try-toolchain* to %s", tweaked_spec)

return tweaked_spec

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

parsed_ec['ec'].dump(tweaked_spec)
_log.debug("Dumped easyconfig tweaked via --try-toolchain* to %s", tweaked_spec)

return tweaked_spec

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
easybuild/framework/easyconfig/easyconfig.py Outdated Show resolved Hide resolved
easybuild/framework/easyconfig/easyconfig.py Outdated Show resolved Hide resolved
easybuild/framework/easyconfig/easyconfig.py Outdated Show resolved Hide resolved
Get the dependency tree of a toolchain

:param toolchain_spec: toolchain spec to get the dependencies of
:param modtool: module tool used
Copy link
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?

test/framework/tweak.py Outdated Show resolved Hide resolved
easybuild/framework/easyconfig/easyconfig.py Outdated Show resolved Hide resolved
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))

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
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
Member Author

ocaisa commented Sep 20, 2018

@boegel Would really like to see this included in 3.7.0

@ocaisa
Copy link
Member Author

ocaisa commented Sep 21, 2018

@boegel still does what it says on the tin

@boegel
Copy link
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