Skip to content

Commit

Permalink
Add TAU= to Makefile.
Browse files Browse the repository at this point in the history
Sameer wants to be able to replace the automatically managed
TAU installation with a manually managed installation.

Usage: make install [INSTALLDIR=/path] [TAU=(minimal|full|<path>)]

TAU=minimal is the default.  It installs just enough TAU to support
`tau initialize` without arguments.

TAU=full is the same as running `INSTALLDIR/system/configure` after
running `make install`, i.e. it creates as many TAU configurations
as it possibly can for the current environment.

TAU=<path> will create a magic file named "override_tau_source" in
the system-level storage prefix.  When this file exists, all targets
will use the contents of that file as their TAU installation path
instead of "download".
  • Loading branch information
jlinford committed Oct 5, 2017
1 parent dc16eb8 commit 7102da0
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 55 deletions.
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
#
###############################################################################

# TAU configuration level:
# minimal: Install just enough to support the default project (`tau initialize` without any args).
# full : Install as many TAU configurations as possible for the current environment.
# <path> : Use the TAU installation provided at <path>.
TAU ?= minimal

# If set to "true" then show commands as they are executed.
# Otherwise only the command's output will be shown.
VERBOSE = true
Expand All @@ -50,8 +56,6 @@ ifeq ($(INSTALLDIR),)
INSTALLDIR=$(HOME)/taucmdr-$(VERSION)
endif

TAU = $(INSTALLDIR)/bin/tau

# Get target OS and architecture
ifeq ($(HOST_OS),)
HOST_OS = $(shell uname -s)
Expand Down Expand Up @@ -145,16 +149,16 @@ help:
@echo "-------------------------------------------------------------------------------"
@echo "TAU Commander installation"
@echo
@echo "Usage: make install [INSTALLDIR=$(INSTALLDIR)]"
@echo "Usage: make install [INSTALLDIR=$(INSTALLDIR)] [TAU=(minimal|full|<path>)]"
@echo "-------------------------------------------------------------------------------"

build: python_check
$(ECHO)$(PYTHON) setup.py build_scripts --executable "$(PYTHON)"
$(ECHO)$(PYTHON) setup.py build

install: build
$(ECHO)$(PYTHON) setup.py install --prefix $(INSTALLDIR)
$(ECHO)$(INSTALLDIR)/system/configure --minimal
$(ECHO)$(INSTALLDIR)/system/configure --tau-config=$(TAU)
@chmod -R a+rX,g+w $(INSTALLDIR)
@echo
@echo "-------------------------------------------------------------------------------"
Expand Down Expand Up @@ -183,7 +187,7 @@ install: build

python_check: $(PYTHON_EXE)
@$(PYTHON) -c "import sys; import setuptools;" || (echo "ERROR: setuptools is required." && false)

python_download: $(CONDA_SRC)

$(CONDA): $(CONDA_SRC)
Expand Down
9 changes: 5 additions & 4 deletions packages/taucmdr/cf/software/tau_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def verify(self):
self.dependencies['papi'].check_metrics(self.metrics)
tau_makefile = self.get_makefile()
self._verify_tau_libs(tau_makefile)
if not (self.unmanaged or os.path.islink(self.install_prefix)):
if not self.unmanaged:
self._verify_dependency_paths(tau_makefile)
if self.io_inst:
self._verify_iowrapper(tau_makefile)
Expand Down Expand Up @@ -1200,12 +1200,13 @@ def get_application_command(self, launcher_cmd, application_cmds):
tags = self._makefile_tags(makefile)
if not self.mpi_support:
tags.add('serial')
if self.uid not in tags:
if self.uid not in tags and self.unmanaged:
LOGGER.warning("Unable to verify runtime compatibility of TAU makefile '%s'.\n\n"
"This might be OK, but it is your responsibility to know that TAU was configured "
"correctly for your experiment. Runtime incompatibility may cause your experiment "
"to crash or produce invalid data. If you're unsure, use --tau=download to allow "
"TAU Commander to manage your TAU configurations.", makefile)
"to crash or produce invalid data. If you're unsure, use '--tau=download' when "
"creating your target to allow TAU Commander to manage your TAU configurations.",
makefile)
tau_exec = ['tau_exec', '-T', ','.join(tags)] + opts
if not application_cmds:
cmd = self._rewrite_launcher_appfile_cmd(launcher_cmd, tau_exec)
Expand Down
3 changes: 3 additions & 0 deletions packages/taucmdr/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
Action = argparse.Action
"""Action base class."""

ArgumentError = argparse.ArgumentError
"""Argument error exception base class."""

SUPPRESS = argparse.SUPPRESS
"""Suppress attribute creation in parsed argument namespace."""

Expand Down
27 changes: 23 additions & 4 deletions packages/taucmdr/model/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from taucmdr.cf.platforms import Architecture, OperatingSystem
from taucmdr.cf.platforms import HOST_ARCH, INTEL_KNC, IBM_BGL, IBM_BGP, IBM_BGQ, HOST_OS, DARWIN, CRAY_CNL
from taucmdr.cf.compiler import Knowledgebase, InstalledCompilerSet
from taucmdr.cf.storage.levels import PROJECT_STORAGE
from taucmdr.cf.storage.levels import PROJECT_STORAGE, SYSTEM_STORAGE


LOGGER = logger.get_logger(__name__)
Expand Down Expand Up @@ -120,14 +120,33 @@ def papi_source_default():
return 'download'


def cuda_default():
def cuda_toolkit_default():
default_path = '/usr/local/cuda'
nvcc = util.which('nvcc')
if not nvcc or os.path.dirname(nvcc) in ('/usr/bin', '/usr/local/bin'):
return default_path if os.path.exists(default_path) else None
else:
return os.path.dirname(os.path.dirname(nvcc))

def tau_source_default():
""""Per Sameer's request, override managed TAU installation with an existing unmanaged TAU installation.
If a file named "override_tau_source" exists in the system-level storage prefix, use the contents of
that file as the default path for TAU. Otherwise use "download" as the default.
Returns:
str: Path to TAU or "download".
"""
try:
with open(os.path.join(SYSTEM_STORAGE.prefix, 'override_tau_source')) as fin:
path = fin.read()
except IOError:
return 'download'
path = path.strip()
if not (os.path.isdir(path) and util.path_accessible(path)):
LOGGER.warning("'%s' does not exist or is not accessable.")
return 'download'
return path

def attributes():
"""Construct attributes dictionary for the target model.
Expand Down Expand Up @@ -324,7 +343,7 @@ def attributes():
'cuda_toolkit': {
'type': 'string',
'description': 'path to NVIDIA CUDA Toolkit (enables OpenCL support)',
'default': cuda_default(),
'default': cuda_toolkit_default(),
'argparse': {'flags': ('--cuda-toolkit',),
'group': 'CUDA',
'metavar': '<path>',
Expand All @@ -334,7 +353,7 @@ def attributes():
'tau_source': {
'type': 'string',
'description': 'path or URL to a TAU installation or archive file',
'default': 'download',
'default': tau_source_default(),
'argparse': {'flags': ('--tau',),
'group': 'software package',
'metavar': '(<path>|<url>|download|nightly)',
Expand Down
93 changes: 52 additions & 41 deletions scripts/system_configure
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,29 @@ sys.path.insert(0, os.path.join(PACKAGE_TOPDIR, '..', 'packages'))

# pylint: disable=wrong-import-position
from taucmdr import logger, util, EXIT_SUCCESS
from taucmdr.error import Error
from taucmdr.cli import arguments
from taucmdr.cli.commands.initialize import COMMAND as initialize_cmd
from taucmdr.cli.commands.select import COMMAND as select_cmd
from taucmdr.cli.commands.measurement.copy import COMMAND as measurement_copy_cmd
from taucmdr.model.project import Project
from taucmdr.cf.software.tau_installation import TauInstallation
from taucmdr.cf.storage.levels import PROJECT_STORAGE
from taucmdr.cf.storage.levels import PROJECT_STORAGE, SYSTEM_STORAGE


LOGGER = logger.get_logger(__name__)


class ParseTauAction(arguments.Action):
def __call__(self, parser, namespace, value, unused_option_string=None):
value_keywords = 'minimal', 'full'
if value not in value_keywords:
value = os.path.abspath(os.path.expanduser(value))
if not (os.path.isdir(value) or util.path_accessible(value)):
raise arguments.ArgumentError(self, "'minimal', 'full', or valid path required: %s" % value)
setattr(namespace, self.dest, value)


def _translate_arg(flag, arg):
if isinstance(arg, basestring):
return [flag, arg]
Expand All @@ -58,7 +69,7 @@ def _translate_arg(flag, arg):
return [flag, str(arg)]


def _initialize_project(args):
def _configure_project(args):
PROJECT_STORAGE.destroy()
argv = []
for key, val in sorted(vars(args).iteritems()):
Expand All @@ -70,63 +81,63 @@ def _initialize_project(args):
return
proj_ctrl = Project.controller()
proj = proj_ctrl.selected().populate()
# Acquire source packages
for targ in proj['targets']:
targ.acquire_sources()
return proj, proj_ctrl


def _configure_project(args):
proj, proj_ctrl = _initialize_project(args)
# Add papi configurations
for meas in proj['measurements']:
measurement_copy_cmd.main([meas['name'], meas['name']+'-papi', '--metrics=TIME,PAPI_TOT_CYC'])
# Add OpenMP measurement methods
if getattr(args, 'openmp', False):
for meas in proj['measurements']:
for pkg in 'ompt', 'opari':
measurement_copy_cmd.main([meas['name'], meas['name']+'-'+pkg, '--openmp='+pkg])
proj = proj_ctrl.selected().populate()
# Iterate through default configurations and configure system-level packages for each
for targ in proj['targets']:
for app in proj['applications']:
for meas in proj['measurements']:
targ_name = targ['name']
app_name = app['name']
meas_name = meas['name']
try:
select_cmd.main(['--target', targ['name'],
'--application', app['name'],
'--measurement', meas['name']])
except:
pass
select_cmd.main(['--target', targ_name, '--application', app_name, '--measurement', meas_name])
except Error as err:
LOGGER.warning("An error occurred configuring TAU for experiment %s-%s-%s: %s.\n\n"
"See '%s' for details.",
targ_name, app_name, meas_name, err, logger.LOG_FILE)
return proj


def main(argv):
"""Program entry point."""
prog = sys.argv[0]
parser = arguments.get_parser(prog=prog, usage='%s [arguments]' % prog,
description="Pre-build TAU configurations.")
parser.add_argument('--minimal', help="Build minimal TAU configuration and exit.",
type=bool, default=False, const=True, nargs='?', metavar='T/F')
parser.add_argument('--tau-config', help="Specify TAU configuration level.",
default='minimal', action=ParseTauAction)
parser.merge(initialize_cmd.parser, include_positional=False,
exclude_groups=['project arguments'],
exclude_arguments=['project-name', 'target-name', 'application-name', 'measurement-name',
'tau-options', 'from-tau-makefile', 'bare'])
args = parser.parse_args(argv)
os.chdir(util.mkdtemp())

have_openmp = True # Update as needed in future
have_mpi = bool(getattr(args, 'MPI_CC', False) and
getattr(args, 'MPI_CXX', False) and
getattr(args, 'MPI_FC', False))
have_shmem = bool(getattr(args, 'SHMEM_CC', False) and
getattr(args, 'SHMEM_CXX', False) and
getattr(args, 'SHMEM_FC', False))
have_cuda = bool(getattr(args, 'CUDA_CXX', False))

tau = TauInstallation.minimal()
tau.install()
_initialize_project(args)
if not args.minimal:
_configure_project(args)
if args.tau_config not in ('minimal', 'full'):
# Per Sameer's request, override managed TAU installation with an existing unmanaged TAU installation
with open(os.path.join(SYSTEM_STORAGE.prefix, 'override_tau_source'), 'w') as fout:
fout.write(args.tau_config)
LOGGER.info("By default, targets will use '%s' as the TAU installation.", args.tau_config)
return EXIT_SUCCESS

os.chdir(util.mkdtemp())
TauInstallation.minimal().install()
proj = _configure_project(args)
if args.tau_config == 'full':
# Add papi configurations
for meas in proj['measurements']:
measurement_copy_cmd.main([meas['name'], meas['name']+'-papi', '--metrics=TIME,PAPI_TOT_CYC'])
# Add OpenMP measurement methods
if getattr(args, 'openmp', False):
for meas in proj['measurements']:
for pkg in 'ompt', 'opari':
measurement_copy_cmd.main([meas['name'], meas['name']+'-'+pkg, '--openmp='+pkg])
# Configure TAU for all combinations
have_openmp = True # Update as needed in future
have_mpi = bool(getattr(args, 'MPI_CC', False) and
getattr(args, 'MPI_CXX', False) and
getattr(args, 'MPI_FC', False))
have_shmem = bool(getattr(args, 'SHMEM_CC', False) and
getattr(args, 'SHMEM_CXX', False) and
getattr(args, 'SHMEM_FC', False))
have_cuda = bool(getattr(args, 'CUDA_CXX', False))
for openmp in set([False, have_openmp]):
for mpi in set([False, have_mpi]):
for shmem in set([False, have_shmem]):
Expand Down

0 comments on commit 7102da0

Please sign in to comment.