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
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d5ba7d6
Add support for including toolchains capabilities when creating toolc…
Jul 25, 2018
cb4904d
Update comment in tests
Jul 25, 2018
b0c5406
No bare excepts
Jul 25, 2018
5259b4a
No bare excepts
Jul 25, 2018
c7ddafe
Expand scope of get_toolchain_hierarchy without relying on build_options
Jul 26, 2018
21b3a53
Address style errors
Jul 26, 2018
d3aba89
Add tests for hierarchy to heirarchy mapping
Jul 26, 2018
46714a9
Be conservative with logic
Jul 26, 2018
4a86c2b
Remove hardcoded GCCcore name
Jul 26, 2018
a5f1d36
Allowing mapping up from GCCcore to another compiler (in the case whe…
Jul 26, 2018
69080d3
Allowing mapping up from GCCcore to another compiler (in the case whe…
Jul 27, 2018
7867ba9
Also grab binutils version built with GCCcore
Jul 30, 2018
444aea5
Style fixes
Jul 30, 2018
f256a32
Add missing easyconfig to test suite
Jul 30, 2018
619c9ff
Temporarily disable alternate method (to allow existing tests to pass)
Jul 30, 2018
9b20491
Add tests for mapping an easyconfig to new hierarchy
Jul 30, 2018
ee1eb88
Miscellaneous bug fixes
Jul 30, 2018
1d07e4a
Style fixes
Jul 30, 2018
9abfe53
Move careless dummy check placement
Jul 30, 2018
97e7d82
Move careless dummy check placement
Jul 30, 2018
9d25494
Make sure to add capabilities also to the parent toolchain
Jul 31, 2018
46a7f7f
Allow creation of tweaked toolchain easyconfig whenever there is an a…
Jul 31, 2018
eddc050
Always map deps if a map exists
Jul 31, 2018
e685231
Always map deps if a map exists
Jul 31, 2018
f003b17
Fix spacing of comments
Jul 31, 2018
a40c2d6
Fix spacing of comments
Jul 31, 2018
cc2168c
Fix more tests
Jul 31, 2018
53646aa
Fix style
Jul 31, 2018
b060dfa
Fall back to regex when things are too complicated
Jul 31, 2018
2073e38
Fi more tests
Jul 31, 2018
b46b093
Fix more tests
Jul 31, 2018
746471d
Fix last test
Jul 31, 2018
6c26f79
Remove stray print
Jul 31, 2018
133b4c7
Fix checking for key in dictionary
Jul 31, 2018
bb3bcde
Be more careful when using toolchain_mapping
Jul 31, 2018
a137e27
Merge branch 'develop' into increase_try_scope
Sep 10, 2018
dd0a7dd
Don't delete spaces
Sep 10, 2018
ae4d50e
Fix some tests
Sep 10, 2018
059a621
Fix another test
Sep 10, 2018
1cf9d36
Fix more tests
Sep 11, 2018
db1400a
Fix final test
Sep 11, 2018
583f047
Merge branch 'develop' into increase_try_scope
Sep 11, 2018
6c13972
Address some of the comments
Sep 11, 2018
1f1b03d
Address last of the comments
Sep 12, 2018
0965f9a
Address newer comments
Sep 12, 2018
5377ff8
Fix comments
Sep 12, 2018
61a0bcb
Fix more comments
Sep 12, 2018
14d80b7
Appease the hound
Sep 12, 2018
4d8b503
Address more comments
Sep 12, 2018
21a638c
Fix broken test
Sep 12, 2018
07384d5
Use more general test method
Sep 12, 2018
5569c50
Update tweak.py
Sep 14, 2018
b6942cc
Merge branch 'develop' into increase_try_scope
Sep 20, 2018
6c49a39
Merge branch 'increase_try_scope' of github.com:ocaisa/easybuild-fram…
Sep 20, 2018
67b816e
minor code cleanup
boegel Sep 21, 2018
6b627a0
Merge pull request #37 from boegel/increase_try_scope
Sep 21, 2018
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
38 changes: 29 additions & 9 deletions easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
# name of easyconfigs archive subdirectory
EASYCONFIGS_ARCHIVE_DIR = '__archive__'

# Available capabilities of toolchains
CAPABILITIES = ['comp_family', 'mpi_family', 'blas_family', 'lapack_family', 'cuda']
ocaisa marked this conversation as resolved.
Show resolved Hide resolved


try:
import autopep8
Expand Down Expand Up @@ -116,16 +119,16 @@ def toolchain_hierarchy_cache(func):
cache = {}

@functools.wraps(func)
def cache_aware_func(toolchain):
def cache_aware_func(toolchain, require_capabilities=False):
"""Look up toolchain hierarchy in cache first, determine and cache it if not available yet."""
cache_key = (toolchain['name'], toolchain['version'])
cache_key = (toolchain['name'], toolchain['version'], require_capabilities)

# fetch from cache if available, cache it if it's not
if cache_key in cache:
_log.debug("Using cache to return hierarchy for toolchain %s: %s", str(toolchain), cache[cache_key])
return cache[cache_key]
else:
toolchain_hierarchy = func(toolchain)
toolchain_hierarchy = func(toolchain, require_capabilities)
cache[cache_key] = toolchain_hierarchy
return cache[cache_key]

Expand All @@ -135,7 +138,7 @@ def cache_aware_func(toolchain):
return cache_aware_func


def det_subtoolchain_version(current_tc, subtoolchain_name, optional_toolchains, cands):
def det_subtoolchain_version(current_tc, subtoolchain_name, optional_toolchains, cands, require_capabilities=False):
ocaisa marked this conversation as resolved.
Show resolved Hide resolved
"""
Returns unique version for subtoolchain, in tc dict.
If there is no unique version:
Expand All @@ -152,7 +155,7 @@ def det_subtoolchain_version(current_tc, subtoolchain_name, optional_toolchains,

# dummy toolchain: bottom of the hierarchy
if subtoolchain_name == DUMMY_TOOLCHAIN_NAME:
if build_option('add_dummy_to_minimal_toolchains'):
if build_option('add_dummy_to_minimal_toolchains') and not require_capabilities:
subtoolchain_version = ''
elif len(uniq_subtc_versions) == 1:
subtoolchain_version = list(uniq_subtc_versions)[0]
Expand All @@ -169,7 +172,7 @@ def det_subtoolchain_version(current_tc, subtoolchain_name, optional_toolchains,


@toolchain_hierarchy_cache
def get_toolchain_hierarchy(parent_toolchain):
def get_toolchain_hierarchy(parent_toolchain, require_capabilities=False):
"""
Determine list of subtoolchains for specified parent toolchain.
Result starts with the most minimal subtoolchains first, ends with specified toolchain.
Expand Down Expand Up @@ -199,8 +202,9 @@ def get_toolchain_hierarchy(parent_toolchain):
optional_toolchains = set(tc_class.NAME for tc_class in all_tc_classes if getattr(tc_class, 'OPTIONAL', False))
composite_toolchains = set(tc_class.NAME for tc_class in all_tc_classes if len(tc_class.__bases__) > 1)

# the parent toolchain is at the top of the hierarchy
toolchain_hierarchy = [parent_toolchain]
# the parent toolchain is at the top of the hierarchy, we need a copy so that adding capabilities (below) doesn't
ocaisa marked this conversation as resolved.
Show resolved Hide resolved
# affect the original object
toolchain_hierarchy = [copy.copy(parent_toolchain)]
# use a queue to handle a breadth-first-search of the hierarchy,
# which is required to take into account the potential for multiple subtoolchains
bfs_queue = [parent_toolchain]
Expand Down Expand Up @@ -268,14 +272,30 @@ def get_toolchain_hierarchy(parent_toolchain):
cands = [c for c in cands if c['name'] in subtoolchain_names]

for subtoolchain_name in subtoolchain_names:
subtoolchain_version = det_subtoolchain_version(current_tc, subtoolchain_name, optional_toolchains, cands)
subtoolchain_version = det_subtoolchain_version(current_tc, subtoolchain_name, optional_toolchains, cands,
require_capabilities=require_capabilities)
# add to hierarchy and move to next
if subtoolchain_version is not None and subtoolchain_name not in visited:
tc = {'name': subtoolchain_name, 'version': subtoolchain_version}
toolchain_hierarchy.insert(0, tc)
bfs_queue.insert(0, tc)
visited.add(subtoolchain_name)

# also add toolchain capabilities
if require_capabilities:
for toolchain in toolchain_hierarchy:
toolchain_class, _ = search_toolchain(toolchain['name'])
tc = toolchain_class(version=toolchain['version'])
for capability in CAPABILITIES:
# cuda is the special case which doesn't have a family attribute
if capability == 'cuda':
# use None rather than False, useful to have it consistent with the rest
toolchain['cuda'] = ('CUDA_CC' in tc.variables) or None
else:
if hasattr(tc, capability):
ocaisa marked this conversation as resolved.
Show resolved Hide resolved
toolchain[capability] = getattr(tc, capability)()


_log.info("Found toolchain hierarchy for toolchain %s: %s", parent_toolchain, toolchain_hierarchy)
return toolchain_hierarchy

Expand Down
Loading