Skip to content

Commit

Permalink
Merge branch 'oneapi' of github.com:ParaToolsInc/taucmdr into unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeekman committed Mar 9, 2022
2 parents 295deeb + 1b6ba61 commit f683c83
Show file tree
Hide file tree
Showing 35 changed files with 239 additions and 199 deletions.
33 changes: 16 additions & 17 deletions packages/taucmdr/cf/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ def probe(cls, absolute_path, candidates=None):
LOGGER.debug("'%s' is a %s compiler", absolute_path, family.name)
cls._probe_cache[absolute_path] = family
return family
else:
LOGGER.debug("'%s' is not a %s compiler", absolute_path, family.name)
LOGGER.debug("'%s' is not a %s compiler", absolute_path, family.name)
else:
LOGGER.debug("'%s' is a %s compiler", absolute_path, family.name)
cls._probe_cache[absolute_path] = family
Expand Down Expand Up @@ -367,19 +366,19 @@ def __repr__(self):
def _find(cls, command, family, role):
if command and family and role:
return [info for info in family.members.get(role, []) if info.command == command]
elif command and family:
if command and family:
return [
info for info_list in family.members.values() for info in info_list if info.command == command
]
elif command and role:
if command and role:
return [info for info in cls.all() if info.role is role and info.command == command]
elif family and role:
if family and role:
return family.members.get(role, [])
elif command:
if command:
return [info for info in cls.all() if info.command == command]
elif family:
if family:
return [info for info_list in family.members.values() for info in info_list]
elif role:
if role:
return [info for info in cls.all() if info.role is role]
return []

Expand Down Expand Up @@ -546,11 +545,11 @@ def _probe_wrapper(self):
cmd = [self.absolute_path] + self.info.family.show_wrapper_flags
try:
stdout = util.get_command_output(cmd)
except CalledProcessError:
except CalledProcessError as err:
# If this command didn't accept show_wrapper_flags then it's not a compiler wrapper to begin with,
# i.e. another command just happens to be the same as a known compiler command.
raise ConfigurationError("'%s' isn't actually a %s since it doesn't accept arguments %s." %
(self.absolute_path, self.info.short_descr, self.info.family.show_wrapper_flags))
(self.absolute_path, self.info.short_descr, self.info.family.show_wrapper_flags)) from err
# Assume the longest line starting with a known compiler command is the wrapped compiler followed by arguments.
known_commands = {info.command for info in _CompilerInfo.all()}
for line in sorted(stdout.split('\n'), key=len, reverse=True):
Expand Down Expand Up @@ -596,7 +595,7 @@ def parse_flags(idx, flags, acc):
if arg == flag:
acc.append(args[idx+1])
return 2
elif arg.startswith(flag):
if arg.startswith(flag):
acc.append(arg[len(flag):])
return 1
return 0
Expand Down Expand Up @@ -696,14 +695,14 @@ def version_string(self):
cmd = [self.absolute_path] + self.info.family.version_flags
try:
self._version_string = util.get_command_output(cmd)
except CalledProcessError:
except CalledProcessError as err:
raise ConfigurationError("Compiler command '%s' failed." % ' '.join(cmd),
"Check that this command works outside of TAU.",
"Check loaded modules and environment variables.",
"Verify that the compiler's license is valid.")
except OSError:
"Verify that the compiler's license is valid.") from err
except OSError as err:
raise ConfigurationError("Compiler '%s' no longer exists or is not executable" %
self.absolute_path)
self.absolute_path) from err
return self._version_string

@property
Expand Down Expand Up @@ -808,8 +807,8 @@ def __getitem__(self, role):
"""
try:
return self.members[role][0]
except IndexError:
raise KeyError
except IndexError as err:
raise KeyError from err

def __iter__(self):
"""Yield one InstalledCompiler for each role filled by any compiler in this installation."""
Expand Down
4 changes: 2 additions & 2 deletions packages/taucmdr/cf/compiler/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
GNU = HOST_COMPILERS.add('GNU', family_regex=r'Free Software Foundation, Inc',
CC='gcc', CXX='g++', FC=('gfortran', 'g77'), UPC='gupc')

INTEL = HOST_COMPILERS.add('Intel', family_regex=r'Intel Corporation',
CC='icc', CXX='icpc', FC='ifort')
INTEL = HOST_COMPILERS.add('Intel', family_regex=r'Intel Corporation|Intel\(R\) oneAPI',
CC=('icc', 'icx'), CXX=('icpc', 'icpx', 'dpcpp'), FC='ifort')

PGI = HOST_COMPILERS.add('PGI', family_regex=r'The Portland Group|NVIDIA CORPORATION',
CC='pgcc', CXX=('pgCC', 'pgc++', 'pgcxx'), FC=('pgfortran', 'pgf90', 'pgf77'))
Expand Down
12 changes: 6 additions & 6 deletions packages/taucmdr/cf/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def detect(cls):
python_arch = platform.machine()
try:
inst = Architecture.find(python_arch)
except KeyError:
raise ConfigurationError("Host architecture '%s' is not yet supported" % python_arch)
except KeyError as err:
raise ConfigurationError("Host architecture '%s' is not yet supported" % python_arch) from err
cls._detect = inst
return cls._detect

Expand Down Expand Up @@ -180,8 +180,8 @@ def detect(cls):
python_os = platform.system()
try:
inst = OperatingSystem.find(python_os)
except KeyError:
raise ConfigurationError("Host operating system '%s' is not yet supported" % python_os)
except KeyError as err:
raise ConfigurationError("Host operating system '%s' is not yet supported" % python_os) from err
cls._detect = inst
return cls._detect

Expand Down Expand Up @@ -230,8 +230,8 @@ def detect(cls):
except AttributeError:
try:
inst = TauMagic.find((HOST_ARCH, HOST_OS))
except KeyError:
raise ConfigurationError(f"{HOST_OS} on {HOST_ARCH} is not supported.")
except KeyError as err:
raise ConfigurationError(f"{HOST_OS} on {HOST_ARCH} is not supported.") from err
cls._detect = inst
return cls._detect

Expand Down
4 changes: 2 additions & 2 deletions packages/taucmdr/cf/software/binutils_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def __init__(self, sources, target_arch, target_os, compilers):
if compilers[CC].unwrap().info.family is PGI:
try:
gnu_compilers = GNU.installation()
except ConfigurationError:
raise SoftwarePackageError("GNU compilers (required to build binutils) could not be found.")
except ConfigurationError as err:
raise SoftwarePackageError("GNU compilers (required to build binutils) could not be found.") from err
compilers = compilers.modify(Host_CC=gnu_compilers[CC], Host_CXX=gnu_compilers[CXX])
super().__init__('binutils', 'GNU Binutils', sources,
target_arch, target_os, compilers, REPOS, None, LIBRARIES, None)
Expand Down
20 changes: 10 additions & 10 deletions packages/taucmdr/cf/software/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def parallel_make_flags(nprocs=None):
nprocs = int(nprocs)
if nprocs < 1:
raise ValueError
except ValueError:
raise ConfigurationError("Invalid parallel make job count: %s" % nprocs)
except ValueError as err:
raise ConfigurationError("Invalid parallel make job count: %s" % nprocs) from err
return ['-j', str(nprocs)]


Expand Down Expand Up @@ -153,8 +153,8 @@ def __init__(self, name, title, sources, target_arch, target_os, compilers,
self.srcs_avail = self.srcs[:]
try:
self.src = self.srcs.pop(0)
except IndexError:
raise ConfigurationError("No sources provided for %s." % self.title)
except IndexError as err:
raise ConfigurationError("No sources provided for %s." % self.title) from err
else:
self.srcs = []
self.srcs_avail = [self.src]
Expand Down Expand Up @@ -325,8 +325,7 @@ def acquire_source(self, reuse_archive=True):
"'%s' and copy that file to '%s' before trying this operation." % (self.src, archive_prefix),
"Check that the file or directory is accessible")
raise ConfigurationError("Cannot acquire source archive '%s'." % ', '.join(self.srcs_avail), *hints)
else:
return str(archive)
return str(archive)

def _prepare_src(self, reuse_archive=True):
"""Prepares source code for installation.
Expand All @@ -353,7 +352,7 @@ def _prepare_src(self, reuse_archive=True):
LOGGER.info("Unable to extract source archive '%s'. Downloading a new copy.", archive)
return str(self._prepare_src(reuse_archive=False))
raise ConfigurationError(f"Cannot extract source archive '{archive}': {err}",
"Check that the file or directory is accessible")
"Check that the file or directory is accessible") from err

def verify(self):
"""Check if the installation at :any:`installation_prefix` is valid.
Expand Down Expand Up @@ -420,8 +419,9 @@ def install(self, force_reinstall=False):
if self.unmanaged:
raise SoftwarePackageError("%s source package is unavailable and the installation at '%s' "
"is invalid: %s" % (self.title, self.install_prefix, err),
"Specify source code path or URL to enable package reinstallation.")
elif not force_reinstall:
"Specify source code path or URL to enable package reinstallation.") \
from err
if not force_reinstall:
LOGGER.debug(err)
LOGGER.info("Installing %s to '%s'", self.title, self.install_prefix)
if os.path.isdir(self.install_prefix):
Expand Down Expand Up @@ -604,7 +604,7 @@ def _get_cmake(self):
try:
stdout = util.get_command_output([cmake, '--version'])
except (CalledProcessError, OSError) as err:
raise ConfigurationError("Failed to get CMake version: %s" % err)
raise ConfigurationError("Failed to get CMake version: %s" % err) from err
for line in stdout.split('\n'):
if 'cmake version' in line:
verstr = (line.split('cmake version ')[1]).split('-')[0]
Expand Down
4 changes: 2 additions & 2 deletions packages/taucmdr/cf/software/libunwind_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def __init__(self, sources, target_arch, target_os, compilers):
if compilers[CC].unwrap().info.family is PGI:
try:
gnu_compilers = GNU.installation()
except ConfigurationError:
raise SoftwarePackageError("GNU compilers (required to build libunwind) could not be found.")
except ConfigurationError as err:
raise SoftwarePackageError("GNU compilers (required to build libunwind) could not be found.") from err
compilers = compilers.modify(Host_CC=gnu_compilers[CC], Host_CXX=gnu_compilers[CXX])
super().__init__('libunwind', 'libunwind', sources, target_arch, target_os,
compilers, REPOS, None, LIBRARIES, HEADERS)
Expand Down
10 changes: 5 additions & 5 deletions packages/taucmdr/cf/software/papi_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def __init__(self, sources, target_arch, target_os, compilers):
if compilers[CC].unwrap().info.family is IBM:
try:
gnu_compilers = GNU.installation()
except ConfigurationError:
raise SoftwarePackageError("GNU compilers (required to build PAPI) could not be found.")
except ConfigurationError as err:
raise SoftwarePackageError("GNU compilers (required to build PAPI) could not be found.") from err
compilers = compilers.modify(Host_CC=gnu_compilers[CC], Host_CXX=gnu_compilers[CXX])
super().__init__('papi', 'PAPI', sources, target_arch, target_os,
compilers, REPOS, None, LIBRARIES, None)
Expand Down Expand Up @@ -133,7 +133,7 @@ def check_metrics(self, metrics):
else:
why = ": %s is not supported on this host" % event
break
elif "can't be found" in line:
if "can't be found" in line:
parts = line.split()
try:
event = parts[1]
Expand All @@ -148,7 +148,7 @@ def check_metrics(self, metrics):
"Use papi_avail to check metric availability.",
"Spread the desired metrics over multiple measurements.",
"Choose fewer metrics.",
"You may ignore this if you are cross-compiling.")
"You may ignore this if you are cross-compiling.") from err

def papi_metrics(self, event_type="PRESET", include_modifiers=False):
"""List PAPI available metrics.
Expand All @@ -164,7 +164,7 @@ def papi_metrics(self, event_type="PRESET", include_modifiers=False):
Returns:
list: List of event name/description tuples.
"""
assert event_type == "PRESET" or event_type == "NATIVE"
assert event_type in ("PRESET", "NATIVE")
metrics = []
def _format(item):
name = item.attrib['name']
Expand Down
4 changes: 2 additions & 2 deletions packages/taucmdr/cf/software/pdt_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def __init__(self, sources, target_arch, target_os, compilers):
if compilers[CC].unwrap().info.family is PGI:
try:
gnu_compilers = GNU.installation()
except ConfigurationError:
raise SoftwarePackageError("GNU compilers (required to build PDT) could not be found.")
except ConfigurationError as err:
raise SoftwarePackageError("GNU compilers (required to build PDT) could not be found.") from err
compilers = compilers.modify(Host_CC=gnu_compilers[CC], Host_CXX=gnu_compilers[CXX])
super().__init__('pdt', 'PDT', sources, target_arch, target_os,
compilers, REPOS, COMMANDS, None, None)
Expand Down
4 changes: 2 additions & 2 deletions packages/taucmdr/cf/software/scorep_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def verify(self):
try:
stdout = util.get_command_output(cmd)
except CalledProcessError as err:
raise SoftwarePackageError("%s failed with return code %d: %s" % (cmd, err.returncode, err.output))
raise SoftwarePackageError("%s failed with return code %d: %s" % (cmd, err.returncode, err.output)) from err
flags = self._get_flags()
found_flags = set()
extra_flags = set()
Expand All @@ -184,7 +184,7 @@ def verify(self):
if line.startswith('Configure command:'):
in_section = True
continue
elif in_section:
if in_section:
line = line.replace('./configure', '')
if not line.startswith(' '):
break
Expand Down
2 changes: 1 addition & 1 deletion packages/taucmdr/cf/software/sqlite3_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ class Sqlite3Installation(AutotoolsInstallation):

def __init__(self, sources, target_arch, target_os, compilers):
super().__init__('sqlite3', 'SQLite3', sources,
target_arch, target_os, compilers, REPOS, COMMANDS, LIBRARIES, HEADERS)
target_arch, target_os, compilers, REPOS, COMMANDS, LIBRARIES, HEADERS)
Loading

0 comments on commit f683c83

Please sign in to comment.