diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4520b6e --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# OS / Desktop +.DS_Store/ +Thumbs.db + +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so + +# Virtual Environments +.env +.venv +venv/ +ENV/ +env/ + +# IDE / Editor +.idea/ +.vscode/ +*.swp +*.swo + +# Build and Distribution +build/ +dist/ +*.egg-info/ +.eggs/ +*.egg + +# Testing / Coverage +.pytest_cache/ +.coverage +htmlcov/ +.tox/ + +# C / C++ Objects and Executables +*.o +*.obj +*.out +*.exe +*.dll +*.dylib +*.dSYM/ + +# Jupyter Notebooks +.ipynb_checkpoints/ diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/README.md b/README.md index 1ad1a08..61d5a65 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ # HLSProject +## Testing PR feature \ No newline at end of file diff --git a/datasets/.DS_Store b/datasets/.DS_Store new file mode 100644 index 0000000..dd212a5 Binary files /dev/null and b/datasets/.DS_Store differ diff --git a/datasets/PolyBenchC/.DS_Store b/datasets/PolyBenchC/.DS_Store new file mode 100644 index 0000000..4882c71 Binary files /dev/null and b/datasets/PolyBenchC/.DS_Store differ diff --git a/datasets/PolyBenchC/AUTHORS b/datasets/PolyBenchC/AUTHORS new file mode 100644 index 0000000..2a94835 --- /dev/null +++ b/datasets/PolyBenchC/AUTHORS @@ -0,0 +1,17 @@ +* * * * * * * * * * * * * +* Authors of PolyBench * +* * * * * * * * * * * * * + + +* Louis-Noel Pouchet + Who provided packaging and harmonization of all test files, + the PolyBench infrastructure and machinery, and several + reference C files. + +* Uday Bondugula + Who provided many of the original reference C files, including + Fortran to C translation. + +* Tomofumi Yuki + Who provided all the fixes implemented in 4.0, and is now the maintainer + of PolyBench/C. diff --git a/datasets/PolyBenchC/CHANGELOG b/datasets/PolyBenchC/CHANGELOG new file mode 100644 index 0000000..52895df --- /dev/null +++ b/datasets/PolyBenchC/CHANGELOG @@ -0,0 +1,147 @@ +------------------- +* Changes in 4.2.1: +------------------- + - Fixed an issue with PAPI support. + Reported by Keyur Joshi + - Added support for PAPI 5.4.x. + +----------------- +* Changes in 4.2: +----------------- + - Fixed an issue with OpenMP pragma for flush_cache. + Reported by Sudheer Kumar . + - Fixed a bug in Makefile generation (utilities/makefile-gen.pl). + Reported by Willy Wolff . + - Fixed a bug in syr2k that caused the kernel to perform twice the work. + It was computing the full symmetric output whereas the BLAS version + only computes one side of the symmetry. + - Input generation for some of the kernels has been updated to produce + fewer zeros in output. + - Add support for inter-array padding when using heap allocation, + and adjust the allocation alignment with posix_memalign to 4096. + +----------------- +* Changes in 4.1: +----------------- + - Added LICENSE.txt + - Fixed a bug in documentation of cholesky. (Reported by François Gindraud) + - Removed two statements from cholesky, which were useless with inplace + memory allocation. (Reported by François Gindraud) + - Updated polybench.R in utilities to match the change in input generation + of lu/ludcmp/cholesky. + - Simplified the macros for switching between data types. + - Now users may specify DATA_TYPE_IS_XXX where XXX is one of + FLOAT/DOUBLE/INT to change all macros associated with data types. + - Fixed a typo in Jacobi-1d loop iterators. + - Fixed issues with SCALAR_VAL macro in some kernels. + (Reported by Sven Verdoolaege) + - Fixed a typo in POLYBENCH_GFLOPS system. + +----------------- +* Changes in 4.0: +----------------- + +This is a detailed ChangeLog for PolyBench/C 4.0 to indicate all +changes made from version 3.2. Due to the high number of changes, +users should be warned the baseline performance of kernels available +in both PolyBench/C 3.2 and 4.0 may differ. + + += General + - tuned the initialization functions to reduce the possibility to have 'inf' + in outputs. Specifically, the initial values are much closer to 1 for most + linear algebra kernels now (was up to N in prior versions). + - changed the name of predefined problem sizes STANDARD to MEDIUM. + - changed the default dataset to LARGE. + - added a few perl scripts to utilities. + - replaced create_cpped_version.sh with a perl script. + - fixed a bug in polybench.h when 4D arrays were allocated. (extra comma) + (Reported by Amarin Phaosawasdi) + - added polybench.pdf as a documentation of all kernels and its + underlying algorithms + - added POLYBENCH_USE_RESTRICT to allow compilers to assume alias-free + (Patch by Tobias Grosser) + - added SCALAR_VAL, SQRT_FUN, EXP_FUN, and POW_FUN macros to switch + float/double versions of the math functions depending on the data type. + - changed naming of a variable in polybench.c/xmalloc to avoid + issues when compiled as C++ (Reported by Sven Verdoolaege) + - changed the outputs produced by POLYBENCH_DUMP_ARRAYS option to + separately print out each array. + - added polybench.R in utilities which defines datamining and + linear-algebra kernels using R script for testing. + += Datamining + - fixed a bug in covariance where array size and loop bounds did not + match each other, causing out-of-bounds for certain parameters. + (Reported by Tobias Grosser) + - fixed a bug in covariance where division by N at the end was missing. + - fixed the initialization of float_n in covariance and correlation. The value + is supposed to be the input size N casted as floats to be used in division, + but was initialized to 1.2. + - changed the name of array 'symmat' in covariance to 'cov'. + - changed the name of array 'symmat' in correlation to 'corr'. + - changed the loop indices in covariance and correlation to match + the documentation. + - removed sqrt_of_array_cell macro from correlation + += Linear Algebra + - fixed a bug in 2mm where array sizes did not match each other, causing + out-of-bounds for non-square inputs. + (Reported by Tobias Grosser) + - fixed a bug in syrk where the loop bounds were incorrect, having + rectangular loop instead of triangular. + - fixed a bug in trmm where loop bounds were incorrect, using the wrong + triangular region in the multiplication. + - reduced the size of 'sum' array in doitgen from 3D to 1D to avoid obvious + waste in memory. + - removed A from print_arrays in gramschmidt; A is updated, but is + not an output. + - removed dynprog; replaced by nussinov in medley. + - moved BLAS kernels (including updated BLAS) to its own sub-category. + - BLAS kernels are now commented with the parameters in original BLAS + which corresponds to the implementation in PolyBench. + - BLAS kernels now closely matches the original version. However, gemver and + gesummv remains the same as it is not part of current BLAS. + - moved cholesky and trisolv to solvers. + - re-implemented cholesky so that it computes the full L + inplace. Previously the diagonal was stored in a separate vector. + - re-implemented durbin to match Durbin's algorithm from a book. There were + off-by-one errors and an excessive memory allocation (due to expanding + accumulation of a summation). + - re-implemented lu. The original implementation was missing a inner most + loop for computing the U matrix. + - re-implemented ludcmp. There were off-by-one errors leading to + incorrect outputs. + - lu and ludcmp now use same input as cholesky to ensure it works. + - input of cholesky/lu/ludcmp now uses L.L^T instead of L^T.L to + create inputs. + - loop bounds of symm/syrk/syr2k/trmm are changed to match the documentation. + += Medley + - changed default datatype of floyd_warshall from double to int. + - removed reg_detect; replaced by deriche. + - added nussinov; a dynamic programming algorithm for sequence alignment. + (Code by Dave Wonnacott and his students) + - added deriche; edge detector filter. + (Code by Gael Deest) + += Stencils + - re-implemented adi based on a figure in "Automatic Data and + Computation Decomposition on Distributed Memory Parallel + Computers" by Peizong Lee and Zvi Meir Kedem, TOPLAS, 2002 + - removed fdtd-apml; replaced by heat-3d + - added heat-3d; Heat equation over 3D data domain (4D iteration space) + (Original specification from Pochoir compiler test case) + - changed jacobi-1d-imper and jacobi-2d-imper to jacobi-1d and + jacobi-2d, respectively. + - jacobi-1d, jacobi-2d, and heat-3d performs two time steps using + alternating arrays per an iteration of the outermost loop. This is + to avoid the copy loop in the old xxx-imper versions. The number + of stencil iterations are now restricted to be even numbers (2x of + the parameter TSTEPS). + += Known Issues + - output of correlation will always be mostly 1.0 due to how the input + is generated. It is difficult to avoid this case when the input + is some function of the indices, and will be addressed with more + fundamental update in the future. diff --git a/datasets/PolyBenchC/LICENSE.txt b/datasets/PolyBenchC/LICENSE.txt new file mode 100644 index 0000000..eebcab6 --- /dev/null +++ b/datasets/PolyBenchC/LICENSE.txt @@ -0,0 +1,51 @@ +OHIO STATE UNIVERSITY SOFTWARE DISTRIBUTION LICENSE + +PolyBench/C, a collection of benchmarks containing static control +parts (the “Software”) +Copyright (c) 2010-2016, Ohio State University. All rights reserved. + +The Software is available for download and use subject to the terms +and conditions of this License. Access or use of the Software +constitutes acceptance and agreement to the terms and conditions of +this License. Redistribution and use of the Software in source and +binary forms, with or without modification, are permitted provided +that the following conditions are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the capitalized paragraph below. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the capitalized paragraph below in +the documentation and/or other materials provided with the +distribution. + +3. The name of Ohio State University, or its faculty, staff or +students may not be used to endorse or promote products derived from +the Software without specific prior written permission. + +This software was produced with support from the U.S. Defense Advanced +Research Projects Agency (DARPA), the U.S. Department of Energy (DoE) +and the U.S. National Science Foundation. Nothing in this work should +be construed as reflecting the official policy or position of the +Defense Department, the United States government or Ohio State +University. + +THIS SOFTWARE HAS BEEN APPROVED FOR PUBLIC RELEASE, UNLIMITED +DISTRIBUTION. THE SOFTWARE IS PROVIDED “AS IS” AND WITHOUT ANY +EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, WARRANTIES OF ACCURACY, COMPLETENESS, NONINFRINGEMENT, +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +ACCESS OR USE OF THE SOFTWARE IS ENTIRELY AT THE USER’S RISK. IN NO +EVENT SHALL OHIO STATE UNIVERSITY OR ITS FACULTY, STAFF OR STUDENTS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE SOFTWARE USER SHALL +INDEMNIFY, DEFEND AND HOLD HARMLESS OHIO STATE UNIVERSITY AND ITS +FACULTY, STAFF AND STUDENTS FROM ANY AND ALL CLAIMS, ACTIONS, DAMAGES, +LOSSES, LIABILITIES, COSTS AND EXPENSES, INCLUDING ATTORNEYS’ FEES AND +COURT COSTS, DIRECTLY OR INDIRECTLY ARISING OUT OF OR IN CONNECTION +WITH ACCESS OR USE OF THE SOFTWARE. diff --git a/datasets/PolyBenchC/README b/datasets/PolyBenchC/README new file mode 100644 index 0000000..8b9955a --- /dev/null +++ b/datasets/PolyBenchC/README @@ -0,0 +1,363 @@ +* * * * * * * * * * * * * * * +* PolyBench/C 4.2.1 (beta) * +* * * * * * * * * * * * * * * + +Copyright (c) 2011-2016 the Ohio State University. + +Contact: + Louis-Noel Pouchet + Tomofumi Yuki + + +PolyBench is a benchmark suite of 30 numerical computations with +static control flow, extracted from operations in various application +domains (linear algebra computations, image processing, physics +simulation, dynamic programming, statistics, etc.). PolyBench features +include: +- A single file, tunable at compile-time, used for the kernel + instrumentation. It performs extra operations such as cache flushing + before the kernel execution, and can set real-time scheduling to + prevent OS interference. +- Non-null data initialization, and live-out data dump. +- Syntactic constructs to prevent any dead code elimination on the kernel. +- Parametric loop bounds in the kernels, for general-purpose implementation. +- Clear kernel marking, using pragma-based delimiters. + + +PolyBench is currently available in C and in Fortran: +- See PolyBench/C 4.2.1 for the C version +- See PolyBench/Fortran 1.0 for the Fortran version (based on PolyBench/C 3.2) + +Available benchmarks (PolyBench/C 4.2.1) + +Benchmark Description +2mm 2 Matrix Multiplications (alpha * A * B * C + beta * D) +3mm 3 Matrix Multiplications ((A*B)*(C*D)) +adi Alternating Direction Implicit solver +atax Matrix Transpose and Vector Multiplication +bicg BiCG Sub Kernel of BiCGStab Linear Solver +cholesky Cholesky Decomposition +correlation Correlation Computation +covariance Covariance Computation +deriche Edge detection filter +doitgen Multi-resolution analysis kernel (MADNESS) +durbin Toeplitz system solver +fdtd-2d 2-D Finite Different Time Domain Kernel +gemm Matrix-multiply C=alpha.A.B+beta.C +gemver Vector Multiplication and Matrix Addition +gesummv Scalar, Vector and Matrix Multiplication +gramschmidt Gram-Schmidt decomposition +head-3d Heat equation over 3D data domain +jacobi-1D 1-D Jacobi stencil computation +jacobi-2D 2-D Jacobi stencil computation +lu LU decomposition +ludcmp LU decomposition followed by Forward Substitution +mvt Matrix Vector Product and Transpose +nussinov Dynamic programming algorithm for sequence alignment +seidel 2-D Seidel stencil computation +symm Symmetric matrix-multiply +syr2k Symmetric rank-2k update +syrk Symmetric rank-k update +trisolv Triangular solver +trmm Triangular matrix-multiply + + +See the end of the README for mailing lists, instructions to use +PolyBench, etc. + +-------------------- +* New in 4.2.1-beta: +-------------------- + - Fix a bug in PAPI support, introduced in 4.2 + - Support PAPI 5.4.x + +------------- +* New in 4.2: +------------- + - Fixed a bug in syr2k. + - Changed the data initialization function of several benchmarks. + - Minor updates in the documentation and PolyBench API. + +------------- +* New in 4.1: +------------- + - Added LICENSE.txt + - Fixed minor issues with cholesky both in documentation and implementation. + (Reported by François Gindraud) + - Simplified the macros for switching between data types. Now users + may specify DATA_TYPE_IS_XXX where XXX is one of FLOAT/DOUBLE/INT + to change all macros associated with data types. + +------------- +* New in 4.0a: +------------- + - Fixed a bug in jacobi-1d (Reported by Sven Verdoolaege) + +------------- +* New in 4.0: +------------- + +This update includes many changes. Please see CHANGELOG for detailed +list of changes. Most of the benchmarks have been edited/modified by +Tomofumi Yuki, thanks to the feedback we have received by PolyBench +users for the past few years. + +- Three benchmarks are out: dynprog, reg-detect, fdtd-apml. +- Three benchmarks are in: nussinov, deriche, heat-3d. +- Jacobi-1D and Jacobi-2D perform two time steps in one time loop + iteration alternating the source and target fields, to avoid the + field copy statement. +- Almost all benchmarks have been edited to ensure the computation + result matches the mathematical specification of the operation. +- A major effort on documentation and harmonization of problem sizes + and data allocations schemes. + +* Important Note: +----------------- + +PolyBench/C 3.2 kernels had numerous implementation errors making +their outputs to not match what is expected from the mathematical +specification of the operation. Many of them did not influence the +program behavior (e.g., the number and type of operations, data +dependences, and overall control-flow was similar to the corrected +implementation), however, some had non-negligible impact. These are +described below. + + - adi: There was an off-by-one error, which made back substitution + part of a pass in ADI to not depend on the forward pass, making the + program fully tilable. +- syrk: A typo on the loop bounds made the iteration space rectangular + instead of triangular. This has led to additional dependences and + two times more operations than intended. +- trmm: A typo on the loop bounds led to the wrong half of the matrix + being used in the computation. This led to additional dependences, + making it harder to parallelize this kernel. +- lu: An innermost loop was missing for the operation to be valid on + general matrices. This cause the kernel to perform about half the + work compared to a general implementation of LU decomposition. The + new implementation is the generic LU decomposition. + +In addition, some of the kernels used "high-footprint" memory allocation for +easier parallelization, where variables used in accumulation were fully +expanded. These variables were changed to only use a scalar. + + +------------- +* New in 3.2: +------------- + +- Rename the package to PolyBench/C, to prepare for the upcoming + PolyBench/Fortran and PolyBench/GPU. +- Fixed a typo in polybench.h, causing compilation problems for 5D arrays. +- Fixed minor typos in correlation, atax, cholesky, fdtd-2d. +- Added an option to build the test suite with constant loop bounds + (default is parametric loop bounds) + +------------- +* New in 3.1: +------------- + +- Fixed a typo in polybench.h, causing compilation problems for 3D arrays. +- Set by default heap arrays, stack arrays are now optional. + +------------- +* New in 3.0: +------------- + +- Multiple dataset sizes are predefined. Each file comes now with a .h + header file defining the dataset. +- Support of heap-allocated arrays. It uses a single malloc for the + entire array region, the data allocated is cast into a C99 + multidimensional array. +- One benchmark is out: gauss_filter +- One benchmark is in: floyd-warshall +- PAPI support has been greatly improved; it also can report the + counters on a specific core to be set by the user. + + + +---------------- +* Mailing lists: +---------------- + +** polybench-announces@lists.sourceforge.net: +--------------------------------------------- + +Announces about releases of PolyBench. + +** polybench-discussion@lists.sourceforge.net: +---------------------------------------------- + +General discussions reg. PolyBench. + + + +----------------------- +* Available benchmarks: +----------------------- + +See utilities/benchmark_list for paths to each files. +See doc/polybench.pdf for detailed description of the algorithms. + + + +------------------------------ +* Sample compilation commands: +------------------------------ + +** To compile a benchmark without any monitoring: +------------------------------------------------- + +$> gcc -I utilities -I linear-algebra/kernels/atax utilities/polybench.c linear-algebra/kernels/atax/atax.c -o atax_base + + +** To compile a benchmark with execution time reporting: +-------------------------------------------------------- + +$> gcc -O3 -I utilities -I linear-algebra/kernels/atax utilities/polybench.c linear-algebra/kernels/atax/atax.c -DPOLYBENCH_TIME -o atax_time + + +** To generate the reference output of a benchmark: +--------------------------------------------------- + +$> gcc -O0 -I utilities -I linear-algebra/kernels/atax utilities/polybench.c linear-algebra/kernels/atax/atax.c -DPOLYBENCH_DUMP_ARRAYS -o atax_ref +$> ./atax_ref 2>atax_ref.out + + + +------------------------- +* Some available options: +------------------------- + +They are all passed as macro definitions during compilation time (e.g, +-Dname_of_the_option). + +** Typical options: +------------------- + +- POLYBENCH_TIME: output execution time (gettimeofday) [default: off] + +- MINI_DATASET, SMALL_DATASET, MEDIUM_DATASET, LARGE_DATASET, + EXTRALARGE_DATASET: set the dataset size to be used + [default: STANDARD_DATASET] + +- POLYBENCH_DUMP_ARRAYS: dump all live-out arrays on stderr [default: off] + +- POLYBENCH_STACK_ARRAYS: use stack allocation instead of malloc [default: off] + + +** Options that may lead to better performance: +----------------------------------------------- + +- POLYBENCH_USE_RESTRICT: Use restrict keyword to allow compilers to + assume absence of aliasing. [default: off] + +- POLYBENCH_USE_SCALAR_LB: Use scalar loop bounds instead of parametric ones. + [default: off] + +- POLYBENCH_PADDING_FACTOR: Pad all dimensions of all arrays by this + value [default: 0] + +- POLYBENCH_INTER_ARRAY_PADDING_FACTOR: Offset the starting address of + polybench arrays allocated on the heap (default) by a multiple of + this value [default: 0] + +- POLYBENCH_USE_C99_PROTO: Use standard C99 prototype for the functions. + [default: off] + + +** Timing/profiling options: +---------------------------- + +- POLYBENCH_PAPI: turn on papi timing (see below). + +- POLYBENCH_CACHE_SIZE_KB: cache size to flush, in kB [default: 33MB] + +- POLYBENCH_NO_FLUSH_CACHE: don't flush the cache before calling the + timer [default: flush the cache] + +- POLYBENCH_CYCLE_ACCURATE_TIMER: Use Time Stamp Counter to monitor + the execution time of the kernel [default: off] + +- POLYBENCH_LINUX_FIFO_SCHEDULER: use FIFO real-time scheduler for the + kernel execution, the program must be run as root, under linux only, + and compiled with -lc [default: off] + + + +--------------- +* PAPI support: +--------------- + +** To compile a benchmark with PAPI support: +-------------------------------------------- + +$> gcc -O3 -I utilities -I linear-algebra/kernels/atax utilities/polybench.c linear-algebra/kernels/atax/atax.c -DPOLYBENCH_PAPI -lpapi -o atax_papi + + +** To specify which counter(s) to monitor: +------------------------------------------ + +Edit utilities/papi_counters.list, and add 1 line per event to +monitor. Each line (including the last one) must finish with a ',' and +both native and standard events are supported. + +The whole kernel is run one time per counter (no multiplexing) and +there is no sampling being used for the counter value. + + + +------------------------------ +* Accurate performance timing: +------------------------------ + +With kernels that have an execution time in the orders of a few tens +of milliseconds, it is critical to validate any performance number by +repeating several times the experiment. A companion script is +available to perform reasonable performance measurement of a PolyBench. + +$> gcc -O3 -I utilities -I linear-algebra/kernels/atax utilities/polybench.c linear-algebra/kernels/atax/atax.c -DPOLYBENCH_TIME -o atax_time +$> ./utilities/time_benchmark.sh ./atax_time + +This script will run five times the benchmark (that must be a +PolyBench compiled with -DPOLYBENCH_TIME), eliminate the two extremal +times, and check that the deviation of the three remaining does not +exceed a given threshold, set to 5%. + +It is also possible to use POLYBENCH_CYCLE_ACCURATE_TIMER to use the +Time Stamp Counter instead of gettimeofday() to monitor the number of +elapsed cycles. + + + +---------------------------------------- +* Generating macro-free benchmark suite: +---------------------------------------- + +(from the root of the archive:) +$> PARGS="-I utilities -DPOLYBENCH_TIME"; +$> for i in `cat utilities/benchmark_list`; do perl utilities/create_cpped_version.pl $i "$PARGS"; done + +This create for each benchmark file 'xxx.c' a new file +'xxx.preproc.c'. The PARGS variable in the above example can be set to +the desired configuration, for instance to create a full C99 version +(parametric arrays): + +$> PARGS="-I utilities -DPOLYBENCH_USE_C99_PROTO"; +$> for i in `cat utilities/benchmark_list`; do perl utilities/create_cpped_version.pl $i "$PARGS"; done + + + +------------------ +* Utility scripts: +------------------ +create_cpped_version.pl: Used in the above for generating macro free version. + +makefile-gen.pl: generates make files in each directory. Options are globally + configurable through config.mk at polybench root. + header-gen.pl: refers to 'polybench.spec' file and generates header in + each directory. Allows default problem sizes and datatype to + be configured without going into each header file. + + run-all.pl: compiles and runs each kernel. + clean.pl: runs make clean in each directory and then removes Makefile. diff --git a/datasets/PolyBenchC/THANKS b/datasets/PolyBenchC/THANKS new file mode 100644 index 0000000..2a67980 --- /dev/null +++ b/datasets/PolyBenchC/THANKS @@ -0,0 +1,20 @@ +We would like to thank the following people for giving reporting bugs and +giving feedback to PolyBench: + * François Gindraud + * Tobias Grosser + * Guillaume Iooss + * Peng Li + * Sanjay Rajopadhye + * Sven Verdoolaege + * Willy Wolff + +and the following for providing reference C implementations: + * Dave Wonnacott, Haverford College + The nussinov implementation was provided by Dave with the help of + - Allison Lake + - Ting Zhou + - Tian Jin + based on algorithm by Nussinov, described in Allison Lake's senior thesis. + + * Gael Deest, University of Rennes 1 + The Deriche filter implementation was provided by Gael. diff --git a/datasets/PolyBenchC/datamining/correlation/correlation.c b/datasets/PolyBenchC/datamining/correlation/correlation.c new file mode 100644 index 0000000..6e81435 --- /dev/null +++ b/datasets/PolyBenchC/datamining/correlation/correlation.c @@ -0,0 +1,168 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* correlation.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "correlation.h" + + +/* Array initialization. */ +static +void init_array (int m, + int n, + DATA_TYPE *float_n, + DATA_TYPE POLYBENCH_2D(data,N,M,n,m)) +{ + int i, j; + + *float_n = (DATA_TYPE)N; + + for (i = 0; i < N; i++) + for (j = 0; j < M; j++) + data[i][j] = (DATA_TYPE)(i*j)/M + i; + +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int m, + DATA_TYPE POLYBENCH_2D(corr,M,M,m,m)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("corr"); + for (i = 0; i < m; i++) + for (j = 0; j < m; j++) { + if ((i * m + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, corr[i][j]); + } + POLYBENCH_DUMP_END("corr"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_correlation(int m, int n, + DATA_TYPE float_n, + DATA_TYPE POLYBENCH_2D(data,N,M,n,m), + DATA_TYPE POLYBENCH_2D(corr,M,M,m,m), + DATA_TYPE POLYBENCH_1D(mean,M,m), + DATA_TYPE POLYBENCH_1D(stddev,M,m)) +{ + int i, j, k; + + DATA_TYPE eps = SCALAR_VAL(0.1); + + +#pragma scop + for (j = 0; j < _PB_M; j++) + { + mean[j] = SCALAR_VAL(0.0); + for (i = 0; i < _PB_N; i++) + mean[j] += data[i][j]; + mean[j] /= float_n; + } + + + for (j = 0; j < _PB_M; j++) + { + stddev[j] = SCALAR_VAL(0.0); + for (i = 0; i < _PB_N; i++) + stddev[j] += (data[i][j] - mean[j]) * (data[i][j] - mean[j]); + stddev[j] /= float_n; + stddev[j] = SQRT_FUN(stddev[j]); + /* The following in an inelegant but usual way to handle + near-zero std. dev. values, which below would cause a zero- + divide. */ + stddev[j] = stddev[j] <= eps ? SCALAR_VAL(1.0) : stddev[j]; + } + + /* Center and reduce the column vectors. */ + for (i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_M; j++) + { + data[i][j] -= mean[j]; + data[i][j] /= SQRT_FUN(float_n) * stddev[j]; + } + + /* Calculate the m * m correlation matrix. */ + for (i = 0; i < _PB_M-1; i++) + { + corr[i][i] = SCALAR_VAL(1.0); + for (j = i+1; j < _PB_M; j++) + { + corr[i][j] = SCALAR_VAL(0.0); + for (k = 0; k < _PB_N; k++) + corr[i][j] += (data[k][i] * data[k][j]); + corr[j][i] = corr[i][j]; + } + } + corr[_PB_M-1][_PB_M-1] = SCALAR_VAL(1.0); +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int m = M; + + /* Variable declaration/allocation. */ + DATA_TYPE float_n; + POLYBENCH_2D_ARRAY_DECL(data,DATA_TYPE,N,M,n,m); + POLYBENCH_2D_ARRAY_DECL(corr,DATA_TYPE,M,M,m,m); + POLYBENCH_1D_ARRAY_DECL(mean,DATA_TYPE,M,m); + POLYBENCH_1D_ARRAY_DECL(stddev,DATA_TYPE,M,m); + + /* Initialize array(s). */ + init_array (m, n, &float_n, POLYBENCH_ARRAY(data)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_correlation (m, n, float_n, + POLYBENCH_ARRAY(data), + POLYBENCH_ARRAY(corr), + POLYBENCH_ARRAY(mean), + POLYBENCH_ARRAY(stddev)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(corr))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(data); + POLYBENCH_FREE_ARRAY(corr); + POLYBENCH_FREE_ARRAY(mean); + POLYBENCH_FREE_ARRAY(stddev); + + return 0; +} diff --git a/datasets/PolyBenchC/datamining/correlation/correlation.h b/datasets/PolyBenchC/datamining/correlation/correlation.h new file mode 100644 index 0000000..f2660e2 --- /dev/null +++ b/datasets/PolyBenchC/datamining/correlation/correlation.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _CORRELATION_H +# define _CORRELATION_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 28 +# define N 32 +# endif + +# ifdef SMALL_DATASET +# define M 80 +# define N 100 +# endif + +# ifdef MEDIUM_DATASET +# define M 240 +# define N 260 +# endif + +# ifdef LARGE_DATASET +# define M 1200 +# define N 1400 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 2600 +# define N 3000 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_CORRELATION_H */ diff --git a/datasets/PolyBenchC/datamining/covariance/covariance.c b/datasets/PolyBenchC/datamining/covariance/covariance.c new file mode 100644 index 0000000..6c50a92 --- /dev/null +++ b/datasets/PolyBenchC/datamining/covariance/covariance.c @@ -0,0 +1,138 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* covariance.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "covariance.h" + + +/* Array initialization. */ +static +void init_array (int m, int n, + DATA_TYPE *float_n, + DATA_TYPE POLYBENCH_2D(data,N,M,n,m)) +{ + int i, j; + + *float_n = (DATA_TYPE)n; + + for (i = 0; i < N; i++) + for (j = 0; j < M; j++) + data[i][j] = ((DATA_TYPE) i*j) / M; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int m, + DATA_TYPE POLYBENCH_2D(cov,M,M,m,m)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("cov"); + for (i = 0; i < m; i++) + for (j = 0; j < m; j++) { + if ((i * m + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, cov[i][j]); + } + POLYBENCH_DUMP_END("cov"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_covariance(int m, int n, + DATA_TYPE float_n, + DATA_TYPE POLYBENCH_2D(data,N,M,n,m), + DATA_TYPE POLYBENCH_2D(cov,M,M,m,m), + DATA_TYPE POLYBENCH_1D(mean,M,m)) +{ + int i, j, k; + +#pragma scop + for (j = 0; j < _PB_M; j++) + { + mean[j] = SCALAR_VAL(0.0); + for (i = 0; i < _PB_N; i++) + mean[j] += data[i][j]; + mean[j] /= float_n; + } + + for (i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_M; j++) + data[i][j] -= mean[j]; + + for (i = 0; i < _PB_M; i++) + for (j = i; j < _PB_M; j++) + { + cov[i][j] = SCALAR_VAL(0.0); + for (k = 0; k < _PB_N; k++) + cov[i][j] += data[k][i] * data[k][j]; + cov[i][j] /= (float_n - SCALAR_VAL(1.0)); + cov[j][i] = cov[i][j]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int m = M; + + /* Variable declaration/allocation. */ + DATA_TYPE float_n; + POLYBENCH_2D_ARRAY_DECL(data,DATA_TYPE,N,M,n,m); + POLYBENCH_2D_ARRAY_DECL(cov,DATA_TYPE,M,M,m,m); + POLYBENCH_1D_ARRAY_DECL(mean,DATA_TYPE,M,m); + + + /* Initialize array(s). */ + init_array (m, n, &float_n, POLYBENCH_ARRAY(data)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_covariance (m, n, float_n, + POLYBENCH_ARRAY(data), + POLYBENCH_ARRAY(cov), + POLYBENCH_ARRAY(mean)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(cov))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(data); + POLYBENCH_FREE_ARRAY(cov); + POLYBENCH_FREE_ARRAY(mean); + + return 0; +} diff --git a/datasets/PolyBenchC/datamining/covariance/covariance.h b/datasets/PolyBenchC/datamining/covariance/covariance.h new file mode 100644 index 0000000..e35f895 --- /dev/null +++ b/datasets/PolyBenchC/datamining/covariance/covariance.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _COVARIANCE_H +# define _COVARIANCE_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 28 +# define N 32 +# endif + +# ifdef SMALL_DATASET +# define M 80 +# define N 100 +# endif + +# ifdef MEDIUM_DATASET +# define M 240 +# define N 260 +# endif + +# ifdef LARGE_DATASET +# define M 1200 +# define N 1400 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 2600 +# define N 3000 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_COVARIANCE_H */ diff --git a/datasets/PolyBenchC/linear-algebra/blas/gemm/gemm.c b/datasets/PolyBenchC/linear-algebra/blas/gemm/gemm.c new file mode 100644 index 0000000..bdbd33a --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/gemm/gemm.c @@ -0,0 +1,146 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* gemm.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "gemm.h" + + +/* Array initialization. */ +static +void init_array(int ni, int nj, int nk, + DATA_TYPE *alpha, + DATA_TYPE *beta, + DATA_TYPE POLYBENCH_2D(C,NI,NJ,ni,nj), + DATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nk), + DATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj)) +{ + int i, j; + + *alpha = 1.5; + *beta = 1.2; + for (i = 0; i < ni; i++) + for (j = 0; j < nj; j++) + C[i][j] = (DATA_TYPE) ((i*j+1) % ni) / ni; + for (i = 0; i < ni; i++) + for (j = 0; j < nk; j++) + A[i][j] = (DATA_TYPE) (i*(j+1) % nk) / nk; + for (i = 0; i < nk; i++) + for (j = 0; j < nj; j++) + B[i][j] = (DATA_TYPE) (i*(j+2) % nj) / nj; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int ni, int nj, + DATA_TYPE POLYBENCH_2D(C,NI,NJ,ni,nj)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("C"); + for (i = 0; i < ni; i++) + for (j = 0; j < nj; j++) { + if ((i * ni + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, C[i][j]); + } + POLYBENCH_DUMP_END("C"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_gemm(int ni, int nj, int nk, + DATA_TYPE alpha, + DATA_TYPE beta, + DATA_TYPE POLYBENCH_2D(C,NI,NJ,ni,nj), + DATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nk), + DATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj)) +{ + int i, j, k; + +//BLAS PARAMS +//TRANSA = 'N' +//TRANSB = 'N' +// => Form C := alpha*A*B + beta*C, +//A is NIxNK +//B is NKxNJ +//C is NIxNJ +#pragma scop + for (i = 0; i < _PB_NI; i++) { + for (j = 0; j < _PB_NJ; j++) + C[i][j] *= beta; + for (k = 0; k < _PB_NK; k++) { + for (j = 0; j < _PB_NJ; j++) + C[i][j] += alpha * A[i][k] * B[k][j]; + } + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int ni = NI; + int nj = NJ; + int nk = NK; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + DATA_TYPE beta; + POLYBENCH_2D_ARRAY_DECL(C,DATA_TYPE,NI,NJ,ni,nj); + POLYBENCH_2D_ARRAY_DECL(A,DATA_TYPE,NI,NK,ni,nk); + POLYBENCH_2D_ARRAY_DECL(B,DATA_TYPE,NK,NJ,nk,nj); + + /* Initialize array(s). */ + init_array (ni, nj, nk, &alpha, &beta, + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_gemm (ni, nj, nk, + alpha, beta, + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(ni, nj, POLYBENCH_ARRAY(C))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(C); + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/blas/gemm/gemm.h b/datasets/PolyBenchC/linear-algebra/blas/gemm/gemm.h new file mode 100644 index 0000000..0d18a0b --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/gemm/gemm.h @@ -0,0 +1,86 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _GEMM_H +# define _GEMM_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(NI) && !defined(NJ) && !defined(NK) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define NI 20 +# define NJ 25 +# define NK 30 +# endif + +# ifdef SMALL_DATASET +# define NI 60 +# define NJ 70 +# define NK 80 +# endif + +# ifdef MEDIUM_DATASET +# define NI 200 +# define NJ 220 +# define NK 240 +# endif + +# ifdef LARGE_DATASET +# define NI 1000 +# define NJ 1100 +# define NK 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define NI 2000 +# define NJ 2300 +# define NK 2600 +# endif + + +#endif /* !(NI NJ NK) */ + +# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni) +# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj) +# define _PB_NK POLYBENCH_LOOP_BOUND(NK,nk) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_GEMM_H */ diff --git a/datasets/PolyBenchC/linear-algebra/blas/gemver/gemver.c b/datasets/PolyBenchC/linear-algebra/blas/gemver/gemver.c new file mode 100644 index 0000000..a8008a8 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/gemver/gemver.c @@ -0,0 +1,186 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* gemver.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "gemver.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE *alpha, + DATA_TYPE *beta, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n), + DATA_TYPE POLYBENCH_1D(u1,N,n), + DATA_TYPE POLYBENCH_1D(v1,N,n), + DATA_TYPE POLYBENCH_1D(u2,N,n), + DATA_TYPE POLYBENCH_1D(v2,N,n), + DATA_TYPE POLYBENCH_1D(w,N,n), + DATA_TYPE POLYBENCH_1D(x,N,n), + DATA_TYPE POLYBENCH_1D(y,N,n), + DATA_TYPE POLYBENCH_1D(z,N,n)) +{ + int i, j; + + *alpha = 1.5; + *beta = 1.2; + + DATA_TYPE fn = (DATA_TYPE)n; + + for (i = 0; i < n; i++) + { + u1[i] = i; + u2[i] = ((i+1)/fn)/2.0; + v1[i] = ((i+1)/fn)/4.0; + v2[i] = ((i+1)/fn)/6.0; + y[i] = ((i+1)/fn)/8.0; + z[i] = ((i+1)/fn)/9.0; + x[i] = 0.0; + w[i] = 0.0; + for (j = 0; j < n; j++) + A[i][j] = (DATA_TYPE) (i*j % n) / n; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_1D(w,N,n)) +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("w"); + for (i = 0; i < n; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, w[i]); + } + POLYBENCH_DUMP_END("w"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_gemver(int n, + DATA_TYPE alpha, + DATA_TYPE beta, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n), + DATA_TYPE POLYBENCH_1D(u1,N,n), + DATA_TYPE POLYBENCH_1D(v1,N,n), + DATA_TYPE POLYBENCH_1D(u2,N,n), + DATA_TYPE POLYBENCH_1D(v2,N,n), + DATA_TYPE POLYBENCH_1D(w,N,n), + DATA_TYPE POLYBENCH_1D(x,N,n), + DATA_TYPE POLYBENCH_1D(y,N,n), + DATA_TYPE POLYBENCH_1D(z,N,n)) +{ + int i, j; + +#pragma scop + + for (i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_N; j++) + A[i][j] = A[i][j] + u1[i] * v1[j] + u2[i] * v2[j]; + + for (i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_N; j++) + x[i] = x[i] + beta * A[j][i] * y[j]; + + for (i = 0; i < _PB_N; i++) + x[i] = x[i] + z[i]; + + for (i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_N; j++) + w[i] = w[i] + alpha * A[i][j] * x[j]; + +#pragma endscop +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + DATA_TYPE beta; + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n); + POLYBENCH_1D_ARRAY_DECL(u1, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(v1, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(u2, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(v2, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(w, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(x, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(y, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(z, DATA_TYPE, N, n); + + + /* Initialize array(s). */ + init_array (n, &alpha, &beta, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(u1), + POLYBENCH_ARRAY(v1), + POLYBENCH_ARRAY(u2), + POLYBENCH_ARRAY(v2), + POLYBENCH_ARRAY(w), + POLYBENCH_ARRAY(x), + POLYBENCH_ARRAY(y), + POLYBENCH_ARRAY(z)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_gemver (n, alpha, beta, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(u1), + POLYBENCH_ARRAY(v1), + POLYBENCH_ARRAY(u2), + POLYBENCH_ARRAY(v2), + POLYBENCH_ARRAY(w), + POLYBENCH_ARRAY(x), + POLYBENCH_ARRAY(y), + POLYBENCH_ARRAY(z)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(w))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(u1); + POLYBENCH_FREE_ARRAY(v1); + POLYBENCH_FREE_ARRAY(u2); + POLYBENCH_FREE_ARRAY(v2); + POLYBENCH_FREE_ARRAY(w); + POLYBENCH_FREE_ARRAY(x); + POLYBENCH_FREE_ARRAY(y); + POLYBENCH_FREE_ARRAY(z); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/blas/gemver/gemver.h b/datasets/PolyBenchC/linear-algebra/blas/gemver/gemver.h new file mode 100644 index 0000000..a0abdd0 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/gemver/gemver.h @@ -0,0 +1,74 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _GEMVER_H +# define _GEMVER_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 40 +# endif + +# ifdef SMALL_DATASET +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 4000 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_GEMVER_H */ diff --git a/datasets/PolyBenchC/linear-algebra/blas/gesummv/gesummv.c b/datasets/PolyBenchC/linear-algebra/blas/gesummv/gesummv.c new file mode 100644 index 0000000..c5e2cd6 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/gesummv/gesummv.c @@ -0,0 +1,147 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* gesummv.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "gesummv.h" + + +/* Array initialization. */ +static +void init_array(int n, + DATA_TYPE *alpha, + DATA_TYPE *beta, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n), + DATA_TYPE POLYBENCH_2D(B,N,N,n,n), + DATA_TYPE POLYBENCH_1D(x,N,n)) +{ + int i, j; + + *alpha = 1.5; + *beta = 1.2; + for (i = 0; i < n; i++) + { + x[i] = (DATA_TYPE)( i % n) / n; + for (j = 0; j < n; j++) { + A[i][j] = (DATA_TYPE) ((i*j+1) % n) / n; + B[i][j] = (DATA_TYPE) ((i*j+2) % n) / n; + } + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_1D(y,N,n)) + +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("y"); + for (i = 0; i < n; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, y[i]); + } + POLYBENCH_DUMP_END("y"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_gesummv(int n, + DATA_TYPE alpha, + DATA_TYPE beta, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n), + DATA_TYPE POLYBENCH_2D(B,N,N,n,n), + DATA_TYPE POLYBENCH_1D(tmp,N,n), + DATA_TYPE POLYBENCH_1D(x,N,n), + DATA_TYPE POLYBENCH_1D(y,N,n)) +{ + int i, j; + +#pragma scop + for (i = 0; i < _PB_N; i++) + { + tmp[i] = SCALAR_VAL(0.0); + y[i] = SCALAR_VAL(0.0); + for (j = 0; j < _PB_N; j++) + { + tmp[i] = A[i][j] * x[j] + tmp[i]; + y[i] = B[i][j] * x[j] + y[i]; + } + y[i] = alpha * tmp[i] + beta * y[i]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + DATA_TYPE beta; + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n); + POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, N, N, n, n); + POLYBENCH_1D_ARRAY_DECL(tmp, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(x, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(y, DATA_TYPE, N, n); + + + /* Initialize array(s). */ + init_array (n, &alpha, &beta, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B), + POLYBENCH_ARRAY(x)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_gesummv (n, alpha, beta, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B), + POLYBENCH_ARRAY(tmp), + POLYBENCH_ARRAY(x), + POLYBENCH_ARRAY(y)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(y))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + POLYBENCH_FREE_ARRAY(tmp); + POLYBENCH_FREE_ARRAY(x); + POLYBENCH_FREE_ARRAY(y); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/blas/gesummv/gesummv.h b/datasets/PolyBenchC/linear-algebra/blas/gesummv/gesummv.h new file mode 100644 index 0000000..64285d8 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/gesummv/gesummv.h @@ -0,0 +1,74 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _GESUMMV_H +# define _GESUMMV_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 30 +# endif + +# ifdef SMALL_DATASET +# define N 90 +# endif + +# ifdef MEDIUM_DATASET +# define N 250 +# endif + +# ifdef LARGE_DATASET +# define N 1300 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 2800 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_GESUMMV_H */ diff --git a/datasets/PolyBenchC/linear-algebra/blas/symm/symm.c b/datasets/PolyBenchC/linear-algebra/blas/symm/symm.c new file mode 100644 index 0000000..0cab754 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/symm/symm.c @@ -0,0 +1,151 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* symm.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "symm.h" + + +/* Array initialization. */ +static +void init_array(int m, int n, + DATA_TYPE *alpha, + DATA_TYPE *beta, + DATA_TYPE POLYBENCH_2D(C,M,N,m,n), + DATA_TYPE POLYBENCH_2D(A,M,M,m,m), + DATA_TYPE POLYBENCH_2D(B,M,N,m,n)) +{ + int i, j; + + *alpha = 1.5; + *beta = 1.2; + for (i = 0; i < m; i++) + for (j = 0; j < n; j++) { + C[i][j] = (DATA_TYPE) ((i+j) % 100) / m; + B[i][j] = (DATA_TYPE) ((n+i-j) % 100) / m; + } + for (i = 0; i < m; i++) { + for (j = 0; j <=i; j++) + A[i][j] = (DATA_TYPE) ((i+j) % 100) / m; + for (j = i+1; j < m; j++) + A[i][j] = -999; //regions of arrays that should not be used + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int m, int n, + DATA_TYPE POLYBENCH_2D(C,M,N,m,n)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("C"); + for (i = 0; i < m; i++) + for (j = 0; j < n; j++) { + if ((i * m + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, C[i][j]); + } + POLYBENCH_DUMP_END("C"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_symm(int m, int n, + DATA_TYPE alpha, + DATA_TYPE beta, + DATA_TYPE POLYBENCH_2D(C,M,N,m,n), + DATA_TYPE POLYBENCH_2D(A,M,M,m,m), + DATA_TYPE POLYBENCH_2D(B,M,N,m,n)) +{ + int i, j, k; + DATA_TYPE temp2; + +//BLAS PARAMS +//SIDE = 'L' +//UPLO = 'L' +// => Form C := alpha*A*B + beta*C +// A is MxM +// B is MxN +// C is MxN +//note that due to Fortran array layout, the code below more closely resembles upper triangular case in BLAS +#pragma scop + for (i = 0; i < _PB_M; i++) + for (j = 0; j < _PB_N; j++ ) + { + temp2 = 0; + for (k = 0; k < i; k++) { + C[k][j] += alpha*B[i][j] * A[i][k]; + temp2 += B[k][j] * A[i][k]; + } + C[i][j] = beta * C[i][j] + alpha*B[i][j] * A[i][i] + alpha * temp2; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int m = M; + int n = N; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + DATA_TYPE beta; + POLYBENCH_2D_ARRAY_DECL(C,DATA_TYPE,M,N,m,n); + POLYBENCH_2D_ARRAY_DECL(A,DATA_TYPE,M,M,m,m); + POLYBENCH_2D_ARRAY_DECL(B,DATA_TYPE,M,N,m,n); + + /* Initialize array(s). */ + init_array (m, n, &alpha, &beta, + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_symm (m, n, + alpha, beta, + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(m, n, POLYBENCH_ARRAY(C))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(C); + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/blas/symm/symm.h b/datasets/PolyBenchC/linear-algebra/blas/symm/symm.h new file mode 100644 index 0000000..8848b3d --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/symm/symm.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _SYMM_H +# define _SYMM_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 20 +# define N 30 +# endif + +# ifdef SMALL_DATASET +# define M 60 +# define N 80 +# endif + +# ifdef MEDIUM_DATASET +# define M 200 +# define N 240 +# endif + +# ifdef LARGE_DATASET +# define M 1000 +# define N 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 2000 +# define N 2600 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_SYMM_H */ diff --git a/datasets/PolyBenchC/linear-algebra/blas/syr2k/syr2k.c b/datasets/PolyBenchC/linear-algebra/blas/syr2k/syr2k.c new file mode 100644 index 0000000..3ce38bf --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/syr2k/syr2k.c @@ -0,0 +1,145 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* syr2k.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "syr2k.h" + + +/* Array initialization. */ +static +void init_array(int n, int m, + DATA_TYPE *alpha, + DATA_TYPE *beta, + DATA_TYPE POLYBENCH_2D(C,N,N,n,n), + DATA_TYPE POLYBENCH_2D(A,N,M,n,m), + DATA_TYPE POLYBENCH_2D(B,N,M,n,m)) +{ + int i, j; + + *alpha = 1.5; + *beta = 1.2; + for (i = 0; i < n; i++) + for (j = 0; j < m; j++) { + A[i][j] = (DATA_TYPE) ((i*j+1)%n) / n; + B[i][j] = (DATA_TYPE) ((i*j+2)%m) / m; + } + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + C[i][j] = (DATA_TYPE) ((i*j+3)%n) / m; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_2D(C,N,N,n,n)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("C"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + if ((i * n + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, C[i][j]); + } + POLYBENCH_DUMP_END("C"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_syr2k(int n, int m, + DATA_TYPE alpha, + DATA_TYPE beta, + DATA_TYPE POLYBENCH_2D(C,N,N,n,n), + DATA_TYPE POLYBENCH_2D(A,N,M,n,m), + DATA_TYPE POLYBENCH_2D(B,N,M,n,m)) +{ + int i, j, k; + +//BLAS PARAMS +//UPLO = 'L' +//TRANS = 'N' +//A is NxM +//B is NxM +//C is NxN +#pragma scop + for (i = 0; i < _PB_N; i++) { + for (j = 0; j <= i; j++) + C[i][j] *= beta; + for (k = 0; k < _PB_M; k++) + for (j = 0; j <= i; j++) + { + C[i][j] += A[j][k]*alpha*B[i][k] + B[j][k]*alpha*A[i][k]; + } + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int m = M; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + DATA_TYPE beta; + POLYBENCH_2D_ARRAY_DECL(C,DATA_TYPE,N,N,n,n); + POLYBENCH_2D_ARRAY_DECL(A,DATA_TYPE,N,M,n,m); + POLYBENCH_2D_ARRAY_DECL(B,DATA_TYPE,N,M,n,m); + + /* Initialize array(s). */ + init_array (n, m, &alpha, &beta, + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_syr2k (n, m, + alpha, beta, + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(C))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(C); + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/blas/syr2k/syr2k.h b/datasets/PolyBenchC/linear-algebra/blas/syr2k/syr2k.h new file mode 100644 index 0000000..7861bcd --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/syr2k/syr2k.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _SYR2K_H +# define _SYR2K_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 20 +# define N 30 +# endif + +# ifdef SMALL_DATASET +# define M 60 +# define N 80 +# endif + +# ifdef MEDIUM_DATASET +# define M 200 +# define N 240 +# endif + +# ifdef LARGE_DATASET +# define M 1000 +# define N 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 2000 +# define N 2600 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_SYR2K_H */ diff --git a/datasets/PolyBenchC/linear-algebra/blas/syrk/syrk.c b/datasets/PolyBenchC/linear-algebra/blas/syrk/syrk.c new file mode 100644 index 0000000..5a9b422 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/syrk/syrk.c @@ -0,0 +1,130 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* syrk.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "syrk.h" + + +/* Array initialization. */ +static +void init_array(int n, int m, + DATA_TYPE *alpha, + DATA_TYPE *beta, + DATA_TYPE POLYBENCH_2D(C,N,N,n,n), + DATA_TYPE POLYBENCH_2D(A,N,M,n,m)) +{ + int i, j; + + *alpha = 1.5; + *beta = 1.2; + for (i = 0; i < n; i++) + for (j = 0; j < m; j++) + A[i][j] = (DATA_TYPE) ((i*j+1)%n) / n; + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + C[i][j] = (DATA_TYPE) ((i*j+2)%m) / m; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_2D(C,N,N,n,n)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("C"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + if ((i * n + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, C[i][j]); + } + POLYBENCH_DUMP_END("C"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_syrk(int n, int m, + DATA_TYPE alpha, + DATA_TYPE beta, + DATA_TYPE POLYBENCH_2D(C,N,N,n,n), + DATA_TYPE POLYBENCH_2D(A,N,M,n,m)) +{ + int i, j, k; + +//BLAS PARAMS +//TRANS = 'N' +//UPLO = 'L' +// => Form C := alpha*A*A**T + beta*C. +//A is NxM +//C is NxN +#pragma scop + for (i = 0; i < _PB_N; i++) { + for (j = 0; j <= i; j++) + C[i][j] *= beta; + for (k = 0; k < _PB_M; k++) { + for (j = 0; j <= i; j++) + C[i][j] += alpha * A[i][k] * A[j][k]; + } + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int m = M; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + DATA_TYPE beta; + POLYBENCH_2D_ARRAY_DECL(C,DATA_TYPE,N,N,n,n); + POLYBENCH_2D_ARRAY_DECL(A,DATA_TYPE,N,M,n,m); + + /* Initialize array(s). */ + init_array (n, m, &alpha, &beta, POLYBENCH_ARRAY(C), POLYBENCH_ARRAY(A)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_syrk (n, m, alpha, beta, POLYBENCH_ARRAY(C), POLYBENCH_ARRAY(A)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(C))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(C); + POLYBENCH_FREE_ARRAY(A); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/blas/syrk/syrk.h b/datasets/PolyBenchC/linear-algebra/blas/syrk/syrk.h new file mode 100644 index 0000000..648fab3 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/syrk/syrk.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _SYRK_H +# define _SYRK_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 20 +# define N 30 +# endif + +# ifdef SMALL_DATASET +# define M 60 +# define N 80 +# endif + +# ifdef MEDIUM_DATASET +# define M 200 +# define N 240 +# endif + +# ifdef LARGE_DATASET +# define M 1000 +# define N 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 2000 +# define N 2600 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_SYRK_H */ diff --git a/datasets/PolyBenchC/linear-algebra/blas/trmm/trmm.c b/datasets/PolyBenchC/linear-algebra/blas/trmm/trmm.c new file mode 100644 index 0000000..5b8ab59 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/trmm/trmm.c @@ -0,0 +1,130 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* trmm.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "trmm.h" + + +/* Array initialization. */ +static +void init_array(int m, int n, + DATA_TYPE *alpha, + DATA_TYPE POLYBENCH_2D(A,M,M,m,m), + DATA_TYPE POLYBENCH_2D(B,M,N,m,n)) +{ + int i, j; + + *alpha = 1.5; + for (i = 0; i < m; i++) { + for (j = 0; j < i; j++) { + A[i][j] = (DATA_TYPE)((i+j) % m)/m; + } + A[i][i] = 1.0; + for (j = 0; j < n; j++) { + B[i][j] = (DATA_TYPE)((n+(i-j)) % n)/n; + } + } + +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int m, int n, + DATA_TYPE POLYBENCH_2D(B,M,N,m,n)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("B"); + for (i = 0; i < m; i++) + for (j = 0; j < n; j++) { + if ((i * m + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, B[i][j]); + } + POLYBENCH_DUMP_END("B"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_trmm(int m, int n, + DATA_TYPE alpha, + DATA_TYPE POLYBENCH_2D(A,M,M,m,m), + DATA_TYPE POLYBENCH_2D(B,M,N,m,n)) +{ + int i, j, k; + +//BLAS parameters +//SIDE = 'L' +//UPLO = 'L' +//TRANSA = 'T' +//DIAG = 'U' +// => Form B := alpha*A**T*B. +// A is MxM +// B is MxN +#pragma scop + for (i = 0; i < _PB_M; i++) + for (j = 0; j < _PB_N; j++) { + for (k = i+1; k < _PB_M; k++) + B[i][j] += A[k][i] * B[k][j]; + B[i][j] = alpha * B[i][j]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int m = M; + int n = N; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + POLYBENCH_2D_ARRAY_DECL(A,DATA_TYPE,M,M,m,m); + POLYBENCH_2D_ARRAY_DECL(B,DATA_TYPE,M,N,m,n); + + /* Initialize array(s). */ + init_array (m, n, &alpha, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_trmm (m, n, alpha, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(m, n, POLYBENCH_ARRAY(B))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/blas/trmm/trmm.h b/datasets/PolyBenchC/linear-algebra/blas/trmm/trmm.h new file mode 100644 index 0000000..b1eaea1 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/blas/trmm/trmm.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _TRMM_H +# define _TRMM_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 20 +# define N 30 +# endif + +# ifdef SMALL_DATASET +# define M 60 +# define N 80 +# endif + +# ifdef MEDIUM_DATASET +# define M 200 +# define N 240 +# endif + +# ifdef LARGE_DATASET +# define M 1000 +# define N 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 2000 +# define N 2600 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_TRMM_H */ diff --git a/datasets/PolyBenchC/linear-algebra/kernels/2mm/2mm.c b/datasets/PolyBenchC/linear-algebra/kernels/2mm/2mm.c new file mode 100644 index 0000000..a1b42ee --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/2mm/2mm.c @@ -0,0 +1,160 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* 2mm.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "2mm.h" + + +/* Array initialization. */ +static +void init_array(int ni, int nj, int nk, int nl, + DATA_TYPE *alpha, + DATA_TYPE *beta, + DATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nk), + DATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj), + DATA_TYPE POLYBENCH_2D(C,NJ,NL,nj,nl), + DATA_TYPE POLYBENCH_2D(D,NI,NL,ni,nl)) +{ + int i, j; + + *alpha = 1.5; + *beta = 1.2; + for (i = 0; i < ni; i++) + for (j = 0; j < nk; j++) + A[i][j] = (DATA_TYPE) ((i*j+1) % ni) / ni; + for (i = 0; i < nk; i++) + for (j = 0; j < nj; j++) + B[i][j] = (DATA_TYPE) (i*(j+1) % nj) / nj; + for (i = 0; i < nj; i++) + for (j = 0; j < nl; j++) + C[i][j] = (DATA_TYPE) ((i*(j+3)+1) % nl) / nl; + for (i = 0; i < ni; i++) + for (j = 0; j < nl; j++) + D[i][j] = (DATA_TYPE) (i*(j+2) % nk) / nk; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int ni, int nl, + DATA_TYPE POLYBENCH_2D(D,NI,NL,ni,nl)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("D"); + for (i = 0; i < ni; i++) + for (j = 0; j < nl; j++) { + if ((i * ni + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, D[i][j]); + } + POLYBENCH_DUMP_END("D"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_2mm(int ni, int nj, int nk, int nl, + DATA_TYPE alpha, + DATA_TYPE beta, + DATA_TYPE POLYBENCH_2D(tmp,NI,NJ,ni,nj), + DATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nk), + DATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj), + DATA_TYPE POLYBENCH_2D(C,NJ,NL,nj,nl), + DATA_TYPE POLYBENCH_2D(D,NI,NL,ni,nl)) +{ + int i, j, k; + +#pragma scop + /* D := alpha*A*B*C + beta*D */ + for (i = 0; i < _PB_NI; i++) + for (j = 0; j < _PB_NJ; j++) + { + tmp[i][j] = SCALAR_VAL(0.0); + for (k = 0; k < _PB_NK; ++k) + tmp[i][j] += alpha * A[i][k] * B[k][j]; + } + for (i = 0; i < _PB_NI; i++) + for (j = 0; j < _PB_NL; j++) + { + D[i][j] *= beta; + for (k = 0; k < _PB_NJ; ++k) + D[i][j] += tmp[i][k] * C[k][j]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int ni = NI; + int nj = NJ; + int nk = NK; + int nl = NL; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + DATA_TYPE beta; + POLYBENCH_2D_ARRAY_DECL(tmp,DATA_TYPE,NI,NJ,ni,nj); + POLYBENCH_2D_ARRAY_DECL(A,DATA_TYPE,NI,NK,ni,nk); + POLYBENCH_2D_ARRAY_DECL(B,DATA_TYPE,NK,NJ,nk,nj); + POLYBENCH_2D_ARRAY_DECL(C,DATA_TYPE,NJ,NL,nj,nl); + POLYBENCH_2D_ARRAY_DECL(D,DATA_TYPE,NI,NL,ni,nl); + + /* Initialize array(s). */ + init_array (ni, nj, nk, nl, &alpha, &beta, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B), + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(D)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_2mm (ni, nj, nk, nl, + alpha, beta, + POLYBENCH_ARRAY(tmp), + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B), + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(D)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(ni, nl, POLYBENCH_ARRAY(D))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(tmp); + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + POLYBENCH_FREE_ARRAY(C); + POLYBENCH_FREE_ARRAY(D); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/kernels/2mm/2mm.h b/datasets/PolyBenchC/linear-algebra/kernels/2mm/2mm.h new file mode 100644 index 0000000..1b0b3d5 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/2mm/2mm.h @@ -0,0 +1,92 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _2MM_H +# define _2MM_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(NI) && !defined(NJ) && !defined(NK) && !defined(NL) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define NI 16 +# define NJ 18 +# define NK 22 +# define NL 24 +# endif + +# ifdef SMALL_DATASET +# define NI 40 +# define NJ 50 +# define NK 70 +# define NL 80 +# endif + +# ifdef MEDIUM_DATASET +# define NI 180 +# define NJ 190 +# define NK 210 +# define NL 220 +# endif + +# ifdef LARGE_DATASET +# define NI 800 +# define NJ 900 +# define NK 1100 +# define NL 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define NI 1600 +# define NJ 1800 +# define NK 2200 +# define NL 2400 +# endif + + +#endif /* !(NI NJ NK NL) */ + +# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni) +# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj) +# define _PB_NK POLYBENCH_LOOP_BOUND(NK,nk) +# define _PB_NL POLYBENCH_LOOP_BOUND(NL,nl) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_2MM_H */ diff --git a/datasets/PolyBenchC/linear-algebra/kernels/3mm/3mm.c b/datasets/PolyBenchC/linear-algebra/kernels/3mm/3mm.c new file mode 100644 index 0000000..d67178b --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/3mm/3mm.c @@ -0,0 +1,169 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* 3mm.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "3mm.h" + + +/* Array initialization. */ +static +void init_array(int ni, int nj, int nk, int nl, int nm, + DATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nk), + DATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj), + DATA_TYPE POLYBENCH_2D(C,NJ,NM,nj,nm), + DATA_TYPE POLYBENCH_2D(D,NM,NL,nm,nl)) +{ + int i, j; + + for (i = 0; i < ni; i++) + for (j = 0; j < nk; j++) + A[i][j] = (DATA_TYPE) ((i*j+1) % ni) / (5*ni); + for (i = 0; i < nk; i++) + for (j = 0; j < nj; j++) + B[i][j] = (DATA_TYPE) ((i*(j+1)+2) % nj) / (5*nj); + for (i = 0; i < nj; i++) + for (j = 0; j < nm; j++) + C[i][j] = (DATA_TYPE) (i*(j+3) % nl) / (5*nl); + for (i = 0; i < nm; i++) + for (j = 0; j < nl; j++) + D[i][j] = (DATA_TYPE) ((i*(j+2)+2) % nk) / (5*nk); +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int ni, int nl, + DATA_TYPE POLYBENCH_2D(G,NI,NL,ni,nl)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("G"); + for (i = 0; i < ni; i++) + for (j = 0; j < nl; j++) { + if ((i * ni + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, G[i][j]); + } + POLYBENCH_DUMP_END("G"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_3mm(int ni, int nj, int nk, int nl, int nm, + DATA_TYPE POLYBENCH_2D(E,NI,NJ,ni,nj), + DATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nk), + DATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj), + DATA_TYPE POLYBENCH_2D(F,NJ,NL,nj,nl), + DATA_TYPE POLYBENCH_2D(C,NJ,NM,nj,nm), + DATA_TYPE POLYBENCH_2D(D,NM,NL,nm,nl), + DATA_TYPE POLYBENCH_2D(G,NI,NL,ni,nl)) +{ + int i, j, k; + +#pragma scop + /* E := A*B */ + for (i = 0; i < _PB_NI; i++) + for (j = 0; j < _PB_NJ; j++) + { + E[i][j] = SCALAR_VAL(0.0); + for (k = 0; k < _PB_NK; ++k) + E[i][j] += A[i][k] * B[k][j]; + } + /* F := C*D */ + for (i = 0; i < _PB_NJ; i++) + for (j = 0; j < _PB_NL; j++) + { + F[i][j] = SCALAR_VAL(0.0); + for (k = 0; k < _PB_NM; ++k) + F[i][j] += C[i][k] * D[k][j]; + } + /* G := E*F */ + for (i = 0; i < _PB_NI; i++) + for (j = 0; j < _PB_NL; j++) + { + G[i][j] = SCALAR_VAL(0.0); + for (k = 0; k < _PB_NJ; ++k) + G[i][j] += E[i][k] * F[k][j]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int ni = NI; + int nj = NJ; + int nk = NK; + int nl = NL; + int nm = NM; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(E, DATA_TYPE, NI, NJ, ni, nj); + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NI, NK, ni, nk); + POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, NK, NJ, nk, nj); + POLYBENCH_2D_ARRAY_DECL(F, DATA_TYPE, NJ, NL, nj, nl); + POLYBENCH_2D_ARRAY_DECL(C, DATA_TYPE, NJ, NM, nj, nm); + POLYBENCH_2D_ARRAY_DECL(D, DATA_TYPE, NM, NL, nm, nl); + POLYBENCH_2D_ARRAY_DECL(G, DATA_TYPE, NI, NL, ni, nl); + + /* Initialize array(s). */ + init_array (ni, nj, nk, nl, nm, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B), + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(D)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_3mm (ni, nj, nk, nl, nm, + POLYBENCH_ARRAY(E), + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(B), + POLYBENCH_ARRAY(F), + POLYBENCH_ARRAY(C), + POLYBENCH_ARRAY(D), + POLYBENCH_ARRAY(G)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(ni, nl, POLYBENCH_ARRAY(G))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(E); + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + POLYBENCH_FREE_ARRAY(F); + POLYBENCH_FREE_ARRAY(C); + POLYBENCH_FREE_ARRAY(D); + POLYBENCH_FREE_ARRAY(G); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/kernels/3mm/3mm.h b/datasets/PolyBenchC/linear-algebra/kernels/3mm/3mm.h new file mode 100644 index 0000000..8cc464e --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/3mm/3mm.h @@ -0,0 +1,98 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _3MM_H +# define _3MM_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(NI) && !defined(NJ) && !defined(NK) && !defined(NL) && !defined(NM) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define NI 16 +# define NJ 18 +# define NK 20 +# define NL 22 +# define NM 24 +# endif + +# ifdef SMALL_DATASET +# define NI 40 +# define NJ 50 +# define NK 60 +# define NL 70 +# define NM 80 +# endif + +# ifdef MEDIUM_DATASET +# define NI 180 +# define NJ 190 +# define NK 200 +# define NL 210 +# define NM 220 +# endif + +# ifdef LARGE_DATASET +# define NI 800 +# define NJ 900 +# define NK 1000 +# define NL 1100 +# define NM 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define NI 1600 +# define NJ 1800 +# define NK 2000 +# define NL 2200 +# define NM 2400 +# endif + + +#endif /* !(NI NJ NK NL NM) */ + +# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni) +# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj) +# define _PB_NK POLYBENCH_LOOP_BOUND(NK,nk) +# define _PB_NL POLYBENCH_LOOP_BOUND(NL,nl) +# define _PB_NM POLYBENCH_LOOP_BOUND(NM,nm) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_3MM_H */ diff --git a/datasets/PolyBenchC/linear-algebra/kernels/atax/atax.c b/datasets/PolyBenchC/linear-algebra/kernels/atax/atax.c new file mode 100644 index 0000000..3cd399b --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/atax/atax.c @@ -0,0 +1,129 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* atax.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "atax.h" + + +/* Array initialization. */ +static +void init_array (int m, int n, + DATA_TYPE POLYBENCH_2D(A,M,N,m,n), + DATA_TYPE POLYBENCH_1D(x,N,n)) +{ + int i, j; + DATA_TYPE fn; + fn = (DATA_TYPE)n; + + for (i = 0; i < n; i++) + x[i] = 1 + (i / fn); + for (i = 0; i < m; i++) + for (j = 0; j < n; j++) + A[i][j] = (DATA_TYPE) ((i+j) % n) / (5*m); +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_1D(y,N,n)) + +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("y"); + for (i = 0; i < n; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, y[i]); + } + POLYBENCH_DUMP_END("y"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_atax(int m, int n, + DATA_TYPE POLYBENCH_2D(A,M,N,m,n), + DATA_TYPE POLYBENCH_1D(x,N,n), + DATA_TYPE POLYBENCH_1D(y,N,n), + DATA_TYPE POLYBENCH_1D(tmp,M,m)) +{ + int i, j; + +#pragma scop + for (i = 0; i < _PB_N; i++) + y[i] = 0; + for (i = 0; i < _PB_M; i++) + { + tmp[i] = SCALAR_VAL(0.0); + for (j = 0; j < _PB_N; j++) + tmp[i] = tmp[i] + A[i][j] * x[j]; + for (j = 0; j < _PB_N; j++) + y[j] = y[j] + A[i][j] * tmp[i]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int m = M; + int n = N; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, M, N, m, n); + POLYBENCH_1D_ARRAY_DECL(x, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(y, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(tmp, DATA_TYPE, M, m); + + /* Initialize array(s). */ + init_array (m, n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(x)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_atax (m, n, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(x), + POLYBENCH_ARRAY(y), + POLYBENCH_ARRAY(tmp)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(y))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(x); + POLYBENCH_FREE_ARRAY(y); + POLYBENCH_FREE_ARRAY(tmp); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/kernels/atax/atax.h b/datasets/PolyBenchC/linear-algebra/kernels/atax/atax.h new file mode 100644 index 0000000..21e12b2 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/atax/atax.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _ATAX_H +# define _ATAX_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 38 +# define N 42 +# endif + +# ifdef SMALL_DATASET +# define M 116 +# define N 124 +# endif + +# ifdef MEDIUM_DATASET +# define M 390 +# define N 410 +# endif + +# ifdef LARGE_DATASET +# define M 1900 +# define N 2100 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 1800 +# define N 2200 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_ATAX_H */ diff --git a/datasets/PolyBenchC/linear-algebra/kernels/bicg/bicg.c b/datasets/PolyBenchC/linear-algebra/kernels/bicg/bicg.c new file mode 100644 index 0000000..72f564f --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/bicg/bicg.c @@ -0,0 +1,145 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* bicg.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "bicg.h" + + +/* Array initialization. */ +static +void init_array (int m, int n, + DATA_TYPE POLYBENCH_2D(A,N,M,n,m), + DATA_TYPE POLYBENCH_1D(r,N,n), + DATA_TYPE POLYBENCH_1D(p,M,m)) +{ + int i, j; + + for (i = 0; i < m; i++) + p[i] = (DATA_TYPE)(i % m) / m; + for (i = 0; i < n; i++) { + r[i] = (DATA_TYPE)(i % n) / n; + for (j = 0; j < m; j++) + A[i][j] = (DATA_TYPE) (i*(j+1) % n)/n; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int m, int n, + DATA_TYPE POLYBENCH_1D(s,M,m), + DATA_TYPE POLYBENCH_1D(q,N,n)) + +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("s"); + for (i = 0; i < m; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, s[i]); + } + POLYBENCH_DUMP_END("s"); + POLYBENCH_DUMP_BEGIN("q"); + for (i = 0; i < n; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, q[i]); + } + POLYBENCH_DUMP_END("q"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_bicg(int m, int n, + DATA_TYPE POLYBENCH_2D(A,N,M,n,m), + DATA_TYPE POLYBENCH_1D(s,M,m), + DATA_TYPE POLYBENCH_1D(q,N,n), + DATA_TYPE POLYBENCH_1D(p,M,m), + DATA_TYPE POLYBENCH_1D(r,N,n)) +{ + int i, j; + +#pragma scop + for (i = 0; i < _PB_M; i++) + s[i] = 0; + for (i = 0; i < _PB_N; i++) + { + q[i] = SCALAR_VAL(0.0); + for (j = 0; j < _PB_M; j++) + { + s[j] = s[j] + r[i] * A[i][j]; + q[i] = q[i] + A[i][j] * p[j]; + } + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int m = M; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, M, n, m); + POLYBENCH_1D_ARRAY_DECL(s, DATA_TYPE, M, m); + POLYBENCH_1D_ARRAY_DECL(q, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(p, DATA_TYPE, M, m); + POLYBENCH_1D_ARRAY_DECL(r, DATA_TYPE, N, n); + + /* Initialize array(s). */ + init_array (m, n, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(r), + POLYBENCH_ARRAY(p)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_bicg (m, n, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(s), + POLYBENCH_ARRAY(q), + POLYBENCH_ARRAY(p), + POLYBENCH_ARRAY(r)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(m, n, POLYBENCH_ARRAY(s), POLYBENCH_ARRAY(q))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(s); + POLYBENCH_FREE_ARRAY(q); + POLYBENCH_FREE_ARRAY(p); + POLYBENCH_FREE_ARRAY(r); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/kernels/bicg/bicg.h b/datasets/PolyBenchC/linear-algebra/kernels/bicg/bicg.h new file mode 100644 index 0000000..984e955 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/bicg/bicg.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _BICG_H +# define _BICG_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 38 +# define N 42 +# endif + +# ifdef SMALL_DATASET +# define M 116 +# define N 124 +# endif + +# ifdef MEDIUM_DATASET +# define M 390 +# define N 410 +# endif + +# ifdef LARGE_DATASET +# define M 1900 +# define N 2100 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 1800 +# define N 2200 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_BICG_H */ diff --git a/datasets/PolyBenchC/linear-algebra/kernels/doitgen/doitgen.c b/datasets/PolyBenchC/linear-algebra/kernels/doitgen/doitgen.c new file mode 100644 index 0000000..58a4d97 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/doitgen/doitgen.c @@ -0,0 +1,128 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* doitgen.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "doitgen.h" + + +/* Array initialization. */ +static +void init_array(int nr, int nq, int np, + DATA_TYPE POLYBENCH_3D(A,NR,NQ,NP,nr,nq,np), + DATA_TYPE POLYBENCH_2D(C4,NP,NP,np,np)) +{ + int i, j, k; + + for (i = 0; i < nr; i++) + for (j = 0; j < nq; j++) + for (k = 0; k < np; k++) + A[i][j][k] = (DATA_TYPE) ((i*j + k)%np) / np; + for (i = 0; i < np; i++) + for (j = 0; j < np; j++) + C4[i][j] = (DATA_TYPE) (i*j % np) / np; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int nr, int nq, int np, + DATA_TYPE POLYBENCH_3D(A,NR,NQ,NP,nr,nq,np)) +{ + int i, j, k; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("A"); + for (i = 0; i < nr; i++) + for (j = 0; j < nq; j++) + for (k = 0; k < np; k++) { + if ((i*nq*np+j*np+k) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, A[i][j][k]); + } + POLYBENCH_DUMP_END("A"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +void kernel_doitgen(int nr, int nq, int np, + DATA_TYPE POLYBENCH_3D(A,NR,NQ,NP,nr,nq,np), + DATA_TYPE POLYBENCH_2D(C4,NP,NP,np,np), + DATA_TYPE POLYBENCH_1D(sum,NP,np)) +{ + int r, q, p, s; + +#pragma scop + for (r = 0; r < _PB_NR; r++) + for (q = 0; q < _PB_NQ; q++) { + for (p = 0; p < _PB_NP; p++) { + sum[p] = SCALAR_VAL(0.0); + for (s = 0; s < _PB_NP; s++) + sum[p] += A[r][q][s] * C4[s][p]; + } + for (p = 0; p < _PB_NP; p++) + A[r][q][p] = sum[p]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int nr = NR; + int nq = NQ; + int np = NP; + + /* Variable declaration/allocation. */ + POLYBENCH_3D_ARRAY_DECL(A,DATA_TYPE,NR,NQ,NP,nr,nq,np); + POLYBENCH_1D_ARRAY_DECL(sum,DATA_TYPE,NP,np); + POLYBENCH_2D_ARRAY_DECL(C4,DATA_TYPE,NP,NP,np,np); + + /* Initialize array(s). */ + init_array (nr, nq, np, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(C4)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_doitgen (nr, nq, np, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(C4), + POLYBENCH_ARRAY(sum)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(nr, nq, np, POLYBENCH_ARRAY(A))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(sum); + POLYBENCH_FREE_ARRAY(C4); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/kernels/doitgen/doitgen.h b/datasets/PolyBenchC/linear-algebra/kernels/doitgen/doitgen.h new file mode 100644 index 0000000..197abef --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/doitgen/doitgen.h @@ -0,0 +1,86 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _DOITGEN_H +# define _DOITGEN_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(NQ) && !defined(NR) && !defined(NP) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define NQ 8 +# define NR 10 +# define NP 12 +# endif + +# ifdef SMALL_DATASET +# define NQ 20 +# define NR 25 +# define NP 30 +# endif + +# ifdef MEDIUM_DATASET +# define NQ 40 +# define NR 50 +# define NP 60 +# endif + +# ifdef LARGE_DATASET +# define NQ 140 +# define NR 150 +# define NP 160 +# endif + +# ifdef EXTRALARGE_DATASET +# define NQ 220 +# define NR 250 +# define NP 270 +# endif + + +#endif /* !(NQ NR NP) */ + +# define _PB_NQ POLYBENCH_LOOP_BOUND(NQ,nq) +# define _PB_NR POLYBENCH_LOOP_BOUND(NR,nr) +# define _PB_NP POLYBENCH_LOOP_BOUND(NP,np) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_DOITGEN_H */ diff --git a/datasets/PolyBenchC/linear-algebra/kernels/mvt/mvt.c b/datasets/PolyBenchC/linear-algebra/kernels/mvt/mvt.c new file mode 100644 index 0000000..4e838a1 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/mvt/mvt.c @@ -0,0 +1,147 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* mvt.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "mvt.h" + + +/* Array initialization. */ +static +void init_array(int n, + DATA_TYPE POLYBENCH_1D(x1,N,n), + DATA_TYPE POLYBENCH_1D(x2,N,n), + DATA_TYPE POLYBENCH_1D(y_1,N,n), + DATA_TYPE POLYBENCH_1D(y_2,N,n), + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + { + x1[i] = (DATA_TYPE) (i % n) / n; + x2[i] = (DATA_TYPE) ((i + 1) % n) / n; + y_1[i] = (DATA_TYPE) ((i + 3) % n) / n; + y_2[i] = (DATA_TYPE) ((i + 4) % n) / n; + for (j = 0; j < n; j++) + A[i][j] = (DATA_TYPE) (i*j % n) / n; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_1D(x1,N,n), + DATA_TYPE POLYBENCH_1D(x2,N,n)) + +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("x1"); + for (i = 0; i < n; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, x1[i]); + } + POLYBENCH_DUMP_END("x1"); + + POLYBENCH_DUMP_BEGIN("x2"); + for (i = 0; i < n; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, x2[i]); + } + POLYBENCH_DUMP_END("x2"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_mvt(int n, + DATA_TYPE POLYBENCH_1D(x1,N,n), + DATA_TYPE POLYBENCH_1D(x2,N,n), + DATA_TYPE POLYBENCH_1D(y_1,N,n), + DATA_TYPE POLYBENCH_1D(y_2,N,n), + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) +{ + int i, j; + +#pragma scop + for (i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_N; j++) + x1[i] = x1[i] + A[i][j] * y_1[j]; + for (i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_N; j++) + x2[i] = x2[i] + A[j][i] * y_2[j]; +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n); + POLYBENCH_1D_ARRAY_DECL(x1, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(x2, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(y_1, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(y_2, DATA_TYPE, N, n); + + + /* Initialize array(s). */ + init_array (n, + POLYBENCH_ARRAY(x1), + POLYBENCH_ARRAY(x2), + POLYBENCH_ARRAY(y_1), + POLYBENCH_ARRAY(y_2), + POLYBENCH_ARRAY(A)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_mvt (n, + POLYBENCH_ARRAY(x1), + POLYBENCH_ARRAY(x2), + POLYBENCH_ARRAY(y_1), + POLYBENCH_ARRAY(y_2), + POLYBENCH_ARRAY(A)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(x1), POLYBENCH_ARRAY(x2))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(x1); + POLYBENCH_FREE_ARRAY(x2); + POLYBENCH_FREE_ARRAY(y_1); + POLYBENCH_FREE_ARRAY(y_2); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/kernels/mvt/mvt.h b/datasets/PolyBenchC/linear-algebra/kernels/mvt/mvt.h new file mode 100644 index 0000000..c41323b --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/kernels/mvt/mvt.h @@ -0,0 +1,74 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _MVT_H +# define _MVT_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 40 +# endif + +# ifdef SMALL_DATASET +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 4000 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_MVT_H */ diff --git a/datasets/PolyBenchC/linear-algebra/solvers/cholesky/cholesky.c b/datasets/PolyBenchC/linear-algebra/solvers/cholesky/cholesky.c new file mode 100644 index 0000000..4fdb72b --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/solvers/cholesky/cholesky.c @@ -0,0 +1,138 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* cholesky.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "cholesky.h" + + +/* Array initialization. */ +static +void init_array(int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + { + for (j = 0; j <= i; j++) + A[i][j] = (DATA_TYPE)(-j % n) / n + 1; + for (j = i+1; j < n; j++) { + A[i][j] = 0; + } + A[i][i] = 1; + } + + /* Make the matrix positive semi-definite. */ + int r,s,t; + POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, N, N, n, n); + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + (POLYBENCH_ARRAY(B))[r][s] = 0; + for (t = 0; t < n; ++t) + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + (POLYBENCH_ARRAY(B))[r][s] += A[r][t] * A[s][t]; + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + A[r][s] = (POLYBENCH_ARRAY(B))[r][s]; + POLYBENCH_FREE_ARRAY(B); + +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("A"); + for (i = 0; i < n; i++) + for (j = 0; j <= i; j++) { + if ((i * n + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, A[i][j]); + } + POLYBENCH_DUMP_END("A"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_cholesky(int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) +{ + int i, j, k; + + +#pragma scop + for (i = 0; i < _PB_N; i++) { + //j + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _CHOLESKY_H +# define _CHOLESKY_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 40 +# endif + +# ifdef SMALL_DATASET +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 4000 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_CHOLESKY_H */ diff --git a/datasets/PolyBenchC/linear-algebra/solvers/durbin/durbin.c b/datasets/PolyBenchC/linear-algebra/solvers/durbin/durbin.c new file mode 100644 index 0000000..e3c2dad --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/solvers/durbin/durbin.c @@ -0,0 +1,132 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* durbin.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "durbin.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_1D(r,N,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + { + r[i] = (n+1-i); + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_1D(y,N,n)) + +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("y"); + for (i = 0; i < n; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, y[i]); + } + POLYBENCH_DUMP_END("y"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_durbin(int n, + DATA_TYPE POLYBENCH_1D(r,N,n), + DATA_TYPE POLYBENCH_1D(y,N,n)) +{ + DATA_TYPE z[N]; + DATA_TYPE alpha; + DATA_TYPE beta; + DATA_TYPE sum; + + int i,k; + +#pragma scop + y[0] = -r[0]; + beta = SCALAR_VAL(1.0); + alpha = -r[0]; + + for (k = 1; k < _PB_N; k++) { + beta = (1-alpha*alpha)*beta; + sum = SCALAR_VAL(0.0); + for (i=0; i + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _DURBIN_H +# define _DURBIN_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 40 +# endif + +# ifdef SMALL_DATASET +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 4000 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_DURBIN_H */ diff --git a/datasets/PolyBenchC/linear-algebra/solvers/gramschmidt/gramschmidt.c b/datasets/PolyBenchC/linear-algebra/solvers/gramschmidt/gramschmidt.c new file mode 100644 index 0000000..7fec004 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/solvers/gramschmidt/gramschmidt.c @@ -0,0 +1,151 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* gramschmidt.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "gramschmidt.h" + + +/* Array initialization. */ +static +void init_array(int m, int n, + DATA_TYPE POLYBENCH_2D(A,M,N,m,n), + DATA_TYPE POLYBENCH_2D(R,N,N,n,n), + DATA_TYPE POLYBENCH_2D(Q,M,N,m,n)) +{ + int i, j; + + for (i = 0; i < m; i++) + for (j = 0; j < n; j++) { + A[i][j] = (((DATA_TYPE) ((i*j) % m) / m )*100) + 10; + Q[i][j] = 0.0; + } + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + R[i][j] = 0.0; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int m, int n, + DATA_TYPE POLYBENCH_2D(A,M,N,m,n), + DATA_TYPE POLYBENCH_2D(R,N,N,n,n), + DATA_TYPE POLYBENCH_2D(Q,M,N,m,n)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("R"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + if ((i*n+j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, R[i][j]); + } + POLYBENCH_DUMP_END("R"); + + POLYBENCH_DUMP_BEGIN("Q"); + for (i = 0; i < m; i++) + for (j = 0; j < n; j++) { + if ((i*n+j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, Q[i][j]); + } + POLYBENCH_DUMP_END("Q"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +/* QR Decomposition with Modified Gram Schmidt: + http://www.inf.ethz.ch/personal/gander/ */ +static +void kernel_gramschmidt(int m, int n, + DATA_TYPE POLYBENCH_2D(A,M,N,m,n), + DATA_TYPE POLYBENCH_2D(R,N,N,n,n), + DATA_TYPE POLYBENCH_2D(Q,M,N,m,n)) +{ + int i, j, k; + + DATA_TYPE nrm; + +#pragma scop + for (k = 0; k < _PB_N; k++) + { + nrm = SCALAR_VAL(0.0); + for (i = 0; i < _PB_M; i++) + nrm += A[i][k] * A[i][k]; + R[k][k] = SQRT_FUN(nrm); + for (i = 0; i < _PB_M; i++) + Q[i][k] = A[i][k] / R[k][k]; + for (j = k + 1; j < _PB_N; j++) + { + R[k][j] = SCALAR_VAL(0.0); + for (i = 0; i < _PB_M; i++) + R[k][j] += Q[i][k] * A[i][j]; + for (i = 0; i < _PB_M; i++) + A[i][j] = A[i][j] - Q[i][k] * R[k][j]; + } + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int m = M; + int n = N; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(A,DATA_TYPE,M,N,m,n); + POLYBENCH_2D_ARRAY_DECL(R,DATA_TYPE,N,N,n,n); + POLYBENCH_2D_ARRAY_DECL(Q,DATA_TYPE,M,N,m,n); + + /* Initialize array(s). */ + init_array (m, n, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(R), + POLYBENCH_ARRAY(Q)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_gramschmidt (m, n, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(R), + POLYBENCH_ARRAY(Q)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(m, n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(R), POLYBENCH_ARRAY(Q))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(R); + POLYBENCH_FREE_ARRAY(Q); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/solvers/gramschmidt/gramschmidt.h b/datasets/PolyBenchC/linear-algebra/solvers/gramschmidt/gramschmidt.h new file mode 100644 index 0000000..e20ddb2 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/solvers/gramschmidt/gramschmidt.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _GRAMSCHMIDT_H +# define _GRAMSCHMIDT_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(M) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define M 20 +# define N 30 +# endif + +# ifdef SMALL_DATASET +# define M 60 +# define N 80 +# endif + +# ifdef MEDIUM_DATASET +# define M 200 +# define N 240 +# endif + +# ifdef LARGE_DATASET +# define M 1000 +# define N 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define M 2000 +# define N 2600 +# endif + + +#endif /* !(M N) */ + +# define _PB_M POLYBENCH_LOOP_BOUND(M,m) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_GRAMSCHMIDT_H */ diff --git a/datasets/PolyBenchC/linear-algebra/solvers/lu/lu.c b/datasets/PolyBenchC/linear-algebra/solvers/lu/lu.c new file mode 100644 index 0000000..9b01cd4 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/solvers/lu/lu.c @@ -0,0 +1,136 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* lu.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "lu.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + { + for (j = 0; j <= i; j++) + A[i][j] = (DATA_TYPE)(-j % n) / n + 1; + for (j = i+1; j < n; j++) { + A[i][j] = 0; + } + A[i][i] = 1; + } + + /* Make the matrix positive semi-definite. */ + /* not necessary for LU, but using same code as cholesky */ + int r,s,t; + POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, N, N, n, n); + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + (POLYBENCH_ARRAY(B))[r][s] = 0; + for (t = 0; t < n; ++t) + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + (POLYBENCH_ARRAY(B))[r][s] += A[r][t] * A[s][t]; + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + A[r][s] = (POLYBENCH_ARRAY(B))[r][s]; + POLYBENCH_FREE_ARRAY(B); + +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("A"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + if ((i * n + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, A[i][j]); + } + POLYBENCH_DUMP_END("A"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_lu(int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) +{ + int i, j, k; + +#pragma scop + for (i = 0; i < _PB_N; i++) { + for (j = 0; j + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _LU_H +# define _LU_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 40 +# endif + +# ifdef SMALL_DATASET +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 4000 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_LU_H */ diff --git a/datasets/PolyBenchC/linear-algebra/solvers/ludcmp/ludcmp.c b/datasets/PolyBenchC/linear-algebra/solvers/ludcmp/ludcmp.c new file mode 100644 index 0000000..a4c2db9 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/solvers/ludcmp/ludcmp.c @@ -0,0 +1,184 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* ludcmp.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "ludcmp.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n), + DATA_TYPE POLYBENCH_1D(b,N,n), + DATA_TYPE POLYBENCH_1D(x,N,n), + DATA_TYPE POLYBENCH_1D(y,N,n)) +{ + int i, j; + DATA_TYPE fn = (DATA_TYPE)n; + + for (i = 0; i < n; i++) + { + x[i] = 0; + y[i] = 0; + b[i] = (i+1)/fn/2.0 + 4; + } + + for (i = 0; i < n; i++) + { + for (j = 0; j <= i; j++) + A[i][j] = (DATA_TYPE)(-j % n) / n + 1; + for (j = i+1; j < n; j++) { + A[i][j] = 0; + } + A[i][i] = 1; + } + + /* Make the matrix positive semi-definite. */ + /* not necessary for LU, but using same code as cholesky */ + int r,s,t; + POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, N, N, n, n); + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + (POLYBENCH_ARRAY(B))[r][s] = 0; + for (t = 0; t < n; ++t) + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + (POLYBENCH_ARRAY(B))[r][s] += A[r][t] * A[s][t]; + for (r = 0; r < n; ++r) + for (s = 0; s < n; ++s) + A[r][s] = (POLYBENCH_ARRAY(B))[r][s]; + POLYBENCH_FREE_ARRAY(B); + +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_1D(x,N,n)) + +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("x"); + for (i = 0; i < n; i++) { + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, x[i]); + } + POLYBENCH_DUMP_END("x"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_ludcmp(int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n), + DATA_TYPE POLYBENCH_1D(b,N,n), + DATA_TYPE POLYBENCH_1D(x,N,n), + DATA_TYPE POLYBENCH_1D(y,N,n)) +{ + int i, j, k; + + DATA_TYPE w; + +#pragma scop + for (i = 0; i < _PB_N; i++) { + for (j = 0; j =0; i--) { + w = y[i]; + for (j = i+1; j < _PB_N; j++) + w -= A[i][j] * x[j]; + x[i] = w / A[i][i]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n); + POLYBENCH_1D_ARRAY_DECL(b, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(x, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(y, DATA_TYPE, N, n); + + + /* Initialize array(s). */ + init_array (n, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(b), + POLYBENCH_ARRAY(x), + POLYBENCH_ARRAY(y)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_ludcmp (n, + POLYBENCH_ARRAY(A), + POLYBENCH_ARRAY(b), + POLYBENCH_ARRAY(x), + POLYBENCH_ARRAY(y)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(x))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(b); + POLYBENCH_FREE_ARRAY(x); + POLYBENCH_FREE_ARRAY(y); + + return 0; +} diff --git a/datasets/PolyBenchC/linear-algebra/solvers/ludcmp/ludcmp.h b/datasets/PolyBenchC/linear-algebra/solvers/ludcmp/ludcmp.h new file mode 100644 index 0000000..01c4f13 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/solvers/ludcmp/ludcmp.h @@ -0,0 +1,74 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _LUDCMP_H +# define _LUDCMP_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 40 +# endif + +# ifdef SMALL_DATASET +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 4000 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_LUDCMP_H */ diff --git a/datasets/PolyBenchC/linear-algebra/solvers/trisolv/trisolv.c b/datasets/PolyBenchC/linear-algebra/solvers/trisolv/trisolv.c new file mode 100644 index 0000000..8a03c28 --- /dev/null +++ b/datasets/PolyBenchC/linear-algebra/solvers/trisolv/trisolv.c @@ -0,0 +1,120 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* trisolv.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "trisolv.h" + + +/* Array initialization. */ +static +void init_array(int n, + DATA_TYPE POLYBENCH_2D(L,N,N,n,n), + DATA_TYPE POLYBENCH_1D(x,N,n), + DATA_TYPE POLYBENCH_1D(b,N,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + { + x[i] = - 999; + b[i] = i ; + for (j = 0; j <= i; j++) + L[i][j] = (DATA_TYPE) (i+n-j+1)*2/n; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_1D(x,N,n)) + +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("x"); + for (i = 0; i < n; i++) { + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, x[i]); + if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + } + POLYBENCH_DUMP_END("x"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_trisolv(int n, + DATA_TYPE POLYBENCH_2D(L,N,N,n,n), + DATA_TYPE POLYBENCH_1D(x,N,n), + DATA_TYPE POLYBENCH_1D(b,N,n)) +{ + int i, j; + +#pragma scop + for (i = 0; i < _PB_N; i++) + { + x[i] = b[i]; + for (j = 0; j + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _TRISOLV_H +# define _TRISOLV_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 40 +# endif + +# ifdef SMALL_DATASET +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 4000 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_TRISOLV_H */ diff --git a/datasets/PolyBenchC/medley/.DS_Store b/datasets/PolyBenchC/medley/.DS_Store new file mode 100644 index 0000000..fa47cd3 Binary files /dev/null and b/datasets/PolyBenchC/medley/.DS_Store differ diff --git a/datasets/PolyBenchC/medley/deriche/deriche.c b/datasets/PolyBenchC/medley/deriche/deriche.c new file mode 100644 index 0000000..3cefa37 --- /dev/null +++ b/datasets/PolyBenchC/medley/deriche/deriche.c @@ -0,0 +1,196 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* deriche.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "deriche.h" + + +/* Array initialization. */ +static +void init_array (int w, int h, DATA_TYPE* alpha, + DATA_TYPE POLYBENCH_2D(imgIn,W,H,w,h), + DATA_TYPE POLYBENCH_2D(imgOut,W,H,w,h)) +{ + int i, j; + + *alpha=0.25; //parameter of the filter + + //input should be between 0 and 1 (grayscale image pixel) + for (i = 0; i < w; i++) + for (j = 0; j < h; j++) + imgIn[i][j] = (DATA_TYPE) ((313*i+991*j)%65536) / 65535.0f; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int w, int h, + DATA_TYPE POLYBENCH_2D(imgOut,W,H,w,h)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("imgOut"); + for (i = 0; i < w; i++) + for (j = 0; j < h; j++) { + if ((i * h + j) % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf(POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, imgOut[i][j]); + } + POLYBENCH_DUMP_END("imgOut"); + POLYBENCH_DUMP_FINISH; +} + + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +/* Original code provided by Gael Deest */ +static +void kernel_deriche(int w, int h, DATA_TYPE alpha, + DATA_TYPE POLYBENCH_2D(imgIn, W, H, w, h), + DATA_TYPE POLYBENCH_2D(imgOut, W, H, w, h), + DATA_TYPE POLYBENCH_2D(y1, W, H, w, h), + DATA_TYPE POLYBENCH_2D(y2, W, H, w, h)) { + int i,j; + DATA_TYPE xm1, tm1, ym1, ym2; + DATA_TYPE xp1, xp2; + DATA_TYPE tp1, tp2; + DATA_TYPE yp1, yp2; + + DATA_TYPE k; + DATA_TYPE a1, a2, a3, a4, a5, a6, a7, a8; + DATA_TYPE b1, b2, c1, c2; + +#pragma scop + k = (SCALAR_VAL(1.0)-EXP_FUN(-alpha))*(SCALAR_VAL(1.0)-EXP_FUN(-alpha))/(SCALAR_VAL(1.0)+SCALAR_VAL(2.0)*alpha*EXP_FUN(-alpha)-EXP_FUN(SCALAR_VAL(2.0)*alpha)); + a1 = a5 = k; + a2 = a6 = k*EXP_FUN(-alpha)*(alpha-SCALAR_VAL(1.0)); + a3 = a7 = k*EXP_FUN(-alpha)*(alpha+SCALAR_VAL(1.0)); + a4 = a8 = -k*EXP_FUN(SCALAR_VAL(-2.0)*alpha); + b1 = POW_FUN(SCALAR_VAL(2.0),-alpha); + b2 = -EXP_FUN(SCALAR_VAL(-2.0)*alpha); + c1 = c2 = 1; + + for (i=0; i<_PB_W; i++) { + ym1 = SCALAR_VAL(0.0); + ym2 = SCALAR_VAL(0.0); + xm1 = SCALAR_VAL(0.0); + for (j=0; j<_PB_H; j++) { + y1[i][j] = a1*imgIn[i][j] + a2*xm1 + b1*ym1 + b2*ym2; + xm1 = imgIn[i][j]; + ym2 = ym1; + ym1 = y1[i][j]; + } + } + + for (i=0; i<_PB_W; i++) { + yp1 = SCALAR_VAL(0.0); + yp2 = SCALAR_VAL(0.0); + xp1 = SCALAR_VAL(0.0); + xp2 = SCALAR_VAL(0.0); + for (j=_PB_H-1; j>=0; j--) { + y2[i][j] = a3*xp1 + a4*xp2 + b1*yp1 + b2*yp2; + xp2 = xp1; + xp1 = imgIn[i][j]; + yp2 = yp1; + yp1 = y2[i][j]; + } + } + + for (i=0; i<_PB_W; i++) + for (j=0; j<_PB_H; j++) { + imgOut[i][j] = c1 * (y1[i][j] + y2[i][j]); + } + + for (j=0; j<_PB_H; j++) { + tm1 = SCALAR_VAL(0.0); + ym1 = SCALAR_VAL(0.0); + ym2 = SCALAR_VAL(0.0); + for (i=0; i<_PB_W; i++) { + y1[i][j] = a5*imgOut[i][j] + a6*tm1 + b1*ym1 + b2*ym2; + tm1 = imgOut[i][j]; + ym2 = ym1; + ym1 = y1 [i][j]; + } + } + + + for (j=0; j<_PB_H; j++) { + tp1 = SCALAR_VAL(0.0); + tp2 = SCALAR_VAL(0.0); + yp1 = SCALAR_VAL(0.0); + yp2 = SCALAR_VAL(0.0); + for (i=_PB_W-1; i>=0; i--) { + y2[i][j] = a7*tp1 + a8*tp2 + b1*yp1 + b2*yp2; + tp2 = tp1; + tp1 = imgOut[i][j]; + yp2 = yp1; + yp1 = y2[i][j]; + } + } + + for (i=0; i<_PB_W; i++) + for (j=0; j<_PB_H; j++) + imgOut[i][j] = c2*(y1[i][j] + y2[i][j]); + +#pragma endscop +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int w = W; + int h = H; + + /* Variable declaration/allocation. */ + DATA_TYPE alpha; + POLYBENCH_2D_ARRAY_DECL(imgIn, DATA_TYPE, W, H, w, h); + POLYBENCH_2D_ARRAY_DECL(imgOut, DATA_TYPE, W, H, w, h); + POLYBENCH_2D_ARRAY_DECL(y1, DATA_TYPE, W, H, w, h); + POLYBENCH_2D_ARRAY_DECL(y2, DATA_TYPE, W, H, w, h); + + + /* Initialize array(s). */ + init_array (w, h, &alpha, POLYBENCH_ARRAY(imgIn), POLYBENCH_ARRAY(imgOut)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_deriche (w, h, alpha, POLYBENCH_ARRAY(imgIn), POLYBENCH_ARRAY(imgOut), POLYBENCH_ARRAY(y1), POLYBENCH_ARRAY(y2)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(w, h, POLYBENCH_ARRAY(imgOut))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(imgIn); + POLYBENCH_FREE_ARRAY(imgOut); + POLYBENCH_FREE_ARRAY(y1); + POLYBENCH_FREE_ARRAY(y2); + + return 0; +} diff --git a/datasets/PolyBenchC/medley/deriche/deriche.h b/datasets/PolyBenchC/medley/deriche/deriche.h new file mode 100644 index 0000000..260757b --- /dev/null +++ b/datasets/PolyBenchC/medley/deriche/deriche.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _DERICHE_H +# define _DERICHE_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(W) && !defined(H) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define W 64 +# define H 64 +# endif + +# ifdef SMALL_DATASET +# define W 192 +# define H 128 +# endif + +# ifdef MEDIUM_DATASET +# define W 720 +# define H 480 +# endif + +# ifdef LARGE_DATASET +# define W 4096 +# define H 2160 +# endif + +# ifdef EXTRALARGE_DATASET +# define W 7680 +# define H 4320 +# endif + + +#endif /* !(W H) */ + +# define _PB_W POLYBENCH_LOOP_BOUND(W,w) +# define _PB_H POLYBENCH_LOOP_BOUND(H,h) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_FLOAT +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_DERICHE_H */ diff --git a/datasets/PolyBenchC/medley/floyd-warshall/floyd-warshall.c b/datasets/PolyBenchC/medley/floyd-warshall/floyd-warshall.c new file mode 100644 index 0000000..6dab27d --- /dev/null +++ b/datasets/PolyBenchC/medley/floyd-warshall/floyd-warshall.c @@ -0,0 +1,112 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* floyd-warshall.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "floyd-warshall.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_2D(path,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + path[i][j] = i*j%7+1; + if ((i+j)%13 == 0 || (i+j)%7==0 || (i+j)%11 == 0) + path[i][j] = 999; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_2D(path,N,N,n,n)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("path"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + if ((i * n + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, path[i][j]); + } + POLYBENCH_DUMP_END("path"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_floyd_warshall(int n, + DATA_TYPE POLYBENCH_2D(path,N,N,n,n)) +{ + int i, j, k; + +#pragma scop + for (k = 0; k < _PB_N; k++) + { + for(i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_N; j++) + path[i][j] = path[i][j] < path[i][k] + path[k][j] ? + path[i][j] : path[i][k] + path[k][j]; + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(path, DATA_TYPE, N, N, n, n); + + + /* Initialize array(s). */ + init_array (n, POLYBENCH_ARRAY(path)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_floyd_warshall (n, POLYBENCH_ARRAY(path)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(path))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(path); + + return 0; +} diff --git a/datasets/PolyBenchC/medley/floyd-warshall/floyd-warshall.h b/datasets/PolyBenchC/medley/floyd-warshall/floyd-warshall.h new file mode 100644 index 0000000..800f42c --- /dev/null +++ b/datasets/PolyBenchC/medley/floyd-warshall/floyd-warshall.h @@ -0,0 +1,74 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _FLOYD_WARSHALL_H +# define _FLOYD_WARSHALL_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 60 +# endif + +# ifdef SMALL_DATASET +# define N 180 +# endif + +# ifdef MEDIUM_DATASET +# define N 500 +# endif + +# ifdef LARGE_DATASET +# define N 2800 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 5600 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_INT +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_FLOYD_WARSHALL_H */ diff --git a/datasets/PolyBenchC/medley/nussinov/Nussinov.orig.c b/datasets/PolyBenchC/medley/nussinov/Nussinov.orig.c new file mode 100644 index 0000000..9f9c01c --- /dev/null +++ b/datasets/PolyBenchC/medley/nussinov/Nussinov.orig.c @@ -0,0 +1,352 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* +Nussinov.c + +Builds a random sequence of base pairs, runs the Nussinov algorithm. +Unless FOUR_WAY_MAX_WITH_REDUNDANCY is define'd to true, it uses the more concise version as per the comment at the end of the file. + +Programmed by Dave Wonnacott at Haverford College , with help from Allison Lake, Ting Zhou, and Tian Jin, based on algorithm by Nussinov, described in Allison Lake's senior thesis. + + +compile&run with: + gcc -O3 -DNDEBUG -Wall -Wno-unused-value -Wno-unknown-pragmas Nussinov.c -o Nussinov && ./Nussinov + +Or, to set a specific size such as 5000, use: + gcc -O3 -DNDEBUG -Dsize=5000 -Wall -Wno-unused-value -Wno-unknown-pragmas Nussinov.c -o Nussinov && ./Nussinov + +------------- +For debugging/verifying we hit all the right points and have all updates before any pure reads: + gcc -Dsize=250 -DCHECK_DEPENDENCES=1 -DVERBOSE=1 -DVERBOSE_OUT=stderr -Wall -Wno-unused-value -Wno-unknown-pragmas Nussinov.c -o Nussinov && ./Nussinov 2> /tmp/Nussinov-log-250.txt ; sort /tmp/Nussinov-log-250.txt -o /tmp/Nussinov-log-250.txt + +------------- +Re-generate small or big matrix for comparison: + gcc -O3 -DPRINT_SIZE=5000 -Wall -Wno-unused-value -Wno-unknown-pragmas Nussinov.c -o Nussinov-print && echo 250 | ./Nussinov-print > printed-matrix-250.out +Or do the comparison + gcc -O3 -DPRINT_SIZE=5000 -Wall -Wno-unused-value -Wno-unknown-pragmas Nussinov.c -o Nussinov-print && echo 250 | ./Nussinov-print | diff printed-matrix-250.out - + +------------- +Re-generate big matrices for comparison: + gcc -O3 -Dsize=5000 -DPRINT_SIZE=5000 -Wall -Wno-unused-value -Wno-unknown-pragmas Nussinov.c -o Nussinov && ./Nussinov > printed-matrix-5000.out + + gcc -DSEED=17 -O3 -Dsize=5000 -DPRINT_SIZE=5000 -Wall -Wno-unused-value -Wno-unknown-pragmas Nussinov.c -o Nussinov && ./Nussinov > printed-matrix-5000-seed17.out + +*/ + +#include +#include +#include +#include +#include +#include + +typedef int bool; +const int true = 1; +const int false = 0; + +#if ! defined SCALAR_REPLACEMENT +#define SCALAR_REPLACEMENT 0 +#endif + +#if ! defined CHECK_DEPENDENCES +#define CHECK_DEPENDENCES false +#endif + +#if defined NDEBUG +#define eassert(EXPR) 1 +#else +#define eassert(EXPR) eassert_func(__STRING(EXPR), EXPR) +void eassert_func(char *expr, bool value) +{ + if (!value) { + fprintf(stderr, "assertion failed: %s\n", expr); + exit(1); + // printf("assertion failed: %s\n", expr); + } +} +#endif + + + +//#define MAX_SIZE 16307 + +#if ! defined FOUR_WAY_MAX_WITH_REDUNDANCY +#define FOUR_WAY_MAX_WITH_REDUNDANCY false +#endif +#if FOUR_WAY_MAX_WITH_REDUNDANCY +#define ZERO_IF_NO_REDUNDANCY 1 +#else +#define ZERO_IF_NO_REDUNDANCY 0 +#endif + +#if ! defined PRINT_SIZE +#define PRINT_SIZE 48 /* print for debugging if not bigger than this */ +#endif +#if ! defined VERBOSE +#define VERBOSE false +#endif +#if ! defined VERBOSE_OUT +#define VERBOSE_OUT stdout +#endif +#if VERBOSE +#if ! defined REALLY_VERBOSE +#define REALLY_VERBOSE false +#endif +#endif + +#if ! defined SEED +#define SEED 42 +#endif + +#define SLOWER (CHECK_DEPENDENCES | VERBOSE) + +double cur_time(void) +{ + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + return tv.tv_sec + tv.tv_usec*1.0e-6; +} + +// for bases, use 0, 1, 2, 3, with (0, 3) and (1, 2) being matches +char *base_print[4] = { "A", "C", "G", "U" }; +typedef int base; // could also try char, short +typedef int score; // could use uint, short, anything that can count high enough + +inline score match(base b1, base b2) +{ + return (b1+b2) == 3 ? 1 : 0; +} + +inline score max_score(score s1, score s2) +{ + return (s1 >= s2) ? s1 : s2; +} + +base seq[MAX_SIZE]; +score N_array[MAX_SIZE][MAX_SIZE]; +#define debug_N(x, y) (N_array[x][y]) /* read secretly without triggering has_been_read */ + +#if ! CHECK_DEPENDENCES +#define N(x, y) (eassert(0 <= x && x < size && 0 <= y && y < size), N_array[x][y]) +#if SCALAR_REPLACEMENT +#define MAX_N_DECLS() int max_tmp_i, max_tmp_j; score max_tmp +#define MAX_N_START(x,y) ((max_tmp_i=x), (max_tmp_j=y), (max_tmp = 0)) +#define MAX_N(x, y, v) (eassert(max_tmp_i==x && max_tmp_j==y), eassert(0 <= x && x < size && 0 <= y && y < size), (max_tmp = max_score(max_tmp, v))) +#define MAX_N_END(x,y) (eassert(max_tmp_i==x && max_tmp_j==y), ((N_array[x][y]) = max_score(N_array[x][y], max_tmp))) +#else /* else not scalar replacement (inside check_deps) */ +#define MAX_N(x, y, v) (eassert(0 <= x && x < size && 0 <= y && y < size), ((N_array[x][y]) = max_score(N_array[x][y], v))) +#endif /* else not scalar replacement (inside check_deps) */ +#else /* not check_deps */ +bool N_array_has_been_read[MAX_SIZE][MAX_SIZE]; +#define N(x, y) (eassert(0 <= x && x < size && 0 <= y && y < size), \ + (REALLY_VERBOSE?fprintf(VERBOSE_OUT, "i, j, k = %d, %d, %d: reading N[%d][%d]\n", i, j, k, x, y):1), \ + (N_array_has_been_read[x][y] = (true)), \ + N_array[x][y]+0) +#if SCALAR_REPLACEMENT /* inside not check_deps */ +#error("Not yet ready to do scalar replacement and check_deps at the same time :-(") +#else /* else not scalar replacement (inside not check_deps) */ +#define MAX_N(x, y, v) (eassert(0 <= x && x < size && 0 <= y && y < size), \ + eassert(!N_array_has_been_read[x][y]), \ + (N_array[x][y] = max_score(N_array[x][y], v))) +#endif /* else not scalar replacement (inside not check_deps) */ +#endif +#if ! SCALAR_REPLACEMENT +#define MAX_N_DECLS() +#define MAX_N_START(x,y) +#define MAX_N_END(x,y) +#endif + + +/* Convenience function */ +int getint(char *prompt) +{ +#if VERBOSE_OUT == stderr + char *terminate = "\n"; +#else + char *terminate = ""; +#endif + int result; + int i=0; + while ( + fprintf(stderr, "%s%s", prompt, terminate), + result = scanf("%d", &i), + result != 1 && result != EOF + ) { + fprintf(stderr, "Sorry, I didn't understand that...\n"); + } + if (result == 1) { + return i; + } else { + fprintf(stderr, "Giving up ... can't read input\n"); + exit(1); + } +} + + +int main(int argc, char *argv[]) +{ +#if ! SLOWER + double start_time, end_time; // , speed; +#endif +#if ! defined size + int size = getint("Enter length of random mRNA sequence (2200 is average for human mRNA): "); // Average (human) mRNA length is 2200; there's one that's 5000, though +#endif + + int i, j, k=-1; + MAX_N_DECLS(); + char *options; +#if VERBOSE +#if CHECK_DEPENDENCES + options = " [DV]"; +#else + options = " [V]"; +#endif +#else +#if CHECK_DEPENDENCES + options = " [D]"; +#else + options = ""; +#endif +#endif + + printf("Running Nussinov RNA algorithm%s for sequence of length %d, random data with seed %d.\n", + options, size, SEED); + + if (size > MAX_SIZE) { + fprintf(stderr, "size (%d) < MAX_SIZE (%d)\n", MAX_SIZE, size); + exit(1); + } + + /* seed it with a constant so we can check/compare the results */ + srand(SEED); + for (i = 0; i < size; i++) + seq[i] = rand() % 4; + +#if ! SLOWER + start_time = cur_time(); +#endif + +// "OPTION 1" +#pragma scop + for (i = size-1; i >= 0; i--) { + for (j=i+1; j=0) MAX_N(i, j, N(i, j-1)); + if (i+1=0 && i+1= s2) ? s1 : s2) + +/* Array initialization. */ +static +void init_array (int n, + base POLYBENCH_1D(seq,N,n), + DATA_TYPE POLYBENCH_2D(table,N,N,n,n)) +{ + int i, j; + + //base is AGCT/0..3 + for (i=0; i , + with help from Allison Lake, Ting Zhou, and Tian Jin, + based on algorithm by Nussinov, described in Allison Lake's senior thesis. +*/ +static +void kernel_nussinov(int n, base POLYBENCH_1D(seq,N,n), + DATA_TYPE POLYBENCH_2D(table,N,N,n,n)) +{ + int i, j, k; + +#pragma scop + for (i = _PB_N-1; i >= 0; i--) { + for (j=i+1; j<_PB_N; j++) { + + if (j-1>=0) + table[i][j] = max_score(table[i][j], table[i][j-1]); + if (i+1<_PB_N) + table[i][j] = max_score(table[i][j], table[i+1][j]); + + if (j-1>=0 && i+1<_PB_N) { + /* don't allow adjacent elements to bond */ + if (i + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _NUSSINOV_H +# define _NUSSINOV_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define N 60 +# endif + +# ifdef SMALL_DATASET +# define N 180 +# endif + +# ifdef MEDIUM_DATASET +# define N 500 +# endif + +# ifdef LARGE_DATASET +# define N 2500 +# endif + +# ifdef EXTRALARGE_DATASET +# define N 5500 +# endif + + +#endif /* !(N) */ + +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_INT +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_NUSSINOV_H */ diff --git a/datasets/PolyBenchC/polybench.pdf b/datasets/PolyBenchC/polybench.pdf new file mode 100644 index 0000000..70a7b56 Binary files /dev/null and b/datasets/PolyBenchC/polybench.pdf differ diff --git a/datasets/PolyBenchC/stencils/adi/adi.c b/datasets/PolyBenchC/stencils/adi/adi.c new file mode 100644 index 0000000..1eee045 --- /dev/null +++ b/datasets/PolyBenchC/stencils/adi/adi.c @@ -0,0 +1,168 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* adi.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "adi.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_2D(u,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + { + u[i][j] = (DATA_TYPE)(i + n-j) / n; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_2D(u,N,N,n,n)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("u"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + if ((i * n + j) % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf (POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, u[i][j]); + } + POLYBENCH_DUMP_END("u"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +/* Based on a Fortran code fragment from Figure 5 of + * "Automatic Data and Computation Decomposition on Distributed Memory Parallel Computers" + * by Peizong Lee and Zvi Meir Kedem, TOPLAS, 2002 + */ +static +void kernel_adi(int tsteps, int n, + DATA_TYPE POLYBENCH_2D(u,N,N,n,n), + DATA_TYPE POLYBENCH_2D(v,N,N,n,n), + DATA_TYPE POLYBENCH_2D(p,N,N,n,n), + DATA_TYPE POLYBENCH_2D(q,N,N,n,n)) +{ + int t, i, j; + DATA_TYPE DX, DY, DT; + DATA_TYPE B1, B2; + DATA_TYPE mul1, mul2; + DATA_TYPE a, b, c, d, e, f; + +#pragma scop + + DX = SCALAR_VAL(1.0)/(DATA_TYPE)_PB_N; + DY = SCALAR_VAL(1.0)/(DATA_TYPE)_PB_N; + DT = SCALAR_VAL(1.0)/(DATA_TYPE)_PB_TSTEPS; + B1 = SCALAR_VAL(2.0); + B2 = SCALAR_VAL(1.0); + mul1 = B1 * DT / (DX * DX); + mul2 = B2 * DT / (DY * DY); + + a = -mul1 / SCALAR_VAL(2.0); + b = SCALAR_VAL(1.0)+mul1; + c = a; + d = -mul2 / SCALAR_VAL(2.0); + e = SCALAR_VAL(1.0)+mul2; + f = d; + + for (t=1; t<=_PB_TSTEPS; t++) { + //Column Sweep + for (i=1; i<_PB_N-1; i++) { + v[0][i] = SCALAR_VAL(1.0); + p[i][0] = SCALAR_VAL(0.0); + q[i][0] = v[0][i]; + for (j=1; j<_PB_N-1; j++) { + p[i][j] = -c / (a*p[i][j-1]+b); + q[i][j] = (-d*u[j][i-1]+(SCALAR_VAL(1.0)+SCALAR_VAL(2.0)*d)*u[j][i] - f*u[j][i+1]-a*q[i][j-1])/(a*p[i][j-1]+b); + } + + v[_PB_N-1][i] = SCALAR_VAL(1.0); + for (j=_PB_N-2; j>=1; j--) { + v[j][i] = p[i][j] * v[j+1][i] + q[i][j]; + } + } + //Row Sweep + for (i=1; i<_PB_N-1; i++) { + u[i][0] = SCALAR_VAL(1.0); + p[i][0] = SCALAR_VAL(0.0); + q[i][0] = u[i][0]; + for (j=1; j<_PB_N-1; j++) { + p[i][j] = -f / (d*p[i][j-1]+e); + q[i][j] = (-a*v[i-1][j]+(SCALAR_VAL(1.0)+SCALAR_VAL(2.0)*a)*v[i][j] - c*v[i+1][j]-d*q[i][j-1])/(d*p[i][j-1]+e); + } + u[i][_PB_N-1] = SCALAR_VAL(1.0); + for (j=_PB_N-2; j>=1; j--) { + u[i][j] = p[i][j] * u[i][j+1] + q[i][j]; + } + } + } +#pragma endscop +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int tsteps = TSTEPS; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(u, DATA_TYPE, N, N, n, n); + POLYBENCH_2D_ARRAY_DECL(v, DATA_TYPE, N, N, n, n); + POLYBENCH_2D_ARRAY_DECL(p, DATA_TYPE, N, N, n, n); + POLYBENCH_2D_ARRAY_DECL(q, DATA_TYPE, N, N, n, n); + + + /* Initialize array(s). */ + init_array (n, POLYBENCH_ARRAY(u)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_adi (tsteps, n, POLYBENCH_ARRAY(u), POLYBENCH_ARRAY(v), POLYBENCH_ARRAY(p), POLYBENCH_ARRAY(q)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(u))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(u); + POLYBENCH_FREE_ARRAY(v); + POLYBENCH_FREE_ARRAY(p); + POLYBENCH_FREE_ARRAY(q); + + return 0; +} diff --git a/datasets/PolyBenchC/stencils/adi/adi.h b/datasets/PolyBenchC/stencils/adi/adi.h new file mode 100644 index 0000000..24fbabc --- /dev/null +++ b/datasets/PolyBenchC/stencils/adi/adi.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _ADI_H +# define _ADI_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(TSTEPS) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define TSTEPS 20 +# define N 20 +# endif + +# ifdef SMALL_DATASET +# define TSTEPS 40 +# define N 60 +# endif + +# ifdef MEDIUM_DATASET +# define TSTEPS 100 +# define N 200 +# endif + +# ifdef LARGE_DATASET +# define TSTEPS 500 +# define N 1000 +# endif + +# ifdef EXTRALARGE_DATASET +# define TSTEPS 1000 +# define N 2000 +# endif + + +#endif /* !(TSTEPS N) */ + +# define _PB_TSTEPS POLYBENCH_LOOP_BOUND(TSTEPS,tsteps) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_ADI_H */ diff --git a/datasets/PolyBenchC/stencils/fdtd-2d/fdtd-2d.c b/datasets/PolyBenchC/stencils/fdtd-2d/fdtd-2d.c new file mode 100644 index 0000000..6dfee88 --- /dev/null +++ b/datasets/PolyBenchC/stencils/fdtd-2d/fdtd-2d.c @@ -0,0 +1,170 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* fdtd-2d.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "fdtd-2d.h" + + +/* Array initialization. */ +static +void init_array (int tmax, + int nx, + int ny, + DATA_TYPE POLYBENCH_2D(ex,NX,NY,nx,ny), + DATA_TYPE POLYBENCH_2D(ey,NX,NY,nx,ny), + DATA_TYPE POLYBENCH_2D(hz,NX,NY,nx,ny), + DATA_TYPE POLYBENCH_1D(_fict_,TMAX,tmax)) +{ + int i, j; + + for (i = 0; i < tmax; i++) + _fict_[i] = (DATA_TYPE) i; + for (i = 0; i < nx; i++) + for (j = 0; j < ny; j++) + { + ex[i][j] = ((DATA_TYPE) i*(j+1)) / nx; + ey[i][j] = ((DATA_TYPE) i*(j+2)) / ny; + hz[i][j] = ((DATA_TYPE) i*(j+3)) / nx; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int nx, + int ny, + DATA_TYPE POLYBENCH_2D(ex,NX,NY,nx,ny), + DATA_TYPE POLYBENCH_2D(ey,NX,NY,nx,ny), + DATA_TYPE POLYBENCH_2D(hz,NX,NY,nx,ny)) +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("ex"); + for (i = 0; i < nx; i++) + for (j = 0; j < ny; j++) { + if ((i * nx + j) % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf(POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, ex[i][j]); + } + POLYBENCH_DUMP_END("ex"); + POLYBENCH_DUMP_FINISH; + + POLYBENCH_DUMP_BEGIN("ey"); + for (i = 0; i < nx; i++) + for (j = 0; j < ny; j++) { + if ((i * nx + j) % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf(POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, ey[i][j]); + } + POLYBENCH_DUMP_END("ey"); + + POLYBENCH_DUMP_BEGIN("hz"); + for (i = 0; i < nx; i++) + for (j = 0; j < ny; j++) { + if ((i * nx + j) % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf(POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, hz[i][j]); + } + POLYBENCH_DUMP_END("hz"); +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_fdtd_2d(int tmax, + int nx, + int ny, + DATA_TYPE POLYBENCH_2D(ex,NX,NY,nx,ny), + DATA_TYPE POLYBENCH_2D(ey,NX,NY,nx,ny), + DATA_TYPE POLYBENCH_2D(hz,NX,NY,nx,ny), + DATA_TYPE POLYBENCH_1D(_fict_,TMAX,tmax)) +{ + int t, i, j; + +#pragma scop + + for(t = 0; t < _PB_TMAX; t++) + { + for (j = 0; j < _PB_NY; j++) + ey[0][j] = _fict_[t]; + for (i = 1; i < _PB_NX; i++) + for (j = 0; j < _PB_NY; j++) + ey[i][j] = ey[i][j] - SCALAR_VAL(0.5)*(hz[i][j]-hz[i-1][j]); + for (i = 0; i < _PB_NX; i++) + for (j = 1; j < _PB_NY; j++) + ex[i][j] = ex[i][j] - SCALAR_VAL(0.5)*(hz[i][j]-hz[i][j-1]); + for (i = 0; i < _PB_NX - 1; i++) + for (j = 0; j < _PB_NY - 1; j++) + hz[i][j] = hz[i][j] - SCALAR_VAL(0.7)* (ex[i][j+1] - ex[i][j] + + ey[i+1][j] - ey[i][j]); + } + +#pragma endscop +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int tmax = TMAX; + int nx = NX; + int ny = NY; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(ex,DATA_TYPE,NX,NY,nx,ny); + POLYBENCH_2D_ARRAY_DECL(ey,DATA_TYPE,NX,NY,nx,ny); + POLYBENCH_2D_ARRAY_DECL(hz,DATA_TYPE,NX,NY,nx,ny); + POLYBENCH_1D_ARRAY_DECL(_fict_,DATA_TYPE,TMAX,tmax); + + /* Initialize array(s). */ + init_array (tmax, nx, ny, + POLYBENCH_ARRAY(ex), + POLYBENCH_ARRAY(ey), + POLYBENCH_ARRAY(hz), + POLYBENCH_ARRAY(_fict_)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_fdtd_2d (tmax, nx, ny, + POLYBENCH_ARRAY(ex), + POLYBENCH_ARRAY(ey), + POLYBENCH_ARRAY(hz), + POLYBENCH_ARRAY(_fict_)); + + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(nx, ny, POLYBENCH_ARRAY(ex), + POLYBENCH_ARRAY(ey), + POLYBENCH_ARRAY(hz))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(ex); + POLYBENCH_FREE_ARRAY(ey); + POLYBENCH_FREE_ARRAY(hz); + POLYBENCH_FREE_ARRAY(_fict_); + + return 0; +} diff --git a/datasets/PolyBenchC/stencils/fdtd-2d/fdtd-2d.h b/datasets/PolyBenchC/stencils/fdtd-2d/fdtd-2d.h new file mode 100644 index 0000000..4ffadd5 --- /dev/null +++ b/datasets/PolyBenchC/stencils/fdtd-2d/fdtd-2d.h @@ -0,0 +1,86 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _FDTD_2D_H +# define _FDTD_2D_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(TMAX) && !defined(NX) && !defined(NY) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define TMAX 20 +# define NX 20 +# define NY 30 +# endif + +# ifdef SMALL_DATASET +# define TMAX 40 +# define NX 60 +# define NY 80 +# endif + +# ifdef MEDIUM_DATASET +# define TMAX 100 +# define NX 200 +# define NY 240 +# endif + +# ifdef LARGE_DATASET +# define TMAX 500 +# define NX 1000 +# define NY 1200 +# endif + +# ifdef EXTRALARGE_DATASET +# define TMAX 1000 +# define NX 2000 +# define NY 2600 +# endif + + +#endif /* !(TMAX NX NY) */ + +# define _PB_TMAX POLYBENCH_LOOP_BOUND(TMAX,tmax) +# define _PB_NX POLYBENCH_LOOP_BOUND(NX,nx) +# define _PB_NY POLYBENCH_LOOP_BOUND(NY,ny) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_FDTD_2D_H */ diff --git a/datasets/PolyBenchC/stencils/heat-3d/heat-3d.c b/datasets/PolyBenchC/stencils/heat-3d/heat-3d.c new file mode 100644 index 0000000..dcb95a8 --- /dev/null +++ b/datasets/PolyBenchC/stencils/heat-3d/heat-3d.c @@ -0,0 +1,131 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* heat-3d.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "heat-3d.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_3D(A,N,N,N,n,n,n), + DATA_TYPE POLYBENCH_3D(B,N,N,N,n,n,n)) +{ + int i, j, k; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + for (k = 0; k < n; k++) + A[i][j][k] = B[i][j][k] = (DATA_TYPE) (i + j + (n-k))* 10 / (n); +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_3D(A,N,N,N,n,n,n)) + +{ + int i, j, k; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("A"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + for (k = 0; k < n; k++) { + if ((i * n * n + j * n + k) % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf(POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, A[i][j][k]); + } + POLYBENCH_DUMP_END("A"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_heat_3d(int tsteps, + int n, + DATA_TYPE POLYBENCH_3D(A,N,N,N,n,n,n), + DATA_TYPE POLYBENCH_3D(B,N,N,N,n,n,n)) +{ + int t, i, j, k; + +#pragma scop + for (t = 1; t <= TSTEPS; t++) { + for (i = 1; i < _PB_N-1; i++) { + for (j = 1; j < _PB_N-1; j++) { + for (k = 1; k < _PB_N-1; k++) { + B[i][j][k] = SCALAR_VAL(0.125) * (A[i+1][j][k] - SCALAR_VAL(2.0) * A[i][j][k] + A[i-1][j][k]) + + SCALAR_VAL(0.125) * (A[i][j+1][k] - SCALAR_VAL(2.0) * A[i][j][k] + A[i][j-1][k]) + + SCALAR_VAL(0.125) * (A[i][j][k+1] - SCALAR_VAL(2.0) * A[i][j][k] + A[i][j][k-1]) + + A[i][j][k]; + } + } + } + for (i = 1; i < _PB_N-1; i++) { + for (j = 1; j < _PB_N-1; j++) { + for (k = 1; k < _PB_N-1; k++) { + A[i][j][k] = SCALAR_VAL(0.125) * (B[i+1][j][k] - SCALAR_VAL(2.0) * B[i][j][k] + B[i-1][j][k]) + + SCALAR_VAL(0.125) * (B[i][j+1][k] - SCALAR_VAL(2.0) * B[i][j][k] + B[i][j-1][k]) + + SCALAR_VAL(0.125) * (B[i][j][k+1] - SCALAR_VAL(2.0) * B[i][j][k] + B[i][j][k-1]) + + B[i][j][k]; + } + } + } + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int tsteps = TSTEPS; + + /* Variable declaration/allocation. */ + POLYBENCH_3D_ARRAY_DECL(A, DATA_TYPE, N, N, N, n, n, n); + POLYBENCH_3D_ARRAY_DECL(B, DATA_TYPE, N, N, N, n, n, n); + + + /* Initialize array(s). */ + init_array (n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_heat_3d (tsteps, n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(A))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + + return 0; +} diff --git a/datasets/PolyBenchC/stencils/heat-3d/heat-3d.h b/datasets/PolyBenchC/stencils/heat-3d/heat-3d.h new file mode 100644 index 0000000..37fb9fd --- /dev/null +++ b/datasets/PolyBenchC/stencils/heat-3d/heat-3d.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _HEAT_3D_H +# define _HEAT_3D_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(TSTEPS) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define TSTEPS 20 +# define N 10 +# endif + +# ifdef SMALL_DATASET +# define TSTEPS 40 +# define N 20 +# endif + +# ifdef MEDIUM_DATASET +# define TSTEPS 100 +# define N 40 +# endif + +# ifdef LARGE_DATASET +# define TSTEPS 500 +# define N 120 +# endif + +# ifdef EXTRALARGE_DATASET +# define TSTEPS 1000 +# define N 200 +# endif + + +#endif /* !(TSTEPS N) */ + +# define _PB_TSTEPS POLYBENCH_LOOP_BOUND(TSTEPS,tsteps) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_HEAT_3D_H */ diff --git a/datasets/PolyBenchC/stencils/jacobi-1d/jacobi-1d.c b/datasets/PolyBenchC/stencils/jacobi-1d/jacobi-1d.c new file mode 100644 index 0000000..feceb5d --- /dev/null +++ b/datasets/PolyBenchC/stencils/jacobi-1d/jacobi-1d.c @@ -0,0 +1,117 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* jacobi-1d.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "jacobi-1d.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_1D(A,N,n), + DATA_TYPE POLYBENCH_1D(B,N,n)) +{ + int i; + + for (i = 0; i < n; i++) + { + A[i] = ((DATA_TYPE) i+ 2) / n; + B[i] = ((DATA_TYPE) i+ 3) / n; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_1D(A,N,n)) + +{ + int i; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("A"); + for (i = 0; i < n; i++) + { + if (i % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf(POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, A[i]); + } + POLYBENCH_DUMP_END("A"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_jacobi_1d(int tsteps, + int n, + DATA_TYPE POLYBENCH_1D(A,N,n), + DATA_TYPE POLYBENCH_1D(B,N,n)) +{ + int t, i; + +#pragma scop + for (t = 0; t < _PB_TSTEPS; t++) + { + for (i = 1; i < _PB_N - 1; i++) + B[i] = 0.33333 * (A[i-1] + A[i] + A[i + 1]); + for (i = 1; i < _PB_N - 1; i++) + A[i] = 0.33333 * (B[i-1] + B[i] + B[i + 1]); + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int tsteps = TSTEPS; + + /* Variable declaration/allocation. */ + POLYBENCH_1D_ARRAY_DECL(A, DATA_TYPE, N, n); + POLYBENCH_1D_ARRAY_DECL(B, DATA_TYPE, N, n); + + + /* Initialize array(s). */ + init_array (n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_jacobi_1d(tsteps, n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(A))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + + return 0; +} diff --git a/datasets/PolyBenchC/stencils/jacobi-1d/jacobi-1d.h b/datasets/PolyBenchC/stencils/jacobi-1d/jacobi-1d.h new file mode 100644 index 0000000..febdfcb --- /dev/null +++ b/datasets/PolyBenchC/stencils/jacobi-1d/jacobi-1d.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _JACOBI_1D_H +# define _JACOBI_1D_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(TSTEPS) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define TSTEPS 20 +# define N 30 +# endif + +# ifdef SMALL_DATASET +# define TSTEPS 40 +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define TSTEPS 100 +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define TSTEPS 500 +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define TSTEPS 1000 +# define N 4000 +# endif + + +#endif /* !(TSTEPS N) */ + +# define _PB_TSTEPS POLYBENCH_LOOP_BOUND(TSTEPS,tsteps) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_JACOBI_1D_H */ diff --git a/datasets/PolyBenchC/stencils/jacobi-2d/jacobi-2d.c b/datasets/PolyBenchC/stencils/jacobi-2d/jacobi-2d.c new file mode 100644 index 0000000..40dc1d3 --- /dev/null +++ b/datasets/PolyBenchC/stencils/jacobi-2d/jacobi-2d.c @@ -0,0 +1,120 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* jacobi-2d.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "jacobi-2d.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n), + DATA_TYPE POLYBENCH_2D(B,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + { + A[i][j] = ((DATA_TYPE) i*(j+2) + 2) / n; + B[i][j] = ((DATA_TYPE) i*(j+3) + 3) / n; + } +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("A"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + if ((i * n + j) % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf(POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, A[i][j]); + } + POLYBENCH_DUMP_END("A"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_jacobi_2d(int tsteps, + int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n), + DATA_TYPE POLYBENCH_2D(B,N,N,n,n)) +{ + int t, i, j; + +#pragma scop + for (t = 0; t < _PB_TSTEPS; t++) + { + for (i = 1; i < _PB_N - 1; i++) + for (j = 1; j < _PB_N - 1; j++) + B[i][j] = SCALAR_VAL(0.2) * (A[i][j] + A[i][j-1] + A[i][1+j] + A[1+i][j] + A[i-1][j]); + for (i = 1; i < _PB_N - 1; i++) + for (j = 1; j < _PB_N - 1; j++) + A[i][j] = SCALAR_VAL(0.2) * (B[i][j] + B[i][j-1] + B[i][1+j] + B[1+i][j] + B[i-1][j]); + } +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int tsteps = TSTEPS; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n); + POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, N, N, n, n); + + + /* Initialize array(s). */ + init_array (n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_jacobi_2d(tsteps, n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(A))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + POLYBENCH_FREE_ARRAY(B); + + return 0; +} diff --git a/datasets/PolyBenchC/stencils/jacobi-2d/jacobi-2d.h b/datasets/PolyBenchC/stencils/jacobi-2d/jacobi-2d.h new file mode 100644 index 0000000..ca0d4d3 --- /dev/null +++ b/datasets/PolyBenchC/stencils/jacobi-2d/jacobi-2d.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _JACOBI_2D_H +# define _JACOBI_2D_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(TSTEPS) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define TSTEPS 20 +# define N 30 +# endif + +# ifdef SMALL_DATASET +# define TSTEPS 40 +# define N 90 +# endif + +# ifdef MEDIUM_DATASET +# define TSTEPS 100 +# define N 250 +# endif + +# ifdef LARGE_DATASET +# define TSTEPS 500 +# define N 1300 +# endif + +# ifdef EXTRALARGE_DATASET +# define TSTEPS 1000 +# define N 2800 +# endif + + +#endif /* !(TSTEPS N) */ + +# define _PB_TSTEPS POLYBENCH_LOOP_BOUND(TSTEPS,tsteps) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_JACOBI_2D_H */ diff --git a/datasets/PolyBenchC/stencils/seidel-2d/seidel-2d.c b/datasets/PolyBenchC/stencils/seidel-2d/seidel-2d.c new file mode 100644 index 0000000..247adda --- /dev/null +++ b/datasets/PolyBenchC/stencils/seidel-2d/seidel-2d.c @@ -0,0 +1,110 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* seidel-2d.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +#include "seidel-2d.h" + + +/* Array initialization. */ +static +void init_array (int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + A[i][j] = ((DATA_TYPE) i*(j+2) + 2) / n; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) + +{ + int i, j; + + POLYBENCH_DUMP_START; + POLYBENCH_DUMP_BEGIN("A"); + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + if ((i * n + j) % 20 == 0) fprintf(POLYBENCH_DUMP_TARGET, "\n"); + fprintf(POLYBENCH_DUMP_TARGET, DATA_PRINTF_MODIFIER, A[i][j]); + } + POLYBENCH_DUMP_END("A"); + POLYBENCH_DUMP_FINISH; +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_seidel_2d(int tsteps, + int n, + DATA_TYPE POLYBENCH_2D(A,N,N,n,n)) +{ + int t, i, j; + +#pragma scop + for (t = 0; t <= _PB_TSTEPS - 1; t++) + for (i = 1; i<= _PB_N - 2; i++) + for (j = 1; j <= _PB_N - 2; j++) + A[i][j] = (A[i-1][j-1] + A[i-1][j] + A[i-1][j+1] + + A[i][j-1] + A[i][j] + A[i][j+1] + + A[i+1][j-1] + A[i+1][j] + A[i+1][j+1])/SCALAR_VAL(9.0); +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + int tsteps = TSTEPS; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n); + + + /* Initialize array(s). */ + init_array (n, POLYBENCH_ARRAY(A)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_seidel_2d (tsteps, n, POLYBENCH_ARRAY(A)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(A))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(A); + + return 0; +} diff --git a/datasets/PolyBenchC/stencils/seidel-2d/seidel-2d.h b/datasets/PolyBenchC/stencils/seidel-2d/seidel-2d.h new file mode 100644 index 0000000..e7761b0 --- /dev/null +++ b/datasets/PolyBenchC/stencils/seidel-2d/seidel-2d.h @@ -0,0 +1,80 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#ifndef _SEIDEL_2D_H +# define _SEIDEL_2D_H + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +# if !defined(TSTEPS) && !defined(N) +/* Define sample dataset sizes. */ +# ifdef MINI_DATASET +# define TSTEPS 20 +# define N 40 +# endif + +# ifdef SMALL_DATASET +# define TSTEPS 40 +# define N 120 +# endif + +# ifdef MEDIUM_DATASET +# define TSTEPS 100 +# define N 400 +# endif + +# ifdef LARGE_DATASET +# define TSTEPS 500 +# define N 2000 +# endif + +# ifdef EXTRALARGE_DATASET +# define TSTEPS 1000 +# define N 4000 +# endif + + +#endif /* !(TSTEPS N) */ + +# define _PB_TSTEPS POLYBENCH_LOOP_BOUND(TSTEPS,tsteps) +# define _PB_N POLYBENCH_LOOP_BOUND(N,n) + + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_DOUBLE +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !_SEIDEL_2D_H */ diff --git a/datasets/PolyBenchC/utilities/benchmark_list b/datasets/PolyBenchC/utilities/benchmark_list new file mode 100644 index 0000000..7ce7b7e --- /dev/null +++ b/datasets/PolyBenchC/utilities/benchmark_list @@ -0,0 +1,30 @@ +./datamining/correlation/correlation.c +./datamining/covariance/covariance.c +./linear-algebra/kernels/2mm/2mm.c +./linear-algebra/kernels/3mm/3mm.c +./linear-algebra/kernels/atax/atax.c +./linear-algebra/kernels/bicg/bicg.c +./linear-algebra/kernels/doitgen/doitgen.c +./linear-algebra/kernels/mvt/mvt.c +./linear-algebra/blas/gemm/gemm.c +./linear-algebra/blas/gemver/gemver.c +./linear-algebra/blas/gesummv/gesummv.c +./linear-algebra/blas/symm/symm.c +./linear-algebra/blas/syr2k/syr2k.c +./linear-algebra/blas/syrk/syrk.c +./linear-algebra/blas/trmm/trmm.c +./linear-algebra/solvers/cholesky/cholesky.c +./linear-algebra/solvers/durbin/durbin.c +./linear-algebra/solvers/gramschmidt/gramschmidt.c +./linear-algebra/solvers/lu/lu.c +./linear-algebra/solvers/ludcmp/ludcmp.c +./linear-algebra/solvers/trisolv/trisolv.c +./medley/deriche/deriche.c +./medley/floyd-warshall/floyd-warshall.c +./medley/nussinov/nussinov.c +./stencils/adi/adi.c +./stencils/fdtd-2d/fdtd-2d.c +./stencils/heat-3d/heat-3d.c +./stencils/jacobi-1d/jacobi-1d.c +./stencils/jacobi-2d/jacobi-2d.c +./stencils/seidel-2d/seidel-2d.c diff --git a/datasets/PolyBenchC/utilities/clean.pl b/datasets/PolyBenchC/utilities/clean.pl new file mode 100644 index 0000000..9b45bb9 --- /dev/null +++ b/datasets/PolyBenchC/utilities/clean.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +# Visits every directory, calls make clean, and then removes the Makefile +# +# Written by Tomofumi Yuki, 11/21 2014 +# + +my $TARGET_DIR = "."; + +if ($#ARGV != 0) { + printf("usage perl clean.pl target-dir\n"); + exit(1); +} + + + +if ($#ARGV == 0) { + $TARGET_DIR = $ARGV[0]; +} + + +my @categories = ('linear-algebra/blas', + 'linear-algebra/kernels', + 'linear-algebra/solvers', + 'datamining', + 'stencils', + 'medley'); + + +foreach $cat (@categories) { + my $target = $TARGET_DIR.'/'.$cat; + opendir DIR, $target or die "directory $target not found.\n"; + while (my $dir = readdir DIR) { + next if ($dir=~'^\..*'); + next if (!(-d $target.'/'.$dir)); + + my $targetDir = $target.'/'.$dir; + my $command = "cd $targetDir; make clean; rm -f Makefile"; + print($command."\n"); + system($command); + } + + closedir DIR; +} + +my $cfgFile = $TARGET_DIR.'/'.'config.mk'; +if (-e $cfgFile) { + unlink $cfgFile; +} + diff --git a/datasets/PolyBenchC/utilities/create_cpped_version.pl b/datasets/PolyBenchC/utilities/create_cpped_version.pl new file mode 100644 index 0000000..3354a1c --- /dev/null +++ b/datasets/PolyBenchC/utilities/create_cpped_version.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +# Creates C Pre-Processed Version +# Additional arguments to the script are all passed to gcc. +# At least the include path of polybench.h must be added. +# +# Written by Tomofumi Yuki, 01/14 2015 +# + +if ($#ARGV == -1) { + printf("usage perl create-cpped-version.pl filename [cflags]\n"); + exit(1); +} + +my @CFLAGS = @ARGV; +my $TARGET = shift @CFLAGS; + +my $TEMP_T = '.__poly_top.c'; +my $TEMP_B = '.__poly_bottom.c'; +my $TEMP_P = '.__poly_bottom.pp.c'; + +$TARGET =~ /([^\.\/]+)\.c$/; +my $KERNEL = $1; +$TARGET_DIR = substr $TARGET, 0, -length($KERNEL)-2; +$TARGET_DIR = '.' if $TARGET_DIR eq ''; + +open FILE, $TARGET or die "Error opening $TARGET"; + +my $top; +my $bottom; +my $current = \$top; +while () { + my $line = $_; + if ($line =~ /polybench\.h/) { + $current = \$bottom; + } + $$current .= $line; +} +close FILE; + +&writeToFile($TEMP_T, $top); +&writeToFile($TEMP_B, $bottom); + +my $ignoreLibs = "-D_STDLIB_H_ -D_STDIO_H_ -D_MATH_H_ -D_STRING_H_ -D_UNISTD_H_"; + +my $command = 'gcc -E '.$ignoreLibs.' '.$TEMP_B.' -I '.$TARGET_DIR.' '.join(" ", @CFLAGS).' 2>/dev/null > '.$TEMP_P; +system($command); + +my $OUTFILE = $TARGET_DIR.'/'.$KERNEL.'.preproc.c'; +system('cat '.$TEMP_T.' > '.$OUTFILE); +system('echo "#include" >> '.$OUTFILE); +$command = 'sed -e "s~'.$TEMP_B.'~'.$KERNEL.'.c~g" '.$TEMP_P.' >> '.$OUTFILE; +system($command); + +unlink $TEMP_P; +unlink $TEMP_B; +unlink $TEMP_T; + +sub writeToFile() { + my $file = $_[0]; + my $content = $_[1]; + + open FILE, ">$file" or die "Error writing to $file"; + + print FILE $content; + + close FILE; +} diff --git a/datasets/PolyBenchC/utilities/header-gen.pl b/datasets/PolyBenchC/utilities/header-gen.pl new file mode 100644 index 0000000..a58ee94 --- /dev/null +++ b/datasets/PolyBenchC/utilities/header-gen.pl @@ -0,0 +1,143 @@ +#!/usr/bin/perl + +# Generates headers using specification in polybench.spec +# +# Written by Tomofumi Yuki, 11/21 2014 +# + +use File::Path; + +if ($#ARGV != 0) { + printf("usage perl header-gen.pl output-dir\n"); + exit(1); +} + +my $SPECFILE = 'polybench.spec'; +my $OUTDIR = $ARGV[0]; +my @DATASET_NAMES = ('MINI', 'SMALL', 'MEDIUM', 'LARGE', 'EXTRALARGE'); + +if (!(-e $OUTDIR)) { + mkdir $OUTDIR; +} + +my %INPUT; +my @keys; + +open FILE, $SPECFILE or die; + while () { + my $line = $_; + $line =~ s/\r|\n//g; + #lines tarting with # is treated as comments + next if ($line=~/^\s*#/); + next if ($line=~/^\s*[\r|\n]+$/); + my @line = split(/\t+/, $line); + + if (!keys %INPUT ) { + foreach (@line) { + $INPUT{$_} = []; + } + @keys = @line; + } else { + for (my $i = 0; $i <= $#line; $i++) { + push @{$INPUT{$keys[$i]}}, $line[$i] ; + } + } + } + +close FILE; + +for (my $r = 0; $r <= $#{$INPUT{'kernel'}}; $r++) { + &generateHeader($r); +} + +sub generateHeader() { + + my $row = $_[0]; + my $name = $INPUT{'kernel'}[$row]; + my $category = $INPUT{'category'}[$row]; + my $datatype = $INPUT{'datatype'}[$row]; + my $datatypeUC = uc $datatype; + my @params = split /\s+/, $INPUT{'params'}[$row]; + + + my $headerDef = '_'. uc $name . '_H'; + $headerDef =~ s/-/_/g; + + my $paramDefs; + foreach $set (@DATASET_NAMES) { + my @sizes = split /\s+/, $INPUT{$set}[$row]; + $paramDefs .= '# ifdef '.$set."_DATASET\n"; + for (my $i = 0; $i <= $#params; $i++) { + $paramDefs .= '# define '.$params[$i].' '.$sizes[$i]."\n"; + } + $paramDefs .= '# endif '."\n\n"; + } + + my $paramCheck = '# if'; + my $loopBoundDef = ''; + { + my $first = 1; + foreach (@params) { + $paramCheck.= ' &&' if (!$first); + $paramCheck .= " !defined($_)"; + $first = 0; + $loopBoundDef .= '# define _PB_'.$_.' POLYBENCH_LOOP_BOUND('.$_.','.lc $_.')'."\n"; + } + } + + my $kernelPath = "$OUTDIR/$category/$name"; + if (!(-e $kernelPath)) { + mkpath $kernelPath; + } + + open HFILE, ">$kernelPath/$name.h"; +print HFILE << "EOF"; +#ifndef $headerDef +# define $headerDef + +/* Default to LARGE_DATASET. */ +# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(MEDIUM_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET) +# define LARGE_DATASET +# endif + +$paramCheck +/* Define sample dataset sizes. */ +$paramDefs +#endif /* !(@params) */ + +$loopBoundDef + +/* Default data type */ +# if !defined(DATA_TYPE_IS_INT) && !defined(DATA_TYPE_IS_FLOAT) && !defined(DATA_TYPE_IS_DOUBLE) +# define DATA_TYPE_IS_$datatypeUC +# endif + +#ifdef DATA_TYPE_IS_INT +# define DATA_TYPE int +# define DATA_PRINTF_MODIFIER "%d " +#endif + +#ifdef DATA_TYPE_IS_FLOAT +# define DATA_TYPE float +# define DATA_PRINTF_MODIFIER "%0.2f " +# define SCALAR_VAL(x) x##f +# define SQRT_FUN(x) sqrtf(x) +# define EXP_FUN(x) expf(x) +# define POW_FUN(x,y) powf(x,y) +# endif + +#ifdef DATA_TYPE_IS_DOUBLE +# define DATA_TYPE double +# define DATA_PRINTF_MODIFIER "%0.2lf " +# define SCALAR_VAL(x) x +# define SQRT_FUN(x) sqrt(x) +# define EXP_FUN(x) exp(x) +# define POW_FUN(x,y) pow(x,y) +# endif + +#endif /* !$headerDef */ + +EOF + close HFILE; +} + diff --git a/datasets/PolyBenchC/utilities/makefile-gen.pl b/datasets/PolyBenchC/utilities/makefile-gen.pl new file mode 100644 index 0000000..00aaa45 --- /dev/null +++ b/datasets/PolyBenchC/utilities/makefile-gen.pl @@ -0,0 +1,90 @@ +#!/usr/bin/perl + +# Generates Makefile for each benchmark in polybench +# Expects to be executed from root folder of polybench +# +# Written by Tomofumi Yuki, 11/21 2014 +# + +my $GEN_CONFIG = 0; +my $TARGET_DIR = "."; + +if ($#ARGV !=0 && $#ARGV != 1) { + printf("usage perl makefile-gen.pl output-dir [-cfg]\n"); + printf(" -cfg option generates config.mk in the output-dir.\n"); + exit(1); +} + + + +foreach my $arg (@ARGV) { + if ($arg =~ /-cfg/) { + $GEN_CONFIG = 1; + } elsif (!($arg =~ /^-/)) { + $TARGET_DIR = $arg; + } +} + + +my %categories = ( + 'linear-algebra/blas' => 3, + 'linear-algebra/kernels' => 3, + 'linear-algebra/solvers' => 3, + 'datamining' => 2, + 'stencils' => 2, + 'medley' => 2 +); + +my %extra_flags = ( + 'cholesky' => '-lm', + 'gramschmidt' => '-lm', + 'correlation' => '-lm' +); + +foreach $key (keys %categories) { + my $target = $TARGET_DIR.'/'.$key; + opendir DIR, $target or die "directory $target not found.\n"; + while (my $dir = readdir DIR) { + next if ($dir=~'^\..*'); + next if (!(-d $target.'/'.$dir)); + + my $kernel = $dir; + my $file = $target.'/'.$dir.'/Makefile'; + my $polybenchRoot = '../'x$categories{$key}; + my $configFile = $polybenchRoot.'config.mk'; + my $utilityDir = $polybenchRoot.'utilities'; + + open FILE, ">$file" or die "failed to open $file."; + +print FILE << "EOF"; +include $configFile + +EXTRA_FLAGS=$extra_flags{$kernel} + +$kernel: $kernel.c $kernel.h + \${VERBOSE} \${CC} -o $kernel $kernel.c \${CFLAGS} -I. -I$utilityDir $utilityDir/polybench.c \${EXTRA_FLAGS} + +clean: + @ rm -f $kernel + +EOF + + close FILE; + } + + + closedir DIR; +} + +if ($GEN_CONFIG) { +open FILE, '>'.$TARGET_DIR.'/config.mk'; + +print FILE << "EOF"; +CC=gcc +CFLAGS=-O2 -DPOLYBENCH_DUMP_ARRAYS -DPOLYBENCH_USE_C99_PROTO +EOF + +close FILE; + +} + diff --git a/datasets/PolyBenchC/utilities/papi_counters.list b/datasets/PolyBenchC/utilities/papi_counters.list new file mode 100644 index 0000000..d8879cb --- /dev/null +++ b/datasets/PolyBenchC/utilities/papi_counters.list @@ -0,0 +1,5 @@ +// Counters must be delimited with ',' including the last one. +// C/C++ comments are allowed. +// Both native and standard PAPI events are supported. +"PAPI_TOT_CYC", +"L1D:REPL", diff --git a/datasets/PolyBenchC/utilities/polybench.R b/datasets/PolyBenchC/utilities/polybench.R new file mode 100644 index 0000000..3e4742d --- /dev/null +++ b/datasets/PolyBenchC/utilities/polybench.R @@ -0,0 +1,358 @@ +correlation <- function (M, N) { + data <- matrix(0, nrow=N, ncol=M); + for (i in 1:N) + for (j in 1:M) + data[i,j] = ((i-1)*(j-1))/M+i; + + cor <- cor(data); +} + +covariance <- function (M, N) { + data <- matrix(0, nrow=N, ncol=M); + for (i in 1:N) + for (j in 1:M) + data[i,j] = ((i-1)*(j-1))/M; + + res <- cov(data); +} + +gemm <- function(NI, NJ, NK) { + alpha <- 1.5; + beta <- 1.2; + C <- matrix(0, nrow=NI, ncol=NJ); + A <- matrix(0, nrow=NI, ncol=NK); + B <- matrix(0, nrow=NK, ncol=NJ); + + for (i in 1:NI) + for (j in 1:NJ) + C[i,j] <- (((i-1)*(j-1)+1) %% NI) / NI; + + for (i in 1:NI) + for (j in 1:NK) + A[i,j] <- (((i-1)*j) %% NK) / NK; + + for (i in 1:NK) + for (j in 1:NJ) + B[i,j] <- (((i-1)*(j+1)) %% NJ) / NJ; + + res <- alpha *A %*% B + beta * C; + +} + +gemver <- function (N) { + alpha <- 1.5; + beta <- 1.2; + A <- matrix(0, nrow=N, ncol=N); + u1 <- numeric(N); + u2 <- numeric(N); + v1 <- numeric(N); + v2 <- numeric(N); + y <- numeric(N); + z <- numeric(N); + + for (i in 1:N) { + ip <- i-1; + u1[i] <- ip; + u2[i] <- ((ip+1)/N)/2.0; + v1[i] <- ((ip+1)/N)/4.0; + v2[i] <- ((ip+1)/N)/6.0; + y[i] <- ((ip+1)/N)/8.0; + z[i] <- ((ip+1)/N)/9.0; + + for (j in 1:N) { + A[i,j] <- (((i-1)*(j-1)) %% N) / N; + } + } + + + Aprime <- A + u1 %o% v1 + u2 %o% v2; + x <- beta * t(Aprime) %*% y + z; + w <- alpha * Aprime %*% x; + + list(Aprime, x, w); +} + +gesummv <- function (N) { + alpha <- 1.5; + beta <- 1.2; + A <- matrix(0, nrow=N, ncol=N); + B <- matrix(0, nrow=N, ncol=N); + x <- numeric(N); + + for (i in 1:N) { + x[i] <- ((i-1) %% N) / N; + + for (j in 1:N) { + A[i,j] <- (((i-1)*(j-1)+1) %% N) / N; + B[i,j] <- (((i-1)*(j-1)+2) %% N) / N; + } + } + + y <- alpha * A %*% x + beta * B %*% x; +} + + +symm <- function(M, N) { + alpha <- 1.5; + beta <- 1.2; + A <- matrix(0, nrow=M, ncol=M); + B <- matrix(0, nrow=M, ncol=N); + C <- matrix(0, nrow=M, ncol=N); + + for (i in 1:M) + for (j in 1:N) { + C[i,j] <- ((i+j-2) %% 100) / M; + B[i,j] <- ((N+i-j) %% 100) / M; + } + for (i in 1:M) + for (j in i:M) { + A[i,j] <- ((i+j-2) %% 100) / M; + A[j,i] <- A[i,j]; + } + + res <- alpha * A %*% B + beta * C; + +} + +syrk <- function(M, N) { + + alpha <- 1.5; + beta <- 1.2; + A <- matrix(0, nrow=N, ncol=M); + C <- matrix(0, nrow=N, ncol=N); + + for (i in 1:N) + for (j in 1:M) + A[i,j] <- (((i-1)*(j-1)+1) %% N) / N; + + for (i in 1:N) + for (j in 1:N) + C[i,j] <- (((i-1)*(j-1)+2) %% M) / M; + + res <- alpha * A %*% t(A) + beta * C; + +#note that syrk only stores lower triangular part of the resulting symmetric matrix +} + +syr2k <- function(M, N) { + + alpha <- 1.5; + beta <- 1.2; + A <- matrix(0, nrow=N, ncol=M); + B <- matrix(0, nrow=N, ncol=M); + C <- matrix(0, nrow=N, ncol=N); + + for (i in 1:N) + for (j in 1:M) { + A[i,j] <- (((i-1)*(j-1)+1) %% N) / N; + B[i,j] <- (((i-1)*(j-1)+2) %% M) / M; + } + + for (i in 1:N) + for (j in 1:N) + C[i,j] <- (((i-1)*(j-1)+3) %% N) / M; + + res <- alpha * A %*% t(B) + alpha * B %*% t(A) + beta * C; + +} + + +trmm <- function(M, N) { + + alpha <- 1.5; + A <- matrix(0, nrow=M, ncol=M); + B <- matrix(0, nrow=M, ncol=N); + + for (i in 1:M) { + for (j in 1:i-1) { + A[i,j] <- (((i-1)+(j-1)) %% M) / M; + } + A[i,i] <- 1.0; + for (j in 1:N) + B[i,j] <- ((N+(i-1)-(j-1)) %% N) / N; + } + + + res <- alpha * t(A) %*% B; +} + +twomm <- function(NI, NJ, NK, NL) { + alpha <- 1.5; + beta <- 1.2; + A <- matrix(0, nrow=NI, ncol=NK); + B <- matrix(0, nrow=NK, ncol=NJ); + C <- matrix(0, nrow=NJ, ncol=NL); + D <- matrix(0, nrow=NI, ncol=NL); + + for (i in 1:NI) + for (j in 1:NK) + A[i,j] <- (((i-1)*(j-1)+1) %% NI) / NI; + + for (i in 1:NK) + for (j in 1:NJ) + B[i,j] <- (((i-1)*(j)) %% NJ) / NJ; + + for (i in 1:NJ) + for (j in 1:NL) + C[i,j] <- (((i-1)*(j+2)+1) %% NL) / NL; + + for (i in 1:NI) + for (j in 1:NL) + D[i,j] <- (((i-1)*(j+1)) %% NK) / NK; + + + res <- alpha * A %*% B %*% C + beta * D; + +} + + +threemm <- function(NI, NJ, NK, NL, NM) { + A <- matrix(0, nrow=NI, ncol=NK); + B <- matrix(0, nrow=NK, ncol=NJ); + C <- matrix(0, nrow=NJ, ncol=NM); + D <- matrix(0, nrow=NM, ncol=NL); + + for (i in 1:NI) + for (j in 1:NK) + A[i,j] <- (((i-1)*(j-1)+1) %% NI) / (5*NI); + + for (i in 1:NK) + for (j in 1:NJ) + B[i,j] <- (((i-1)*(j)+2) %% NJ) / (5*NJ); + + for (i in 1:NJ) + for (j in 1:NM) + C[i,j] <- (((i-1)*(j+2)) %% NL) / (5*NL); + + for (i in 1:NM) + for (j in 1:NL) + D[i,j] <- (((i-1)*(j+1)+2) %% NK) / (5*NK); + + + E <- A %*% B; + F <- C %*% D; + G <- E %*% F; + +} + +atax <- function(M, N) { + A <- matrix(0, nrow=M, ncol=N); + x <- numeric(N); + + for (i in 1:N) + x[i] <- 1 + ((i-1) / N); + + for (i in 1:M) + for (j in 1:N) + A[i,j] <- (((i-1)+(j-1)) %% N) / (5*M) + + + y <- t(A) %*% (A %*% x); + +} + +mvt <- function(N) { + x1 <- numeric(N); + x2 <- numeric(N); + y1 <- numeric(N); + y2 <- numeric(N); + A <- matrix(0, nrow=N, ncol=N); + + for (i in 1:N) { + ip <- i-1; + x1[i] <- (ip %% N) / N; + x2[i] <- ((ip + 1) %% N) / N; + y1[i] <- ((ip + 3) %% N) / N; + y2[i] <- ((ip + 4) %% N) / N; + for (j in 1:N) + A[i,j] <- (((i-1)*(j-1)) %% N) / N; + } + + + x1 <- x1 + A %*% y1; + x2 <- x2 + t(A) %*% y2; +} + +cholesky <- function(N) { + A <- matrix(0, nrow=N, ncol=N) + + for (i in 1:N) { + for (j in 1:i) + A[i,j] <- ((-((j-1) %% N)) / N) + 1 + A[i,i] <- 1; + } + + A <- A %*% t(A); + + res <- chol(A); +} + +durbin <- function(N) { + r <- numeric(N+1) + + r[1] = 1; + for (i in 2:(N+1)) + r[i] <- N+1-(i-2) + + r1 <- r[1:N] + r2 <- r[2:(N+1)] + + res <- solve(toeplitz(r1), -r2) +} + +gramschmidt <- function(M, N) { + A <- matrix(0, nrow=M, ncol=N); + + for (i in 1:M) + for (j in 1:N) + A[i,j] <- ((((i-1)*(j-1)) %% M) / M)*100 + 10 + + res <- qr(A); + + list(res, qr.Q(res), qr.R(res)) +} + +library('Matrix') +lu.polybench <- function(N) { + A <- matrix(0, nrow=N, ncol=N) + + + for (i in 1:N) { + for (j in 1:i) + A[i,j] <- ((-((j-1) %% N)) / N) + 1 + A[i,i] <- 1; + } + + A <- A %*% t(A); + + res <- expand(lu(A)); +} + +ludcmp <- function(N) { + b <- numeric(N); + for (i in 1:N) + b[i] <- ((i/N)/2.0) +4; + + A <- matrix(0, nrow=N, ncol=N) + + for (i in 1:N) { + for (j in 1:i) + A[i,j] <- ((-((j-1) %% N)) / N) + 1 + A[i,i] <- 1; + } + + A <- A %*% t(A); + + res <- solve(A, b); +} + +trisolv <- function(N) { + L <- matrix(0, nrow=N, ncol=N) + b <- c(0:(N-1)) + + for (i in 1:N) + for (j in 0:i) + L[i,j] <- (((i-1)+N-(j-1)+1)*2) / N + + res <- solve(L, b) +} diff --git a/datasets/PolyBenchC/utilities/polybench.c b/datasets/PolyBenchC/utilities/polybench.c new file mode 100644 index 0000000..e335933 --- /dev/null +++ b/datasets/PolyBenchC/utilities/polybench.c @@ -0,0 +1,569 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* polybench.c: this file is part of PolyBench/C */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef _OPENMP +# include +#endif + +#if defined(POLYBENCH_PAPI) +# undef POLYBENCH_PAPI +# include "polybench.h" +# define POLYBENCH_PAPI +#else +# include "polybench.h" +#endif + +/* By default, collect PAPI counters on thread 0. */ +#ifndef POLYBENCH_THREAD_MONITOR +# define POLYBENCH_THREAD_MONITOR 0 +#endif + +/* Total LLC cache size. By default 32+MB.. */ +#ifndef POLYBENCH_CACHE_SIZE_KB +# define POLYBENCH_CACHE_SIZE_KB 32770 +#endif + + +int polybench_papi_counters_threadid = POLYBENCH_THREAD_MONITOR; +double polybench_program_total_flops = 0; + +#ifdef POLYBENCH_PAPI +# include +# define POLYBENCH_MAX_NB_PAPI_COUNTERS 96 + char* _polybench_papi_eventlist[] = { +#include "papi_counters.list" + NULL + }; + int polybench_papi_eventset; + int polybench_papi_eventlist[POLYBENCH_MAX_NB_PAPI_COUNTERS]; + long_long polybench_papi_values[POLYBENCH_MAX_NB_PAPI_COUNTERS]; + +#endif + +/* + * Allocation table, to enable inter-array padding. All data allocated + * with polybench_alloc_data should be freed with polybench_free_data. + * + */ +#define NB_INITIAL_TABLE_ENTRIES 512 +struct polybench_data_ptrs +{ + void** user_view; + void** real_ptr; + int nb_entries; + int nb_avail_entries; +}; +static struct polybench_data_ptrs* _polybench_alloc_table = NULL; +static size_t polybench_inter_array_padding_sz = 0; + +/* Timer code (gettimeofday). */ +double polybench_t_start, polybench_t_end; +/* Timer code (RDTSC). */ +unsigned long long int polybench_c_start, polybench_c_end; + +static +double rtclock() +{ +#if defined(POLYBENCH_TIME) || defined(POLYBENCH_GFLOPS) + struct timeval Tp; + int stat; + stat = gettimeofday (&Tp, NULL); + if (stat != 0) + printf ("Error return from gettimeofday: %d", stat); + return (Tp.tv_sec + Tp.tv_usec * 1.0e-6); +#else + return 0; +#endif +} + + +#ifdef POLYBENCH_CYCLE_ACCURATE_TIMER +static +unsigned long long int rdtsc() +{ + unsigned long long int ret = 0; + unsigned int cycles_lo; + unsigned int cycles_hi; + __asm__ volatile ("RDTSC" : "=a" (cycles_lo), "=d" (cycles_hi)); + ret = (unsigned long long int)cycles_hi << 32 | cycles_lo; + + return ret; +} +#endif + +void polybench_flush_cache() +{ + int cs = POLYBENCH_CACHE_SIZE_KB * 1024 / sizeof(double); + double* flush = (double*) calloc (cs, sizeof(double)); + int i; + double tmp = 0.0; +#ifdef _OPENMP +#pragma omp parallel for reduction(+:tmp) private(i) +#endif + for (i = 0; i < cs; i++) + tmp += flush[i]; + assert (tmp <= 10.0); + free (flush); +} + + +#ifdef POLYBENCH_LINUX_FIFO_SCHEDULER +void polybench_linux_fifo_scheduler() +{ + /* Use FIFO scheduler to limit OS interference. Program must be run + as root, and this works only for Linux kernels. */ + struct sched_param schedParam; + schedParam.sched_priority = sched_get_priority_max (SCHED_FIFO); + sched_setscheduler (0, SCHED_FIFO, &schedParam); +} + + +void polybench_linux_standard_scheduler() +{ + /* Restore to standard scheduler policy. */ + struct sched_param schedParam; + schedParam.sched_priority = sched_get_priority_max (SCHED_OTHER); + sched_setscheduler (0, SCHED_OTHER, &schedParam); +} +#endif + +#ifdef POLYBENCH_PAPI + +static +void test_fail(char *file, int line, char *call, int retval) +{ + char buf[128]; + + memset(buf, '\0', sizeof(buf)); + if (retval != 0) + fprintf (stdout,"%-40s FAILED\nLine # %d\n", file, line); + else + { + fprintf (stdout,"%-40s SKIPPED\n", file); + fprintf (stdout,"Line # %d\n", line); + } + if (retval == PAPI_ESYS) + { + sprintf (buf, "System error in %s", call); + perror (buf); + } + else if (retval > 0) + fprintf (stdout,"Error: %s\n", call); + else if (retval == 0) + fprintf (stdout,"Error: %s\n", call); + else + { + char errstring[PAPI_MAX_STR_LEN]; + // PAPI 5.4.3 has changed the API for PAPI_perror. + #if defined (PAPI_VERSION) && ((PAPI_VERSION_MAJOR(PAPI_VERSION) == 5 && PAPI_VERSION_MINOR(PAPI_VERSION) >= 4) || PAPI_VERSION_MAJOR(PAPI_VERSION) > 5) + fprintf (stdout, "Error in %s: %s\n", call, PAPI_strerror(retval)); + #else + PAPI_perror (retval, errstring, PAPI_MAX_STR_LEN); + fprintf (stdout,"Error in %s: %s\n", call, errstring); + #endif + } + fprintf (stdout,"\n"); + if (PAPI_is_initialized ()) + PAPI_shutdown (); + exit (1); +} + + +void polybench_papi_init() +{ +# ifdef _OPENMP +#pragma omp parallel + { +#pragma omp master + { + if (omp_get_max_threads () < polybench_papi_counters_threadid) + polybench_papi_counters_threadid = omp_get_max_threads () - 1; + } +#pragma omp barrier + + if (omp_get_thread_num () == polybench_papi_counters_threadid) + { +# endif + int retval; + polybench_papi_eventset = PAPI_NULL; + if ((retval = PAPI_library_init (PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) + test_fail (__FILE__, __LINE__, "PAPI_library_init", retval); + if ((retval = PAPI_create_eventset (&polybench_papi_eventset)) + != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_create_eventset", retval); + int k; + for (k = 0; _polybench_papi_eventlist[k]; ++k) + { + if ((retval = + PAPI_event_name_to_code (_polybench_papi_eventlist[k], + &(polybench_papi_eventlist[k]))) + != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_event_name_to_code", retval); + } + polybench_papi_eventlist[k] = 0; + + +# ifdef _OPENMP + } + } +#pragma omp barrier +# endif +} + + +void polybench_papi_close() +{ +# ifdef _OPENMP +#pragma omp parallel + { + if (omp_get_thread_num () == polybench_papi_counters_threadid) + { +# endif + int retval; + if ((retval = PAPI_destroy_eventset (&polybench_papi_eventset)) + != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_destroy_eventset", retval); + if (PAPI_is_initialized ()) + PAPI_shutdown (); +# ifdef _OPENMP + } + } +#pragma omp barrier +# endif +} + +int polybench_papi_start_counter(int evid) +{ +# ifndef POLYBENCH_NO_FLUSH_CACHE + polybench_flush_cache(); +# endif + +# ifdef _OPENMP +# pragma omp parallel + { + if (omp_get_thread_num () == polybench_papi_counters_threadid) + { +# endif + + int retval = 1; + char descr[PAPI_MAX_STR_LEN]; + PAPI_event_info_t evinfo; + PAPI_event_code_to_name (polybench_papi_eventlist[evid], descr); + if (PAPI_add_event (polybench_papi_eventset, + polybench_papi_eventlist[evid]) != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_add_event", 1); + if (PAPI_get_event_info (polybench_papi_eventlist[evid], &evinfo) + != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_get_event_info", retval); + if ((retval = PAPI_start (polybench_papi_eventset)) != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_start", retval); +# ifdef _OPENMP + } + } +#pragma omp barrier +# endif + return 0; +} + + +void polybench_papi_stop_counter(int evid) +{ +# ifdef _OPENMP +# pragma omp parallel + { + if (omp_get_thread_num () == polybench_papi_counters_threadid) + { +# endif + int retval; + long_long values[1]; + values[0] = 0; + if ((retval = PAPI_read (polybench_papi_eventset, &values[0])) + != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_read", retval); + + if ((retval = PAPI_stop (polybench_papi_eventset, NULL)) != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_stop", retval); + + polybench_papi_values[evid] = values[0]; + + if ((retval = PAPI_remove_event + (polybench_papi_eventset, + polybench_papi_eventlist[evid])) != PAPI_OK) + test_fail (__FILE__, __LINE__, "PAPI_remove_event", retval); +# ifdef _OPENMP + } + } +#pragma omp barrier +# endif +} + + +void polybench_papi_print() +{ + int verbose = 0; +# ifdef _OPENMP +# pragma omp parallel + { + if (omp_get_thread_num() == polybench_papi_counters_threadid) + { +#ifdef POLYBENCH_PAPI_VERBOSE + verbose = 1; +#endif + if (verbose) + printf ("On thread %d:\n", polybench_papi_counters_threadid); +#endif + int evid; + for (evid = 0; polybench_papi_eventlist[evid] != 0; ++evid) + { + if (verbose) + printf ("%s=", _polybench_papi_eventlist[evid]); + printf ("%llu ", polybench_papi_values[evid]); + if (verbose) + printf ("\n"); + } + printf ("\n"); +# ifdef _OPENMP + } + } +#pragma omp barrier +# endif +} + +#endif +/* ! POLYBENCH_PAPI */ + +void polybench_prepare_instruments() +{ +#ifndef POLYBENCH_NO_FLUSH_CACHE + polybench_flush_cache (); +#endif +#ifdef POLYBENCH_LINUX_FIFO_SCHEDULER + polybench_linux_fifo_scheduler (); +#endif +} + + +void polybench_timer_start() +{ + polybench_prepare_instruments (); +#ifndef POLYBENCH_CYCLE_ACCURATE_TIMER + polybench_t_start = rtclock (); +#else + polybench_c_start = rdtsc (); +#endif +} + + +void polybench_timer_stop() +{ +#ifndef POLYBENCH_CYCLE_ACCURATE_TIMER + polybench_t_end = rtclock (); +#else + polybench_c_end = rdtsc (); +#endif +#ifdef POLYBENCH_LINUX_FIFO_SCHEDULER + polybench_linux_standard_scheduler (); +#endif +} + + +void polybench_timer_print() +{ +#ifdef POLYBENCH_GFLOPS + if (polybench_program_total_flops == 0) + { + printf ("[PolyBench][WARNING] Program flops not defined, use polybench_set_program_flops(value)\n"); + printf ("%0.6lf\n", polybench_t_end - polybench_t_start); + } + else + printf ("%0.2lf\n", + (polybench_program_total_flops / + (double)(polybench_t_end - polybench_t_start)) / 1000000000); +#else +# ifndef POLYBENCH_CYCLE_ACCURATE_TIMER + printf ("%0.6f\n", polybench_t_end - polybench_t_start); +# else + printf ("%Ld\n", polybench_c_end - polybench_c_start); +# endif +#endif +} + +/* + * These functions are used only if the user defines a specific + * inter-array padding. It grows a global structure, + * _polybench_alloc_table, which keeps track of the data allocated via + * polybench_alloc_data (on which inter-array padding is applied), so + * that the original, non-shifted pointer can be recovered when + * calling polybench_free_data. + * + */ +#ifdef POLYBENCH_ENABLE_INTARRAY_PAD +static +void grow_alloc_table() +{ + if (_polybench_alloc_table == NULL || + (_polybench_alloc_table->nb_entries % NB_INITIAL_TABLE_ENTRIES) != 0 || + _polybench_alloc_table->nb_avail_entries != 0) + { + /* Should never happen if the API is properly used. */ + fprintf (stderr, "[ERROR] Inter-array padding requires to use polybench_alloc_data and polybench_free_data\n"); + exit (1); + } + size_t sz = _polybench_alloc_table->nb_entries; + sz += NB_INITIAL_TABLE_ENTRIES; + _polybench_alloc_table->user_view = + realloc (_polybench_alloc_table->user_view, sz * sizeof(void*)); + assert(_polybench_alloc_table->user_view != NULL); + _polybench_alloc_table->real_ptr = + realloc (_polybench_alloc_table->real_ptr, sz * sizeof(void*)); + assert(_polybench_alloc_table->real_ptr != NULL); + _polybench_alloc_table->nb_avail_entries = NB_INITIAL_TABLE_ENTRIES; +} + +static +void* register_padded_pointer(void* ptr, size_t orig_sz, size_t padded_sz) +{ + if (_polybench_alloc_table == NULL) + { + fprintf (stderr, "[ERROR] Inter-array padding requires to use polybench_alloc_data and polybench_free_data\n"); + exit (1); + } + if (_polybench_alloc_table->nb_avail_entries == 0) + grow_alloc_table (); + int id = _polybench_alloc_table->nb_entries++; + _polybench_alloc_table->real_ptr[id] = ptr; + _polybench_alloc_table->user_view[id] = ptr + (padded_sz - orig_sz); + + return _polybench_alloc_table->user_view[id]; +} + + +static +void +free_data_from_alloc_table (void* ptr) +{ + if (_polybench_alloc_table != NULL && _polybench_alloc_table->nb_entries > 0) + { + int i; + for (i = 0; i < _polybench_alloc_table->nb_entries; ++i) + if (_polybench_alloc_table->user_view[i] == ptr || + _polybench_alloc_table->real_ptr[i] == ptr) + break; + if (i != _polybench_alloc_table->nb_entries) + { + free (_polybench_alloc_table->real_ptr[i]); + for (; i < _polybench_alloc_table->nb_entries - 1; ++i) + { + _polybench_alloc_table->user_view[i] = + _polybench_alloc_table->user_view[i + 1]; + _polybench_alloc_table->real_ptr[i] = + _polybench_alloc_table->real_ptr[i + 1]; + } + _polybench_alloc_table->nb_entries--; + _polybench_alloc_table->nb_avail_entries++; + if (_polybench_alloc_table->nb_entries == 0) + { + free (_polybench_alloc_table->user_view); + free (_polybench_alloc_table->real_ptr); + free (_polybench_alloc_table); + _polybench_alloc_table = NULL; + } + } + } +} + +static +void check_alloc_table_state() +{ + if (_polybench_alloc_table == NULL) + { + _polybench_alloc_table = (struct polybench_data_ptrs*) + malloc (sizeof(struct polybench_data_ptrs)); + assert(_polybench_alloc_table != NULL); + _polybench_alloc_table->user_view = + (void**) malloc (sizeof(void*) * NB_INITIAL_TABLE_ENTRIES); + assert(_polybench_alloc_table->user_view != NULL); + _polybench_alloc_table->real_ptr = + (void**) malloc (sizeof(void*) * NB_INITIAL_TABLE_ENTRIES); + assert(_polybench_alloc_table->real_ptr != NULL); + _polybench_alloc_table->nb_entries = 0; + _polybench_alloc_table->nb_avail_entries = NB_INITIAL_TABLE_ENTRIES; + } +} + +#endif // !POLYBENCH_ENABLE_INTARRAY_PAD + + +static +void* +xmalloc(size_t alloc_sz) +{ + void* ret = NULL; + /* By default, post-pad the arrays. Safe behavior, but likely useless. */ + polybench_inter_array_padding_sz += POLYBENCH_INTER_ARRAY_PADDING_FACTOR; + size_t padded_sz = alloc_sz + polybench_inter_array_padding_sz; + int err = posix_memalign (&ret, 4096, padded_sz); + if (! ret || err) + { + fprintf (stderr, "[PolyBench] posix_memalign: cannot allocate memory"); + exit (1); + } + /* Safeguard: this is invoked only if polybench.c has been compiled + with inter-array padding support from polybench.h. If so, move + the starting address of the allocation and return it to the + user. The original pointer is registered in an allocation table + internal to polybench.c. Data must then be freed using + polybench_free_data, which will inspect the allocation table to + free the original pointer.*/ +#ifdef POLYBENCH_ENABLE_INTARRAY_PAD + /* This moves the 'ret' pointer by (padded_sz - alloc_sz) positions, and + registers it in the lookup table for future free using + polybench_free_data. */ + ret = register_padded_pointer(ret, alloc_sz, padded_sz); +#endif + + return ret; +} + + +void polybench_free_data(void* ptr) +{ +#ifdef POLYBENCH_ENABLE_INTARRAY_PAD + free_data_from_alloc_table (ptr); +#else + free (ptr); +#endif +} + + +void* polybench_alloc_data(unsigned long long int n, int elt_size) +{ +#ifdef POLYBENCH_ENABLE_INTARRAY_PAD + check_alloc_table_state (); +#endif + + /// FIXME: detect overflow! + size_t val = n; + val *= elt_size; + void* ret = xmalloc (val); + + return ret; +} diff --git a/datasets/PolyBenchC/utilities/polybench.h b/datasets/PolyBenchC/utilities/polybench.h new file mode 100644 index 0000000..e6f30f5 --- /dev/null +++ b/datasets/PolyBenchC/utilities/polybench.h @@ -0,0 +1,241 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +/* + * polybench.h: this file is part of PolyBench/C + * + * Polybench header for instrumentation. + * + * Programs must be compiled with `-I utilities utilities/polybench.c' + * + * Optionally, one can define: + * + * -DPOLYBENCH_TIME, to report the execution time, + * OR (exclusive): + * -DPOLYBENCH_PAPI, to use PAPI H/W counters (defined in polybench.c) + * + * + * See README or utilities/polybench.c for additional options. + * + */ +#ifndef POLYBENCH_H +# define POLYBENCH_H + +# include + +/* Array padding. By default, none is used. */ +# ifndef POLYBENCH_PADDING_FACTOR +/* default: */ +# define POLYBENCH_PADDING_FACTOR 0 +# endif + +/* Inter-array padding, for use with . By default, none is used. */ +# ifndef POLYBENCH_INTER_ARRAY_PADDING_FACTOR +/* default: */ +# define POLYBENCH_INTER_ARRAY_PADDING_FACTOR 0 +# undef POLYBENCH_ENABLE_INTARRAY_PAD +# else +# define POLYBENCH_ENABLE_INTARRAY_PAD +# endif + + +/* C99 arrays in function prototype. By default, do not use. */ +# ifdef POLYBENCH_USE_C99_PROTO +# define POLYBENCH_C99_SELECT(x,y) y +# else +/* default: */ +# define POLYBENCH_C99_SELECT(x,y) x +# endif + + +/* Scalar loop bounds in SCoPs. By default, use parametric loop bounds. */ +# ifdef POLYBENCH_USE_SCALAR_LB +# define POLYBENCH_LOOP_BOUND(x,y) x +# else +/* default: */ +# define POLYBENCH_LOOP_BOUND(x,y) y +# endif + +/* Use the 'restrict' keyword to declare that the different arrays do not + * alias. By default, we do not use it as it is only supported in C99 and + * even here several compilers do not properly get it. + */ +# ifdef POLYBENCH_USE_RESTRICT +# define POLYBENCH_RESTRICT restrict +# else +/* default: */ +# define POLYBENCH_RESTRICT +# endif + +/* Macros to reference an array. Generic for heap and stack arrays + (C99). Each array dimensionality has his own macro, to be used at + declaration or as a function argument. + Example: + int b[x] => POLYBENCH_1D_ARRAY(b, x) + int A[N][N] => POLYBENCH_2D_ARRAY(A, N, N) +*/ +# ifndef POLYBENCH_STACK_ARRAYS +# define POLYBENCH_ARRAY(x) *x +# ifdef POLYBENCH_ENABLE_INTARRAY_PAD +# define POLYBENCH_FREE_ARRAY(x) polybench_free_data((void*)x); +# else +# define POLYBENCH_FREE_ARRAY(x) free((void*)x); +# endif +# define POLYBENCH_DECL_VAR(x) (*x) +# else +# define POLYBENCH_ARRAY(x) x +# define POLYBENCH_FREE_ARRAY(x) +# define POLYBENCH_DECL_VAR(x) x +# endif +/* Macros for using arrays in the function prototypes. */ +# define POLYBENCH_1D(var, dim1,ddim1) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR] +# define POLYBENCH_2D(var, dim1, dim2, ddim1, ddim2) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR] +# define POLYBENCH_3D(var, dim1, dim2, dim3, ddim1, ddim2, ddim3) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR] +# define POLYBENCH_4D(var, dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim4,ddim4) + POLYBENCH_PADDING_FACTOR] +# define POLYBENCH_5D(var, dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim4,ddim4) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim5,ddim5) + POLYBENCH_PADDING_FACTOR] +/* Macros for using arrays within the functions. */ +# define POLYBENCH_1D_F(var, dim1,ddim1) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR] +# define POLYBENCH_2D_F(var, dim1, dim2, ddim1, ddim2) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR] +# define POLYBENCH_3D_F(var, dim1, dim2, dim3, ddim1, ddim2, ddim3) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR] +# define POLYBENCH_4D_F(var, dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim4,ddim4) + POLYBENCH_PADDING_FACTOR] +# define POLYBENCH_5D_F(var, dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim4,ddim4) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim5,ddim5) + POLYBENCH_PADDING_FACTOR] + + +/* Macros to allocate heap arrays. + Example: + polybench_alloc_2d_array(N, M, double) => allocates N x M x sizeof(double) + and returns a pointer to the 2d array + */ +# define POLYBENCH_ALLOC_1D_ARRAY(n1, type) \ + (type(*)[n1 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data (n1 + POLYBENCH_PADDING_FACTOR, sizeof(type)) +# define POLYBENCH_ALLOC_2D_ARRAY(n1, n2, type) \ + (type(*)[n1 + POLYBENCH_PADDING_FACTOR][n2 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data ((n1 + POLYBENCH_PADDING_FACTOR) * (n2 + POLYBENCH_PADDING_FACTOR), sizeof(type)) +# define POLYBENCH_ALLOC_3D_ARRAY(n1, n2, n3, type) \ + (type(*)[n1 + POLYBENCH_PADDING_FACTOR][n2 + POLYBENCH_PADDING_FACTOR][n3 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data ((n1 + POLYBENCH_PADDING_FACTOR) * (n2 + POLYBENCH_PADDING_FACTOR) * (n3 + POLYBENCH_PADDING_FACTOR), sizeof(type)) +# define POLYBENCH_ALLOC_4D_ARRAY(n1, n2, n3, n4, type) \ + (type(*)[n1 + POLYBENCH_PADDING_FACTOR][n2 + POLYBENCH_PADDING_FACTOR][n3 + POLYBENCH_PADDING_FACTOR][n4 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data ((n1 + POLYBENCH_PADDING_FACTOR) * (n2 + POLYBENCH_PADDING_FACTOR) * (n3 + POLYBENCH_PADDING_FACTOR) * (n4 + POLYBENCH_PADDING_FACTOR), sizeof(type)) +# define POLYBENCH_ALLOC_5D_ARRAY(n1, n2, n3, n4, n5, type) \ + (type(*)[n1 + POLYBENCH_PADDING_FACTOR][n2 + POLYBENCH_PADDING_FACTOR][n3 + POLYBENCH_PADDING_FACTOR][n4 + POLYBENCH_PADDING_FACTOR][n5 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data ((n1 + POLYBENCH_PADDING_FACTOR) * (n2 + POLYBENCH_PADDING_FACTOR) * (n3 + POLYBENCH_PADDING_FACTOR) * (n4 + POLYBENCH_PADDING_FACTOR) * (n5 + POLYBENCH_PADDING_FACTOR), sizeof(type)) + +/* Macros for array declaration. */ +# ifndef POLYBENCH_STACK_ARRAYS +# define POLYBENCH_1D_ARRAY_DECL(var, type, dim1, ddim1) \ + type POLYBENCH_1D_F(POLYBENCH_DECL_VAR(var), dim1, ddim1); \ + var = POLYBENCH_ALLOC_1D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), type); +# define POLYBENCH_2D_ARRAY_DECL(var, type, dim1, dim2, ddim1, ddim2) \ + type POLYBENCH_2D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, ddim1, ddim2); \ + var = POLYBENCH_ALLOC_2D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), POLYBENCH_C99_SELECT(dim2, ddim2), type); +# define POLYBENCH_3D_ARRAY_DECL(var, type, dim1, dim2, dim3, ddim1, ddim2, ddim3) \ + type POLYBENCH_3D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, ddim1, ddim2, ddim3); \ + var = POLYBENCH_ALLOC_3D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), POLYBENCH_C99_SELECT(dim2, ddim2), POLYBENCH_C99_SELECT(dim3, ddim3), type); +# define POLYBENCH_4D_ARRAY_DECL(var, type, dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4) \ + type POLYBENCH_4D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4); \ + var = POLYBENCH_ALLOC_4D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), POLYBENCH_C99_SELECT(dim2, ddim2), POLYBENCH_C99_SELECT(dim3, ddim3), POLYBENCH_C99_SELECT(dim4, ddim4), type); +# define POLYBENCH_5D_ARRAY_DECL(var, type, dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5) \ + type POLYBENCH_5D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5); \ + var = POLYBENCH_ALLOC_5D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), POLYBENCH_C99_SELECT(dim2, ddim2), POLYBENCH_C99_SELECT(dim3, ddim3), POLYBENCH_C99_SELECT(dim4, ddim4), POLYBENCH_C99_SELECT(dim5, ddim5), type); +# else +# define POLYBENCH_1D_ARRAY_DECL(var, type, dim1, ddim1) \ + type POLYBENCH_1D_F(POLYBENCH_DECL_VAR(var), dim1, ddim1); +# define POLYBENCH_2D_ARRAY_DECL(var, type, dim1, dim2, ddim1, ddim2) \ + type POLYBENCH_2D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, ddim1, ddim2); +# define POLYBENCH_3D_ARRAY_DECL(var, type, dim1, dim2, dim3, ddim1, ddim2, ddim3) \ + type POLYBENCH_3D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, ddim1, ddim2, ddim3); +# define POLYBENCH_4D_ARRAY_DECL(var, type, dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4) \ + type POLYBENCH_4D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4); +# define POLYBENCH_5D_ARRAY_DECL(var, type, dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5) \ + type POLYBENCH_5D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5); +# endif + + +/* Dead-code elimination macros. Use argc/argv for the run-time check. */ +# ifndef POLYBENCH_DUMP_ARRAYS +# define POLYBENCH_DCE_ONLY_CODE if (argc > 42 && ! strcmp(argv[0], "")) +# else +# define POLYBENCH_DCE_ONLY_CODE +# endif + +#define POLYBENCH_DUMP_TARGET stderr +#define POLYBENCH_DUMP_START fprintf(POLYBENCH_DUMP_TARGET, "==BEGIN DUMP_ARRAYS==\n") +#define POLYBENCH_DUMP_FINISH fprintf(POLYBENCH_DUMP_TARGET, "==END DUMP_ARRAYS==\n") +#define POLYBENCH_DUMP_BEGIN(s) fprintf(POLYBENCH_DUMP_TARGET, "begin dump: %s", s) +#define POLYBENCH_DUMP_END(s) fprintf(POLYBENCH_DUMP_TARGET, "\nend dump: %s\n", s) + +# define polybench_prevent_dce(func) \ + POLYBENCH_DCE_ONLY_CODE \ + func + + +/* Performance-related instrumentation. See polybench.c */ +# define polybench_start_instruments +# define polybench_stop_instruments +# define polybench_print_instruments + + +/* PAPI support. */ +# ifdef POLYBENCH_PAPI +extern const unsigned int polybench_papi_eventlist[]; +# undef polybench_start_instruments +# undef polybench_stop_instruments +# undef polybench_print_instruments +# define polybench_set_papi_thread_report(x) \ + polybench_papi_counters_threadid = x; +# define polybench_start_instruments \ + polybench_prepare_instruments(); \ + polybench_papi_init(); \ + int evid; \ + for (evid = 0; polybench_papi_eventlist[evid] != 0; evid++) \ + { \ + if (polybench_papi_start_counter(evid)) \ + continue; \ + +# define polybench_stop_instruments \ + polybench_papi_stop_counter(evid); \ + } \ + polybench_papi_close(); \ + +# define polybench_print_instruments polybench_papi_print(); +# endif + + +/* Timing support. */ +# if defined(POLYBENCH_TIME) || defined(POLYBENCH_GFLOPS) +# undef polybench_start_instruments +# undef polybench_stop_instruments +# undef polybench_print_instruments +# define polybench_start_instruments polybench_timer_start(); +# define polybench_stop_instruments polybench_timer_stop(); +# define polybench_print_instruments polybench_timer_print(); +extern double polybench_program_total_flops; +extern void polybench_timer_start(); +extern void polybench_timer_stop(); +extern void polybench_timer_print(); +# endif + +/* PAPI support. */ +# ifdef POLYBENCH_PAPI +extern int polybench_papi_start_counter(int evid); +extern void polybench_papi_stop_counter(int evid); +extern void polybench_papi_init(); +extern void polybench_papi_close(); +extern void polybench_papi_print(); +# endif + +/* Function prototypes. */ +extern void* polybench_alloc_data(unsigned long long int n, int elt_size); +extern void polybench_free_data(void* ptr); + +/* PolyBench internal functions that should not be directly called by */ +/* the user, unless when designing customized execution profiling */ +/* approaches. */ +extern void polybench_flush_cache(); +extern void polybench_prepare_instruments(); + + +#endif /* !POLYBENCH_H */ diff --git a/datasets/PolyBenchC/utilities/polybench.spec b/datasets/PolyBenchC/utilities/polybench.spec new file mode 100644 index 0000000..67448d3 --- /dev/null +++ b/datasets/PolyBenchC/utilities/polybench.spec @@ -0,0 +1,31 @@ +kernel category datatype params MINI SMALL MEDIUM LARGE EXTRALARGE +correlation datamining double M N 28 32 80 100 240 260 1200 1400 2600 3000 +covariance datamining double M N 28 32 80 100 240 260 1200 1400 2600 3000 +2mm linear-algebra/kernels double NI NJ NK NL 16 18 22 24 40 50 70 80 180 190 210 220 800 900 1100 1200 1600 1800 2200 2400 +3mm linear-algebra/kernels double NI NJ NK NL NM 16 18 20 22 24 40 50 60 70 80 180 190 200 210 220 800 900 1000 1100 1200 1600 1800 2000 2200 2400 +atax linear-algebra/kernels double M N 38 42 116 124 390 410 1900 2100 1800 2200 +bicg linear-algebra/kernels double M N 38 42 116 124 390 410 1900 2100 1800 2200 +doitgen linear-algebra/kernels double NQ NR NP 8 10 12 20 25 30 40 50 60 140 150 160 220 250 270 +mvt linear-algebra/kernels double N 40 120 400 2000 4000 +gemm linear-algebra/blas double NI NJ NK 20 25 30 60 70 80 200 220 240 1000 1100 1200 2000 2300 2600 +gemver linear-algebra/blas double N 40 120 400 2000 4000 +gesummv linear-algebra/blas double N 30 90 250 1300 2800 +symm linear-algebra/blas double M N 20 30 60 80 200 240 1000 1200 2000 2600 +syr2k linear-algebra/blas double M N 20 30 60 80 200 240 1000 1200 2000 2600 +syrk linear-algebra/blas double M N 20 30 60 80 200 240 1000 1200 2000 2600 +trmm linear-algebra/blas double M N 20 30 60 80 200 240 1000 1200 2000 2600 +cholesky linear-algebra/solvers double N 40 120 400 2000 4000 +durbin linear-algebra/solvers double N 40 120 400 2000 4000 +gramschmidt linear-algebra/solvers double M N 20 30 60 80 200 240 1000 1200 2000 2600 +lu linear-algebra/solvers double N 40 120 400 2000 4000 +ludcmp linear-algebra/solvers double N 40 120 400 2000 4000 +trisolv linear-algebra/solvers double N 40 120 400 2000 4000 +deriche medley float W H 64 64 192 128 720 480 4096 2160 7680 4320 +floyd-warshall medley int N 60 180 500 2800 5600 +nussinov medley int N 60 180 500 2500 5500 +adi stencils double TSTEPS N 20 20 40 60 100 200 500 1000 1000 2000 +fdtd-2d stencils double TMAX NX NY 20 20 30 40 60 80 100 200 240 500 1000 1200 1000 2000 2600 +heat-3d stencils double TSTEPS N 20 10 40 20 100 40 500 120 1000 200 +jacobi-1d stencils double TSTEPS N 20 30 40 120 100 400 500 2000 1000 4000 +jacobi-2d stencils double TSTEPS N 20 30 40 90 100 250 500 1300 1000 2800 +seidel-2d stencils double TSTEPS N 20 40 40 120 100 400 500 2000 1000 4000 \ No newline at end of file diff --git a/datasets/PolyBenchC/utilities/run-all.pl b/datasets/PolyBenchC/utilities/run-all.pl new file mode 100644 index 0000000..6b6674d --- /dev/null +++ b/datasets/PolyBenchC/utilities/run-all.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +# Visits every directory, calls make, and then executes the benchmark +# (Designed for making sure every kernel compiles/runs after modifications) +# +# Written by Tomofumi Yuki, 01/15 2015 +# + +my $TARGET_DIR = "."; + +if ($#ARGV != 0 && $#ARGV != 1) { + printf("usage perl run-all.pl target-dir [output-file]\n"); + exit(1); +} + + + +if ($#ARGV >= 0) { + $TARGET_DIR = $ARGV[0]; +} + +my $OUTFILE = ""; +if ($#ARGV == 1) { + $OUTFILE = $ARGV[1]; +} + + +my @categories = ('linear-algebra/blas', + 'linear-algebra/kernels', + 'linear-algebra/solvers', + 'datamining', + 'stencils', + 'medley'); + + +foreach $cat (@categories) { + my $target = $TARGET_DIR.'/'.$cat; + opendir DIR, $target or die "directory $target not found.\n"; + while (my $dir = readdir DIR) { + next if ($dir=~'^\..*'); + next if (!(-d $target.'/'.$dir)); + + my $kernel = $dir; + my $targetDir = $target.'/'.$dir; + my $command = "cd $targetDir; make clean; make; ./$kernel"; + $command .= " 2>> $OUTFILE" if ($OUTFILE ne ''); + print($command."\n"); + system($command); + } + + closedir DIR; +} + diff --git a/datasets/PolyBenchC/utilities/template-for-new-benchmark.c b/datasets/PolyBenchC/utilities/template-for-new-benchmark.c new file mode 100644 index 0000000..064c5c7 --- /dev/null +++ b/datasets/PolyBenchC/utilities/template-for-new-benchmark.c @@ -0,0 +1,96 @@ +/** + * This version is stamped on May 10, 2016 + * + * Contact: + * Louis-Noel Pouchet + * Tomofumi Yuki + * + * Web address: http://polybench.sourceforge.net + */ +#include +#include +#include +#include + +/* Include polybench common header. */ +#include + +/* Include benchmark-specific header. */ +/* Default data type is double, default size is N=1024. */ +#include "template-for-new-benchmark.h" + + +/* Array initialization. */ +static +void init_array(int n, DATA_TYPE POLYBENCH_2D(C,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + C[i][j] = 42; +} + + +/* DCE code. Must scan the entire live-out data. + Can be used also to check the correctness of the output. */ +static +void print_array(int n, DATA_TYPE POLYBENCH_2D(C,N,N,n,n)) +{ + int i, j; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) { + fprintf (stderr, DATA_PRINTF_MODIFIER, C[i][j]); + if (i % 20 == 0) fprintf (stderr, "\n"); + } + fprintf (stderr, "\n"); +} + + +/* Main computational kernel. The whole function will be timed, + including the call and return. */ +static +void kernel_template(int n, DATA_TYPE POLYBENCH_2D(C,N,N,n,n)) +{ + int i, j; + +#pragma scop + for (i = 0; i < _PB_N; i++) + for (j = 0; j < _PB_N; j++) + C[i][j] += 42; +#pragma endscop + +} + + +int main(int argc, char** argv) +{ + /* Retrieve problem size. */ + int n = N; + + /* Variable declaration/allocation. */ + POLYBENCH_2D_ARRAY_DECL(C,DATA_TYPE,N,N,n,n); + + /* Initialize array(s). */ + init_array (n, POLYBENCH_ARRAY(C)); + + /* Start timer. */ + polybench_start_instruments; + + /* Run kernel. */ + kernel_template (n, POLYBENCH_ARRAY(C)); + + /* Stop and print timer. */ + polybench_stop_instruments; + polybench_print_instruments; + + /* Prevent dead-code elimination. All live-out data must be printed + by the function call in argument. */ + polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(C))); + + /* Be clean. */ + POLYBENCH_FREE_ARRAY(C); + + return 0; +} diff --git a/datasets/PolyBenchC/utilities/time_benchmark.sh b/datasets/PolyBenchC/utilities/time_benchmark.sh new file mode 100644 index 0000000..b9dc69e --- /dev/null +++ b/datasets/PolyBenchC/utilities/time_benchmark.sh @@ -0,0 +1,78 @@ +#!/bin/sh +## time_benchmark.sh for in /Users/pouchet +## +## Made by Louis-Noel Pouchet +## Contact: +## +## Started on Sat Oct 29 00:03:48 2011 Louis-Noel Pouchet +## Last update Fri Apr 22 15:39:13 2016 Louis-Noel Pouchet +## + +## Maximal variance accepted between the 3 median runs for performance results. +## Here 5% +VARIANCE_ACCEPTED=5; + +if [ $# -ne 1 ]; then + echo "Usage: ./time_benchmarh.sh "; + echo "Example: ./time_benchmarh.sh \"./a.out\""; + echo "Note: the file must be a Polybench program compiled with -DPOLYBENCH_TIME"; + exit 1; +fi; + + +compute_mean_exec_time() +{ + file="$1"; + benchcomputed="$2"; + cat "$file" | grep "[0-9]\+" | sort -n | head -n 4 | tail -n 3 > avg.out; + expr="(0"; + while read n; do + expr="$expr+$n"; + done < avg.out; + time=`echo "scale=8;$expr)/3" | bc`; + tmp=`echo "$time" | cut -d '.' -f 1`; + if [ -z "$tmp" ]; then + time="0$time"; + fi; + val1=`cat avg.out | head -n 1`; + val2=`cat avg.out | head -n 2 | tail -n 1`; + val3=`cat avg.out | head -n 3 | tail -n 1`; + val11=`echo "a=$val1 - $time;if(0>a)a*=-1;a" | bc 2>&1`; + test_err=`echo "$val11" | grep error`; + if ! [ -z "$test_err" ]; then + echo "[ERROR] Program output does not match expected single-line with time."; + echo "[ERROR] The program must be a PolyBench, compiled with -DPOLYBENCH_TIME"; + exit 1; + fi; + val12=`echo "a=$val2 - $time;if(0>a)a*=-1;a" | bc`; + val13=`echo "a=$val3 - $time;if(0>a)a*=-1;a" | bc`; + myvar=`echo "$val11 $val12 $val13" | awk '{ if ($1 > $2) { if ($1 > $3) print $1; else print $3; } else { if ($2 > $3) print $2; else print $3; } }'`; + variance=`echo "scale=5;($myvar/$time)*100" | bc`; + tmp=`echo "$variance" | cut -d '.' -f 1`; + if [ -z "$tmp" ]; then + variance="0$variance"; + fi; + compvar=`echo "$variance $VARIANCE_ACCEPTED" | awk '{ if ($1 < $2) print "ok"; else print "error"; }'`; + if [ "$compvar" = "error" ]; then + echo "[WARNING] Variance is above thresold, unsafe performance measurement"; + echo " => max deviation=$variance%, tolerance=$VARIANCE_ACCEPTED%"; + WARNING_VARIANCE="$WARNING_VARIANCE\n$benchcomputed: max deviation=$variance%, tolerance=$VARIANCE_ACCEPTED%"; + else + echo "[INFO] Maximal deviation from arithmetic mean of 3 average runs: $variance%"; + fi; + PROCESSED_TIME="$time"; + rm -f avg.out; +} + +echo "[INFO] Running 5 times $1..." +echo "[INFO] Maximal variance authorized on 3 average runs: $VARIANCE_ACCEPTED%..."; + +$1 > ____tempfile.data.polybench; +$1 >> ____tempfile.data.polybench; +$1 >> ____tempfile.data.polybench; +$1 >> ____tempfile.data.polybench; +$1 >> ____tempfile.data.polybench; + +compute_mean_exec_time "____tempfile.data.polybench" "$1"; +echo "[INFO] Normalized time: $PROCESSED_TIME"; +rm -f ____tempfile.data.polybench; diff --git a/experiments/__init__.py b/experiments/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/library/__init__.py b/library/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/library/data_handler.py b/library/data_handler.py new file mode 100644 index 0000000..fc5a5c2 --- /dev/null +++ b/library/data_handler.py @@ -0,0 +1,39 @@ +FILE_REGISTRY = {} + +def register_file(arg): + """Decorator to register a dataset class. Can be used as @register_file or @register_file('Name').""" + if isinstance(arg, type): + FILE_REGISTRY[arg.__name__] = arg + return arg + else: + def decorator(cls): + FILE_REGISTRY[arg] = cls + return cls + return decorator + +class PolyBenchFile: + file_path = "" + + def get_file(self): + with open(self.file_path, 'r') as f: + return f.read() + + +@register_file("2mm") +class MM2(PolyBenchFile): + file_path = "datasets/PolyBenchC/linear-algebra/kernels/2mm/2mm.c" + +@register_file("atax") +class ATAX(PolyBenchFile): + file_path = "datasets/PolyBenchC/linear-algebra/kernels/atax/atax.c" + + +class ApplicationDataset: + def __init__(self): + self.applications = FILE_REGISTRY + + def get_applications(self): + code_dict = {} + for app in self.applications: + code_dict[app] = self.applications[app]().get_file() + return code_dict diff --git a/library/model.py b/library/model.py new file mode 100644 index 0000000..e69de29 diff --git a/library/utils.py b/library/utils.py new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py new file mode 100644 index 0000000..59dbd49 --- /dev/null +++ b/main.py @@ -0,0 +1,6 @@ +def main(): + print("Hello from hlsproject!") + + +if __name__ == "__main__": + main() diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..80b2ef6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[project] +name = "hlsproject" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.12" +dependencies = [] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29