User API + reorganized lib folders (#30)

* User API + reorganized lib folders

- omnitrace_user_start_trace
- omnitrace_user_stop_trace
- omnitrace_user_start_thread_trace
- omnitrace_user_stop_thread_trace
- omnitrace_user_push_region
- omnitrace_user_pop_region

* New OpenMP examples/tests

* Fix to KokkosP

* OMPT support

- fixed omnitrace instrumenting reporting
- common invoke improvements
- component::user_region

* exclude kmp_threadprivate_

* Separate omnitrace into multiple files

* PTL and timemory submodule updates

* Active guards + USE_OMPT guards in omnitrace-dl

* Tweak transpose default iterations

* omnitrace-precommit build target

* Omnitrace exe restructuring pt 2

- Never instrument functions with less than 4 instructions
- Never instrument ompt_start_tool or nanosleep
- module_function serializes heuristics
- removed hash stuff from omnitrace
- removed instr_procedures lambda
- WAITPID_DEBUG_MESSAGE

* set_state, "_hidden" fix, CI exceptions, backtrace fix

- set_state function
- fixed "_hidden" from appearing in print macros using __FUNCTION__
- OMNITRACE_CI_THROW
- more CI checks in library
- fixed backtrace init value sample issue being ignored

* Tweaks to OMPT tests

* cmake-formatting

* Removed debug output from backtrace processing

* Fix warnings and verbosity

* omnitrace-dl fix for libomp

* omnitrace-avail fixes

- remove second omnitrace_init_library call
- fix -r option not working

* Additional testing

- source/bin/tests
- tests for omnitrace-exe
- tests for omnitrace-avail

* cmake-format

* Reduce runtime of openmp-lu

* Update openmp-lu and tests timeout

* openmp-lu and CI tweaks

- decrease iterations
- OMP_NUM_THREADS=2
- install clang and libomp-dev in linux-ci
- fix data-files in linux-ci

[ROCm/rocprofiler-systems commit: d80752bc69]
This commit is contained in:
Jonathan R. Madsen
2022-03-07 20:40:48 -06:00
committed by GitHub
parent a23bf28aaa
commit 083035dd8b
106 changed files with 9180 additions and 1947 deletions
@@ -7,6 +7,8 @@ set(CMAKE_CXX_VISIBILITY_PRESET "default")
add_subdirectory(transpose)
add_subdirectory(parallel-overhead)
add_subdirectory(user-api)
add_subdirectory(openmp)
option(BUILD_SHARED_LIBS "Build dynamic libraries" ON)
@@ -55,17 +55,3 @@ if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR})
endif()
enable_testing()
if(LULESH_USE_MPI)
add_test(
NAME lulesh
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 8
$<TARGET_FILE:${PROJECT_NAME}> -i 100 -s 20 -p
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
else()
add_test(
NAME lulesh
COMMAND $<TARGET_FILE:${PROJECT_NAME}> -i 100 -s 20 -p
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
endif()
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,23 @@
/* CLASS = B */
/*
c This file is generated automatically by the setparams utility.
c It sets the number of processors and the class_npb of the NPB
c in this directory. Do not modify it by hand.
*/
#define NA 75000
#define NONZER 13
#define NITER 75
#define SHIFT 60.0
#define RCOND 1.0e-1
#define CONVERTDOUBLE FALSE
#define COMPILETIME "01 Mar 2022"
#define NPBVERSION "4.1"
#define LIBVERSION "201511"
#define COMPILERVERSION "11.1.0"
#define CS1 "g++ -std=c++14"
#define CS2 "$(CC)"
#define CS3 "-lm"
#define CS4 "-I../common "
#define CS5 "-O3 -fopenmp -mcmodel=medium"
#define CS6 "-O3 -fopenmp -mcmodel=medium"
#define CS7 "randdp"
@@ -0,0 +1,27 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
file(GLOB common_source ${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp)
add_library(openmp-common OBJECT ${common_source})
target_include_directories(openmp-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/common)
add_executable(openmp-cg ${CMAKE_CURRENT_SOURCE_DIR}/CG/cg.cpp
$<TARGET_OBJECTS:openmp-common>)
add_executable(openmp-lu ${CMAKE_CURRENT_SOURCE_DIR}/LU/lu.cpp
$<TARGET_OBJECTS:openmp-common>)
find_program(CLANGXX_EXECUTABLE NAMES clang++)
if(CLANGXX_EXECUTABLE)
target_compile_options(openmp-common PUBLIC -W -Wall -fopenmp=libomp)
target_compile_options(openmp-cg PRIVATE -W -Wall -fopenmp=libomp)
target_link_libraries(openmp-cg PRIVATE omp)
target_compile_options(openmp-lu PRIVATE -W -Wall -fopenmp=libomp)
target_link_libraries(openmp-lu PRIVATE omp)
omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-common)
omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-cg)
omnitrace_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET openmp-lu)
else()
find_package(OpenMP REQUIRED)
target_link_libraries(openmp-common PUBLIC OpenMP::OpenMP_CXX)
endif()
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,27 @@
/* CLASS = W */
/*
c This file is generated automatically by the setparams utility.
c It sets the number of processors and the class_npb of the NPB
c in this directory. Do not modify it by hand.
*/
/* full problem size */
#define ISIZ1 25
#define ISIZ2 25
#define ISIZ3 25
/* number of iterations and how often to print the norm */
#define ITMAX_DEFAULT 150
#define INORM_DEFAULT 150
#define DT_DEFAULT 1.5e-3
#define CONVERTDOUBLE FALSE
#define COMPILETIME "07 Mar 2022"
#define NPBVERSION "4.1"
#define LIBVERSION "201511"
#define COMPILERVERSION "11.1.0"
#define CS1 "g++ -std=c++14"
#define CS2 "$(CC)"
#define CS3 "-lm"
#define CS4 "-I../common "
#define CS5 "-O3 -fopenmp -mcmodel=medium"
#define CS6 "-O3 -fopenmp -mcmodel=medium"
#define CS7 "randdp"
@@ -0,0 +1,159 @@
/*
MIT License
Copyright (c) 2021 Parallel Applications Modelling Group - GMAP
GMAP website: https://gmap.pucrs.br
Pontifical Catholic University of Rio Grande do Sul (PUCRS)
Av. Ipiranga, 6681, Porto Alegre - Brazil, 90619-900
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
The original NPB 3.4.1 version was written in Fortran and belongs to:
http://www.nas.nasa.gov/Software/NPB/
------------------------------------------------------------------------------
The serial C++ version is a translation of the original NPB 3.4.1
Serial C++ version: https://github.com/GMAP/NPB-CPP/tree/master/NPB-SER
Authors of the C++ code:
Dalvan Griebler <dalvangriebler@gmail.com>
Gabriell Araujo <hexenoften@gmail.com>
Júnior Löff <loffjh@gmail.com>
*/
#include <cmath>
#include <cstdio>
#include <cstdlib>
/*****************************************************************/
/****** C _ P R I N T _ R E S U L T S ******/
/*****************************************************************/
void
c_print_results(char* name, char class_npb, int n1, int n2, int n3, int niter, double t,
double mops, char* optype, int passed_verification, char* npbversion,
char* compiletime, char* compilerversion, char* libversion,
char* totalthreads, char* cc, char* clink, char* c_lib, char* c_inc,
char* cflags, char* clinkflags, char* rand)
{
printf("\n\n %s Benchmark Completed\n", name);
printf(" class_npb = %c\n", class_npb);
if((name[0] == 'I') && (name[1] == 'S'))
{
if(n3 == 0)
{
long nn = n1;
if(n2 != 0)
{
nn *= n2;
}
printf(" Size = %12ld\n", nn); /* as in IS */
}
else
{
printf(" Size = %4dx%4dx%4d\n", n1, n2, n3);
}
}
else
{
char size[16];
int j;
if((n2 == 0) && (n3 == 0))
{
if((name[0] == 'E') && (name[1] == 'P'))
{
sprintf(size, "%15.0lf", pow(2.0, n1));
j = 14;
if(size[j] == '.')
{
size[j] = ' ';
j--;
}
size[j + 1] = '\0';
printf(" Size = %15s\n", size);
}
else
{
printf(" Size = %12d\n", n1);
}
}
else
{
printf(" Size = %4dx%4dx%4d\n", n1, n2, n3);
}
}
printf(" Total threads = %12s\n", totalthreads);
printf(" Iterations = %12d\n", niter);
printf(" Time in seconds = %12.2f\n", t);
printf(" Mop/s total = %12.2f\n", mops);
printf(" Operation type = %24s\n", optype);
if(passed_verification < 0)
{
printf(" Verification = NOT PERFORMED\n");
}
else if(passed_verification)
{
printf(" Verification = SUCCESSFUL\n");
}
else
{
printf(" Verification = UNSUCCESSFUL\n");
}
printf(" Version = %12s\n", npbversion);
printf(" Compile date = %12s\n", compiletime);
printf(" Compiler ver = %12s\n", compilerversion);
printf(" OpenMP version = %12s\n", libversion);
printf("\n Compile options:\n");
printf(" CC = %s\n", cc);
printf(" CLINK = %s\n", clink);
printf(" C_LIB = %s\n", c_lib);
printf(" C_INC = %s\n", c_inc);
printf(" CFLAGS = %s\n", cflags);
printf(" CLINKFLAGS = %s\n", clinkflags);
printf(" RAND = %s\n", rand);
#ifdef SMP
evalue = getenv("MP_SET_NUMTHREADS");
printf(" MULTICPUS = %s\n", evalue);
#endif
/*
* printf(" Please send the results of this run to:\n\n");
* printf(" NPB Development Team\n");
* printf(" Internet: npb@nas.nasa.gov\n \n");
* printf(" If email is not available, send this to:\n\n");
* printf(" MS T27A-1\n");
* printf(" NASA Ames Research Center\n");
* printf(" Moffett Field, CA 94035-1000\n\n");
* printf(" Fax: 650-604-3957\n\n");
*/
printf("\n\n");
printf("----------------------------------------------------------------------\n");
printf(" NPB-CPP is developed by: \n");
printf(" Dalvan Griebler\n");
printf(" Gabriell Araujo (Sequential Porting)\n");
printf(" Júnior Löff (Parallel Implementation)\n");
printf("\n");
printf(" In case of questions or problems, please send an e-mail to us:\n");
printf(" dalvan.griebler; gabriell.araujo; junior.loff@edu.pucrs.br\n");
printf("----------------------------------------------------------------------\n");
printf("\n");
}
@@ -0,0 +1,184 @@
/*
MIT License
Copyright (c) 2021 Parallel Applications Modelling Group - GMAP
GMAP website: https://gmap.pucrs.br
Pontifical Catholic University of Rio Grande do Sul (PUCRS)
Av. Ipiranga, 6681, Porto Alegre - Brazil, 90619-900
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
The original NPB 3.4.1 version was written in Fortran and belongs to:
http://www.nas.nasa.gov/Software/NPB/
------------------------------------------------------------------------------
The serial C++ version is a translation of the original NPB 3.4.1
Serial C++ version: https://github.com/GMAP/NPB-CPP/tree/master/NPB-SER
Authors of the C++ code:
Dalvan Griebler <dalvangriebler@gmail.com>
Gabriell Araujo <hexenoften@gmail.com>
Júnior Löff <loffjh@gmail.com>
*/
#if defined(USE_POW)
# define r23 pow(0.5, 23.0)
# define r46 (r23 * r23)
# define t23 pow(2.0, 23.0)
# define t46 (t23 * t23)
#else
# define r23 \
(0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * \
0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5)
# define r46 (r23 * r23)
# define t23 \
(2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * \
2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0)
# define t46 (t23 * t23)
#endif
/*
* ---------------------------------------------------------------------
*
* this routine returns a uniform pseudorandom double precision number in the
* range (0, 1) by using the linear congruential generator
*
* x_{k+1} = a x_k (mod 2^46)
*
* where 0 < x_k < 2^46 and 0 < a < 2^46. this scheme generates 2^44 numbers
* before repeating. the argument A is the same as 'a' in the above formula,
* and X is the same as x_0. A and X must be odd double precision integers
* in the range (1, 2^46). the returned value RANDLC is normalized to be
* between 0 and 1, i.e. RANDLC = 2^(-46) * x_1. X is updated to contain
* the new seed x_1, so that subsequent calls to RANDLC using the same
* arguments will generate a continuous sequence.
*
* this routine should produce the same results on any computer with at least
* 48 mantissa bits in double precision floating point data. On 64 bit
* systems, double precision should be disabled.
*
* David H. Bailey, October 26, 1990
*
* ---------------------------------------------------------------------
*/
double
randlc(double* x, double a)
{
double t1, t2, t3, t4, a1, a2, x1, x2, z;
/*
* ---------------------------------------------------------------------
* break A into two parts such that A = 2^23 * A1 + A2.
* ---------------------------------------------------------------------
*/
t1 = r23 * a;
a1 = (int) t1;
a2 = a - t23 * a1;
/*
* ---------------------------------------------------------------------
* break X into two parts such that X = 2^23 * X1 + X2, compute
* Z = A1 * X2 + A2 * X1 (mod 2^23), and then
* X = 2^23 * Z + A2 * X2 (mod 2^46).
* ---------------------------------------------------------------------
*/
t1 = r23 * (*x);
x1 = (int) t1;
x2 = (*x) - t23 * x1;
t1 = a1 * x2 + a2 * x1;
t2 = (int) (r23 * t1);
z = t1 - t23 * t2;
t3 = t23 * z + a2 * x2;
t4 = (int) (r46 * t3);
(*x) = t3 - t46 * t4;
return (r46 * (*x));
}
/*
* ---------------------------------------------------------------------
*
* this routine generates N uniform pseudorandom double precision numbers in
* the range (0, 1) by using the linear congruential generator
*
* x_{k+1} = a x_k (mod 2^46)
*
* where 0 < x_k < 2^46 and 0 < a < 2^46. this scheme generates 2^44 numbers
* before repeating. the argument A is the same as 'a' in the above formula,
* and X is the same as x_0. A and X must be odd double precision integers
* in the range (1, 2^46). the N results are placed in Y and are normalized
* to be between 0 and 1. X is updated to contain the new seed, so that
* subsequent calls to VRANLC using the same arguments will generate a
* continuous sequence. if N is zero, only initialization is performed, and
* the variables X, A and Y are ignored.
*
* this routine is the standard version designed for scalar or RISC systems.
* however, it should produce the same results on any single processor
* computer with at least 48 mantissa bits in double precision floating point
* data. on 64 bit systems, double precision should be disabled.
*
* ---------------------------------------------------------------------
*/
void
vranlc(int n, double* x_seed, double a, double y[])
{
int i;
double x, t1, t2, t3, t4, a1, a2, x1, x2, z;
/*
* ---------------------------------------------------------------------
* break A into two parts such that A = 2^23 * A1 + A2.
* ---------------------------------------------------------------------
*/
t1 = r23 * a;
a1 = (int) t1;
a2 = a - t23 * a1;
x = *x_seed;
/*
* ---------------------------------------------------------------------
* generate N results. this loop is not vectorizable.
* ---------------------------------------------------------------------
*/
for(i = 0; i < n; i++)
{
/*
* ---------------------------------------------------------------------
* break X into two parts such that X = 2^23 * X1 + X2, compute
* Z = A1 * X2 + A2 * X1 (mod 2^23), and then
* X = 2^23 * Z + A2 * X2 (mod 2^46).
* ---------------------------------------------------------------------
*/
t1 = r23 * x;
x1 = (int) t1;
x2 = x - t23 * x1;
t1 = a1 * x2 + a2 * x1;
t2 = (int) (r23 * t1);
z = t1 - t23 * t2;
t3 = t23 * z + a2 * x2;
t4 = (int) (r46 * t3);
x = t3 - t46 * t4;
y[i] = r46 * x;
}
*x_seed = x;
}
@@ -0,0 +1,101 @@
/*
MIT License
Copyright (c) 2021 Parallel Applications Modelling Group - GMAP
GMAP website: https://gmap.pucrs.br
Pontifical Catholic University of Rio Grande do Sul (PUCRS)
Av. Ipiranga, 6681, Porto Alegre - Brazil, 90619-900
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
The original NPB 3.4.1 version was written in Fortran and belongs to:
http://www.nas.nasa.gov/Software/NPB/
------------------------------------------------------------------------------
The serial C++ version is a translation of the original NPB 3.4.1
Serial C++ version: https://github.com/GMAP/NPB-CPP/tree/master/NPB-SER
Authors of the C++ code:
Dalvan Griebler <dalvangriebler@gmail.com>
Gabriell Araujo <hexenoften@gmail.com>
Júnior Löff <loffjh@gmail.com>
*/
#include "wtime.hpp"
#include <cstdlib>
/* prototype */
void
wtime(double*);
/*****************************************************************/
/****** E L A P S E D _ T I M E ******/
/*****************************************************************/
double
elapsed_time(void)
{
double t;
wtime(&t);
return (t);
}
double start[64], elapsed[64];
/*****************************************************************/
/****** T I M E R _ C L E A R ******/
/*****************************************************************/
void
timer_clear(int n)
{
elapsed[n] = 0.0;
}
/*****************************************************************/
/****** T I M E R _ S T A R T ******/
/*****************************************************************/
void
timer_start(int n)
{
start[n] = elapsed_time();
}
/*****************************************************************/
/****** T I M E R _ S T O P ******/
/*****************************************************************/
void
timer_stop(int n)
{
double t, now;
now = elapsed_time();
t = now - start[n];
elapsed[n] += t;
}
/*****************************************************************/
/****** T I M E R _ R E A D ******/
/*****************************************************************/
double
timer_read(int n)
{
return (elapsed[n]);
}
@@ -0,0 +1,124 @@
/*
MIT License
Copyright (c) 2021 Parallel Applications Modelling Group - GMAP
GMAP website: https://gmap.pucrs.br
Pontifical Catholic University of Rio Grande do Sul (PUCRS)
Av. Ipiranga, 6681, Porto Alegre - Brazil, 90619-900
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
The original NPB 3.4.1 version was written in Fortran and belongs to:
http://www.nas.nasa.gov/Software/NPB/
------------------------------------------------------------------------------
The serial C++ version is a translation of the original NPB 3.4.1
Serial C++ version: https://github.com/GMAP/NPB-CPP/tree/master/NPB-SER
Authors of the C++ code:
Dalvan Griebler <dalvangriebler@gmail.com>
Gabriell Araujo <hexenoften@gmail.com>
Júnior Löff <loffjh@gmail.com>
*/
#include <cmath>
#include <cstdio>
#include <cstdlib>
typedef int boolean;
typedef struct
{
double real;
double imag;
} dcomplex;
#define TRUE 1
#define FALSE 0
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define pow2(a) ((a) * (a))
/* old version of the complex number operations */
#define get_real(c) c.real
#define get_imag(c) c.imag
#define cadd(c, a, b) (c.real = a.real + b.real, c.imag = a.imag + b.imag)
#define csub(c, a, b) (c.real = a.real - b.real, c.imag = a.imag - b.imag)
#define cmul(c, a, b) \
(c.real = a.real * b.real - a.imag * b.imag, \
c.imag = a.real * b.imag + a.imag * b.real)
#define crmul(c, a, b) (c.real = a.real * b, c.imag = a.imag * b)
/* latest version of the complex number operations */
#define dcomplex_create(r, i) \
(dcomplex) { r, i }
#define dcomplex_add(a, b) \
(dcomplex) { (a).real + (b).real, (a).imag + (b).imag }
#define dcomplex_sub(a, b) \
(dcomplex) { (a).real - (b).real, (a).imag - (b).imag }
#define dcomplex_mul(a, b) \
(dcomplex) \
{ \
((a).real * (b).real) - ((a).imag * (b).imag), \
((a).real * (b).imag) + ((a).imag * (b).real) \
}
#define dcomplex_mul2(a, b) \
(dcomplex) { (a).real*(b), (a).imag*(b) }
static inline dcomplex
dcomplex_div(dcomplex z1, dcomplex z2)
{
double a = z1.real;
double b = z1.imag;
double c = z2.real;
double d = z2.imag;
double divisor = c * c + d * d;
double real = (a * c + b * d) / divisor;
double imag = (b * c - a * d) / divisor;
dcomplex result = (dcomplex){ real, imag };
return result;
}
#define dcomplex_div2(a, b) \
(dcomplex) { (a).real / (b), (a).imag / (b) }
#define dcomplex_abs(x) sqrt(((x).real * (x).real) + ((x).imag * (x).imag))
#define dconjg(x) \
(dcomplex) { (x).real, -1.0 * (x).imag }
extern double
randlc(double*, double);
extern void
vranlc(int, double*, double, double*);
extern void
timer_clear(int);
extern void
timer_start(int);
extern void
timer_stop(int);
extern double
timer_read(int);
extern void
c_print_results(char* name, char class_npb, int n1, int n2, int n3, int niter, double t,
double mops, char* optype, int passed_verification, char* npbversion,
char* compiletime, char* compilerversion, char* libversion,
char* totalthreads, char* cc, char* clink, char* c_lib, char* c_inc,
char* cflags, char* clinkflags, char* rand);
@@ -0,0 +1,55 @@
/*
MIT License
Copyright (c) 2021 Parallel Applications Modelling Group - GMAP
GMAP website: https://gmap.pucrs.br
Pontifical Catholic University of Rio Grande do Sul (PUCRS)
Av. Ipiranga, 6681, Porto Alegre - Brazil, 90619-900
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
The original NPB 3.4.1 version was written in Fortran and belongs to:
http://www.nas.nasa.gov/Software/NPB/
------------------------------------------------------------------------------
The serial C++ version is a translation of the original NPB 3.4.1
Serial C++ version: https://github.com/GMAP/NPB-CPP/tree/master/NPB-SER
Authors of the C++ code:
Dalvan Griebler <dalvangriebler@gmail.com>
Gabriell Araujo <hexenoften@gmail.com>
Júnior Löff <loffjh@gmail.com>
*/
#include "wtime.hpp"
#include <sys/time.h>
void
wtime(double* t)
{
static int sec = -1;
struct timeval tv;
gettimeofday(&tv, 0);
if(sec < 0) sec = tv.tv_sec;
*t = (tv.tv_sec - sec) + 1.0e-6 * tv.tv_usec;
}
@@ -0,0 +1,54 @@
/*
MIT License
Copyright (c) 2021 Parallel Applications Modelling Group - GMAP
GMAP website: https://gmap.pucrs.br
Pontifical Catholic University of Rio Grande do Sul (PUCRS)
Av. Ipiranga, 6681, Porto Alegre - Brazil, 90619-900
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
The original NPB 3.4.1 version was written in Fortran and belongs to:
http://www.nas.nasa.gov/Software/NPB/
------------------------------------------------------------------------------
The serial C++ version is a translation of the original NPB 3.4.1
Serial C++ version: https://github.com/GMAP/NPB-CPP/tree/master/NPB-SER
Authors of the C++ code:
Dalvan Griebler <dalvangriebler@gmail.com>
Gabriell Araujo <hexenoften@gmail.com>
Júnior Löff <loffjh@gmail.com>
*/
/*
* C/Fortran interface is different on different machines.
* you may need to tweak this.
*/
#if defined(IBM)
# define wtime wtime
#elif defined(CRAY)
# define wtime WTIME
#else
# define wtime wtime_
#endif
@@ -95,7 +95,7 @@ transpose_a(int* in, int* out, int M, int N)
void
run(int rank, int tid, hipStream_t stream, int argc, char** argv)
{
size_t nitr = 5000;
size_t nitr = 500;
unsigned int M = 4960 * 2;
unsigned int N = 4960 * 2;
if(argc > 2) nitr = atoll(argv[2]);
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
project(omnitrace-user-api LANGUAGES CXX)
set(CMAKE_BUILD_TYPE "Release")
find_package(Threads REQUIRED)
add_executable(user-api user-api.cpp)
target_link_libraries(user-api PRIVATE Threads::Threads omnitrace::omnitrace-user-library)
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set_target_properties(user-api PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR})
endif()
@@ -0,0 +1,80 @@
#include <omnitrace/user.h>
#include <atomic>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <thread>
#include <vector>
std::atomic<long> total{ 0 };
long
fib(long n) __attribute__((noinline));
void
run(size_t nitr, long) __attribute__((noinline));
long
fib(long n)
{
return (n < 2) ? n : fib(n - 1) + fib(n - 2);
}
#define RUN_LABEL \
std::string{ std::string{ __FUNCTION__ } + "(" + std::to_string(n) + ") x " + \
std::to_string(nitr) } \
.c_str()
void
run(size_t nitr, long n)
{
omnitrace_user_stop_thread_trace();
omnitrace_user_push_region(RUN_LABEL);
long local = 0;
for(size_t i = 0; i < nitr; ++i)
local += fib(n);
total += local;
omnitrace_user_pop_region(RUN_LABEL);
omnitrace_user_start_thread_trace();
}
int
main(int argc, char** argv)
{
omnitrace_user_push_region(argv[0]);
omnitrace_user_push_region("initialization");
size_t nthread = std::min<size_t>(16, std::thread::hardware_concurrency());
size_t nitr = 50000;
long nfib = 10;
if(argc > 1) nfib = atol(argv[1]);
if(argc > 2) nthread = atol(argv[2]);
if(argc > 3) nitr = atol(argv[3]);
omnitrace_user_pop_region("initialization");
printf("[%s] Threads: %zu\n[%s] Iterations: %zu\n[%s] fibonacci(%li)...\n", argv[0],
nthread, argv[0], nitr, argv[0], nfib);
omnitrace_user_push_region("thread_creation");
std::vector<std::thread> threads{};
threads.reserve(nthread);
for(size_t i = 0; i < nthread; ++i)
{
size_t _nitr = ((i % 2) == 1) ? (nitr - (0.1 * nitr)) : (nitr + (0.1 * nitr));
threads.emplace_back(&run, _nitr, nfib);
}
omnitrace_user_pop_region("thread_creation");
run(nitr - 0.25 * nitr, nfib - 0.1 * nfib);
omnitrace_user_push_region("thread_wait");
for(auto& itr : threads)
itr.join();
omnitrace_user_pop_region("thread_wait");
printf("[%s] fibonacci(%li) x %lu = %li\n", argv[0], nfib, nthread, total.load());
omnitrace_user_pop_region(argv[0]);
return 0;
}