Skip to content

Commit

Permalink
Merge branch 'unstable' of github.com:ParaToolsInc/taucmdr
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeekman committed Jul 5, 2022
2 parents eae3ae7 + 72ead21 commit 61ea295
Show file tree
Hide file tree
Showing 56 changed files with 770 additions and 247 deletions.
85 changes: 85 additions & 0 deletions .testfiles/jacobi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 2013 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <math.h>
#include <string.h>
#include <openacc.h>
#include <stdio.h>
#include "timer.h"

#define NN 1024
#define NM 1024

double A[NN][NM];
double Anew[NN][NM];

int main(int argc, char** argv)
{
const int n = NN;
const int m = NM;
const int iter_max = 1000;

const double tol = 1.0e-6;
double error = 1.0;

memset(A, 0, n * m * sizeof(double));
memset(Anew, 0, n * m * sizeof(double));

for (int j = 0; j < n; j++)
{
A[j][0] = 1.0;
Anew[j][0] = 1.0;
}

printf("Jacobi relaxation Calculation: %d x %d mesh\n", n, m);

StartTimer();
int iter = 0;

#pragma acc data copyin(Anew), copy(A)
while ( error > tol && iter < iter_max )
{
error = 0.0;

#pragma acc kernels
for( int j = 1; j < n-1; j++)
{
for( int i = 1; i < m-1; i++ )
{
Anew[j][i] = 0.25 * ( A[j][i+1] + A[j][i-1]
+ A[j-1][i] + A[j+1][i]);
error = fmax( error, fabs(Anew[j][i] - A[j][i]));
}
}

#pragma acc kernels
for( int j = 1; j < n-1; j++)
{
for( int i = 1; i < m-1; i++ )
{
A[j][i] = Anew[j][i];
}
}

if(iter % 100 == 0) printf("%5d, %0.6f\n", iter, error);

iter++;
}

double runtime = GetTimer();

printf(" total: %f s\n", runtime / 1000);
}
67 changes: 67 additions & 0 deletions .testfiles/timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2012 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef TIMER_H
#define TIMER_H

#include <stdlib.h>

#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <sys/time.h>
#endif

#ifdef WIN32
double PCFreq = 0.0;
__int64 timerStart = 0;
#else
struct timeval timerStart;
#endif

void StartTimer()
{
#ifdef WIN32
LARGE_INTEGER li;
if(!QueryPerformanceFrequency(&li))
printf("QueryPerformanceFrequency failed!\n");

PCFreq = (double)li.QuadPart/1000.0;

QueryPerformanceCounter(&li);
timerStart = li.QuadPart;
#else
gettimeofday(&timerStart, NULL);
#endif
}

// time elapsed in ms
double GetTimer()
{
#ifdef WIN32
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
return (double)(li.QuadPart-timerStart)/PCFreq;
#else
struct timeval timerStop, timerElapsed;
gettimeofday(&timerStop, NULL);
timersub(&timerStop, &timerStart, &timerElapsed);
return timerElapsed.tv_sec*1000.0+timerElapsed.tv_usec/1000.0;
#endif
}

#endif // TIMER_H
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN DEBIAN_FRONTEND=noninteractive set -v && \
rm -rf /var/lib/apt/lists/* && \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \
useradd -ms /bin/bash tau
ENV LANG=en_US.UTF-8 INSTALLDIR=/home/tau/taucmdr
ENV LANG=en_US.UTF-8 INSTALLDIR=/home/tau/taucmdr __TAUCMDR_DEVELOPER__=1
COPY .gitignore .gitattributes .version.sh LICENSE README.md Makefile setup.py MANIFEST.in requirements-dev.txt /tmp/taucmdr/
COPY scripts /tmp/taucmdr/scripts
COPY packages /tmp/taucmdr/packages
Expand All @@ -15,7 +15,7 @@ COPY examples /tmp/taucmdr/examples
COPY .testfiles /tmp/taucmdr/.testfiles
COPY .git /tmp/taucmdr/.testfiles
WORKDIR /tmp/taucmdr
RUN ls -la ; make clean ; make install ; chown -R tau:tau ${INSTALLDIR}
RUN ls -la ; make clean ; mkdir ${INSTALLDIR}; make install; chown -R tau:tau ${INSTALLDIR}
USER tau
WORKDIR /home/tau/src
ENV PATH="/home/tau/taucmdr/conda/bin:$PATH:/home/tau/taucmdr/bin"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ endif

# Get build system locations from configuration file or command line
ifneq ("$(wildcard setup.cfg)","")
BUILDDIR = $(shell grep '^build-base =' setup.cfg | sed 's/build-base = //')
INSTALLDIR = $(shell grep '^prefix =' setup.cfg | sed 's/prefix = //')
BUILDDIR ?= $(shell grep '^build-base =' setup.cfg | sed 's/build-base = //')
INSTALLDIR ?= $(shell grep '^prefix =' setup.cfg | sed 's/prefix = //')
endif
ifeq ($(BUILDDIR),)
BUILDDIR=build
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ TAU Commander developers should visit the [developer documentation](http://parat
Acknowledgements
================

This work is supported by the United States Department of Energy under
DoE SBIR grant DE-SC0009593.
Initial development of TAU Commander was supported by the United States
Department of Energy under DOE SBIR award DE-SC0009593. Development of support
for machine learning and artificial intelligence applications is supported by
the United States Department of Energy under DOE SBIR award DE-SC0019700.

The work on extending TAU Commander for OpenSHMEM was supported by the
United States Department of Defense (DoD) and used resources of the
Expand Down
2 changes: 1 addition & 1 deletion docs/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ General Definitions
A list of configuration options (a "configuration object") that completely describes the hardware and
software environment in which the TAU Commander workflow will be performed. This includes, among other things, the
operating system distribution (e.g. Linux, Darwin, CNL, etc.) CPU architecture (x86_64, ppc64, etc.) compiler
installation paths, compiler family (e.g. Intel, Cray, PGI, etc.), MPI installation path, and TAU and PDT
installation paths, compiler family (e.g. Intel, Cray, PGI, NVHPC, etc.), MPI installation path, and TAU and PDT
installation paths.

:Application:
Expand Down
45 changes: 26 additions & 19 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 @@ -428,7 +427,7 @@ class InstalledCompilerCreator(type):
and `icc` would be probed twice. With this metaclass, ``b is a == True`` and `icc` is only invoked once.
"""
def __call__(cls, absolute_path, info, **kwargs):
assert isinstance(absolute_path, str) and os.path.isabs(absolute_path)
assert absolute_path == '' or (isinstance(absolute_path, str) and os.path.isabs(absolute_path))
assert isinstance(info, _CompilerInfo)
# Don't allow unchecked values into the instance cache
if kwargs:
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 @@ -637,7 +636,10 @@ def probe(cls, command, family=None, role=None):
assert isinstance(role, _CompilerRole) or role is None
absolute_path = util.which(command)
if not absolute_path:
raise ConfigurationError("Compiler '%s' not found on PATH" % command)
if family is None:
absolute_path = ''
else:
raise ConfigurationError("Compiler '%s' not found on PATH" % command)
command = os.path.basename(absolute_path)
LOGGER.debug("Probe: command='%s', abspath='%s', family='%s', role='%s'",
command, absolute_path, family, role)
Expand Down Expand Up @@ -693,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 @@ -765,6 +767,11 @@ def __init__(self, family):
LOGGER.warning(err)
continue
self.members.setdefault(role, []).append(installed)
for role, info_list in family.members.items():
for info in info_list:
if family.name == 'None':
installed = InstalledCompiler(info.command, info)
self.members.setdefault(role, []).append(installed)
if not self.members:
cmds = [info.command for info_list in family.members.values() for info in info_list]
raise ConfigurationError(f"{self.family.name} {self.family.kbase.description} not found.",
Expand Down Expand Up @@ -800,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: 4 additions & 0 deletions packages/taucmdr/cf/compiler/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@
CXX=('CUDA', 'CU'),
FC=('CUDA Fortran', 'CUF'))

NVHPC = CUDA_COMPILERS.add('NVHPC', CXX='nvcc')

NVIDIA = CUDA_COMPILERS.add('NVIDIA', CXX='nvcc')

IBM = CUDA_COMPILERS.add('IBM', family_regex=r'^IBM XL', version_flags=['-qversion'],
FC='xlcuf')

NONE = CUDA_COMPILERS.add('None', CXX='', FC='')

CUDA_CXX = CUDA_COMPILERS.roles['CXX']
CUDA_FC = CUDA_COMPILERS.roles['FC']
7 changes: 5 additions & 2 deletions packages/taucmdr/cf/compiler/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@
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'))

NVHPC = HOST_COMPILERS.add('NVHPC', family_regex=r'NVIDIA CORPORATION',
CC='nvc' , CXX=('nvc++', 'nvcc'), FC='nvfortran')

IBM = HOST_COMPILERS.add('IBM', family_regex=r'^IBM XL',
version_flags=['-qversion'],
CC=('xlc_r', 'xlc'),
Expand Down
9 changes: 9 additions & 0 deletions packages/taucmdr/cf/compiler/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
CXX=('MPI C++', 'MPI_CXX'),
FC=('MPI Fortran', ('MPI_FC', 'MPI_F77', 'MPI_F90')))

NVHPC = MPI_COMPILERS.add('NVHPC', family_regex=r'NVIDIA CORPORATION', show_wrapper_flags=['-show'],
CC='mpicc',
CXX=('mpic++', 'mpicxx', 'mpiCC'),
FC=('mpiftn', 'mpif90', 'mpif77', 'mpifort'))

SYSTEM = MPI_COMPILERS.add('System', show_wrapper_flags=['-show'],
CC='mpicc',
CXX=('mpic++', 'mpicxx', 'mpiCC'),
Expand All @@ -66,6 +71,10 @@
show_wrapper_flags=['-craype-verbose', '--version', '-E'],
CC='cc', CXX='CC', FC='ftn')

NONE = MPI_COMPILERS.add('None', #family_regex='',
CC='', CXX='', FC='')


MPI_CC = MPI_COMPILERS.roles['CC']
MPI_CXX = MPI_COMPILERS.roles['CXX']
MPI_FC = MPI_COMPILERS.roles['FC']
Loading

0 comments on commit 61ea295

Please sign in to comment.