diff --git a/Makefile b/Makefile index 9de86b59..281634ca 100644 --- a/Makefile +++ b/Makefile @@ -94,23 +94,25 @@ distclean: clean install: $(TARGET) mkdir -m 0755 -p $(PREFIX)/bin mkdir -m 0755 -p $(PREFIX)/lib - mkdir -m 0755 -p $(PREFIX)/include + mkdir -m 0755 -p $(PREFIX)/include/flit mkdir -m 0755 -p $(PREFIX)/share/flit/scripts mkdir -m 0755 -p $(PREFIX)/share/flit/doc mkdir -m 0755 -p $(PREFIX)/share/flit/data/tests mkdir -m 0755 -p $(PREFIX)/share/flit/data/db mkdir -m 0755 -p $(PREFIX)/share/flit/config mkdir -m 0755 -p $(PREFIX)/share/flit/litmus-tests + mkdir -m 0755 -p $(PREFIX)/share/flit/benchmarks mkdir -m 0755 -p $(PREFIX)/share/licenses/flit ln -sf ../share/flit/scripts/flit.py $(PREFIX)/bin/flit install -m 0755 $(TARGET) $(PREFIX)/lib/$(notdir $(TARGET)) - install -m 0644 $(HEADERS) $(PREFIX)/include/ + install -m 0644 $(HEADERS) $(PREFIX)/include/flit/ install -m 0755 $(SCRIPT_DIR)/flit.py $(PREFIX)/share/flit/scripts/ install -m 0755 $(SCRIPT_DIR)/flit_*.py $(PREFIX)/share/flit/scripts/ install -m 0644 $(SCRIPT_DIR)/flitutil.py $(PREFIX)/share/flit/scripts/ install -m 0644 $(SCRIPT_DIR)/README.md $(PREFIX)/share/flit/scripts/ install -m 0644 $(DOC_DIR)/*.md $(PREFIX)/share/flit/doc/ install -m 0644 $(DATA_DIR)/Makefile.in $(PREFIX)/share/flit/data/ + install -m 0644 $(DATA_DIR)/Makefile_bisect_binary.in $(PREFIX)/share/flit/data/ install -m 0644 $(DATA_DIR)/custom.mk $(PREFIX)/share/flit/data/ install -m 0644 $(DATA_DIR)/main.cpp $(PREFIX)/share/flit/data/ install -m 0644 $(DATA_DIR)/tests/Empty.cpp $(PREFIX)/share/flit/data/tests/ @@ -119,6 +121,7 @@ install: $(TARGET) install -m 0644 $(CONFIG_DIR)/flit-default.toml.in $(PREFIX)/share/flit/config/ install -m 0644 $(LITMUS_TESTS) $(PREFIX)/share/flit/litmus-tests/ install -m 0644 LICENSE $(PREFIX)/share/licenses/flit/ + cp -r benchmarks/* $(PREFIX)/share/flit/benchmarks/ @echo "Generating $(INSTALL_FLIT_CONFIG)" @# Make the flitconfig.py script specifying this installation information @echo "'''" > $(INSTALL_FLIT_CONFIG) @@ -150,7 +153,7 @@ install: $(TARGET) @echo "lib_dir = '$(abspath $(PREFIX))/lib'" >> $(INSTALL_FLIT_CONFIG) @echo >> $(INSTALL_FLIT_CONFIG) @echo "# flit C++ include files, primarily flit.h" >> $(INSTALL_FLIT_CONFIG) - @echo "include_dir = '$(abspath $(PREFIX))/include'" >> $(INSTALL_FLIT_CONFIG) + @echo "include_dir = '$(abspath $(PREFIX))/include/flit'" >> $(INSTALL_FLIT_CONFIG) @echo >> $(INSTALL_FLIT_CONFIG) @echo "# default configuration for flit init" >> $(INSTALL_FLIT_CONFIG) @echo "config_dir = '$(abspath $(PREFIX))/share/flit/config'" >> $(INSTALL_FLIT_CONFIG) @@ -165,3 +168,16 @@ install: $(TARGET) @echo "# directory containing litmus tests" >> $(INSTALL_FLIT_CONFIG) @echo "litmus_test_dir = '$(abspath $(PREFIX))/share/flit/litmus-tests'" >> $(INSTALL_FLIT_CONFIG) +.PHONY: uninstall +uninstall: + rm -rf $(PREFIX)/include/flit + rm -rf $(PREFIX)/share/flit + rm -rf $(PREFIX)/share/licenses/flit + rm -f $(PREFIX)/bin/flit + rm -f $(PREFIX)/lib/$(notdir $(TARGET)) + -rmdir --ignore-fail-on-non-empty $(PREFIX)/include + -rmdir --ignore-fail-on-non-empty $(PREFIX)/share/licenses + -rmdir --ignore-fail-on-non-empty $(PREFIX)/share + -rmdir --ignore-fail-on-non-empty $(PREFIX)/bin + -rmdir --ignore-fail-on-non-empty $(PREFIX)/lib + -rmdir --ignore-fail-on-non-empty $(PREFIX) diff --git a/R/analyzeOpcodes.R b/R/analyzeOpcodes.R deleted file mode 100644 index b938576d..00000000 --- a/R/analyzeOpcodes.R +++ /dev/null @@ -1,170 +0,0 @@ -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -install.packages("RPostgreSQL") -require("RPostgreSQL") - -drv <- dbDriver("PostgreSQL") - -con <- dbConnect(drv, dbname = "flit") - - #sanity test -dbExistsTable(con, "tests") - - #first, we'll get the column (variable) names -db_columnNames <- dbGetQuery(con, "select name from opcodes order by index") -db_pcolumnNames <- dbGetQuery(con, "select concat('pred_', name) as name from opcodes order by index") - -db_opcounts <- dbGetQuery(con, "select concat(switches, '_', precision, '_', name) as switches, array_to_string(array(select coalesce(count,0) from opcodes left join op_counts on (opcodes.index = op_counts.opcode and op_counts.test_id = tests.index and dynamic=true) order by opcodes.index), ' ') count, array_to_string(array(select coalesce(pred_count,0) from opcodes left join op_counts on (opcodes.index = op_counts.opcode and op_counts.test_id = tests.index and dynamic=true) order by opcodes.index), ' ') pcount from tests where run = 16 and host = 'kingspeak' and compiler = 'icpc' and exists (select 1 from op_counts where test_id = tests.index)") - -## db_opcounts <- dbGetQuery(con, "select concat(switches, '_', precision, '_', name) as switches, array_to_string(array(select coalesce(count,0) from opcodes left join op_counts on (opcodes.index = op_counts.opcode and op_counts.test_id = tests.index and dynamic=true) order by opcodes.index), ' ') as count, array_to_string(array(select coalesce(pred_count,0) from opcodes left join op_counts on (opcodes.index = op_counts.opcode and op_counts.test_id = tests.index and dynamic=true) order by opcodes.index), ' ') as pcount from tests where run = 16 and host = 'kingspeak' and compiler = 'icpc'") - -data <- matrix(nrow = length(db_opcounts[,1]), ncol = 2 * length(db_columnNames[,1]), byrow = TRUE, - dimnames = list(unlist(db_opcounts["switches"]), - mapply(c, db_columnNames["name"], db_pcolumnNames["name"]))) - -for (i in 1:length(unlist(db_opcounts["count"]))){ - data[i,] = mapply(c, strsplit(db_opcounts["count"][i,], " "), - strsplit(db_opcounts["pcount"][i,], " ")) -} - -#convert our strings to numbers (seemingly necessary with the arrays from query) -class(data) <- "numeric" - -#remove the zero columns -- unable to scale data sets with these -data2 <- data[ , !apply(data==0,2,all)] - -#also must remove constant columns -data3 <- data2[,apply(data2, 2, var, na.rm=TRUE) != 0] - -#generate PCs (PCA) -pc <- prcomp(data3, scale.=TRUE) - -plot(pc) - -plot(pc, type='l') - -summary(pc) - -#gather PCs (we'll use first 4 -- #1 dominates seriously, might try a log scaling later) -comp <- data.frame(pc$x[,1:4]) - -plot(comp, pch=16, col=rgb(0,0,0,0.5)) - -#base variance -wss <- (nrow(comp)-1)*sum(apply(comp,2,var)) - -for (i in 2:15) wss[i] <- sum(kmeans(comp, - centers=i, nstart=25, iter.max=1000)$withinss) - -plot(1:15, wss, type="b", xlab="Number of Clusters", - ylab="Within groups sum of squares") - -#we'll try 6 clusters, based on previous output -k <- kmeans(comp, 6, nstart=25, iter.max=1000) - -library(RColorBrewer) -library(scales) -palette(alpha(brewer.pal(9, 'Set1'), 0.5)) -plot(comp, col=k$clust, pch=16) - - - #dump the list by cluster - -sort(table(k$clust)) -clust <- names(sort(table(k$clust))) - -row.names(data[k$clust==clust[1],]) - -row.names(data[k$clust==clust[2],]) - -row.names(data[k$clust==clust[3],]) - -row.names(data[k$clust==clust[4],]) - -row.names(data[k$clust==clust[5],]) - -row.names(data[k$clust==clust[6],]) - - - -dbDisconnect(con) diff --git a/README.md b/README.md index aaa15fe4..e1a38e0d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,14 @@ Floating-point Litmus Tests (FLiT) is a C++ test infrastructure for detecting variability in floating-point code caused by variations in compiler code generation, hardware and execution environments. +Originally, FLiT stood for "Floating-point Litmus Tests", but has grown into a +tool with much more flexability than to study simple litmus tests. However, it +has always been the focus of FLiT to study the variability caused by compilers. +That brings us to the other reason for the name, "flit" is defined by the +Merriam Webster dictionary as "to pass quickly or abruptly from one place or +condition to another". This fits in well with testing for various sources of +variability. + Compilers are primarily focused on optimizing the speed of your code. However, when it comes to floating-point, compilers go a little further than some might want, to the point that you may not get the same result from your @@ -29,19 +37,17 @@ More than simply comparing against a "ground truth" test result, the FLiT framework also measures runtime of your tests. Using this information, you can not only determine which compilations of your code are safe for your specific application, but you can also determine the fastest safe compilation. This -ability really helps the developer navigate the tradeoff between -reproducibility and performance. +ability helps the developer navigate the tradeoff between reproducibility and +performance. It consists of the following components: -* a c++ reproducibility test infrastructure +* a C++ reproducibility test infrastructure * a dynamic make system to generate diverse compilations -* _(currently broken)_ an execution disbursement system -* an SQL database for collecting results - * _(currently broken)_ a collection of queries to help the user understand - results - * _(currently broken)_ some data analysis tools, providing visualization of - results +* an SQLite database containing results +* tools to help analyze test results +* a bisection tool that can isolate the file(s) and function(s) where + variability was introduced by the compiler. Contents: @@ -49,12 +55,17 @@ Contents: * [Litmus Tests](documentation/litmus-tests.md) * [FLiT Command-Line](documentation/flit-command-line.md) * [FLiT Configuration File](documentation/flit-configuration-file.md) - * [Available Compiler Flags](documentation/available-compiler-flags.md) + * [Available Compiler Flags](documentation/available-compiler-flags.md) * [Writing Test Cases](documentation/writing-test-cases.md) + * [MPI Support](documentation/mpi-support.md) + * [CUDA Support](documentation/cuda-support.md) + * [Run Wrapper and HPC Support](run-wrapper-and-hpc-support.md) +* [Compiling Your Tests](documentation/compiling-your-tests.md) * [Test Executable](documentation/test-executable.md) +* [Benchmarks](documentation/benchmarks.md) * [Database Structure](documentation/database-structure.md) * [Analyze Results](documentation/analyze-results.md) -* **Extra Tools** - * [Autogenerated Tests](documentation/autogenerated-tests.md) - * [Test Input Generator](documentation/test-input-generator.md) +* Extra Tools + * [Autogenerated Tests](documentation/autogenerated-tests.md) + * [Test Input Generator](documentation/test-input-generator.md) diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 00000000..311b466a --- /dev/null +++ b/benchmarks/README.md @@ -0,0 +1,14 @@ +# Benchmarks + +[Top-Level Documentation](../README.md) + +These benchmarks give insights into the usefulness of FLiT. Each benchmark has +its own goals, either to demonstrate how FLiT can be useful, or to give +insights into specific tools and functionalities. + +These benchmarks are also part of the installation, and can be copied from +there to exercise FLiT's capabilities. They are installed in + +`$(PREFIX)/share/flit/benchmarks` + +[Top-Level Documentation](../README.md) diff --git a/benchmarks/polybench/README.md b/benchmarks/polybench/README.md new file mode 100644 index 00000000..0044069e --- /dev/null +++ b/benchmarks/polybench/README.md @@ -0,0 +1,27 @@ +This is a test suite that was translated from the Polybench benchmark suite. +The original can be found [here](http://web.cse.ohio-state.edu/~pouchet.2/software/polybench/). + +Each source file has a main class extending the FLiT test class while also +parameterizing the size of input arrays for the given polyhedral kernel. +The number of parameters varies from benchmark to benchmark. + +For convenience these classes can be specialized and entered into the FLiT tests +by using the REGISTER_*N* macros where *N* is the number of parameterized arguments +not including the float type used by FLiT. This macro takes the name of the base +class as the first argument and numbers for all other arguments. + +To run the suite as is, with flit in your path: +``` +flit update +flit make +``` + +Manifest: + -custom.mk: A FLiT generated makefile used to add additional flags to + the compilations. + -flit-config.toml: A FLiT generated configuration for integration into + FLiT with a default setup for ibriggs on the machine + fractus. + -README.md: This file. + -tests/*.cpp: Kernels from the Polybench suite. + -tests/polybench_utils.hpp: Convenience functions and macros. \ No newline at end of file diff --git a/benchmarks/polybench/custom.mk b/benchmarks/polybench/custom.mk new file mode 100644 index 00000000..8db5b81a --- /dev/null +++ b/benchmarks/polybench/custom.mk @@ -0,0 +1,39 @@ +# This file is included at the end of the copied Makefile. If you have some +# things you want to change about the Makefile, it is best to do it here. + +# additional source files to compile other than what is in '.' and 'tests/' +# since those directories are added by a wildcard. +SOURCE += + +# for when cuda is compiled, you can specify different source files +CUSOURCE += + +# required compiler flags +# for example, include directories +# CC_REQUIRED += -I +# or defines +# CC_REQUIRED += -DDEBUG_ENABLED=1 +CC_REQUIRED += + +# required linker flags +# for example, link libraries +# LD_REQUIRED += -L -l +# or rpath +# LD_REQUIRED += -Wl,-rpath= +LD_REQUIRED += + +# compiler and linker flags respectively - specifically for a dev build +# - DEV_CFLAGS: non-recorded compiler flags (such as includes) +# - DEV_LDFLAGS: linker flags (also not under test) +DEV_CFLAGS += +DEV_LDFLAGS += + +# required compiler flags for CUDA +NVCC_CFLAGS += + +# required link flags for CUDA +NVCC_LINK += + +# compiler and linker flags respectively - specifically for a dev cuda build +DEV_NVCC_CC += +DEV_NVCC_LD += diff --git a/benchmarks/polybench/flit-config.toml b/benchmarks/polybench/flit-config.toml new file mode 100644 index 00000000..cbe16d21 --- /dev/null +++ b/benchmarks/polybench/flit-config.toml @@ -0,0 +1,24 @@ +# Autogenerated by "flit init" +# flit version v2.0-alpha.3 + +[database] + +type = 'sqlite' +filepath = 'results.sqlite' + + +[[hosts]] + +[hosts.dev_build] + +compiler_name = 'g++' +optimization_level = '-O2' +switches = '-funsafe-math-optimizations' + + +[hosts.ground_truth] + +compiler_name = 'g++' +optimization_level = '-O0' +switches = '' + diff --git a/benchmarks/polybench/main.cpp b/benchmarks/polybench/main.cpp new file mode 100644 index 00000000..60a4a640 --- /dev/null +++ b/benchmarks/polybench/main.cpp @@ -0,0 +1,5 @@ +#include "flit.h" + +int main(int argCount, char* argList[]) { + return flit::runFlitTests(argCount, argList); +} diff --git a/benchmarks/polybench/tests/adi.cpp b/benchmarks/polybench/tests/adi.cpp new file mode 100644 index 00000000..507d035a --- /dev/null +++ b/benchmarks/polybench/tests/adi.cpp @@ -0,0 +1,180 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class AdiBase : public flit::TestBase { +public: + AdiBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto u = ti; + std::vector v(N*N), p(N*N), q(N*N); + + int t, i, j; + T DX, DY, DT; + T B1, B2; + T mul1, mul2; + T a, b, c, d, e, f; + + DX = T(1.0) / T(N); + DY = T(1.0) / T(N); + DT = T(1.0) / T(TSTEPS); + B1 = T(2.0); + B2 = T(1.0); + mul1 = B1 * DT / (DX * DX); + mul2 = B2 * DT / (DY * DY); + + a = -mul1 / T(2.0); + b = T(1.0) + mul1; + c = a; + d = -mul2 / T(2.0); + e = T(1.0) + mul2; + f = d; + + for (t = 1; t <= TSTEPS; t++) { + // Column Sweep + for (i = 1; i < N-1; i++) { + v[0*N + i] = T(1.0); + p[i*N + 0] = T(0.0); + q[i*N + 0] = v[0*N + i]; + for (j = 1; j < N-1; j++) { + p[i*N + j] = -c / (a*p[i*N + j-1]+b); + q[i*N + j] = + (-d*u[j*N + i-1] + (T(1.0) + T(2.0)*d) * u[j*N + i] - f*u[j*N + i+1] + - a * q[i*N + j-1]) + / (a * p[i*N + j - 1] + b); + } + + v[(N-1)*N + i] = T(1.0); + for (j = N-2; j >= 1; j--) { + v[j*N + i] = p[i*N + j] * v[(j+1)*N + i] + q[i*N + j]; + } + } + // Row Sweep + for (i = 1; i < N-1; i++) { + u[i*N + 0] = T(1.0); + p[i*N + 0] = T(0.0); + q[i*N + 0] = u[i*N + 0]; + for (j = 1; j < N-1; j++) { + p[i*N + j] = -f / (d*p[i*N + j-1]+e); + q[i*N + j] = + (-a*v[(i-1)*N + j] + (T(1.0) + T(2.0)*a) * v[i*N + j] + - c*v[(i+1)*N + j] - d*q[i*N + j-1]) + / (d * p[i*N + j-1] + e); + } + u[i*N + N-1] = T(1.0); + for (j = N-2; j >= 1; j--) { + u[i*N + j] = p[i*N + j] * u[i*N + j+1] + q[i*N + j]; + } + } + } + + return pickles({u, v, p, q}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Adi, 4, 4) +POLY_REGISTER_DIM2(Adi, 5, 5) +POLY_REGISTER_DIM2(Adi, 6, 6) +POLY_REGISTER_DIM2(Adi, 7, 7) +POLY_REGISTER_DIM2(Adi, 8, 8) diff --git a/benchmarks/polybench/tests/atax.cpp b/benchmarks/polybench/tests/atax.cpp new file mode 100644 index 00000000..5614b828 --- /dev/null +++ b/benchmarks/polybench/tests/atax.cpp @@ -0,0 +1,135 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class AtaxBase : public flit::TestBase { +public: + AtaxBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return M*N + N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {M*N, N}); + auto &A = split[0]; + auto &x = split[1]; + std::vector y(N), tmp(M); + + int i, j; + + for (i = 0; i < M; i++) { + tmp[i] = T(0.0); + for (j = 0; j < N; j++) { + tmp[i] += A[i*M + j] * x[j]; + } + for (j = 0; j < N; j++) { + y[j] += A[i*M + j] * tmp[i]; + } + } + + return pickles({y, tmp}); + } + +protected: +using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Atax, 4, 4) +POLY_REGISTER_DIM2(Atax, 5, 5) +POLY_REGISTER_DIM2(Atax, 6, 6) +POLY_REGISTER_DIM2(Atax, 7, 7) +POLY_REGISTER_DIM2(Atax, 8, 8) diff --git a/benchmarks/polybench/tests/bicg.cpp b/benchmarks/polybench/tests/bicg.cpp new file mode 100644 index 00000000..37b027c1 --- /dev/null +++ b/benchmarks/polybench/tests/bicg.cpp @@ -0,0 +1,135 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class BicgBase : public flit::TestBase { +public: + BicgBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*M + N + M; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + std::vector sizes = {N*M, N, M}; + auto split = split_vector(ti, {N*M, N, M}); + auto &A = split[0]; + auto &r = split[1]; + auto &p = split[2]; + std::vector s(M), q(N); + + int i, j; + + for (i = 0; i < N; i++) { + q[i] = T(0.0); + for (j = 0; j < M; j++) { + s[j] += r[i] * A[i*N + j]; + q[i] += A[i*N + j] * p[j]; + } + } + + return pickles({s, q}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Bicg, 4, 4) +POLY_REGISTER_DIM2(Bicg, 5, 5) +POLY_REGISTER_DIM2(Bicg, 6, 6) +POLY_REGISTER_DIM2(Bicg, 7, 7) +POLY_REGISTER_DIM2(Bicg, 8, 8) diff --git a/benchmarks/polybench/tests/cholesky.cpp b/benchmarks/polybench/tests/cholesky.cpp new file mode 100644 index 00000000..258d850f --- /dev/null +++ b/benchmarks/polybench/tests/cholesky.cpp @@ -0,0 +1,137 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class CholeskyBase : public flit::TestBase { +public: + CholeskyBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto A = ti; + + int i, j, k; + + for (i = 0; i < N; i++) { + // j < i + for (j = 0; j < i; j++) { + for (k = 0; k < j; k++) { + A[i*N + j] -= A[i*N + k] * A[j*N + k]; + } + A[i*N + j] /= A[j*N + j]; + } + // i == j case + for (k = 0; k < i; k++) { + A[i*N + i] -= A[i*N + k] * A[i*N + k]; + } + A[i*N + i] = std::sqrt(A[i*N + i]); + } + + return pickles({A}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM1(Cholesky, 4) +POLY_REGISTER_DIM1(Cholesky, 5) +POLY_REGISTER_DIM1(Cholesky, 6) +POLY_REGISTER_DIM1(Cholesky, 7) +POLY_REGISTER_DIM1(Cholesky, 8) diff --git a/src/MatrixCU.h b/benchmarks/polybench/tests/correlation.cpp similarity index 54% rename from src/MatrixCU.h rename to benchmarks/polybench/tests/correlation.cpp index 0e64b587..7a7ccc5a 100644 --- a/src/MatrixCU.h +++ b/benchmarks/polybench/tests/correlation.cpp @@ -81,155 +81,90 @@ * -- LICENSE END -- */ -#ifndef MATRIX_CU_H -#define MATRIX_CU_H +#include "polybench_utils.h" -#include "CUHelpers.h" -#include "VectorCU.h" -#include "cuvector.h" +#include -namespace flit { +#include -template -class MatrixCU { - using rdtype = cuvector; - cuvector data; +template +class CorrelationBase : public flit::TestBase { public: - using vsize_t = typename cuvector::cvs_t; + CorrelationBase(std::string id) : flit::TestBase(std::move(id)) {} - HOST_DEVICE - MatrixCU(vsize_t rows, vsize_t cols): - data(rows, cuvector(cols,0)){} - - HOST_DEVICE - inline - rdtype& - operator[](vsize_t indx){ - return data[indx]; + virtual size_t getInputsPerRun() override { return N*M; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); } - HOST_DEVICE - inline - rdtype - operator[](vsize_t indx) const { - return data[indx]; + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); } - HOST_DEVICE - bool - operator==(MatrixCU const &rhs) const { - if(data.size() != rhs.data.size()) return false; - bool retVal = true; - for(vsize_t x = 0; x < data.size(); ++x){ - for(vsize_t y = 0; y < data[0].size(); ++y){ - if(data[x][y] != rhs.data[x][y]){ - retVal = false; - break; - } - } - } - return retVal; - } +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto data = ti; + std::vector corr(M*M), mean(M), stddev(M); + T float_n = N; - HOST_DEVICE - MatrixCU - operator*(T const &sca){ - MatrixCU retVal(data.size(), data[0].size()); - for(vsize_t x = 0; x < data.size(); ++x){ - for(vsize_t y = 0; y < data[0].size(); ++y){ - retVal.data[x][y] = data[x][y] * sca; - } - } - return retVal; - } + int i, j, k; - HOST_DEVICE - MatrixCU - operator*(MatrixCU const &rhs){ - MatrixCU retVal(data.size(), rhs.data[0].size()); - for(vsize_t bcol = 0; bcol < rhs.data[0].size(); ++bcol){ - for(vsize_t x = 0; x < data.size(); ++x){ - for(vsize_t y = 0; y < data[0].size(); ++y){ - retVal.data[x][bcol] += data[x][y] * rhs.data[y][bcol]; - } + T eps = 0.1; + + for (j = 0; j < M; j++) { + mean[j] = 0.0; + for (i = 0; i < N; i++) { + mean[j] += data[i*N + j]; } + mean[j] /= float_n; } - return retVal; - } - HOST_DEVICE - static - MatrixCU - SkewSymCrossProdM(VectorCU const &v){ - MatrixCU retVal(3,3); - retVal[0][0] = 0; - retVal[0][1] = -v[2]; - retVal[0][2] = v[1]; - retVal[0][0] = v[2]; - retVal[1][1] = 0; - retVal[2][2] = -v[0]; - - retVal[0][0] = -v[1]; - retVal[1][1] = v[0]; - retVal[2][2] = 0; - - return retVal; - } - - HOST_DEVICE - static - MatrixCU - Identity(size_t dims){ - MatrixCU retVal(dims, dims); - for(size_t x = 0; x < dims; ++x){ - for(size_t y = 0; y < dims; ++y){ - if(x == y) retVal[x][y] = 1; - else retVal[x][y] = 0; + for (j = 0; j < M; j++) { + stddev[j] = 0.0; + for (i = 0; i < N; i++) { + stddev[j] += (data[i*N + j] - mean[j]) * (data[i*N + j] - mean[j]); } + stddev[j] /= float_n; + stddev[j] = std::sqrt(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 ? 1.0 : stddev[j]; } - return retVal; - } - HOST_DEVICE - VectorCU - operator*(VectorCU const &v) const { - VectorCU retVal((vsize_t)data.size()); - vsize_t resI = 0; - for(vsize_t x = 0; - x < data.size(); - ++x){ - auto row = data[x]; - for(vsize_t i = 0; i < row.size(); ++i){ - retVal[resI] += row[i] * v[i]; + /* Center and reduce the column vectors. */ + for (i = 0; i < N; i++) { + for (j = 0; j < M; j++) { + data[i*N + j] -= mean[j]; + data[i*N + j] /= std::sqrt(float_n) * stddev[j]; } - ++resI; } - return retVal; - } - HOST_DEVICE - MatrixCU - operator+(MatrixCU const&rhs) const{ - MatrixCU retVal(data.size(), data.size()); - int x = 0; int y = 0; - for(vsize_t j = 0; - j < data.size(); - ++j){ - auto r = data[j]; - for(vsize_t k = 0; - k < data.size(); - ++k){ - auto i = r[k]; - retVal[x][y] = i + rhs[x][y]; - ++y; + /* Calculate the m * m correlation matrix. */ + for (i = 0; i < M-1; i++) { + corr[i*M + i] = 1.0; + for (j = i+1; j < M; j++) { + corr[i*M + j] = 0.0; + for (k = 0; k < N; k++) { + corr[i*M + j] += (data[k*N + i] * data[k*N + j]); + } + corr[j*M + i] = corr[i*M + j]; } - y = 0; ++x; } - return retVal; + corr[(M-1)*M + (M-1)] = 1.0; + + + return pickles({data, corr, mean, stddev}); } -}; -} // end of namespace flit +protected: + using flit::TestBase::id; +}; -#endif // MATRIX_CU_H +POLY_REGISTER_DIM2(Correlation, 4, 4) +POLY_REGISTER_DIM2(Correlation, 5, 5) +POLY_REGISTER_DIM2(Correlation, 6, 6) +POLY_REGISTER_DIM2(Correlation, 7, 7) +POLY_REGISTER_DIM2(Correlation, 8, 8) diff --git a/benchmarks/polybench/tests/covariance.cpp b/benchmarks/polybench/tests/covariance.cpp new file mode 100644 index 00000000..d0c09788 --- /dev/null +++ b/benchmarks/polybench/tests/covariance.cpp @@ -0,0 +1,149 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class CovarianceBase : public flit::TestBase { +public: + CovarianceBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*M; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + T float_n{N}; + auto data = ti; + std::vector cov(M*M), mean(M); + + int i, j, k; + + for (j = 0; j < M; j++) { + mean[j] = T(0.0); + for (i = 0; i < N; i++) { + mean[j] += data[i*N + j]; + } + mean[j] /= float_n; + } + + for (i = 0; i < N; i++) { + for (j = 0; j < M; j++) { + data[i*N + j] -= mean[j]; + } + } + + for (i = 0; i < M; i++) { + for (j = i; j < M; j++) { + cov[i*M + j] = T(0.0); + for (k = 0; k < N; k++) { + cov[i*M + j] += data[k*N + i] * data[k*N + j]; + } + cov[i*M + j] /= (float_n - T(1.0)); + cov[j*M + i] = cov[i*M + j]; + } + } + + return pickles({data, cov, mean}) ; + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Covariance, 4, 4) +POLY_REGISTER_DIM2(Covariance, 5, 5) +POLY_REGISTER_DIM2(Covariance, 6, 6) +POLY_REGISTER_DIM2(Covariance, 7, 7) +POLY_REGISTER_DIM2(Covariance, 8, 8) diff --git a/benchmarks/polybench/tests/deriche.cpp b/benchmarks/polybench/tests/deriche.cpp new file mode 100644 index 00000000..681a1148 --- /dev/null +++ b/benchmarks/polybench/tests/deriche.cpp @@ -0,0 +1,211 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class DericheBase : public flit::TestBase { +public: + DericheBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 2*W*H; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {W*H, W*H}); + auto &imgIn = split[0]; + auto &imgOut = split[1]; + std::vector y1(W*H), y2(W*H); + + T alpha{0.25}; + + int i,j; + T xm1, tm1, ym1, ym2; + T xp1, xp2; + T tp1, tp2; + T yp1, yp2; + + T k; + T a1, a2, a3, a4, a5, a6, a7, a8; + T b1, b2, c1, c2; + + k = (T(1.0) - std::exp(-alpha)) * + (T(1.0) - std::exp(-alpha)) + / (T(1.0) + T(2.0) * alpha * std::exp(-alpha) + - std::exp(T(2.0) * alpha)); + a1 = a5 = k; + a2 = a6 = k * std::exp(-alpha) * (alpha - T(1.0)); + a3 = a7 = k * std::exp(-alpha) * (alpha + T(1.0)); + a4 = a8 = -k * std::exp(T(-2.0) * alpha); + b1 = std::pow(T(2.0), -alpha); + b2 = -std::exp(T(-2.0) * alpha); + c1 = c2 = 1; + + for (i = 0; i < W; i++) { + ym1 = T(0.0); + ym2 = T(0.0); + xm1 = T(0.0); + for (j = 0; j < H; j++) { + y1[i*W + j] = a1 * imgIn[i*W + j] + a2 * xm1 + b1 * ym1 + b2 * ym2; + xm1 = imgIn[i*W + j]; + ym2 = ym1; + ym1 = y1[i*W + j]; + } + } + + for (i = 0; i < W; i++) { + yp1 = T(0.0); + yp2 = T(0.0); + xp1 = T(0.0); + xp2 = T(0.0); + for (j = H-1; j >= 0; j--) { + y2[i*W + j] = a3 * xp1 + a4 * xp2 + b1 * yp1 + b2 * yp2; + xp2 = xp1; + xp1 = imgIn[i*W + j]; + yp2 = yp1; + yp1 = y2[i*W + j]; + } + } + + for (i = 0; i < W; i++) + for (j = 0; j < H; j++) { + imgOut[i*W + j] = c1 * (y1[i*W + j] + y2[i*W + j]); + } + + for (j = 0; j < H; j++) { + tm1 = T(0.0); + ym1 = T(0.0); + ym2 = T(0.0); + for (i = 0; i < W; i++) { + y1[i*W + j] = a5 * imgOut[i*W + j] + a6 * tm1 + b1 * ym1 + b2 * ym2; + tm1 = imgOut[i*W + j]; + ym2 = ym1; + ym1 = y1[i*W + j]; + } + } + + + for (j = 0; j < H; j++) { + tp1 = T(0.0); + tp2 = T(0.0); + yp1 = T(0.0); + yp2 = T(0.0); + for (i = W-1; i >= 0; i--) { + y2[i*W + j] = a7 * tp1 + a8 * tp2 + b1 * yp1 + b2 * yp2; + tp2 = tp1; + tp1 = imgOut[i*W + j]; + yp2 = yp1; + yp1 = y2[i*W + j]; + } + } + + for (i = 0; i < W; i++) { + for (j = 0; j < H; j++) { + imgOut[i*W + j] = c2 * (y1[i*W + j] + y2[i*W + j]); + } + } + + return pickles({imgOut, y1, y2}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Deriche, 4, 4) +POLY_REGISTER_DIM2(Deriche, 5, 5) +POLY_REGISTER_DIM2(Deriche, 6, 6) +POLY_REGISTER_DIM2(Deriche, 7, 7) +POLY_REGISTER_DIM2(Deriche, 8, 8) diff --git a/benchmarks/polybench/tests/doitgen.cpp b/benchmarks/polybench/tests/doitgen.cpp new file mode 100644 index 00000000..7d208a2d --- /dev/null +++ b/benchmarks/polybench/tests/doitgen.cpp @@ -0,0 +1,139 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class DoitgenBase : public flit::TestBase { +public: + DoitgenBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return NR*NQ*NP + NP*NP; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {NR*NQ*NP, NP*NP}); + auto &A = split[0]; + auto &C4 = split[1]; + std::vector sum(NP); + + int r, q, p, s; + + for (r = 0; r < NR; r++) { + for (q = 0; q < NQ; q++) { + for (p = 0; p < NP; p++) { + sum[p] = T(0.0); + for (s = 0; s < NP; s++) { + sum[p] += A[r*NR*NQ + q*NQ + s] * C4[s*NP + p]; + } + } + for (p = 0; p < NP; p++) { + A[r*NR*NQ + q*NQ + p] = sum[p]; + } + } + } + + return pickles({A, sum}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM3(Doitgen, 4, 4, 4) +POLY_REGISTER_DIM3(Doitgen, 5, 5, 5) +POLY_REGISTER_DIM3(Doitgen, 6, 6, 6) +POLY_REGISTER_DIM3(Doitgen, 7, 7, 7) +POLY_REGISTER_DIM3(Doitgen, 8, 8, 8) diff --git a/benchmarks/polybench/tests/durbin.cpp b/benchmarks/polybench/tests/durbin.cpp new file mode 100644 index 00000000..a0eee597 --- /dev/null +++ b/benchmarks/polybench/tests/durbin.cpp @@ -0,0 +1,143 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class DurbinBase : public flit::TestBase { +public: + DurbinBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto &r = ti; + std::vector y(N), z(N); + y[0] = -r[0]; + + T alpha{-r[0]}, beta{1.0}, sum; + + int i, k; + + for (k = 1; k < N; k++) { + beta = (1-alpha*alpha)*beta; + sum = T(0.0); + for (i = 0; i < k; i++) { + sum += r[k-i-1] * y[i]; + } + alpha = - (r[k] + sum)/beta; + + for (i = 0; i < k; i++) { + z[i] = y[i] + alpha*y[k-i-1]; + } + for (i = 0; i < k; i++) { + y[i] = z[i]; + } + y[k] = alpha; + } + + return pickles({y, z}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM1(Durbin, 4) +POLY_REGISTER_DIM1(Durbin, 5) +POLY_REGISTER_DIM1(Durbin, 6) +POLY_REGISTER_DIM1(Durbin, 7) +POLY_REGISTER_DIM1(Durbin, 8) diff --git a/benchmarks/polybench/tests/fdtd_2d.cpp b/benchmarks/polybench/tests/fdtd_2d.cpp new file mode 100644 index 00000000..744781c7 --- /dev/null +++ b/benchmarks/polybench/tests/fdtd_2d.cpp @@ -0,0 +1,148 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Fdtd_2dBase : public flit::TestBase { +public: + Fdtd_2dBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 3*NX*NY + TMAX; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {NX*NY, NX*NY, NX*NY, TMAX}); + auto &ex = split[0]; + auto &ey = split[1]; + auto &hz = split[2]; + auto &_fict_ = split[3]; + + int t, i, j; + + for(t = 0; t < TMAX; t++) { + for (j = 0; j < NY; j++) { + ey[0*NX + j] = _fict_[t]; + } + for (i = 1; i < NX; i++) { + for (j = 0; j < NY; j++) { + ey[i*NX + j] -= T(0.5) * (hz[i*NX + j] - hz[(i-1)*NX + j]); + } + } + for (i = 0; i < NX; i++) { + for (j = 1; j < NY; j++) { + ex[i*NX + j] -= T(0.5) * (hz[i*NX + j] - hz[i*NX + j-1]); + } + } + for (i = 0; i < NX - 1; i++) { + for (j = 0; j < NY - 1; j++) { + hz[i*NX + j] -= T(0.7) * (ex[i*NX + j+1] - ex[i*NX + j] + + ey[(i+1)*NX + j] - ey[i*NX + j]); + } + } + } + + return pickles({ex, ey, hz}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM3(Fdtd_2d, 4, 4, 4) +POLY_REGISTER_DIM3(Fdtd_2d, 5, 5, 5) +POLY_REGISTER_DIM3(Fdtd_2d, 6, 6, 6) +POLY_REGISTER_DIM3(Fdtd_2d, 7, 7, 7) +POLY_REGISTER_DIM3(Fdtd_2d, 8, 8, 8) diff --git a/benchmarks/polybench/tests/floyd_warshall.cpp b/benchmarks/polybench/tests/floyd_warshall.cpp new file mode 100644 index 00000000..2f0b8b48 --- /dev/null +++ b/benchmarks/polybench/tests/floyd_warshall.cpp @@ -0,0 +1,131 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Floyd_WarshallBase : public flit::TestBase { +public: + Floyd_WarshallBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto path = ti; + + int i, j, k; + + for (k = 0; k < N; k++) { + for(i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + path[i*N + j] = path[i*N + j] < path[i*N + k] + path[k*N + j] ? + path[i*N + j] : path[i*N + k] + path[k*N + j]; + } + } + } + + return pickles({path}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM1(Floyd_Warshall, 4) +POLY_REGISTER_DIM1(Floyd_Warshall, 5) +POLY_REGISTER_DIM1(Floyd_Warshall, 6) +POLY_REGISTER_DIM1(Floyd_Warshall, 7) +POLY_REGISTER_DIM1(Floyd_Warshall, 8) diff --git a/benchmarks/polybench/tests/gemm.cpp b/benchmarks/polybench/tests/gemm.cpp new file mode 100644 index 00000000..b9c0cb57 --- /dev/null +++ b/benchmarks/polybench/tests/gemm.cpp @@ -0,0 +1,138 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class GemmBase : public flit::TestBase { +public: + GemmBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return NI*NJ + NI*NK + NK+NJ; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + T alpha{1.5}; + T beta{1.2}; + auto split = split_vector(ti, {NI*NI, NI*NK, NK+NJ}); + auto &C = split[0]; + auto &A = split[1]; + auto &B = split[2]; + + int i, j, k; + + for (i = 0; i < NI; i++) { + for (j = 0; j < NJ; j++) { + C[i*NI + j] *= beta; + } + for (k = 0; k < NK; k++) { + for (j = 0; j < NJ; j++) { + C[i*NI + j] += alpha * A[i*NI + k] * B[k*NK + j]; + } + } + } + + return pickles({C}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM3(Gemm, 4, 4, 4) +POLY_REGISTER_DIM3(Gemm, 5, 5, 5) +POLY_REGISTER_DIM3(Gemm, 6, 6, 6) +POLY_REGISTER_DIM3(Gemm, 7, 7, 7) +POLY_REGISTER_DIM3(Gemm, 8, 8, 8) diff --git a/benchmarks/polybench/tests/gemver.cpp b/benchmarks/polybench/tests/gemver.cpp new file mode 100644 index 00000000..6852e99a --- /dev/null +++ b/benchmarks/polybench/tests/gemver.cpp @@ -0,0 +1,155 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class GemverBase : public flit::TestBase { +public: + GemverBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N + 8*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + T alpha{1.5}; + T beta{1.2}; + auto split = split_vector(ti, {N*N, N, N, N, N, N, N, N, N}); + auto &A = split[0]; + auto &u1 = split[1]; + auto &v1 = split[2]; + auto &u2 = split[3]; + auto &v2 = split[4]; + auto &w = split[5]; + auto &x = split[6]; + auto &y = split[7]; + auto &z = split[8]; + + int i, j; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + A[i*N + j] = A[i*N + j] + u1[i] * v1[j] + u2[i] * v2[j]; + } + } + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + x[i] = x[i] + beta * A[j*N + i] * y[j]; + } + } + + for (i = 0; i < N; i++) { + x[i] = x[i] + z[i]; + } + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + w[i] = w[i] + alpha * A[i*N + j] * x[j]; + } + } + + return pickles({A, w, x}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM1(Gemver, 4) +POLY_REGISTER_DIM1(Gemver, 5) +POLY_REGISTER_DIM1(Gemver, 6) +POLY_REGISTER_DIM1(Gemver, 7) +POLY_REGISTER_DIM1(Gemver, 8) diff --git a/benchmarks/polybench/tests/gesummv.cpp b/benchmarks/polybench/tests/gesummv.cpp new file mode 100644 index 00000000..58bfd8ec --- /dev/null +++ b/benchmarks/polybench/tests/gesummv.cpp @@ -0,0 +1,139 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class GesummvBase : public flit::TestBase { +public: + GesummvBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 2*N*N + N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + T alpha{1.5}; + T beta{1.2}; + auto split = split_vector(ti, {N*N, N*N, N}); + auto &A = split[0]; + auto &B = split[1]; + auto &x = split[2]; + + std::vector tmp(N), y(N); + + int i, j; + + for (i = 0; i < N; i++) { + tmp[i] = T(0.0); + y[i] = T(0.0); + for (j = 0; j < N; j++) { + tmp[i] = A[i*N + j] * x[j] + tmp[i]; + y[i] = B[i*N + j] * x[j] + y[i]; + } + y[i] = alpha * tmp[i] + beta * y[i]; + } + + return pickles({tmp, y}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM1(Gesummv, 4) +POLY_REGISTER_DIM1(Gesummv, 5) +POLY_REGISTER_DIM1(Gesummv, 6) +POLY_REGISTER_DIM1(Gesummv, 7) +POLY_REGISTER_DIM1(Gesummv, 8) diff --git a/benchmarks/polybench/tests/gramschmidt.cpp b/benchmarks/polybench/tests/gramschmidt.cpp new file mode 100644 index 00000000..bd2ee3f0 --- /dev/null +++ b/benchmarks/polybench/tests/gramschmidt.cpp @@ -0,0 +1,147 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class GramschmidtBase : public flit::TestBase { +public: + GramschmidtBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 2*M*N + N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {M*N, N*N, M*N}); + auto &A = split[0]; + auto &R = split[1]; + auto &Q = split[2]; + + int i, j, k; + + T nrm; + + for (k = 0; k < N; k++) { + nrm = T(0.0); + for (i = 0; i < M; i++) { + nrm += A[i*M + k] * A[i*M + k]; + } + R[k*N + k] = std::sqrt(nrm); + for (i = 0; i < M; i++) { + Q[i*M + k] = A[i*M + k] / R[k*N + k]; + } + for (j = k + 1; j < N; j++) { + R[k*N + j] = T(0.0); + for (i = 0; i < M; i++) { + R[k*N + j] += Q[i*M + k] * A[i*M + j]; + } + for (i = 0; i < M; i++) { + A[i*M + j] = A[i*M + j] - Q[i*M + k] * R[k*N + j]; + } + } + } + + return pickles({A, R, Q}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Gramschmidt, 4, 4) +POLY_REGISTER_DIM2(Gramschmidt, 5, 5) +POLY_REGISTER_DIM2(Gramschmidt, 6, 6) +POLY_REGISTER_DIM2(Gramschmidt, 7, 7) +POLY_REGISTER_DIM2(Gramschmidt, 8, 8) diff --git a/benchmarks/polybench/tests/heat_3d.cpp b/benchmarks/polybench/tests/heat_3d.cpp new file mode 100644 index 00000000..164e47a6 --- /dev/null +++ b/benchmarks/polybench/tests/heat_3d.cpp @@ -0,0 +1,162 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Heat_3dBase : public flit::TestBase { +public: + Heat_3dBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 2*N*N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N*N*N, N*N*N}); + auto &A = split[0]; + auto &B = split[1]; + + int t, i, j, k; + + for (t = 1; t <= TSTEPS; t++) { + for (i = 1; i < N-1; i++) { + for (j = 1; j < N-1; j++) { + for (k = 1; k < N-1; k++) { + B[i*N*N + j*N +k] = + T(0.125) * (A[(i+1)*N*N + j*N +k] - T(2.0) * A[i*N*N + j*N +k] + + A[(i-1)*N*N + j*N +k]) + + + T(0.125) * (A[i*N*N + (j+1)*N +k] - T(2.0) * A[i*N*N + j*N +k] + + A[i*N*N + (j-1)*N*N + k]) + + + T(0.125) * (A[i*N*N + j*N +k+1] - T(2.0) * A[i*N*N + j*N +k] + + A[i*N*N + j*N +k-1]) + + + A[i*N*N + j*N +k]; + } + } + } + for (i = 1; i < N-1; i++) { + for (j = 1; j < N-1; j++) { + for (k = 1; k < N-1; k++) { + A[i*N*N + j*N +k] = + T(0.125) * (B[(i+1)*N*N + j*N +k] - T(2.0) * B[i*N*N + j*N +k] + + B[(i-1)*N*N + j*N +k]) + + + T(0.125) * (B[i*N*N + (j+1)*N*N + k] - + T(2.0) * B[i*N*N + j*N +k] + + B[i*N*N + (j-1)*N*N + k]) + + + T(0.125) * (B[i*N*N + j*N + k+1] - T(2.0) * B[i*N*N + j*N + k] + + B[i*N*N + j*N + k-1]) + + + B[i*N*N + j*N +k]; + } + } + } + } + + return pickles({A, B}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Heat_3d, 4, 4) +POLY_REGISTER_DIM2(Heat_3d, 5, 5) +POLY_REGISTER_DIM2(Heat_3d, 6, 6) +POLY_REGISTER_DIM2(Heat_3d, 7, 7) +POLY_REGISTER_DIM2(Heat_3d, 8, 8) diff --git a/benchmarks/polybench/tests/jacobi_1d.cpp b/benchmarks/polybench/tests/jacobi_1d.cpp new file mode 100644 index 00000000..96a9031c --- /dev/null +++ b/benchmarks/polybench/tests/jacobi_1d.cpp @@ -0,0 +1,133 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Jacobi_1dBase : public flit::TestBase { +public: + Jacobi_1dBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 2*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N, N}); + auto &A = split[0]; + auto &B = split[1]; + + int t, i; + + for (t = 0; t < TSTEPS; t++) { + for (i = 1; i < N - 1; i++) { + B[i] = T(0.33333) * (A[i-1] + A[i] + A[i + 1]); + } + for (i = 1; i < N - 1; i++) { + A[i] = T(0.33333) * (B[i-1] + B[i] + B[i + 1]); + } + } + + return pickles({A, B}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Jacobi_1d, 4, 4) +POLY_REGISTER_DIM2(Jacobi_1d, 5, 5) +POLY_REGISTER_DIM2(Jacobi_1d, 6, 6) +POLY_REGISTER_DIM2(Jacobi_1d, 7, 7) +POLY_REGISTER_DIM2(Jacobi_1d, 8, 8) diff --git a/benchmarks/polybench/tests/jacobi_2d.cpp b/benchmarks/polybench/tests/jacobi_2d.cpp new file mode 100644 index 00000000..e8e52691 --- /dev/null +++ b/benchmarks/polybench/tests/jacobi_2d.cpp @@ -0,0 +1,139 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Jacobi_2dBase : public flit::TestBase { +public: + Jacobi_2dBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 2*N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N*N, N*N}); + auto &A = split[0]; + auto &B = split[1]; + + int t, i, j; + + for (t = 0; t < TSTEPS; t++) { + for (i = 1; i < N - 1; i++) { + for (j = 1; j < N - 1; j++) { + B[i*N + j] = T(0.2) * (A[i*N + j] + A[i*N + j-1] + A[i*N + 1+j] + + A[(1+i)*N + j] + A[(i-1)*N + j]); + } + } + for (i = 1; i < N - 1; i++) { + for (j = 1; j < N - 1; j++) { + A[i*N + j] = T(0.2) * (B[i*N + j] + B[i*N + j-1] + B[i*N + 1+j] + + B[(1+i)*N + j] + B[(i-1)*N + j]); + } + } + } + + return pickles({A, B}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Jacobi_2d, 4, 4) +POLY_REGISTER_DIM2(Jacobi_2d, 5, 5) +POLY_REGISTER_DIM2(Jacobi_2d, 6, 6) +POLY_REGISTER_DIM2(Jacobi_2d, 7, 7) +POLY_REGISTER_DIM2(Jacobi_2d, 8, 8) diff --git a/benchmarks/polybench/tests/lu.cpp b/benchmarks/polybench/tests/lu.cpp new file mode 100644 index 00000000..2878742b --- /dev/null +++ b/benchmarks/polybench/tests/lu.cpp @@ -0,0 +1,136 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class LuBase : public flit::TestBase { +public: + LuBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto A = ti; + + int i, j, k; + + for (i = 0; i < N; i++) { + for (j = 0; j ::id; +}; + +POLY_REGISTER_DIM1(Lu, 4) +POLY_REGISTER_DIM1(Lu, 5) +POLY_REGISTER_DIM1(Lu, 6) +POLY_REGISTER_DIM1(Lu, 7) +POLY_REGISTER_DIM1(Lu, 8) diff --git a/benchmarks/polybench/tests/ludcmp.cpp b/benchmarks/polybench/tests/ludcmp.cpp new file mode 100644 index 00000000..734428b4 --- /dev/null +++ b/benchmarks/polybench/tests/ludcmp.cpp @@ -0,0 +1,161 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class LudcmpBase : public flit::TestBase { +public: + LudcmpBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N + 3*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N*N, N, N, N}); + auto &A = split[0]; + auto &b = split[1]; + auto &x = split[2]; + auto &y = split[3]; + + int i, j, k; + + T w; + + for (i = 0; i < N; i++) { + for (j = 0; j =0; i--) { + w = y[i]; + for (j = i+1; j < N; j++) { + w -= A[i*N + j] * x[j]; + } + x[i] = w / A[i*N + i]; + } + + return pickles({A, x, y}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM1(Ludcmp, 4) +POLY_REGISTER_DIM1(Ludcmp, 5) +POLY_REGISTER_DIM1(Ludcmp, 6) +POLY_REGISTER_DIM1(Ludcmp, 7) +POLY_REGISTER_DIM1(Ludcmp, 8) diff --git a/benchmarks/polybench/tests/mvt.cpp b/benchmarks/polybench/tests/mvt.cpp new file mode 100644 index 00000000..5790de26 --- /dev/null +++ b/benchmarks/polybench/tests/mvt.cpp @@ -0,0 +1,138 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class MvtBase : public flit::TestBase { +public: + MvtBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 4*N + N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N, N, N, N, N*N}); + auto &x1 = split[0]; + auto &x2 = split[1]; + auto &y_1 = split[2]; + auto &y_2 = split[3]; + auto &A = split[4]; + + int i, j; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + x1[i] = x1[i] + A[i*N +j] * y_1[j]; + } + } + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + x2[i] = x2[i] + A[j*N + i] * y_2[j]; + } + } + + return pickles({x1, x2}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM1(Mvt, 4) +POLY_REGISTER_DIM1(Mvt, 5) +POLY_REGISTER_DIM1(Mvt, 6) +POLY_REGISTER_DIM1(Mvt, 7) +POLY_REGISTER_DIM1(Mvt, 8) diff --git a/benchmarks/polybench/tests/nussinov.cpp b/benchmarks/polybench/tests/nussinov.cpp new file mode 100644 index 00000000..2c1b0967 --- /dev/null +++ b/benchmarks/polybench/tests/nussinov.cpp @@ -0,0 +1,154 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +#define match(b1, b2) (((b1)+(b2)) == 3 ? 1 : 0) + +template +class NussinovBase : public flit::TestBase { +public: + NussinovBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N + N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N, N*N}); + auto &seq = split[0]; + auto &table = split[1]; + + int i, j, k; + + for (i = N-1; i >= 0; i--) { + for (j = i+1; j < N; j++) { + + if (j-1 >= 0) { + table[i*N + j] = std::max(table[i*N + j], table[i*N + j-1]); + } + if (i+1 < N) { + table[i*N + j] = std::max(table[i*N + j], table[(i+1)*N + j]); + } + + if (j-1 >= 0 && i+1 < N) { + /* don't allow adjacent elements to bond */ + if (i < j-1) { + table[i*N + j] = + std::max(table[i*N + j], + table[(i+1)*N + j-1] + match(seq[i], seq[j])); + } else { + table[i*N + j] = std::max(table[i*N + j], table[(i+1)*N + j-1]); + } + } + + for (k = i+1; k < j; k++) { + table[i*N + j] = std::max(table[i*N + j], + table[i*N + k] + table[(k+1)*N + j]); + } + } + } + + return pickles({table}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM1(Nussinov, 4) +POLY_REGISTER_DIM1(Nussinov, 5) +POLY_REGISTER_DIM1(Nussinov, 6) +POLY_REGISTER_DIM1(Nussinov, 7) +POLY_REGISTER_DIM1(Nussinov, 8) diff --git a/benchmarks/polybench/tests/polybench_utils.h b/benchmarks/polybench/tests/polybench_utils.h new file mode 100644 index 00000000..6f922b89 --- /dev/null +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -0,0 +1,242 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ +#ifndef POLYBENCH_UTILS_H +#define POLYBENCH_UTILS_H + + +#include +#include +#include +#include +#include +#include + +#include +#include + +/** These REGISTER definitions are helper macro functions that create a + * specification of the given NAME with different amounts of extra template + * parameters. + * + * These will create test classes named ${NAME}_${DIM0}_${DIM1}_... + * (for how many extra template parameters exist) + */ +#define POLY_REGISTER_DIM1(NAME, DIM0) \ + template class NAME##_##DIM0 : public NAME##Base { \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0) \ + +#define POLY_REGISTER_DIM2(NAME, DIM0, DIM1) \ + template class NAME##_##DIM0##_##DIM1 \ + : public NAME##Base \ + { \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1) \ + +#define POLY_REGISTER_DIM3(NAME, DIM0, DIM1, DIM2) \ + template class NAME##_##DIM0##_##DIM1##_##DIM2 \ + : public NAME##Base \ + { \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1##_##DIM2) \ + +#define POLY_REGISTER_DIM4(NAME, DIM0, DIM1, DIM2, DIM3) \ + template class NAME##_##DIM0##_##DIM1##_##DIM2##_##DIM3 \ + : public NAME##Base \ + { \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1##_##DIM2##_##DIM3) \ + +#define POLY_REGISTER_DIM5(NAME, DIM0, DIM1, DIM2, DIM3, DIM4) \ + template \ + class NAME##_##DIM0##_##DIM1##_##DIM2##_##DIM3##_##DIM4 \ + : public NAME##Base \ + { \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1##_##DIM2##_##DIM3##_##DIM4) \ + + +/** Generates a random vector of numbers from a seeded random number generator + * + * @param n: number of random numbers to generate + * @param seed: random number generator seed + * @param lower: lower bound of numbers to generate + * @param upper: upper bound of numbers to generate + * + * @return std::vector containing the generated random numbers + */ +template +std::vector seeded_random_vector(size_t n, unsigned int seed, T lower = 0.0, + T upper = std::numeric_limits::max()) +{ + std::vector v(n); + std::minstd_rand g(seed); + std::uniform_real_distribution dist(lower, upper); + std::generate_n(v.begin(), n, [&g, &dist]() { return dist(g); }); + return v; +} + +/** Generates a random vector with a hard-coded seed + * + * This is a convenience function that calls seeded_random_vector(). + */ +template +std::vector random_vector(size_t n, T lower = 0.0, + T upper = std::numeric_limits::max()) +{ + return seeded_random_vector(n, 42, lower, upper); +} + + +/// Compare two strings representing vectors using L1 norm +template +long double +vector_string_compare(const std::string &ground_truth, + const std::string &test_results) { + long double absdiff = 0; + + std::stringstream expected(ground_truth); + std::stringstream actual(test_results); + T e; + T a; + while (expected.good() && actual.good()) { + expected >> e; + actual >> a; + absdiff += std::abs(e - a); + } + + if (expected.good() != actual.good()) { + absdiff = std::numeric_limits::max(); + } + + return absdiff; +} + + +/** Convert a vector of vectors into a single string + * + * Note: the sequence of vectors are collapsed as a single vector + */ +template +std::string +pickles(std::initializer_list> cucumbers) { + std::stringstream ss; + ss << std::setprecision(22); // enough to round trip long doubles + + for (const auto& cuke : cucumbers) { + for (T c : cuke) { + ss << c << " "; + } + } + + return ss.str(); +} + + +/// Splits the ti vector into multiple disjoint vectors specified by sizes +template +std::vector> +split_vector(const std::vector &ti, const std::vector &sizes) { + std::vector> split; + auto start = ti.begin(); + auto stop = start; + for (size_t i = 0; i < sizes.size(); i++) { + start = stop; + stop += sizes[i]; + split.emplace_back(start, stop); + } + return split; +} + +#endif // POLYBENCH_UTILS_H + diff --git a/benchmarks/polybench/tests/seidel_2d.cpp b/benchmarks/polybench/tests/seidel_2d.cpp new file mode 100644 index 00000000..4c08ad4a --- /dev/null +++ b/benchmarks/polybench/tests/seidel_2d.cpp @@ -0,0 +1,134 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Seidel_2dBase : public flit::TestBase { +public: + Seidel_2dBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto A = ti; + + int t, i, j; + + for (t = 0; t <= TSTEPS - 1; t++) { + for (i = 1; i<= N - 2; i++) { + for (j = 1; j <= N - 2; j++) { + A[(i)*N + (j)] = + (A[(i-1)*N + (j-1)] + A[(i-1)*N + (j)] + A[(i-1)*N + (j+1)] + + A[(i)*N + (j-1)] + A[(i)*N + (j)] + A[(i)*N + (j+1)] + + A[(i+1)*N + (j-1)] + A[(i+1)*N + (j)] + A[(i+1)*N + (j+1)]) + / T(9.0); + } + } + } + + return pickles({A}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Seidel_2d, 4, 4) +POLY_REGISTER_DIM2(Seidel_2d, 5, 5) +POLY_REGISTER_DIM2(Seidel_2d, 6, 6) +POLY_REGISTER_DIM2(Seidel_2d, 7, 7) +POLY_REGISTER_DIM2(Seidel_2d, 8, 8) diff --git a/benchmarks/polybench/tests/symm.cpp b/benchmarks/polybench/tests/symm.cpp new file mode 100644 index 00000000..ed66954b --- /dev/null +++ b/benchmarks/polybench/tests/symm.cpp @@ -0,0 +1,140 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class SymmBase : public flit::TestBase { +public: + SymmBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 2*M*N + M*M; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + T alpha{1.5}; + T beta{1.2}; + auto split = split_vector(ti, {M*N, M*M, M*N}); + auto &C = split[0]; + auto &A = split[1]; + auto &B = split[2]; + + int i, j, k; + T temp2; + + for (i = 0; i < M; i++) { + for (j = 0; j < N; j++ ) { + temp2 = 0; + for (k = 0; k < i; k++) { + C[k*M +j] += alpha*B[i*M +j] * A[i*M +k]; + temp2 += B[k*M +j] * A[i*M +k]; + } + C[i*M +j] = beta * C[i*M +j] + alpha*B[i*M +j] * A[i*M +i] + + alpha * temp2; + } + } + + return pickles({C}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Symm, 4, 4) +POLY_REGISTER_DIM2(Symm, 5, 5) +POLY_REGISTER_DIM2(Symm, 6, 6) +POLY_REGISTER_DIM2(Symm, 7, 7) +POLY_REGISTER_DIM2(Symm, 8, 8) diff --git a/benchmarks/polybench/tests/syr2k.cpp b/benchmarks/polybench/tests/syr2k.cpp new file mode 100644 index 00000000..05324d36 --- /dev/null +++ b/benchmarks/polybench/tests/syr2k.cpp @@ -0,0 +1,138 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Syr2kBase : public flit::TestBase { +public: + Syr2kBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N + 2*N*M; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N*N, N*M, N*M}); + auto &C = split[0]; + auto &A = split[1]; + auto &B = split[2]; + T alpha{1.5}; + T beta{1.2}; + + int i, j, k; + + for (i = 0; i < N; i++) { + for (j = 0; j <= i; j++) { + C[i*N + j] *= beta; + } + for (k = 0; k < M; k++) { + for (j = 0; j <= i; j++) { + C[i*N + j] += A[j*N + k]*alpha*B[i*N + k] + B[j*N + k]*alpha*A[i*N + k]; + } + } + } + + return pickles({C}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Syr2k, 4, 4) +POLY_REGISTER_DIM2(Syr2k, 5, 5) +POLY_REGISTER_DIM2(Syr2k, 6, 6) +POLY_REGISTER_DIM2(Syr2k, 7, 7) +POLY_REGISTER_DIM2(Syr2k, 8, 8) diff --git a/benchmarks/polybench/tests/syrk.cpp b/benchmarks/polybench/tests/syrk.cpp new file mode 100644 index 00000000..324b61df --- /dev/null +++ b/benchmarks/polybench/tests/syrk.cpp @@ -0,0 +1,137 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class SyrkBase : public flit::TestBase { +public: + SyrkBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N + N*M; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N*N, N*M}); + auto &C = split[0]; + auto &A = split[1]; + T alpha{1.5}; + T beta{1.2}; + + int i, j, k; + + for (i = 0; i < N; i++) { + for (j = 0; j <= i; j++) { + C[i*N + j] *= beta; + } + for (k = 0; k < M; k++) { + for (j = 0; j <= i; j++) { + C[i*N + j] += alpha * A[i*N + k] * A[j*N + k]; + } + } + } + + return pickles({C}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Syrk, 4, 4) +POLY_REGISTER_DIM2(Syrk, 5, 5) +POLY_REGISTER_DIM2(Syrk, 6, 6) +POLY_REGISTER_DIM2(Syrk, 7, 7) +POLY_REGISTER_DIM2(Syrk, 8, 8) diff --git a/benchmarks/polybench/tests/test2mm.cpp b/benchmarks/polybench/tests/test2mm.cpp new file mode 100644 index 00000000..88550c2d --- /dev/null +++ b/benchmarks/polybench/tests/test2mm.cpp @@ -0,0 +1,147 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Test2mmBase : public flit::TestBase { +public: + Test2mmBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return NI*NK + NK*NJ + NJ*NL + NI*NL; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {NI*NK, NK*NJ, NJ*NL, NI*NL}); + auto &A = split[0]; + auto &B = split[1]; + auto &C = split[2]; + auto &D = split[3]; + std::vector tmp(NI*NJ); + T alpha{1.5}; + T beta{1.2}; + + int i, j, k; + + /* D := alpha*A*B*C + beta*D */ + for (i = 0; i < NI; i++) { + for (j = 0; j < NJ; j++) { + tmp[i*NI + j] = T(0.0); + for (k = 0; k < NK; ++k) { + tmp[i*NI + j] += alpha * A[i*NI + k] * B[k*NK + j]; + } + } + } + for (i = 0; i < NI; i++) { + for (j = 0; j < NL; j++) { + D[i*NI + j] *= beta; + for (k = 0; k < NJ; ++k) { + D[i*NI + j] += tmp[i*NI + k] * C[k*NJ + j]; + } + } + } + + return pickles({tmp, D}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM4(Test2mm, 4, 4, 4, 4) +POLY_REGISTER_DIM4(Test2mm, 5, 5, 5, 5) +POLY_REGISTER_DIM4(Test2mm, 6, 6, 6, 6) +POLY_REGISTER_DIM4(Test2mm, 7, 7, 7, 7) +POLY_REGISTER_DIM4(Test2mm, 8, 8, 8, 8) diff --git a/benchmarks/polybench/tests/test3mm.cpp b/benchmarks/polybench/tests/test3mm.cpp new file mode 100644 index 00000000..8162219a --- /dev/null +++ b/benchmarks/polybench/tests/test3mm.cpp @@ -0,0 +1,155 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class Test3mmBase : public flit::TestBase { +public: + Test3mmBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return NI*NK + NK*NJ + NJ*NM + NM*NL; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {NI*NK, NK*NJ, NJ*NM, NM*NL}); + auto &A = split[0]; + auto &B = split[1]; + auto &C = split[2]; + auto &D = split[3]; + std::vector E(NI*NJ), F(NJ*NL), G(NI*NL); + + int i, j, k; + + /* E := A*B */ + for (i = 0; i < NI; i++) { + for (j = 0; j < NJ; j++) { + E[i*NI + j] = T(0.0); + for (k = 0; k < NK; ++k) { + E[i*NI + j] += A[i*NI + k] * B[k*NK + j]; + } + } + } + /* F := C*D */ + for (i = 0; i < NJ; i++) { + for (j = 0; j < NL; j++) { + F[i*NJ + j] = T(0.0); + for (k = 0; k < NM; ++k) { + F[i*NJ + j] += C[i*NJ + k] * D[k*NM + j]; + } + } + } + /* G := E*F */ + for (i = 0; i < NI; i++) { + for (j = 0; j < NL; j++) { + G[i*NI + j] = T(0.0); + for (k = 0; k < NJ; ++k) { + G[i*NI + j] += E[i*NI + k] * F[k*NJ + j]; + } + } + } + + return pickles({E, F, G}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM5(Test3mm, 4, 4, 4, 4, 4) +POLY_REGISTER_DIM5(Test3mm, 5, 5, 5, 5, 5) +POLY_REGISTER_DIM5(Test3mm, 6, 6, 6, 6, 6) +POLY_REGISTER_DIM5(Test3mm, 7, 7, 7, 7, 7) +POLY_REGISTER_DIM5(Test3mm, 8, 8, 8, 8, 8) diff --git a/benchmarks/polybench/tests/trisolv.cpp b/benchmarks/polybench/tests/trisolv.cpp new file mode 100644 index 00000000..9770bb7c --- /dev/null +++ b/benchmarks/polybench/tests/trisolv.cpp @@ -0,0 +1,133 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class TrisolvBase : public flit::TestBase { +public: + TrisolvBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return N*N + 2*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {N*N, N, N}); + auto &L = split[0]; + auto &x = split[1]; + auto &b = split[2]; + + int i, j; + + for (i = 0; i < N; i++) { + x[i] = b[i]; + for (j = 0; j ::id; +}; + +POLY_REGISTER_DIM1(Trisolv, 4) +POLY_REGISTER_DIM1(Trisolv, 5) +POLY_REGISTER_DIM1(Trisolv, 6) +POLY_REGISTER_DIM1(Trisolv, 7) +POLY_REGISTER_DIM1(Trisolv, 8) diff --git a/benchmarks/polybench/tests/trmm.cpp b/benchmarks/polybench/tests/trmm.cpp new file mode 100644 index 00000000..1719686d --- /dev/null +++ b/benchmarks/polybench/tests/trmm.cpp @@ -0,0 +1,134 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include "polybench_utils.h" + +#include + +#include + +template +class TrmmBase : public flit::TestBase { +public: + TrmmBase(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return M*M + M*N; } + virtual std::vector getDefaultInput() override { + return random_vector(this->getInputsPerRun()); + } + + virtual long double compare(const std::string &ground_truth, + const std::string &test_results) const override { + return vector_string_compare(ground_truth, test_results); + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + auto split = split_vector(ti, {M*M, M*N}); + auto &A = split[0]; + auto &B = split[1]; + T alpha{1.5}; + + int i, j, k; + + for (i = 0; i < M; i++) { + for (j = 0; j < N; j++) { + for (k = i+1; k < M; k++) { + B[i*M + j] += A[k*M + i] * B[k*M + j]; + } + B[i*M + j] = alpha * B[i*M + j]; + } + } + + return pickles({B}); + } + +protected: + using flit::TestBase::id; +}; + +POLY_REGISTER_DIM2(Trmm, 4, 4) +POLY_REGISTER_DIM2(Trmm, 5, 5) +POLY_REGISTER_DIM2(Trmm, 6, 6) +POLY_REGISTER_DIM2(Trmm, 7, 7) +POLY_REGISTER_DIM2(Trmm, 8, 8) diff --git a/benchmarks/random/README.md b/benchmarks/random/README.md new file mode 100644 index 00000000..d5ab3410 --- /dev/null +++ b/benchmarks/random/README.md @@ -0,0 +1,11 @@ +# Random Benchmark + +This benchmark is to test that the C++ `` header is portable accross +compilers. My guess is that they will be since I suspect they are implemented +in the GLibC, but I'm not sure. Hence the tests. This can give us confidence +that this is indeed safe to depend on in FLiT tests. + +We also test the `rand()` and `srand()` functions that are part of the standard +`` header file. However, we do not test the non-portable `random()`, +`srandom()`, `initstate()`, and `setstate()` functions that are part of the +POSIX standard, but are not part of the C++ standard. diff --git a/benchmarks/random/custom.mk b/benchmarks/random/custom.mk new file mode 100644 index 00000000..ab838123 --- /dev/null +++ b/benchmarks/random/custom.mk @@ -0,0 +1,27 @@ +# This file is included at the end of the copied Makefile. If you have some +# things you want to change about the Makefile, it is best to do it here. + +# additional source files to compile other than what is in '.' and 'tests/' +# since those directories are added by a wildcard. +SOURCE += + +# required compiler flags +# for example, include directories +# CC_REQUIRED += -I +# or defines +# CC_REQUIRED += -DDEBUG_ENABLED=1 +CC_REQUIRED += + +# required linker flags +# for example, link libraries +# LD_REQUIRED += -L -l +# or rpath +# LD_REQUIRED += -Wl,-rpath= +LD_REQUIRED += + +# compiler and linker flags respectively - specifically for a dev build +# - DEV_CFLAGS: non-recorded compiler flags (such as includes) +# - DEV_LDFLAGS: linker flags (also not under test) +DEV_CFLAGS += +DEV_LDFLAGS += + diff --git a/benchmarks/random/flit-config.toml b/benchmarks/random/flit-config.toml new file mode 100644 index 00000000..6fc21156 --- /dev/null +++ b/benchmarks/random/flit-config.toml @@ -0,0 +1,50 @@ +# Autogenerated by "flit init" +# flit version v2.0-alpha.3 + +[database] + +# older versions of flit supported postgres. that has been removed. only +# sqlite is supported at the moment. +type = 'sqlite' + +# if relative path, it is relative to the directory containing this +# configuration file. +filepath = 'results.sqlite' + +[run] +timing = false + +# For now, only one host is supported, all others are ignored +[[hosts]] + +name = 'yoga-manjaro' +flit_path = '/home/bentley/git/FLiT/scripts/flitcli/flit.py' +config_dir = '/home/bentley/git/FLiT/scripts/flitcli/config' + +# The settings for "make dev" +[hosts.dev_build] +# compiler_name must be found in [[hosts.compilers]] list under name attribute +# but the optimization level and switches do not need to be in the compiler list +compiler_name = 'g++' +optimization_level = '-O2' +switches = '-funsafe-math-optimizations' + +# The ground truth compilation to use in analysis, for "make gt" +[hosts.ground_truth] +# compiler_name must be found in [[hosts.compilers]] list under name attribute +# but the optimization level and switches do not need to be in the compiler list +compiler_name = 'g++' +optimization_level = '-O0' +switches = '' + + # This host's list of compilers. + # For now, only used for hosts.ground_truth and hosts.dev_build. + # TODO: use this list to generate the Makefile + [[hosts.compilers]] + + # binary can be an absolute path, relative path, or binary name (found in + # PATH). If you want to specify a compiler in the same directory as this + # config file, prepend with a "./" (e.g. "./my-compiler") + binary = 'g++' + name = 'g++' + diff --git a/benchmarks/random/main.cpp b/benchmarks/random/main.cpp new file mode 100644 index 00000000..60a4a640 --- /dev/null +++ b/benchmarks/random/main.cpp @@ -0,0 +1,5 @@ +#include "flit.h" + +int main(int argCount, char* argList[]) { + return flit::runFlitTests(argCount, argList); +} diff --git a/benchmarks/random/tests/Rand.cpp b/benchmarks/random/tests/Rand.cpp new file mode 100644 index 00000000..ba35c481 --- /dev/null +++ b/benchmarks/random/tests/Rand.cpp @@ -0,0 +1,114 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include + +#include +#include + +#include + +template +class Rand : public flit::TestBase { +public: + Rand(std::string id) : flit::TestBase(std::move(id)) {} + virtual size_t getInputsPerRun() override { return 1; } + virtual std::vector getDefaultInput() override { return { 0, 42, 24, 12, 103 }; } +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + FLIT_UNUSED(ti); + return {}; + } +protected: + using flit::TestBase::id; +}; + +// Only implement the test for double precision +template <> +flit::Variant Rand::run_impl(const std::vector &ti) { + size_t seed = ti[0]; + srand(seed); + return rand(); +} + +REGISTER_TYPE(Rand); diff --git a/benchmarks/random/tests/Random.cpp b/benchmarks/random/tests/Random.cpp new file mode 100644 index 00000000..d4f277db --- /dev/null +++ b/benchmarks/random/tests/Random.cpp @@ -0,0 +1,164 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include + +#include +#include + +using namespace std; + +template +class Random : public flit::TestBase { +public: + Random(string id) : flit::TestBase(move(id)) {} + virtual size_t getInputsPerRun() override { return 1; } + virtual vector getDefaultInput() override { return { 0, 42, 24, 12, 103 }; } +protected: + virtual flit::Variant run_impl(const vector &ti) override { + size_t seed = ti[0]; + Gen g(seed); + return Dist()(g); + } +protected: + using flit::TestBase::id; +}; + +// A simple passthrough distribution that returns the generator's value +template +struct Pass { + auto operator() (Gen &g) -> decltype(g()) { + return g(); + } +}; + +// A distribution between [0, 1) using std::generate_canonical() +template +struct Canonical { + template + T operator() (G &g) { + return generate_canonical::digits>(g); + } +}; + +// Convenience macro to create new tests with a generator and distribution +#define MY_REGISTRATION(name, gen, dist) \ + template \ + class name : public Random { \ + using Random::Random; \ + }; \ + REGISTER_TYPE(name) + +// Convenience macro to create a suite of tests varying the distribution for the given generator +#define REGISTER_GENERATOR(name, klass) \ + MY_REGISTRATION(Random_##name##_Pass, klass, Pass ) \ + MY_REGISTRATION(Random_##name##_uniformint, klass, uniform_int_distribution ) \ + MY_REGISTRATION(Random_##name##_uniformreal, klass, uniform_real_distribution ) \ + MY_REGISTRATION(Random_##name##_binomial, klass, binomial_distribution ) \ + MY_REGISTRATION(Random_##name##_bernoulli, klass, bernoulli_distribution ) \ + MY_REGISTRATION(Random_##name##_geometric, klass, geometric_distribution ) \ + MY_REGISTRATION(Random_##name##_negative_binomial, klass, negative_binomial_distribution) \ + MY_REGISTRATION(Random_##name##_poisson, klass, poisson_distribution ) \ + MY_REGISTRATION(Random_##name##_exponential, klass, exponential_distribution ) \ + MY_REGISTRATION(Random_##name##_gamma, klass, gamma_distribution ) \ + MY_REGISTRATION(Random_##name##_weibull, klass, weibull_distribution ) \ + MY_REGISTRATION(Random_##name##_extreme_value, klass, extreme_value_distribution ) \ + MY_REGISTRATION(Random_##name##_normal, klass, normal_distribution ) \ + MY_REGISTRATION(Random_##name##_lognormal, klass, lognormal_distribution ) \ + MY_REGISTRATION(Random_##name##_chi_squared, klass, chi_squared_distribution ) \ + MY_REGISTRATION(Random_##name##_cauchy, klass, cauchy_distribution ) \ + MY_REGISTRATION(Random_##name##_fisher_f, klass, fisher_f_distribution ) \ + MY_REGISTRATION(Random_##name##_student_t, klass, student_t_distribution ) \ + MY_REGISTRATION(Random_##name##_canonical, klass, Canonical ) + +// Create all of the tests now for various generators +REGISTER_GENERATOR(mt19937, mt19937 ) +REGISTER_GENERATOR(mt19937_64, mt19937_64 ) +REGISTER_GENERATOR(default, default_random_engine) +REGISTER_GENERATOR(minstd_rand, minstd_rand ) +REGISTER_GENERATOR(minstd_rand0, minstd_rand0 ) +REGISTER_GENERATOR(ranlux24, ranlux24 ) +REGISTER_GENERATOR(ranlux48, ranlux48 ) +REGISTER_GENERATOR(knuth_b, knuth_b ) + + diff --git a/data/Makefile.in b/data/Makefile.in index 802ce086..426053d8 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -84,7 +84,6 @@ FFLAGS ?= DEV_TARGET ?= devrun -DEV_CUTARGET ?= cu_devrun GT_TARGET ?= gtrun GT_OUT := ground-truth.csv @@ -103,9 +102,30 @@ GT_CC := {ground_truth_compiler} GT_OPTL := {ground_truth_optl} GT_SWITCHES := {ground_truth_switches} -OBJ_DIR = obj +TEST_RUN_ARGS := {test_run_args} + +ENABLE_MPI := {enable_mpi} +MPIRUN_ARGS := {mpirun_args} + +# initalize some variables to be appended later +CC_REQUIRED := +DEV_CFLAGS := +LD_REQUIRED := + +RUNWRAP = $(RUN_WRAPPER) +ifeq ($(ENABLE_MPI),yes) # If we are using MPI + $(info MPI is enabled) + RUNWRAP += mpirun $(MPIRUN_ARGS) + CC_REQUIRED += -DFLIT_USE_MPI + CC_REQUIRED += $(shell mpic++ --showme:compile) + LD_REQUIRED += $(shell mpic++ --showme:link) +endif + +OBJ_DIR := obj CC_REQUIRED += $(FFLAGS) +# This flag specifies NOT to build position-independent executables +CC_REQUIRED += -fno-pie CC_REQUIRED += -std=c++11 CC_REQUIRED += -I. CC_REQUIRED += -I$(FLIT_INC_DIR) @@ -116,6 +136,8 @@ DEV_CFLAGS += -Wextra DEV_CFLAGS += -Wuninitialized DEV_CFLAGS += -Wno-shift-count-overflow +# This flag specifies NOT to link as a position-independent executable +LD_REQUIRED += -no-pie LD_REQUIRED += -lm LD_REQUIRED += -lstdc++ ifeq ($(UNAME_S),Darwin) # If we are on a Mac OSX system @@ -135,45 +157,6 @@ SOURCE += $(TESTS) VPATH = $(dir $(SOURCE)) -CUSOURCE += $(TESTS) -CUSOURCE += $(wildcard *.cpp) -# TODO: use DEV_CUOBJ. It is not yet used -DEV_CUOBJ += $(addprefix $(OBJ_DIR)/,$(notdir $(CUSOURCE:%.cpp=%_cu_dev.o))) - -VPATH += $(dir $(CUSOURCE)) - -NVCC_BIN := nvcc -HAS_CUDA := $(shell command -v $(NVCC_BIN) 2> /dev/null) -ifdef HAS_CUDA -NVCC := $(shell which $(NVCC_BIN) 2>/dev/null) -CUDA_DIR := $(dir $(NVCC))/.. -NVCC_CFLAGS += --std=c++11 -NVCC_CFLAGS += -ccbin=g++ -NVCC_CFLAGS += $(DEVCAP) -NVCC_CFLAGS += -I . -NVCC_CFLAGS += -x cu -NVCC_CFLAGS += -dc -NVCC_CFLAGS += -D__CUDA__ -NVCC_CFLAGS += -I$(FLIT_INC_DIR) -NVCC_CFLAGS += -I$(CUDA_DIR)/samples/common/inc -endif # end of ifdef HAS_CUDA - -ifeq ($(UNAME_S),Darwin) # If we are on a Mac OSX system - NVCC_LINK += -Llib -lflit -else # not on Mac OSX - NVCC_LINK += -L$(FLIT_LIB_DIR) -lflit - NVCC_LINK += -Xcompiler \"-Wl,-rpath=$(realpath $(FLIT_LIB_DIR))\" -endif # end of if on Mac OSX - -NVCC_LINK += --std=c++11 -NVCC_LINK += -ccbin=g++ -NVCC_LINK += -L$(CUDA_DIR)/lib64 - -# TODO: double check CUDA flags. Really? No optimization levels? - -DEV_NVCC_CC += -DEV_NVCC_LD += - .PHONY: help help: @echo 'You can run the Makefile directly, but it is recommended to use' @@ -187,7 +170,6 @@ help: @echo @echo ' help Show this help and exit (default target)' @echo ' dev Only run the devel compilation to test things out' - @echo ' devcuda Only run the devel CUDA compilation to test CUDA out' @echo ' groundtruth Compile the ground-truth version' @echo ' gt Same as groundtruth' @echo ' runbuild Build all executables needed for the run target' @@ -213,13 +195,11 @@ CLANG := clang++ INTEL := icpc GCC := g++ -ifndef CUDA_ONLY -COMPILERS := $(foreach c, GCC INTEL CLANG, \ - $(if $(shell which $($(c)) 2>/dev/null), $c,)) -endif - ifdef CLANG_ONLY -COMPILERS = CLANG +COMPILERS := CLANG +else +COMPILERS := $(foreach c, GCC INTEL CLANG, \ + $(if $(shell which $($(c)) 2>/dev/null), $c,)) endif HOSTNAME := $(shell hostname) @@ -359,45 +339,6 @@ SWITCHES_INTEL += SINGLEPRECCONST SWITCHES_INTEL += SSE SWITCHES_INTEL += USEFASTM -################################################## -# -# Now deal with CUDA stuff if it is even available -# -################################################## - - - -# These are the fp affecting switches for CUDA (7.5). -# We will naively apply these (though the docs say -# that, for instance, --use_fast_math implies -# --ftz=true --prec-div=false --prec-sqrt=false -# --fmad=true. - -ifdef HAS_CUDA - -FASTMC := --use_fast_math -FMADFC := --fmad=false -FMADTC := --fmad=true -FTZFC := --ftz=false -FTZTC := --ftz=true -PRECDFC := --prec-div=false -PRECDTC := --prec-div=true -PRECSFC := --prec-sqrt=false -PRECSTC := --prec-sqrt=true - -CUSWITCHES += DEFFLAGS -CUSWITCHES += FASTMC -CUSWITCHES += FMADFC -CUSWITCHES += FMADTC -CUSWITCHES += FTZFC -CUSWITCHES += FTZTC -CUSWITCHES += PRECDFC -CUSWITCHES += PRECDTC -CUSWITCHES += PRECSFC -CUSWITCHES += PRECSTC - -endif # end of ifdef HAS_CUDA - ########################################################## # @@ -419,8 +360,6 @@ R_TARGET := $(RESULTS_DIR)/$(R_ID) R_OBJ := $(addprefix $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_$(R_ID).o))) R_DEP := $(R_OBJ:%.o=%.d) -$(info $(R_OBJ)) - -include $(R_DEP) .PHONY: rec @@ -430,7 +369,7 @@ $(R_TARGET): $(R_OBJ) $($(R_CUR_COMPILER)) $($(R_CUR_OPTL)) $($(R_CUR_SWITCHES)) \ $($(R_CUR_COMPILER)_REQUIRED) $(CC_REQUIRED) \ $(R_OBJ) -o $@ \ - $(LD_REQUIRED) + $(LD_REQUIRED) $(OBJ_DIR)/%_$(R_ID).o: %.cpp Makefile custom.mk | $(OBJ_DIR) $($(R_CUR_COMPILER)) $($(R_CUR_OPTL)) $($(R_CUR_SWITCHES)) \ @@ -466,7 +405,7 @@ define RECURSION_RULE TARGETS += $$(RESULTS_DIR)/$(strip $1)_$$(HOSTNAME)_$(strip $3)_$(strip $2) # TODO: use the variable $$(MAKECMDGOALS) to get the original make target -# or see if it is even necessary +# TODO- or see if it is even necessary # Make the recursive target depend on $$(GT_TARGET), not because it actually # depends on that target, but we know that when $$(GT_TARGET) needs to be @@ -486,10 +425,15 @@ $(foreach c, $(COMPILERS), \ $(foreach s, $(SWITCHES_$(strip $c)), \ $(foreach o, $(OPCODES), \ $(eval $(call RECURSION_RULE, $c, $o, $s))))) -TARGET_OUTS := $(TARGETS:%=%_out.csv) +TARGET_OUTS := $(TARGETS:%=%-out) +TARGET_RESULTS := $(TARGET_OUTS:%=%-comparison.csv) + +%-out: % + $(RUNWRAP) ./$< $(TEST_RUN_ARGS) --output $@ || touch $@ -%_out.csv: % - -./$< --output $@ +# specify how to get comparison +%-out-comparison.csv: %-out $(GT_OUT) $(GT_TARGET) + $(RUNWRAP) ./$(GT_TARGET) --compare-mode --compare-gt $(GT_OUT) --suffix "-comparison.csv" $< -o /dev/null #$(RESULTS_DIR)/%_out.csv: $(RESULTS_DIR)/% # $< --output $@ @@ -500,20 +444,15 @@ TARGET_OUTS := $(TARGETS:%=%_out.csv) OBJ_CLEAN = $(addprefix $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_*.o))) DEP_CLEAN += $(OBJ_CLEAN:%.o=%.d) -ifdef HAS_CUDA -CUTARGET_OUTS := $(foreach s, $(CUSWITCHES), \ - $(RESULTS_DIR)/NVCC_$(HOSTNAME)_$(strip $(s))_out.csv) -CUTARGETS := $(CUTARGET_OUTS:%_out.csv=%) -endif # ifdef HAS_CUDA - -.PHONY: dev devcuda gt groundtruth run runbuild +.PHONY: dev gt groundtruth run runbuild dev: $(DEV_TARGET) -devcuda: $(DEV_CUTARGET) gt: groundtruth groundtruth: $(GT_TARGET) -run: $(TARGET_OUTS) $(CUTARGET_OUTS) runbuild $(GT_OUT) -runbuild: $(TARGETS) $(CUTARGETS) groundtruth +run: $(TARGET_RESULTS) $(TARGET_OUTS) +run: $(GT_OUT) +run: runbuild +runbuild: $(TARGETS) groundtruth .PHONY: clean clean: @@ -527,13 +466,10 @@ clean: veryclean: distclean distclean: clean rm -f $(DEV_TARGET) - rm -f $(DEV_CUTARGET) rm -f $(TARGET_OUTS) + rm -f $(TARGET_RESULTS) rm -f $(addsuffix *.dat,$(TARGET_OUTS)) rm -f $(TARGETS) - rm -f $(CUTARGET_OUTS) - rm -f $(addsuffix *.dat,$(CUTARGET_OUTS)) - rm -f $(CUTARGETS) rm -f $(GT_TARGET) rm -f $(GT_OUT) rm -f $(addsuffix *.dat,$(GT_OUT)) @@ -559,14 +495,12 @@ cleanlibflit: rm -rf lib $(DEV_TARGET): lib/libflit.so -$(GT_TARGET): lib/libflit.so -$(TARGETS): lib/libflit.so -$(CUTARGETS): lib/libflit.so +$(GT_TARGET): lib/libflit.so +$(TARGETS): lib/libflit.so else $(DEV_TARGET): $(FLIT_LIB_DIR)/libflit.so -$(GT_TARGET): $(FLIT_LIB_DIR)/libflit.so -$(TARGETS): $(FLIT_LIB_DIR)/libflit.so -$(CUTARGETS): $(FLIT_LIB_DIR)/libflit.so +$(GT_TARGET): $(FLIT_LIB_DIR)/libflit.so +$(TARGETS): $(FLIT_LIB_DIR)/libflit.so endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac # include the build dependencies for gt and dev @@ -591,24 +525,15 @@ $(OBJ_DIR)/%_dev.o: %.cpp Makefile custom.mk | $(OBJ_DIR) -DFLIT_SWITCHES='"$(DEV_SWITCHES)"' \ -DFLIT_FILENAME='"$(notdir $(DEV_TARGET))"' -ifdef HAS_CUDA -$(DEV_CUTARGET): $(DEV_CUOBJ) Makefile custom.mk - $(NVCC) $(NVCC_LINK) $(DEV_NVCC_LD) $(DEV_CUOBJ) -o $(DEV_CUTARGET) - -$(OBJ_DIR)/%_cu_dev.o: %.cpp Makefile custom.mk | $(OBJ_DIR) - $(NVCC) -c $(NVCC_CFLAGS) $(DEV_NVCC_CC) $< -o $@ -endif # ifdef HAS_CUDA - # Ground truth compilation rules -$(GT_OUT): $(GT_TARGET) $(TARGET_OUTS) $(CUTARGET_OUTS) - ./$(GT_TARGET) --output $(GT_OUT) \ - --compare-mode $(TARGET_OUTS) $(CUTARGET_OUTS) +$(GT_OUT): $(GT_TARGET) + $(RUNWRAP) ./$(GT_TARGET) --output $(GT_OUT) --no-timing $(GT_TARGET): $(GT_OBJ) Makefile custom.mk $(GT_CC) $(CC_REQUIRED) -o $@ $(GT_OBJ) $(LD_REQUIRED) $(OBJ_DIR)/%_gt.o: %.cpp Makefile custom.mk | $(OBJ_DIR) - $(GT_CC) $(GT_OPTL) $(GT_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -c $< -o $@ \ + $(GT_CC) -g $(GT_OPTL) $(GT_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -c $< -o $@ \ -DFLIT_HOST='"$(HOSTNAME)"' \ -DFLIT_COMPILER='"$(GT_CC)"' \ -DFLIT_OPTL='"$(GT_OPTL)"' \ diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in new file mode 100644 index 00000000..aca9b2fb --- /dev/null +++ b/data/Makefile_bisect_binary.in @@ -0,0 +1,326 @@ +# -- LICENSE BEGIN -- +# +# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. +# +# Produced at the Lawrence Livermore National Laboratory +# +# Written by +# Michael Bentley (mikebentley15@gmail.com), +# Geof Sawaya (fredricflinstone@gmail.com), +# and Ian Briggs (ian.briggs@utah.edu) +# under the direction of +# Ganesh Gopalakrishnan +# and Dong H. Ahn. +# +# LLNL-CODE-743137 +# +# All rights reserved. +# +# This file is part of FLiT. For details, see +# https://pruners.github.io/flit +# Please also read +# https://github.com/PRUNERS/FLiT/blob/master/LICENSE +# +# Redistribution and use in source and binary forms, with or +# without modification, are permitted provided that the following +# conditions are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the disclaimer below. +# +# - Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the disclaimer +# (as noted below) in the documentation and/or other materials +# provided with the distribution. +# +# - Neither the name of the LLNS/LLNL nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. +# +# Additional BSD Notice +# +# 1. This notice is required to be provided under our contract +# with the U.S. Department of Energy (DOE). This work was +# produced at Lawrence Livermore National Laboratory under +# Contract No. DE-AC52-07NA27344 with the DOE. +# +# 2. Neither the United States Government nor Lawrence Livermore +# National Security, LLC nor any of their employees, makes any +# warranty, express or implied, or assumes any liability or +# responsibility for the accuracy, completeness, or usefulness of +# any information, apparatus, product, or process disclosed, or +# represents that its use would not infringe privately-owned +# rights. +# +# 3. Also, reference herein to any specific commercial products, +# process, or services by trade name, trademark, manufacturer or +# otherwise does not necessarily constitute or imply its +# endorsement, recommendation, or favoring by the United States +# Government or Lawrence Livermore National Security, LLC. The +# views and opinions of authors expressed herein do not +# necessarily state or reflect those of the United States +# Government or Lawrence Livermore National Security, LLC, and +# shall not be used for advertising or product endorsement +# purposes. +# +# -- LICENSE END -- + +# Autogenerated Makefile using "flit bisect" +# Date: {datetime} +# FLiT version: {flit_version} +# +# This file is intended to test one combination of compiling between a +# troublesome compilation and the ground truth compilation. +# +# For every combination that needs to be tested, a new Makefile is generated + +# include the main Makefiles for this project, getting their juicy settings +# Note: Makefile already includes custom.mk, so we don't need to explicitly +# include it here. +-include Makefile + +PRECISION := {precision} +TEST_CASE := {test_case} + +TROUBLE_CC := {trouble_cc} +TROUBLE_OPTL := {trouble_optl} +TROUBLE_SWITCHES := {trouble_switches} +BISECT_LINK := $(GT_CC) + +TROUBLE_ID := {trouble_id} + +MAKEFILE := {makefile} +NUMBER := {number} +BISECT_DIR := {bisect_dir} +BISECT_OBJ_DIR := $(BISECT_DIR)/obj +BISECT_TARGET := $(BISECT_DIR)/runbisect-$(NUMBER) +TROUBLE_TARGET := $(BISECT_DIR)/runtrouble-$(TROUBLE_ID) + +BISECT_GT_SRC := +{BISECT_GT_SRC} + +TROUBLE_SRC := +{TROUBLE_SRC} + +SPLIT_SRC := +{SPLIT_SRC} + +# Add to the CC_REQUIRED and LD_REQUIRED if necessary +{EXTRA_CC_FLAGS} +{EXTRA_LD_FLAGS} + +BUILD_GT_LOCAL := {build_gt_local} + +TROUBLE_TARGET_OBJ := $(addprefix \ + $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_bisect_$(TROUBLE_ID).o))) +BISECT_GT_OBJ := $(addprefix \ + $(OBJ_DIR)/,$(notdir $(BISECT_GT_SRC:%.cpp=%_gt.o))) +TROUBLE_OBJ := $(addprefix \ + $(OBJ_DIR)/,$(notdir $(TROUBLE_SRC:%.cpp=%_bisect_$(TROUBLE_ID).o))) +BISECT_OBJ := $(BISECT_GT_OBJ) +BISECT_OBJ += $(TROUBLE_OBJ) +TROUBLE_TARGET_DEPS := $(TROUBLE_TARGET_OBJ:%.o=%.d) +FPIC_OBJ := $(addprefix \ + $(BISECT_OBJ_DIR)/,$(notdir $(SPLIT_SRC:%.cpp=%_gt_fPIC.o))) +FPIC_OBJ := $(addprefix \ + $(BISECT_OBJ_DIR)/,$(notdir $(SPLIT_SRC:%.cpp=%_bisect_$(TROUBLE_ID)_fPIC.o))) +FPIC_DEPS := $(FPIC_OBJ:%.o=%.d) +SPLIT_OBJ := $(addprefix \ + $(BISECT_OBJ_DIR)/,$(notdir $(SPLIT_SRC:%.cpp=%_gt_split_$(NUMBER).o))) +SPLIT_OBJ += $(addprefix \ + $(BISECT_OBJ_DIR)/,$(notdir \ + $(SPLIT_SRC:%.cpp=%_trouble_split_$(NUMBER).o))) +SPLIT_DEPS := $(SPLIT_OBJ:%.o=%.d) +TROUBLE_SYMBOLS := $(addprefix \ + $(BISECT_OBJ_DIR)/,$(notdir \ + $(SPLIT_SRC:%.cpp=%_trouble_symbols_$(NUMBER).txt))) + +TROUBLE_TARGET_OUT := $(TROUBLE_TARGET:%=%-out) +TROUBLE_TARGET_RESULT := $(TROUBLE_TARGET_OUT:%=%-comparison.csv) +BISECT_OUT := $(BISECT_TARGET:%=%-out) +BISECT_RESULT := $(BISECT_OUT:%=%-comparison.csv) + +# TODO: test this on a mac +ifeq ($(UNAME_S),Darwin) +$(BISECT_TARGET): lib/libflit.so +$(TROUBLE_TARGET): lib/libflit.so +else +$(BISECT_TARGET): $(FLIT_LIB_DIR)/libflit.so +$(TROUBLE_TARGET): $(FLIT_LIB_DIR)/libflit.so +endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac + + +# If we want the ground-truth build to be done locally, for example if we have +# added to the $(LD_REQUIRED) flag and want to recompile the ground-truth +# executable, then simply set BUILD_GT_LOCAL=true. This generates +# $(BISECT_DIR)/gtrun-lib that will be the ground truth for this bisect +# execution. + +GT_LIB_TARGET := $(BISECT_DIR)/gtrun-lib +GT_LIB_OUT := $(BISECT_DIR)/gtrun-lib-out + +ifeq ($(BUILD_GT_LOCAL),true) + +ifeq ($(UNAME_S),Darwin) +$(GT_LIB_TARGET): lib/libflit.so +else +$(GT_LIB_TARGET): $(FLIT_LIB_DIR)/libflit.so +endif # ifeq ($(UNAME_S),Darwin): meaning we are on a mac + +$(GT_LIB_OUT): $(GT_LIB_TARGET) + $(RUNWRAP) ./$(GT_LIB_TARGET) --output $(GT_LIB_OUT) --no-timing --precision "$(PRECISION)" $(TEST_CASE) + +$(GT_LIB_TARGET): $(GT_OBJ) Makefile custom.mk $(MAKEFILE) + $(GT_CC) $(CC_REQUIRED) -o $@ $(GT_OBJ) $(LD_REQUIRED) + +$(BISECT_RESULT): $(BISECT_OUT) $(GT_LIB_OUT) $(GT_LIB_TARGET) + $(RUNWRAP) ./$(GT_LIB_TARGET) --compare-mode --compare-gt $(GT_LIB_OUT) --suffix "-comparison.csv" $< -o /dev/null + +endif # ifeq ($(BUILD_GT_LOCAL),true): meaning we are making a local gt + + +-include $(TROUBLE_TARGET_DEPS) +-include $(FPIC_DEPS) +-include $(SPLIT_DEPS) + +$(BISECT_OUT): $(BISECT_TARGET) | $(BISECT_DIR) + $(RUNWRAP) ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing +$(TROUBLE_TARGET_OUT): $(TROUBLE_TARGET) | $(BISECT_DIR) + $(RUNWRAP) ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing + +$(BISECT_TARGET): $(BISECT_OBJ) $(SPLIT_OBJ) Makefile custom.mk | $(BISECT_DIR) + $(GT_CC) $(CC_REQUIRED) -o $@ $(BISECT_OBJ) $(SPLIT_OBJ) $(LD_REQUIRED) + +$(TROUBLE_TARGET): $(TROUBLE_TARGET_OBJ) Makefile custom.mk | $(BISECT_DIR) + $(TROUBLE_CC) $(CC_REQUIRED) -o $@ $(TROUBLE_TARGET_OBJ) $(LD_REQUIRED) + +.PHONY: trouble trouble-out +trouble: $(TROUBLE_TARGET) +trouble-out: $(TROUBLE_TARGET_RESULT) $(TROUBLE_TARGET_OUT) + +.PHONY: bisect +bisect: $(BISECT_TARGET) $(GT_TARGET) +bisect: $(BISECT_RESULT) $(BISECT_OUT) + +.PHONY: bisect-smallclean bisect-clean bisect-distclean +clean: bisect-clean +distclean: bisect-distclean +bisect-smallclean: + rm -f $(BISECT_TARGET) + rm -f $(BISECT_OUT) + rm -f $(addsuffix *.dat,$(BISECT_OUT)) + rm -f $(TROUBLE_TARGET) + rm -f $(TROUBLE_TARGET_OUT) + rm -f $(addsuffix *.dat,$(TROUBLE_TARGET_OUT)) + rm -f $(TROUBLE_SYMBOLS) + rm -f $(FPIC_OBJ) + rm -f $(FPIC_DEPS) + rm -f $(SPLIT_OBJ) + rm -f $(SPLIT_DEPS) + -rmdir $(BISECT_OBJ_DIR) + +bisect-clean: bisect-smallclean + rm -f $(TROUBLE_TARGET_OBJ) + rm -f $(TROUBLE_TARGET_DEPS) + rm -f $(GT_LIB_TARGET) + rm -f $(GT_LIB_OUT) + rm -f $(addsuffix *.dat,$(GT_LIB_OUT)) + -rmdir $(BISECT_OBJ_DIR) + +bisect-distclean: bisect-clean + rm -f bisect.log + rm -f $(TROUBLE_TARGET_RESULT) + rm -f $(BISECT_RESULT) + rm -f $(MAKEFILE) + -rmdir $(BISECT_DIR) + +$(BISECT_DIR): + mkdir -p $(BISECT_DIR) + +$(BISECT_OBJ_DIR): + mkdir -p $(BISECT_OBJ_DIR) + +# ground-truth files are already specified in Makefile +# but need to specify how to do the fPIC variant +$(BISECT_OBJ_DIR)/%_gt_fPIC.o: %.cpp Makefile custom.mk | $(BISECT_OBJ_DIR) + $(GT_CC) $(GT_OPTL) $(GT_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -fPIC -c $< -o $@ \ + -DFLIT_HOST='"$(HOSTNAME)"' \ + -DFLIT_COMPILER='"$(GT_CC)"' \ + -DFLIT_OPTL='"$(GT_OPTL)"' \ + -DFLIT_SWITCHES='"$(GT_SWITCHES)"' \ + -DFLIT_FILENAME='"$(notdir $(GT_TARGET))"' + + +# specify how to build the troublesome ones +$(OBJ_DIR)/%_bisect_$(TROUBLE_ID).o: %.cpp Makefile custom.mk | $(OBJ_DIR) + $(TROUBLE_CC) $(TROUBLE_OPTL) $(TROUBLE_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -c $< -o $@ \ + -DFLIT_HOST='"$(HOSTNAME)"' \ + -DFLIT_COMPILER='"$(TROUBLE_CC)"' \ + -DFLIT_OPTL='"$(TROUBLE_OPTL)"' \ + -DFLIT_SWITCHES='"$(TROUBLE_SWITCHES)"' \ + -DFLIT_FILENAME='"bisect-default-out"' + +# and the fPIC variant +$(BISECT_OBJ_DIR)/%_bisect_$(TROUBLE_ID)_fPIC.o: %.cpp Makefile custom.mk | $(BISECT_OBJ_DIR) + $(TROUBLE_CC) $(TROUBLE_OPTL) $(TROUBLE_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -fPIC -c $< -o $@ \ + -DFLIT_HOST='"$(HOSTNAME)"' \ + -DFLIT_COMPILER='"$(TROUBLE_CC)"' \ + -DFLIT_OPTL='"$(TROUBLE_OPTL)"' \ + -DFLIT_SWITCHES='"$(TROUBLE_SWITCHES)"' \ + -DFLIT_FILENAME='"bisect-default-out"' + +# Specify how to split symbols using objcopy + +# Defines how to split the one object file into two object files using objcopy +# @param 1: src basename (e.g. for 'tests/Example01.cpp' pass in 'Example01') +define SPLIT_RULE + +$$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o: $$(BISECT_OBJ_DIR)/$1_gt_fPIC.o +$$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o: $$(BISECT_OBJ_DIR)/$1_trouble_symbols_$$(NUMBER).txt +$$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o: $$(MAKEFILE) +$$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o: | $$(BISECT_OBJ_DIR) + if [ -s "$$(BISECT_OBJ_DIR)/$1_trouble_symbols_$$(NUMBER).txt" ]; then \ + objcopy \ + --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_trouble_symbols_$$(NUMBER).txt \ + $$(BISECT_OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ + else \ + cp \ + $$(BISECT_OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ + fi + +$$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: $$(BISECT_OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o +$$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: $$(MAKEFILE) +$$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: $$(BISECT_OBJ_DIR)/$1_gt_symbols_$$(NUMBER).txt +$$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: | $$(BISECT_OBJ_DIR) + if [ -s "$$(BISECT_OBJ_DIR)/$1_gt_symbols_$$(NUMBER).txt" ]; then \ + objcopy \ + --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_gt_symbols_$$(NUMBER).txt \ + $$(BISECT_OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ + else \ + cp \ + $$(BISECT_OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ + fi + +endef + +$(foreach s, $(notdir $(SPLIT_SRC:%.cpp=%)), \ + $(eval $(call SPLIT_RULE,$s))) diff --git a/data/custom.mk b/data/custom.mk index dec800b5..2f7ef3f7 100644 --- a/data/custom.mk +++ b/data/custom.mk @@ -79,16 +79,13 @@ # purposes. # # -- LICENSE END -- -# This file is included at the end of the copied Makefile. If you have some -# things you want to change about the Makefile, it is best to do it here. +# This file is included by the generated Makefile. If you have some things you +# want to change about the Makefile, it is best to do it here. # additional source files to compile other than what is in '.' and 'tests/' # since those directories are added by a wildcard. SOURCE += -# for when cuda is compiled, you can specify different source files -CUSOURCE += - # required compiler flags # for example, include directories # CC_REQUIRED += -I @@ -109,12 +106,9 @@ LD_REQUIRED += DEV_CFLAGS += DEV_LDFLAGS += -# required compiler flags for CUDA -NVCC_CFLAGS += - -# required link flags for CUDA -NVCC_LINK += +# wrapper around the running of the test executable when run through the +# Makefile. +# For example, to run a test incorporating MPI, you could use +# RUN_WRAPPER := srun --nodes 1 +RUN_WRAPPER := -# compiler and linker flags respectively - specifically for a dev cuda build -DEV_NVCC_CC += -DEV_NVCC_LD += diff --git a/data/db/CreateFlitDBInstaller.sh b/data/db/CreateFlitDBInstaller.sh deleted file mode 100755 index 8d729ecb..00000000 --- a/data/db/CreateFlitDBInstaller.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -# this creates a script for execution on the desired DB Host. -# The script will contain files needed for its configuration, -# currently, setup_db_host.sh and matplotlibrc - -DIR=$(dirname "$(readlink -f "$0")") -FILE=InstallFlitDB.sh -INFILE=${DIR}/${FILE}.in -PREFIX=$RANDOM - -echo "#!/bin/bash" > $FILE - -echo -n "TAGS=(" >> $FILE - -for ifile in "$@" -do - echo -n $ifile ' ' >> $FILE -done - -echo ")" >> $FILE - -echo "PREFIX="$PREFIX >> $FILE - -cat $INFILE >> $FILE - -for ifile in "$@" -do - echo ${PREFIX}$ifile >> $FILE - cat $ifile >> $FILE -done - -chmod 775 $FILE - diff --git a/data/db/InstallFlitDB.sh b/data/db/InstallFlitDB.sh deleted file mode 100755 index b6217b41..00000000 --- a/data/db/InstallFlitDB.sh +++ /dev/null @@ -1,1631 +0,0 @@ -#!/bin/bash - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -TAGS=(setup_db_host.sh matplotlibrc tables.sql ) -PREFIX=18370 -#This file was auto-generated - -#This is the FLiT DB installer - -for x in $(seq 0 $((${#TAGS[@]}-2))); -do - begin=$(grep --line-number ^${PREFIX}${TAGS[$x]}$ $0 | cut -d ':' -f 1) - end=$(grep --line-number ^${PREFIX}${TAGS[$(($x + 1))]}$ $0 | cut -d ':' -f 1) - sed -n $((begin + 1)),$((end - 1))p $0 > ${TAGS[$x]#${PREFIX}} -done - -tail -n +$((end + 1)) $0 > ${TAGS[$((${#TAGS[@]}-1))]#${PREFIX}} - -EXE=${TAGS[0]#${PREFIX}} - -chmod 775 $EXE - -./$EXE - -exit -18370setup_db_host.sh -#!/bin/bash - -set -x - -exists () -{ - command -v "$1" >/dev/null 2>&1 -} - -python3_has () -{ - python3 -c "import $1" >/dev/null 2>&1 -} - -SCRIPT_DIR="$(pwd)/$(dirname $0)" - -# Check for psql install -if ! exists createdb || ! exists psql; then - # Install if not present - echo "Postgres does not seem to be installed." - echo "Attempting install now." - - # Try different package managers - if exists apt; then - sudo apt install postgresql postgresql-plpython3 - elif exists apt-get; then - sudo apt install postgresql postgresql-plpython3 - elif exists pacman; then - sudo pacman -S postgresql postgresql-lib-python3 - elif exists yum; then - sudo yum install postgresql-server #name-for-plpython3 - elif exists brew; then - brew install postgresql --with-python3 - brew services start postgresql - else - echo "Unable to find a suitable package manager." - echo "Please install Postgres and plpython3" - exit -1 - fi -fi - - -# Check for numpy install -if ! python3_has numpy; then - # Install if not present - echo "Numpy does not seem to be installed for python 3." - echo "Attempting install now." - - Try different package managers - if exists apt; then - sudo apt install python3-numpy - elif exists apt-get; then - sudo apt install python3-numpy - elif exists pacman; then - sudo pacman -S python3-numpy - elif exists yum; then - sudo yum install python3-numpy - elif exists brew; then - brew install numpy -with-ptyhon3 - else - echo "Unable to find a suitable package manager." - echo "Please install numpy for python3" - exit -1 - fi -fi - - -# Check for matplotlib install -if ! python3_has matplotlib; then - # Install if not present - echo "Matplotlib does not seem to be installed for python 3." - echo "Attempting install now." - - Try different package managers - if exists apt; then - sudo apt install python3-matplotlib - elif exists apt-get; then - sudo apt install python3-matplotlib - elif exists pacman; then - sudo pacman -S python3-matplotlib - elif exists yum; then - sudo yum install python3-matplotlib - elif exists brew; then - brew tap homebrew/science - brew install homebrew/science/matplotlib -with-ptyhon3 - else - echo "Unable to find a suitable package manager." - echo "Please install Postgres and plpython3" - exit -1 - fi -fi - -# Check if user exists -# from http://stackoverflow.com/questions/8546759/how-to-check-if-a-postgres-user-exists -if psql -t -c '\du' | cut -d \| -f 1 | grep -qw `whoami`; then - echo "User `whoami` already exists" -else - echo "Creating user `whoami`" - sudo -u postgres createuser --superuser `whoami` -fi - - -createdb flit "The database for collecting all FLiT results" -psql flit < "$SCRIPT_DIR/tables.sql" - -wait - -#add our config to postgres for matplotlib -PGDIR=$(psql flit -t -c 'select getpwd()') -if [ ! -e ${PGDIR}/matplotlibrc ]; then - sudo -u postgres cp ${SCRIPT_DIR}/matplotlibrc ${PGDIR}/matplotlibrc -else - if ! egrep '^backend[[:space:]]*:[[:space:]]*Agg$' ${PGDIR}/matplotlibrc; then - echo "FLiT reporting will fail without the setting 'backend : Agg' in ${PGDIR}/matplotlibrc. Please set before using FLiT" - fi -fi - -#now we need to add the user and postres to the flit group - -sudo addgroup flit -sudo usermod -aG flit sawaya -sudo usermod -aG flit postgres -sudo service postgresql restart -18370matplotlibrc -### MATPLOTLIBRC FORMAT - -# This is a sample matplotlib configuration file - you can find a copy -# of it on your system in -# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it -# there, please note that it will be overwritten in your next install. -# If you want to keep a permanent local copy that will not be -# overwritten, place it in the following location: -# unix/linux: -# $HOME/.config/matplotlib/matplotlibrc or -# $XDG_CONFIG_HOME/matplotlib/matplotlibrc (if $XDG_CONFIG_HOME is set) -# other platforms: -# $HOME/.matplotlib/matplotlibrc -# -# See http://matplotlib.org/users/customizing.html#the-matplotlibrc-file for -# more details on the paths which are checked for the configuration file. -# -# This file is best viewed in a editor which supports python mode -# syntax highlighting. Blank lines, or lines starting with a comment -# symbol, are ignored, as are trailing comments. Other lines must -# have the format -# key : val # optional comment -# -# Colors: for the color values below, you can either use - a -# matplotlib color string, such as r, k, or b - an rgb tuple, such as -# (1.0, 0.5, 0.0) - a hex string, such as ff00ff or #ff00ff - a scalar -# grayscale intensity such as 0.75 - a legal html color name, e.g., red, -# blue, darkslategray - -#### CONFIGURATION BEGINS HERE - -# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo -# CocoaAgg MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG -# Template. -# You can also deploy your own backend outside of matplotlib by -# referring to the module name (which must be in the PYTHONPATH) as -# 'module://my_backend'. -backend : Agg - -# If you are using the Qt4Agg backend, you can choose here -# to use the PyQt4 bindings or the newer PySide bindings to -# the underlying Qt4 toolkit. -#backend.qt4 : PyQt4 # PyQt4 | PySide - -# Note that this can be overridden by the environment variable -# QT_API used by Enthought Tool Suite (ETS); valid values are -# "pyqt" and "pyside". The "pyqt" setting has the side effect of -# forcing the use of Version 2 API for QString and QVariant. - -# The port to use for the web server in the WebAgg backend. -# webagg.port : 8888 - -# If webagg.port is unavailable, a number of other random ports will -# be tried until one that is available is found. -# webagg.port_retries : 50 - -# When True, open the webbrowser to the plot that is shown -# webagg.open_in_browser : True - -# When True, the figures rendered in the nbagg backend are created with -# a transparent background. -# nbagg.transparent : True - -# if you are running pyplot inside a GUI and your backend choice -# conflicts, we will automatically try to find a compatible one for -# you if backend_fallback is True -#backend_fallback: True - -#interactive : False -#toolbar : toolbar2 # None | toolbar2 ("classic" is deprecated) -#timezone : UTC # a pytz timezone string, e.g., US/Central or Europe/Paris - -# Where your matplotlib data lives if you installed to a non-default -# location. This is where the matplotlib fonts, bitmaps, etc reside -#datapath : /home/jdhunter/mpldata - - -### LINES -# See http://matplotlib.org/api/artist_api.html#module-matplotlib.lines for more -# information on line properties. -#lines.linewidth : 1.0 # line width in points -#lines.linestyle : - # solid line -#lines.color : blue # has no affect on plot(); see axes.prop_cycle -#lines.marker : None # the default marker -#lines.markeredgewidth : 0.5 # the line width around the marker symbol -#lines.markersize : 6 # markersize, in points -#lines.dash_joinstyle : miter # miter|round|bevel -#lines.dash_capstyle : butt # butt|round|projecting -#lines.solid_joinstyle : miter # miter|round|bevel -#lines.solid_capstyle : projecting # butt|round|projecting -#lines.antialiased : True # render lines in antialiased (no jaggies) - -#markers.fillstyle: full # full|left|right|bottom|top|none - -### PATCHES -# Patches are graphical objects that fill 2D space, like polygons or -# circles. See -# http://matplotlib.org/api/artist_api.html#module-matplotlib.patches -# information on patch properties -#patch.linewidth : 1.0 # edge width in points -#patch.facecolor : blue -#patch.edgecolor : black -#patch.antialiased : True # render patches in antialiased (no jaggies) - -### FONT -# -# font properties used by text.Text. See -# http://matplotlib.org/api/font_manager_api.html for more -# information on font properties. The 6 font properties used for font -# matching are given below with their default values. -# -# The font.family property has five values: 'serif' (e.g., Times), -# 'sans-serif' (e.g., Helvetica), 'cursive' (e.g., Zapf-Chancery), -# 'fantasy' (e.g., Western), and 'monospace' (e.g., Courier). Each of -# these font families has a default list of font names in decreasing -# order of priority associated with them. When text.usetex is False, -# font.family may also be one or more concrete font names. -# -# The font.style property has three values: normal (or roman), italic -# or oblique. The oblique style will be used for italic, if it is not -# present. -# -# The font.variant property has two values: normal or small-caps. For -# TrueType fonts, which are scalable fonts, small-caps is equivalent -# to using a font size of 'smaller', or about 83% of the current font -# size. -# -# The font.weight property has effectively 13 values: normal, bold, -# bolder, lighter, 100, 200, 300, ..., 900. Normal is the same as -# 400, and bold is 700. bolder and lighter are relative values with -# respect to the current weight. -# -# The font.stretch property has 11 values: ultra-condensed, -# extra-condensed, condensed, semi-condensed, normal, semi-expanded, -# expanded, extra-expanded, ultra-expanded, wider, and narrower. This -# property is not currently implemented. -# -# The font.size property is the default font size for text, given in pts. -# 12pt is the standard value. -# -#font.family : sans-serif -#font.style : normal -#font.variant : normal -#font.weight : medium -#font.stretch : normal -# note that font.size controls default text sizes. To configure -# special text sizes tick labels, axes, labels, title, etc, see the rc -# settings for axes and ticks. Special text sizes can be defined -# relative to font.size, using the following values: xx-small, x-small, -# small, medium, large, x-large, xx-large, larger, or smaller -#font.size : 12.0 -#font.serif : Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif -#font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif -#font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, cursive -#font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, Humor Sans, fantasy -#font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace - -### TEXT -# text properties used by text.Text. See -# http://matplotlib.org/api/artist_api.html#module-matplotlib.text for more -# information on text properties - -#text.color : black - -### LaTeX customizations. See http://wiki.scipy.org/Cookbook/Matplotlib/UsingTex -#text.usetex : False # use latex for all text handling. The following fonts - # are supported through the usual rc parameter settings: - # new century schoolbook, bookman, times, palatino, - # zapf chancery, charter, serif, sans-serif, helvetica, - # avant garde, courier, monospace, computer modern roman, - # computer modern sans serif, computer modern typewriter - # If another font is desired which can loaded using the - # LaTeX \usepackage command, please inquire at the - # matplotlib mailing list -#text.latex.unicode : False # use "ucs" and "inputenc" LaTeX packages for handling - # unicode strings. -#text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES - # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP - # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. - # preamble is a comma separated list of LaTeX statements - # that are included in the LaTeX document preamble. - # An example: - # text.latex.preamble : \usepackage{bm},\usepackage{euler} - # The following packages are always loaded with usetex, so - # beware of package collisions: color, geometry, graphicx, - # type1cm, textcomp. Adobe Postscript (PSSNFS) font packages - # may also be loaded, depending on your font settings - -#text.dvipnghack : None # some versions of dvipng don't handle alpha - # channel properly. Use True to correct - # and flush ~/.matplotlib/tex.cache - # before testing and False to force - # correction off. None will try and - # guess based on your dvipng version - -#text.hinting : auto # May be one of the following: - # 'none': Perform no hinting - # 'auto': Use freetype's autohinter - # 'native': Use the hinting information in the - # font file, if available, and if your - # freetype library supports it - # 'either': Use the native hinting information, - # or the autohinter if none is available. - # For backward compatibility, this value may also be - # True === 'auto' or False === 'none'. -#text.hinting_factor : 8 # Specifies the amount of softness for hinting in the - # horizontal direction. A value of 1 will hint to full - # pixels. A value of 2 will hint to half pixels etc. - -#text.antialiased : True # If True (default), the text will be antialiased. - # This only affects the Agg backend. - -# The following settings allow you to select the fonts in math mode. -# They map from a TeX font name to a fontconfig font pattern. -# These settings are only used if mathtext.fontset is 'custom'. -# Note that this "custom" mode is unsupported and may go away in the -# future. -#mathtext.cal : cursive -#mathtext.rm : serif -#mathtext.tt : monospace -#mathtext.it : serif:italic -#mathtext.bf : serif:bold -#mathtext.sf : sans -#mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix', - # 'stixsans' or 'custom' -#mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern - # fonts when a symbol can not be found in one of - # the custom math fonts. - -#mathtext.default : it # The default font to use for math. - # Can be any of the LaTeX font names, including - # the special name "regular" for the same font - # used in regular text. - -### AXES -# default face and edge color, default tick sizes, -# default fontsizes for ticklabels, and so on. See -# http://matplotlib.org/api/axes_api.html#module-matplotlib.axes -#axes.hold : True # whether to clear the axes by default on -#axes.facecolor : white # axes background color -#axes.edgecolor : black # axes edge color -#axes.linewidth : 1.0 # edge linewidth -#axes.grid : False # display grid or not -#axes.titlesize : large # fontsize of the axes title -#axes.labelsize : medium # fontsize of the x any y labels -#axes.labelpad : 5.0 # space between label and axis -#axes.labelweight : normal # weight of the x and y labels -#axes.labelcolor : black -#axes.axisbelow : False # whether axis gridlines and ticks are below - # the axes elements (lines, text, etc) - -#axes.formatter.limits : -7, 7 # use scientific notation if log10 - # of the axis range is smaller than the - # first or larger than the second -#axes.formatter.use_locale : False # When True, format tick labels - # according to the user's locale. - # For example, use ',' as a decimal - # separator in the fr_FR locale. -#axes.formatter.use_mathtext : False # When True, use mathtext for scientific - # notation. -#axes.formatter.useoffset : True # If True, the tick label formatter - # will default to labeling ticks relative - # to an offset when the data range is very - # small compared to the minimum absolute - # value of the data. - -#axes.unicode_minus : True # use unicode for the minus symbol - # rather than hyphen. See - # http://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes -#axes.prop_cycle : cycler('color', 'bgrcmyk') - # color cycle for plot lines - # as list of string colorspecs: - # single letter, long name, or - # web-style hex -#axes.xmargin : 0 # x margin. See `axes.Axes.margins` -#axes.ymargin : 0 # y margin See `axes.Axes.margins` - -#polaraxes.grid : True # display grid on polar axes -#axes3d.grid : True # display grid on 3d axes - -### TICKS -# see http://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick -#xtick.major.size : 4 # major tick size in points -#xtick.minor.size : 2 # minor tick size in points -#xtick.major.width : 0.5 # major tick width in points -#xtick.minor.width : 0.5 # minor tick width in points -#xtick.major.pad : 4 # distance to major tick label in points -#xtick.minor.pad : 4 # distance to the minor tick label in points -#xtick.color : k # color of the tick labels -#xtick.labelsize : medium # fontsize of the tick labels -#xtick.direction : in # direction: in, out, or inout - -#ytick.major.size : 4 # major tick size in points -#ytick.minor.size : 2 # minor tick size in points -#ytick.major.width : 0.5 # major tick width in points -#ytick.minor.width : 0.5 # minor tick width in points -#ytick.major.pad : 4 # distance to major tick label in points -#ytick.minor.pad : 4 # distance to the minor tick label in points -#ytick.color : k # color of the tick labels -#ytick.labelsize : medium # fontsize of the tick labels -#ytick.direction : in # direction: in, out, or inout - - -### GRIDS -#grid.color : black # grid color -#grid.linestyle : : # dotted -#grid.linewidth : 0.5 # in points -#grid.alpha : 1.0 # transparency, between 0.0 and 1.0 - -### Legend -#legend.fancybox : False # if True, use a rounded box for the - # legend, else a rectangle -#legend.isaxes : True -#legend.numpoints : 2 # the number of points in the legend line -#legend.fontsize : large -#legend.borderpad : 0.5 # border whitespace in fontsize units -#legend.markerscale : 1.0 # the relative size of legend markers vs. original -# the following dimensions are in axes coords -#legend.labelspacing : 0.5 # the vertical space between the legend entries in fraction of fontsize -#legend.handlelength : 2. # the length of the legend lines in fraction of fontsize -#legend.handleheight : 0.7 # the height of the legend handle in fraction of fontsize -#legend.handletextpad : 0.8 # the space between the legend line and legend text in fraction of fontsize -#legend.borderaxespad : 0.5 # the border between the axes and legend edge in fraction of fontsize -#legend.columnspacing : 2. # the border between the axes and legend edge in fraction of fontsize -#legend.shadow : False -#legend.frameon : True # whether or not to draw a frame around legend -#legend.framealpha : None # opacity of of legend frame -#legend.scatterpoints : 3 # number of scatter points - -### FIGURE -# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure -#figure.titlesize : medium # size of the figure title -#figure.titleweight : normal # weight of the figure title -#figure.figsize : 8, 6 # figure size in inches -#figure.dpi : 80 # figure dots per inch -#figure.facecolor : 0.75 # figure facecolor; 0.75 is scalar gray -#figure.edgecolor : white # figure edgecolor -#figure.autolayout : False # When True, automatically adjust subplot - # parameters to make the plot fit the figure -#figure.max_open_warning : 20 # The maximum number of figures to open through - # the pyplot interface before emitting a warning. - # If less than one this feature is disabled. - -# The figure subplot parameters. All dimensions are a fraction of the -# figure width or height -#figure.subplot.left : 0.125 # the left side of the subplots of the figure -#figure.subplot.right : 0.9 # the right side of the subplots of the figure -#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure -#figure.subplot.top : 0.9 # the top of the subplots of the figure -#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots -#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots - -### IMAGES -#image.aspect : equal # equal | auto | a number -#image.interpolation : bilinear # see help(imshow) for options -#image.cmap : jet # gray | jet etc... -#image.lut : 256 # the size of the colormap lookup table -#image.origin : upper # lower | upper -#image.resample : False -#image.composite_image : True # When True, all the images on a set of axes are - # combined into a single composite image before - # saving a figure as a vector graphics file, - # such as a PDF. - -### CONTOUR PLOTS -#contour.negative_linestyle : dashed # dashed | solid -#contour.corner_mask : True # True | False | legacy - -### ERRORBAR PLOTS -#errorbar.capsize : 3 # length of end cap on error bars in pixels - -### Agg rendering -### Warning: experimental, 2008/10/10 -#agg.path.chunksize : 0 # 0 to disable; values in the range - # 10000 to 100000 can improve speed slightly - # and prevent an Agg rendering failure - # when plotting very large data sets, - # especially if they are very gappy. - # It may cause minor artifacts, though. - # A value of 20000 is probably a good - # starting point. -### SAVING FIGURES -#path.simplify : True # When True, simplify paths by removing "invisible" - # points to reduce file size and increase rendering - # speed -#path.simplify_threshold : 0.1 # The threshold of similarity below which - # vertices will be removed in the simplification - # process -#path.snap : True # When True, rectilinear axis-aligned paths will be snapped to - # the nearest pixel when certain criteria are met. When False, - # paths will never be snapped. -#path.sketch : None # May be none, or a 3-tuple of the form (scale, length, - # randomness). - # *scale* is the amplitude of the wiggle - # perpendicular to the line (in pixels). *length* - # is the length of the wiggle along the line (in - # pixels). *randomness* is the factor by which - # the length is randomly scaled. - -# the default savefig params can be different from the display params -# e.g., you may want a higher resolution, or to make the figure -# background white -#savefig.dpi : 100 # figure dots per inch -#savefig.facecolor : white # figure facecolor when saving -#savefig.edgecolor : white # figure edgecolor when saving -#savefig.format : png # png, ps, pdf, svg -#savefig.bbox : standard # 'tight' or 'standard'. - # 'tight' is incompatible with pipe-based animation - # backends but will workd with temporary file based ones: - # e.g. setting animation.writer to ffmpeg will not work, - # use ffmpeg_file instead -#savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight' -#savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter. -#savefig.directory : ~ # default directory in savefig dialog box, - # leave empty to always use current working directory -#savefig.transparent : False # setting that controls whether figures are saved with a - # transparent background by default - -# tk backend params -#tk.window_focus : False # Maintain shell focus for TkAgg - -# ps backend params -#ps.papersize : letter # auto, letter, legal, ledger, A0-A10, B0-B10 -#ps.useafm : False # use of afm fonts, results in small files -#ps.usedistiller : False # can be: None, ghostscript or xpdf - # Experimental: may produce smaller files. - # xpdf intended for production of publication quality files, - # but requires ghostscript, xpdf and ps2eps -#ps.distiller.res : 6000 # dpi -#ps.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) - -# pdf backend params -#pdf.compression : 6 # integer from 0 to 9 - # 0 disables compression (good for debugging) -#pdf.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) - -# svg backend params -#svg.image_inline : True # write raster image data directly into the svg file -#svg.image_noscale : False # suppress scaling of raster data embedded in SVG -#svg.fonttype : 'path' # How to handle SVG fonts: -# 'none': Assume fonts are installed on the machine where the SVG will be viewed. -# 'path': Embed characters as paths -- supported by most SVG renderers -# 'svgfont': Embed characters as SVG fonts -- supported only by Chrome, -# Opera and Safari - -# docstring params -#docstring.hardcopy = False # set this when you want to generate hardcopy docstring - -# Set the verbose flags. This controls how much information -# matplotlib gives you at runtime and where it goes. The verbosity -# levels are: silent, helpful, debug, debug-annoying. Any level is -# inclusive of all the levels below it. If your setting is "debug", -# you'll get all the debug and helpful messages. When submitting -# problems to the mailing-list, please set verbose to "helpful" or "debug" -# and paste the output into your report. -# -# The "fileo" gives the destination for any calls to verbose.report. -# These objects can a filename, or a filehandle like sys.stdout. -# -# You can override the rc default verbosity from the command line by -# giving the flags --verbose-LEVEL where LEVEL is one of the legal -# levels, e.g., --verbose-helpful. -# -# You can access the verbose instance in your code -# from matplotlib import verbose. -#verbose.level : silent # one of silent, helpful, debug, debug-annoying -#verbose.fileo : sys.stdout # a log filename, sys.stdout or sys.stderr - -# Event keys to interact with figures/plots via keyboard. -# Customize these settings according to your needs. -# Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '') - -#keymap.fullscreen : f # toggling -#keymap.home : h, r, home # home or reset mnemonic -#keymap.back : left, c, backspace # forward / backward keys to enable -#keymap.forward : right, v # left handed quick navigation -#keymap.pan : p # pan mnemonic -#keymap.zoom : o # zoom mnemonic -#keymap.save : s # saving current figure -#keymap.quit : ctrl+w, cmd+w # close the current figure -#keymap.grid : g # switching on/off a grid in current axes -#keymap.yscale : l # toggle scaling of y-axes ('log'/'linear') -#keymap.xscale : L, k # toggle scaling of x-axes ('log'/'linear') -#keymap.all_axes : a # enable all axes - -# Control location of examples data files -#examples.directory : '' # directory to look in for custom installation - -###ANIMATION settings -#animation.html : 'none' # How to display the animation as HTML in - # the IPython notebook. 'html5' uses - # HTML5 video tag. -#animation.writer : ffmpeg # MovieWriter 'backend' to use -#animation.codec : mpeg4 # Codec to use for writing movie -#animation.bitrate: -1 # Controls size/quality tradeoff for movie. - # -1 implies let utility auto-determine -#animation.frame_format: 'png' # Controls frame format used by temp files -#animation.ffmpeg_path: 'ffmpeg' # Path to ffmpeg binary. Without full path - # $PATH is searched -#animation.ffmpeg_args: '' # Additional arguments to pass to ffmpeg -#animation.avconv_path: 'avconv' # Path to avconv binary. Without full path - # $PATH is searched -#animation.avconv_args: '' # Additional arguments to pass to avconv -#animation.mencoder_path: 'mencoder' - # Path to mencoder binary. Without full path - # $PATH is searched -#animation.mencoder_args: '' # Additional arguments to pass to mencoder -#animation.convert_path: 'convert' # Path to ImageMagick's convert binary. - # On Windows use the full path since convert - # is also the name of a system tool. -18370tables.sql --- --- PostgreSQL database dump --- - --- Dumped from database version 9.5.6 --- Dumped by pg_dump version 9.5.6 - -SET statement_timeout = 0; -SET lock_timeout = 0; -SET client_encoding = 'SQL_ASCII'; -SET standard_conforming_strings = on; -SET check_function_bodies = false; -SET client_min_messages = warning; -SET row_security = off; - --- --- Name: flit; Type: DATABASE; Schema: -; Owner: - --- - -CREATE DATABASE flit WITH TEMPLATE = template0 ENCODING = 'SQL_ASCII' LC_COLLATE = 'C' LC_CTYPE = 'C'; - - -\connect flit - -SET statement_timeout = 0; -SET lock_timeout = 0; -SET client_encoding = 'SQL_ASCII'; -SET standard_conforming_strings = on; -SET check_function_bodies = false; -SET client_min_messages = warning; -SET row_security = off; - --- --- Name: flit; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON DATABASE flit IS 'The database for collecting all FLiT results'; - - --- --- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; - - --- --- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; - - --- --- Name: plpython3u; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: - --- - -CREATE OR REPLACE PROCEDURAL LANGUAGE plpython3u; - - -SET search_path = public, pg_catalog; - --- --- Name: breakdowntest(text, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION breakdowntest(name text, run integer) RETURNS integer - LANGUAGE plpython3u - AS $$ - - quer = ("select distinct trunc(score0d, 15) as score, precision, " + - "compiler, optl, array(select distinct switches from tests " + - "where name = t1.name and score0 = t1.score0 and precision " + - "= t1.precision and compiler = t1.compiler and run = t1.run " + - "and optl = t1.optl) from tests as t1 where name = '" + - name + "' and run = " + str(run) + " order by score, compiler") - res = plpy.execute(quer) - return res.nrows() -$$; - - --- --- Name: cleanupresults(integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION cleanupresults(run integer DEFAULT '-1'::integer) RETURNS integer[] - LANGUAGE plpython3u - AS $$ -global run -rn = run -if rn == -1: - r = ("SELECT MAX(index)as index from runs;") - res = plpy.execute(r) - rn = res[0]["index"] - -s = ("update tests set compiler = 'icpc' where compiler ~ " + - "'.*icpc.*' and run = " + str(rn)) -res = plpy.execute(s) -s = ("update tests set host = 'kingspeak' where host ~ " + - "'.*kingspeak.*' and run = " + str(rn)) -res2 = plpy.execute(s) -s = ("update tests set switches=trim(switches)") -res3 = plpy.execute(s) -s = ("update tests set compiler=trim(compiler)") -res4 = plpy.execute(s) -s = ("update tests set compiler='clang++' where compiler='clang++-3.6'") -return [res.nrows(), res2.nrows(), res3.nrows(), res4.nrows()] -$$; - - --- --- Name: createschmoo(integer, text[], text[], text[], text, integer, text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION createschmoo(run integer, prec text[], compilers text[], optls text[], host text, labsize integer, fname text) RETURNS text - LANGUAGE plpython3u - AS $$ -from plpy import spiexceptions -from sys import path -from os import environ -path.append('/tmp/flitDbDir/python') -import plotting as pl - -host_str = '' -if len(host) > 0: - host_str = " and host = '" + host + "'" - -prec_str = "" -if len(prec) > 0: - prec_str = " and (precision = '" - for t in prec: - prec_str += t + "' or precision = '" - prec_str = prec_str[:-17] + ")" - -optl_str = "" -if len(optls) > 0: - optl_str = " and (optl = '" - for t in optls: - optl_str += t + "' or optl = '" - optl_str = optl_str[:-12] + ")" - -comp_str = "" -if len(compilers) > 0: - comp_str = " and (compiler = '" - for c in compilers: - comp_str += c + "' or compiler = '" - comp_str = comp_str[:-16] + ")" - -quer = ("select distinct name from tests as t1 where exists " + - "(select 1 from tests where t1.name = name and t1.precision " + - "= precision and t1.score0 != score0 and t1.run = run " + - "and t1.compiler = compiler and t1.optl = optl and t1.host = host) " + - "and run = " + str(run) + prec_str + optl_str + comp_str + - host_str + " order by name") -tests = plpy.execute(quer) - -tests_str = "" -if len(tests) > 0: - tests_str = " and (name = '" - for t in tests: - tests_str += t['name'] + "' or name = '" - tests_str = tests_str[:-12] + ")" - -querx = ("select distinct switches, compiler, optl, precision, host " + - "from tests where " + - "run = " + str(run) + - host_str + prec_str + comp_str + optl_str + tests_str + - " UNION " + - "select distinct switches, compiler, optl, precision, host " + - "from tests where " + - "run = " + str(run) + - host_str + prec_str + comp_str + tests_str + " and switches = ''" + - " and optl = '-O0'" + - " order by compiler, optl, switches") -x_axis = plpy.execute(querx) -xa_count = len(x_axis) - -quer = ("select distinct name from tests where run = " + str(run) + - prec_str + tests_str + comp_str + " order by name") - -y_axis = plpy.execute(quer) -ya_count = len(y_axis) -x_ticks = [] -y_ticks = [] -z_data = [] - -x_count = 0 -y_count = 0 - -for x in x_axis: - x_ticks.append(x['switches'] + ' ' + - x['optl']) - if len(compilers) > 1: - x_ticks[-1] += ' ' + x['compiler'][0] -for t in y_axis: - y_ticks.append(t['name']) - y_count += 1 - quers = ("select distinct score0, switches, compiler, " + - "optl, host from tests where run = " + str(run) + " and name = '" + - t['name'] + "'" + prec_str + comp_str + " and optl = '-O0'" + - host_str + - " and switches = '' UNION select distinct score0, switches, " + - "compiler, optl, host from " + - " tests where run = " + str(run) + - " and name = '" + t['name'] + "'" + prec_str + comp_str + - optl_str + host_str + - " order by compiler, optl, switches") - scores = plpy.execute(quers) - eq_classes = {} - line_classes = [] - color = 0 - for x in scores: - if not x['score0'] in eq_classes: - eq_classes[x['score0']] = color - color += 1 - for x in x_axis: - quer = ("select score0 from tests where name = '" + - t['name'] + "' and precision = '" + x['precision'] + - "' and switches = '" + x['switches'] + - "' and compiler = '" + x['compiler'] + - "' and optl = '" + x['optl'] + "' and run = " + str(run) + - " and host = '" + x['host'] + "'") - score = plpy.execute(quer) - x_count += 1 - try: - line_classes.append(eq_classes[score[0]['score0']]) - except KeyError: - return "key error fetching color: " + quer + " " + quers - z_data.append(line_classes) - -pl.plot(x_ticks, y_ticks, z_data, fname, ', '.join(compilers) + - ' @ precision(s): ' + - ', '.join(prec), labsize) - -return str(len(z_data)) - -$$; - - --- --- Name: createswitchestable(text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION createswitchestable(csv_path text) RETURNS integer - LANGUAGE plpython3u - AS $$ -from plpy import spiexceptions - -count = 0 -with open(csv_path) as csv: - for line in csv: - vals = line.split(',') - name = vals[0] - descr = vals[1] - quer = ("insert into switch_desc (name, descr) values('" + - name + "','" + descr + "')") - plpy.execute(quer) - count += 1 -return count -$$; - - --- --- Name: createtimeplot(integer, text[], text[], text[], text, integer, text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION createtimeplot(run integer, prec text[], compilers text[], optls text[], host text, labsize integer, fname text) RETURNS text - LANGUAGE plpython3u - AS $$ -from plpy import spiexceptions -from sys import path -import matplotlib.pyplot as plt -import matplotlib.cm as cm -import numpy as np -#import plotting as pl - -plt.autoscale(enable=True, axis='both', tight=False) - -host_str = '' -if len(host) > 0: - host_str = " and host = '" + host + "'" - -prec_str = "" -if len(prec) > 0: - prec_str = " and (precision = '" - for t in prec: - prec_str += t + "' or precision = '" - prec_str = prec_str[:-17] + ")" - -optl_str = "" -if len(optls) > 0: - optl_str = " and (optl = '" - for t in optls: - optl_str += t + "' or optl = '" - optl_str = optl_str[:-12] + ")" - -comp_str = "" -if len(compilers) > 0: - comp_str = " and (compiler = '" - for c in compilers: - comp_str += c + "' or compiler = '" - comp_str = comp_str[:-16] + ")" - - -quer = ("select distinct name from tests where " - + "run = " + str(run) + prec_str + optl_str + comp_str + host_str - + " order by name") - -tests = plpy.execute(quer) - - -for t in tests: - quer = ("select nanosec, score0, switches, optl, compiler, precision from tests where " - + "run = " + str(run) + prec_str + optl_str + comp_str + host_str - + " and name = '" + t['name'] + "' order by nanosec") - x_data = plpy.execute(quer) - color = 0 - x_axis = [] - colors = {} - x_labels = [] - values = [] - x_colors = [] - cstrings = ['black', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink', 'red'] - #cmap = cm.get_cmap('Accent') - colors.clear() - for x in x_data: - score = x['score0'] - if not score in colors: - colors[score] = color - color += 1 - x_labels.append(x['compiler'] + '_' + - x['switches'] + '_' + - x['optl']) - x_colors.append(colors[score]) - values.append(x['nanosec']) - fig, ax = plt.subplots() - ax.plot(np.arange(len(x_labels)), values) - ax.set_xticks([i + .5 for i in range(0, len(x_labels))]) - ax.set_xticklabels(x_labels, rotation=270) - #ncolor = np.asarray(x_colors) / np.amax(np.asarray(x_colors)) - for xtick, c in zip(ax.get_xticklabels(), x_colors): - xtick.set_color(cstrings[c]) - ax.tick_params(axis='both', which='major', labelsize=labsize) - ax.tick_params(axis='both', which='minor', labelsize=labsize) - plt.tight_layout() - plt.savefig(fname + '/' + t['name'] + '_' + x['precision'] + - '_time.pdf') - -return str(len(values)) - -$$; - - --- --- Name: dofullflitimport(text, text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION dofullflitimport(path text, label text) RETURNS integer[] - LANGUAGE plpython3u - AS $$ -import datetime - -query = ("INSERT INTO runs (rdate, label) " - "VALUES ('" + str(datetime.datetime.now()) + - "','" + label + "')") -plpy.execute(query) -query = ("SELECT MAX(index) from runs") -res = plpy.execute(query) -run = res[0]['max'] -query = ("SELECT importflitresults2('" + path + "', " + - str(run) + ")") -res = plpy.execute(query) -query = ("SELECT importopcoderesults('" + path + "/pins'," + - str(run) + ")") -res2 = plpy.execute(query) - -return [res[0]['importflitresults2'][0],res[0]['importflitresults2'][1], - res2[0]['importopcoderesults'][0],res2[0]['importopcoderesults'][1]] - -$$; - - --- --- Name: dumpswitcheslatex(text, text[]); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION dumpswitcheslatex(tex_path text, switches text[]) RETURNS integer - LANGUAGE plpython3u - AS $$ -from plpy import spiexceptions - -count = 0 -quer = ("select * from switch_desc") -switchesq = plpy.execute(quer) - -with open(tex_path, 'w+') as tp: - tp.write(' \\begin{tabular}{r|l}\n\tSwitch & Description\\\\ \n\t\\hline\n') - for sw in switchesq: - for s in switches: - if s == sw['name']: - tp.write('\t' + sw['name'] + ' & ' + sw['descr'].strip() + - '\\\\ \n') - count += 1 - break - tp.write('\\end{tabular}\n') -return count -$$; - - --- --- Name: getcurrentuser(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION getcurrentuser() RETURNS text - LANGUAGE plpython3u - AS $$ -from subprocess import check_output -return check_output('/usr/bin/whoami').decode("utf-8") - -$$; - - --- --- Name: getpwd(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION getpwd() RETURNS text - LANGUAGE plpython3u - AS $$ - -import os - -return os.getcwd() - -$$; - - --- --- Name: importopcoderesults(text, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION importopcoderesults(path text, run integer) RETURNS integer[] - LANGUAGE plpython3u - AS $$ -import glob -from plpy import spiexceptions -import os -count = 0 -skipped = 0 -for f in glob.iglob(path + '/*'): - fels = os.path.basename(f).split('_') - if len(fels) != 6: - continue - if fels[0] == 'INTEL': - compiler = 'icpc' - elif fels[0] == 'GCC': - compiler = 'g++' - elif fels[0] == 'CLANG': - compiler = 'clang++' - dynamic = False - host = fels[1] - flags = fels[2] - optl = '-' + fels[3] - precision = fels[4] - name = fels[5] - tq = ("SELECT index from tests where " + - "name = '" + name + "' and " + - "host = '" + host + "' and " + - "precision = '" + precision + "' and " + - "optl = '" + optl + "' and " + - "compiler = '" + compiler + "' and " + - "switches = (select switches from switch_conv where abbrev = '" + flags + "') and " + - "run = " + str(run)) - res = plpy.execute(tq) - if res.nrows() != 1: - dup = res.nrows() > 1 - skq = ("insert into skipped_pin (name, host, precision, optl, " + - "compiler, switches, run, dup)" + - " select '" + name + "','" + host + "','" + precision + "','" + - optl + "','" + compiler + "',switch_conv.switches," + str(run) + - "," + str(dup) + " from switch_conv where abbrev = '" + flags + "'") - plpy.execute(skq) - skipped = skipped + 1 - continue - tindx = res[0]["index"] - with open(f) as inf: - for line in inf: - l = line.split() - if len(line.lstrip()) > 0 and line.lstrip()[0] == '#': - if 'dynamic' in line: - dynamic = True - continue - if len(l) < 4: - continue - opq = ("INSERT INTO opcodes VALUES(" + - str(l[0]) + ", '" + l[1] +"')") - try: - plpy.execute(opq) - except spiexceptions.UniqueViolation: - pass - - cntq = ("INSERT INTO op_counts (test_id, opcode, " + - "count, pred_count, dynamic) "+ - "VALUES(" + str(tindx) + ", " + str(l[0]) + - ", " + str(l[2]) + ", " + str(l[3]) + ", " + str(dynamic) + ")") - plpy.execute(cntq) - count = count + 1 -return [count, skipped] -$$; - - --- --- Name: importflitresults(text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION importflitresults(path text) RETURNS integer - LANGUAGE plpython3u - AS $$ - r = ("SELECT MAX(index)as index from runs;") - res = plpy.execute(r) - run = res[0]["index"] - s = ("COPY tests " + - "(host, switches, optl, compiler, precision, sort, " + - "score0d, score0, score1d, score1, name, file) " + - "FROM '" + - path + - "' (DELIMITER ',')") - plpy.execute(s) - s = ("UPDATE tests SET run = " + str(run) + " WHERE run IS NULL;") - res = plpy.execute(s) - return res.nrows() -$$; - - --- --- Name: importflitresults2(text, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION importflitresults2(path text, run integer) RETURNS integer[] - LANGUAGE plpython3u - AS $$ -import glob -from plpy import spiexceptions -import os -count = 0 -skipped = 0 -for f in glob.iglob(path + '/*_out_'): - with open(f) as inf: - for line in inf: - elms = line.split(',') - host = elms[0].strip() - switches = elms[1].strip() - optl = elms[2].strip() - compiler = elms[3].strip() - prec = elms[4].strip() - sort = elms[5].strip() - score0d = elms[6].strip() - score0 = elms[7].strip() - score1d = elms[8].strip() - score1 = elms[9].strip() - name = elms[10].strip() - nseconds = elms[11].strip() - filen = elms[12].strip() - quer = ("insert into tests " - "(host, switches, optl, compiler, precision, sort, " - "score0d, score0, score1d, score1, name, nanosec, file, run) " - "VALUES ('" + - host + "','" + - switches + "','" + - optl + "','" + - compiler + "','" + - prec + "','" + - sort + "'," + - score0d + ",'" + - score0 + "'," + - score1d + ",'" + - score1 + "','" + - name + "'," + - nseconds + ",'" + - filen + "'," + - str(run) + ")") - try: - plpy.execute(quer) - except (spiexceptions.InvalidTextRepresentation, - spiexceptions.UndefinedColumn, - spiexceptions.NumericValueOutOfRange): - quer = ("insert into tests " - "(host, switches, optl, compiler, precision, sort, " - "score0d, score0, score1d, score1, name, nanosec, file, run) " - "VALUES ('" + - host + "','" + - switches + "','" + - optl + "','" + - compiler + "','" + - prec + "','" + - sort + "'," + - str(0) + ",'" + - score0 + "'," + - str(0) + ",'" + - score1 + "','" + - name + "'," + - nseconds + ",'" + - filen + "'," + - str(run) + ")") - #try: - plpy.execute(quer) - #except: - # skipped = skipped + 1 - # continue - count = count + 1 -return [count, skipped] -$$; - - --- --- Name: importswitches(text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION importswitches(path text) RETURNS integer - LANGUAGE plpython3u - AS $$ -with open(path) as inf: - count = 0 - for line in inf: - spc = line.find(' ') - if spc == -1: - abbrev = line - swts = '' - else: - abbrev = line[0:spc] - swts = line[spc+1:-1] - q = ("INSERT INTO switch_conv VALUES " + - "('" + abbrev + "', '" + swts + "')") - plpy.execute(q) - count = count + 1 -return count -$$; - - -SET default_tablespace = ''; - -SET default_with_oids = false; - --- --- Name: clusters; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE clusters ( - testid integer NOT NULL, - number integer -); - - --- --- Name: op_counts; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE op_counts ( - test_id integer NOT NULL, - opcode integer NOT NULL, - count integer, - pred_count integer, - dynamic boolean NOT NULL -); - - --- --- Name: opcodes; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE opcodes ( - index integer NOT NULL, - name text -); - - --- --- Name: runs; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE runs ( - index integer NOT NULL, - rdate timestamp without time zone, - label text -); - - --- --- Name: run_index_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE run_index_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: run_index_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE run_index_seq OWNED BY runs.index; - - --- --- Name: skipped_pin; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE skipped_pin ( - switches character varying(512), - "precision" character varying(1), - sort character varying(2), - score0 character varying(32), - score0d numeric(1000,180), - host character varying(50), - compiler character varying(50), - name character varying(255), - index integer, - score1 character varying(32), - score1d numeric(1000,180), - run integer, - file character varying(512), - optl character varying(10), - dup boolean -); - - --- --- Name: switch_conv; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE switch_conv ( - abbrev text NOT NULL, - switches text -); - - --- --- Name: switch_desc; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE switch_desc ( - name character varying(100), - descr text -); - - --- --- Name: tests; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE tests ( - switches character varying(512), - "precision" character varying(1), - sort character varying(2), - score0 character varying(32), - score0d numeric(1000,180), - host character varying(50), - compiler character varying(50), - name character varying(255), - index integer NOT NULL, - score1 character varying(32), - score1d numeric(1000,180), - run integer, - file character varying(512), - optl character varying(10), - nanosec numeric(20,0) -); - - --- --- Name: tests_colname_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE tests_colname_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: tests_colname_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE tests_colname_seq OWNED BY tests.index; - - --- --- Name: index; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY runs ALTER COLUMN index SET DEFAULT nextval('run_index_seq'::regclass); - - --- --- Name: index; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY tests ALTER COLUMN index SET DEFAULT nextval('tests_colname_seq'::regclass); - - --- --- Name: clusters_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY clusters - ADD CONSTRAINT clusters_pkey PRIMARY KEY (testid); - - --- --- Name: op_counts_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY op_counts - ADD CONSTRAINT op_counts_pkey PRIMARY KEY (test_id, opcode, dynamic); - - --- --- Name: opcodes_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY opcodes - ADD CONSTRAINT opcodes_pkey PRIMARY KEY (index); - - --- --- Name: runs_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY runs - ADD CONSTRAINT runs_pkey PRIMARY KEY (index); - - --- --- Name: switch_conv_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY switch_conv - ADD CONSTRAINT switch_conv_pkey PRIMARY KEY (abbrev); - - --- --- Name: switchdesc; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY switch_desc - ADD CONSTRAINT switchdesc UNIQUE (name); - - --- --- Name: tests_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY tests - ADD CONSTRAINT tests_pkey PRIMARY KEY (index); - - --- --- Name: op_counts_opcode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY op_counts - ADD CONSTRAINT op_counts_opcode_fkey FOREIGN KEY (opcode) REFERENCES opcodes(index); - - --- --- Name: op_counts_test_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY op_counts - ADD CONSTRAINT op_counts_test_id_fkey FOREIGN KEY (test_id) REFERENCES tests(index); - - --- --- Name: tests_run_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY tests - ADD CONSTRAINT tests_run_fkey FOREIGN KEY (run) REFERENCES runs(index); - - --- --- PostgreSQL database dump complete --- - diff --git a/data/db/InstallFlitDB.sh.in b/data/db/InstallFlitDB.sh.in deleted file mode 100644 index cd544d33..00000000 --- a/data/db/InstallFlitDB.sh.in +++ /dev/null @@ -1,102 +0,0 @@ -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -#This file was auto-generated - -#This is the FLiT DB installer - -for x in $(seq 0 $((${#TAGS[@]}-2))); -do - begin=$(grep --line-number ^${PREFIX}${TAGS[$x]}$ $0 | cut -d ':' -f 1) - end=$(grep --line-number ^${PREFIX}${TAGS[$(($x + 1))]}$ $0 | cut -d ':' -f 1) - sed -n $((begin + 1)),$((end - 1))p $0 > ${TAGS[$x]#${PREFIX}} -done - -tail -n +$((end + 1)) $0 > ${TAGS[$((${#TAGS[@]}-1))]#${PREFIX}} - -EXE=${TAGS[0]#${PREFIX}} - -chmod 775 $EXE - -./$EXE - -exit diff --git a/data/db/README b/data/db/README deleted file mode 100644 index 3e09b056..00000000 --- a/data/db/README +++ /dev/null @@ -1,8 +0,0 @@ -This describes how to create the DB Installer script: -InstallFlitDB.sh. - -The installFlitDB.sh script curently has setup_db_host.sh and -matplotlibrc embedded and is self extracting. - -Run './CreateFlitDBInstaller.sh setup_db_host.sh matplotlibrc' - diff --git a/data/db/dump_flit.sh b/data/db/dump_flit.sh deleted file mode 100755 index ea669455..00000000 --- a/data/db/dump_flit.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -pg_dump --create --schema-only --no-owner --no-privileges --dbname=flit diff --git a/data/db/matplotlibrc b/data/db/matplotlibrc deleted file mode 100644 index f0673d12..00000000 --- a/data/db/matplotlibrc +++ /dev/null @@ -1,510 +0,0 @@ -### MATPLOTLIBRC FORMAT - -# This is a sample matplotlib configuration file - you can find a copy -# of it on your system in -# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it -# there, please note that it will be overwritten in your next install. -# If you want to keep a permanent local copy that will not be -# overwritten, place it in the following location: -# unix/linux: -# $HOME/.config/matplotlib/matplotlibrc or -# $XDG_CONFIG_HOME/matplotlib/matplotlibrc (if $XDG_CONFIG_HOME is set) -# other platforms: -# $HOME/.matplotlib/matplotlibrc -# -# See http://matplotlib.org/users/customizing.html#the-matplotlibrc-file for -# more details on the paths which are checked for the configuration file. -# -# This file is best viewed in a editor which supports python mode -# syntax highlighting. Blank lines, or lines starting with a comment -# symbol, are ignored, as are trailing comments. Other lines must -# have the format -# key : val # optional comment -# -# Colors: for the color values below, you can either use - a -# matplotlib color string, such as r, k, or b - an rgb tuple, such as -# (1.0, 0.5, 0.0) - a hex string, such as ff00ff or #ff00ff - a scalar -# grayscale intensity such as 0.75 - a legal html color name, e.g., red, -# blue, darkslategray - -#### CONFIGURATION BEGINS HERE - -# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo -# CocoaAgg MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG -# Template. -# You can also deploy your own backend outside of matplotlib by -# referring to the module name (which must be in the PYTHONPATH) as -# 'module://my_backend'. -backend : Agg - -# If you are using the Qt4Agg backend, you can choose here -# to use the PyQt4 bindings or the newer PySide bindings to -# the underlying Qt4 toolkit. -#backend.qt4 : PyQt4 # PyQt4 | PySide - -# Note that this can be overridden by the environment variable -# QT_API used by Enthought Tool Suite (ETS); valid values are -# "pyqt" and "pyside". The "pyqt" setting has the side effect of -# forcing the use of Version 2 API for QString and QVariant. - -# The port to use for the web server in the WebAgg backend. -# webagg.port : 8888 - -# If webagg.port is unavailable, a number of other random ports will -# be tried until one that is available is found. -# webagg.port_retries : 50 - -# When True, open the webbrowser to the plot that is shown -# webagg.open_in_browser : True - -# When True, the figures rendered in the nbagg backend are created with -# a transparent background. -# nbagg.transparent : True - -# if you are running pyplot inside a GUI and your backend choice -# conflicts, we will automatically try to find a compatible one for -# you if backend_fallback is True -#backend_fallback: True - -#interactive : False -#toolbar : toolbar2 # None | toolbar2 ("classic" is deprecated) -#timezone : UTC # a pytz timezone string, e.g., US/Central or Europe/Paris - -# Where your matplotlib data lives if you installed to a non-default -# location. This is where the matplotlib fonts, bitmaps, etc reside -#datapath : /home/jdhunter/mpldata - - -### LINES -# See http://matplotlib.org/api/artist_api.html#module-matplotlib.lines for more -# information on line properties. -#lines.linewidth : 1.0 # line width in points -#lines.linestyle : - # solid line -#lines.color : blue # has no affect on plot(); see axes.prop_cycle -#lines.marker : None # the default marker -#lines.markeredgewidth : 0.5 # the line width around the marker symbol -#lines.markersize : 6 # markersize, in points -#lines.dash_joinstyle : miter # miter|round|bevel -#lines.dash_capstyle : butt # butt|round|projecting -#lines.solid_joinstyle : miter # miter|round|bevel -#lines.solid_capstyle : projecting # butt|round|projecting -#lines.antialiased : True # render lines in antialiased (no jaggies) - -#markers.fillstyle: full # full|left|right|bottom|top|none - -### PATCHES -# Patches are graphical objects that fill 2D space, like polygons or -# circles. See -# http://matplotlib.org/api/artist_api.html#module-matplotlib.patches -# information on patch properties -#patch.linewidth : 1.0 # edge width in points -#patch.facecolor : blue -#patch.edgecolor : black -#patch.antialiased : True # render patches in antialiased (no jaggies) - -### FONT -# -# font properties used by text.Text. See -# http://matplotlib.org/api/font_manager_api.html for more -# information on font properties. The 6 font properties used for font -# matching are given below with their default values. -# -# The font.family property has five values: 'serif' (e.g., Times), -# 'sans-serif' (e.g., Helvetica), 'cursive' (e.g., Zapf-Chancery), -# 'fantasy' (e.g., Western), and 'monospace' (e.g., Courier). Each of -# these font families has a default list of font names in decreasing -# order of priority associated with them. When text.usetex is False, -# font.family may also be one or more concrete font names. -# -# The font.style property has three values: normal (or roman), italic -# or oblique. The oblique style will be used for italic, if it is not -# present. -# -# The font.variant property has two values: normal or small-caps. For -# TrueType fonts, which are scalable fonts, small-caps is equivalent -# to using a font size of 'smaller', or about 83% of the current font -# size. -# -# The font.weight property has effectively 13 values: normal, bold, -# bolder, lighter, 100, 200, 300, ..., 900. Normal is the same as -# 400, and bold is 700. bolder and lighter are relative values with -# respect to the current weight. -# -# The font.stretch property has 11 values: ultra-condensed, -# extra-condensed, condensed, semi-condensed, normal, semi-expanded, -# expanded, extra-expanded, ultra-expanded, wider, and narrower. This -# property is not currently implemented. -# -# The font.size property is the default font size for text, given in pts. -# 12pt is the standard value. -# -#font.family : sans-serif -#font.style : normal -#font.variant : normal -#font.weight : medium -#font.stretch : normal -# note that font.size controls default text sizes. To configure -# special text sizes tick labels, axes, labels, title, etc, see the rc -# settings for axes and ticks. Special text sizes can be defined -# relative to font.size, using the following values: xx-small, x-small, -# small, medium, large, x-large, xx-large, larger, or smaller -#font.size : 12.0 -#font.serif : Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif -#font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif -#font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, cursive -#font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, Humor Sans, fantasy -#font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace - -### TEXT -# text properties used by text.Text. See -# http://matplotlib.org/api/artist_api.html#module-matplotlib.text for more -# information on text properties - -#text.color : black - -### LaTeX customizations. See http://wiki.scipy.org/Cookbook/Matplotlib/UsingTex -#text.usetex : False # use latex for all text handling. The following fonts - # are supported through the usual rc parameter settings: - # new century schoolbook, bookman, times, palatino, - # zapf chancery, charter, serif, sans-serif, helvetica, - # avant garde, courier, monospace, computer modern roman, - # computer modern sans serif, computer modern typewriter - # If another font is desired which can loaded using the - # LaTeX \usepackage command, please inquire at the - # matplotlib mailing list -#text.latex.unicode : False # use "ucs" and "inputenc" LaTeX packages for handling - # unicode strings. -#text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES - # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP - # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. - # preamble is a comma separated list of LaTeX statements - # that are included in the LaTeX document preamble. - # An example: - # text.latex.preamble : \usepackage{bm},\usepackage{euler} - # The following packages are always loaded with usetex, so - # beware of package collisions: color, geometry, graphicx, - # type1cm, textcomp. Adobe Postscript (PSSNFS) font packages - # may also be loaded, depending on your font settings - -#text.dvipnghack : None # some versions of dvipng don't handle alpha - # channel properly. Use True to correct - # and flush ~/.matplotlib/tex.cache - # before testing and False to force - # correction off. None will try and - # guess based on your dvipng version - -#text.hinting : auto # May be one of the following: - # 'none': Perform no hinting - # 'auto': Use freetype's autohinter - # 'native': Use the hinting information in the - # font file, if available, and if your - # freetype library supports it - # 'either': Use the native hinting information, - # or the autohinter if none is available. - # For backward compatibility, this value may also be - # True === 'auto' or False === 'none'. -#text.hinting_factor : 8 # Specifies the amount of softness for hinting in the - # horizontal direction. A value of 1 will hint to full - # pixels. A value of 2 will hint to half pixels etc. - -#text.antialiased : True # If True (default), the text will be antialiased. - # This only affects the Agg backend. - -# The following settings allow you to select the fonts in math mode. -# They map from a TeX font name to a fontconfig font pattern. -# These settings are only used if mathtext.fontset is 'custom'. -# Note that this "custom" mode is unsupported and may go away in the -# future. -#mathtext.cal : cursive -#mathtext.rm : serif -#mathtext.tt : monospace -#mathtext.it : serif:italic -#mathtext.bf : serif:bold -#mathtext.sf : sans -#mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix', - # 'stixsans' or 'custom' -#mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern - # fonts when a symbol can not be found in one of - # the custom math fonts. - -#mathtext.default : it # The default font to use for math. - # Can be any of the LaTeX font names, including - # the special name "regular" for the same font - # used in regular text. - -### AXES -# default face and edge color, default tick sizes, -# default fontsizes for ticklabels, and so on. See -# http://matplotlib.org/api/axes_api.html#module-matplotlib.axes -#axes.hold : True # whether to clear the axes by default on -#axes.facecolor : white # axes background color -#axes.edgecolor : black # axes edge color -#axes.linewidth : 1.0 # edge linewidth -#axes.grid : False # display grid or not -#axes.titlesize : large # fontsize of the axes title -#axes.labelsize : medium # fontsize of the x any y labels -#axes.labelpad : 5.0 # space between label and axis -#axes.labelweight : normal # weight of the x and y labels -#axes.labelcolor : black -#axes.axisbelow : False # whether axis gridlines and ticks are below - # the axes elements (lines, text, etc) - -#axes.formatter.limits : -7, 7 # use scientific notation if log10 - # of the axis range is smaller than the - # first or larger than the second -#axes.formatter.use_locale : False # When True, format tick labels - # according to the user's locale. - # For example, use ',' as a decimal - # separator in the fr_FR locale. -#axes.formatter.use_mathtext : False # When True, use mathtext for scientific - # notation. -#axes.formatter.useoffset : True # If True, the tick label formatter - # will default to labeling ticks relative - # to an offset when the data range is very - # small compared to the minimum absolute - # value of the data. - -#axes.unicode_minus : True # use unicode for the minus symbol - # rather than hyphen. See - # http://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes -#axes.prop_cycle : cycler('color', 'bgrcmyk') - # color cycle for plot lines - # as list of string colorspecs: - # single letter, long name, or - # web-style hex -#axes.xmargin : 0 # x margin. See `axes.Axes.margins` -#axes.ymargin : 0 # y margin See `axes.Axes.margins` - -#polaraxes.grid : True # display grid on polar axes -#axes3d.grid : True # display grid on 3d axes - -### TICKS -# see http://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick -#xtick.major.size : 4 # major tick size in points -#xtick.minor.size : 2 # minor tick size in points -#xtick.major.width : 0.5 # major tick width in points -#xtick.minor.width : 0.5 # minor tick width in points -#xtick.major.pad : 4 # distance to major tick label in points -#xtick.minor.pad : 4 # distance to the minor tick label in points -#xtick.color : k # color of the tick labels -#xtick.labelsize : medium # fontsize of the tick labels -#xtick.direction : in # direction: in, out, or inout - -#ytick.major.size : 4 # major tick size in points -#ytick.minor.size : 2 # minor tick size in points -#ytick.major.width : 0.5 # major tick width in points -#ytick.minor.width : 0.5 # minor tick width in points -#ytick.major.pad : 4 # distance to major tick label in points -#ytick.minor.pad : 4 # distance to the minor tick label in points -#ytick.color : k # color of the tick labels -#ytick.labelsize : medium # fontsize of the tick labels -#ytick.direction : in # direction: in, out, or inout - - -### GRIDS -#grid.color : black # grid color -#grid.linestyle : : # dotted -#grid.linewidth : 0.5 # in points -#grid.alpha : 1.0 # transparency, between 0.0 and 1.0 - -### Legend -#legend.fancybox : False # if True, use a rounded box for the - # legend, else a rectangle -#legend.isaxes : True -#legend.numpoints : 2 # the number of points in the legend line -#legend.fontsize : large -#legend.borderpad : 0.5 # border whitespace in fontsize units -#legend.markerscale : 1.0 # the relative size of legend markers vs. original -# the following dimensions are in axes coords -#legend.labelspacing : 0.5 # the vertical space between the legend entries in fraction of fontsize -#legend.handlelength : 2. # the length of the legend lines in fraction of fontsize -#legend.handleheight : 0.7 # the height of the legend handle in fraction of fontsize -#legend.handletextpad : 0.8 # the space between the legend line and legend text in fraction of fontsize -#legend.borderaxespad : 0.5 # the border between the axes and legend edge in fraction of fontsize -#legend.columnspacing : 2. # the border between the axes and legend edge in fraction of fontsize -#legend.shadow : False -#legend.frameon : True # whether or not to draw a frame around legend -#legend.framealpha : None # opacity of of legend frame -#legend.scatterpoints : 3 # number of scatter points - -### FIGURE -# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure -#figure.titlesize : medium # size of the figure title -#figure.titleweight : normal # weight of the figure title -#figure.figsize : 8, 6 # figure size in inches -#figure.dpi : 80 # figure dots per inch -#figure.facecolor : 0.75 # figure facecolor; 0.75 is scalar gray -#figure.edgecolor : white # figure edgecolor -#figure.autolayout : False # When True, automatically adjust subplot - # parameters to make the plot fit the figure -#figure.max_open_warning : 20 # The maximum number of figures to open through - # the pyplot interface before emitting a warning. - # If less than one this feature is disabled. - -# The figure subplot parameters. All dimensions are a fraction of the -# figure width or height -#figure.subplot.left : 0.125 # the left side of the subplots of the figure -#figure.subplot.right : 0.9 # the right side of the subplots of the figure -#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure -#figure.subplot.top : 0.9 # the top of the subplots of the figure -#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots -#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots - -### IMAGES -#image.aspect : equal # equal | auto | a number -#image.interpolation : bilinear # see help(imshow) for options -#image.cmap : jet # gray | jet etc... -#image.lut : 256 # the size of the colormap lookup table -#image.origin : upper # lower | upper -#image.resample : False -#image.composite_image : True # When True, all the images on a set of axes are - # combined into a single composite image before - # saving a figure as a vector graphics file, - # such as a PDF. - -### CONTOUR PLOTS -#contour.negative_linestyle : dashed # dashed | solid -#contour.corner_mask : True # True | False | legacy - -### ERRORBAR PLOTS -#errorbar.capsize : 3 # length of end cap on error bars in pixels - -### Agg rendering -### Warning: experimental, 2008/10/10 -#agg.path.chunksize : 0 # 0 to disable; values in the range - # 10000 to 100000 can improve speed slightly - # and prevent an Agg rendering failure - # when plotting very large data sets, - # especially if they are very gappy. - # It may cause minor artifacts, though. - # A value of 20000 is probably a good - # starting point. -### SAVING FIGURES -#path.simplify : True # When True, simplify paths by removing "invisible" - # points to reduce file size and increase rendering - # speed -#path.simplify_threshold : 0.1 # The threshold of similarity below which - # vertices will be removed in the simplification - # process -#path.snap : True # When True, rectilinear axis-aligned paths will be snapped to - # the nearest pixel when certain criteria are met. When False, - # paths will never be snapped. -#path.sketch : None # May be none, or a 3-tuple of the form (scale, length, - # randomness). - # *scale* is the amplitude of the wiggle - # perpendicular to the line (in pixels). *length* - # is the length of the wiggle along the line (in - # pixels). *randomness* is the factor by which - # the length is randomly scaled. - -# the default savefig params can be different from the display params -# e.g., you may want a higher resolution, or to make the figure -# background white -#savefig.dpi : 100 # figure dots per inch -#savefig.facecolor : white # figure facecolor when saving -#savefig.edgecolor : white # figure edgecolor when saving -#savefig.format : png # png, ps, pdf, svg -#savefig.bbox : standard # 'tight' or 'standard'. - # 'tight' is incompatible with pipe-based animation - # backends but will workd with temporary file based ones: - # e.g. setting animation.writer to ffmpeg will not work, - # use ffmpeg_file instead -#savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight' -#savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter. -#savefig.directory : ~ # default directory in savefig dialog box, - # leave empty to always use current working directory -#savefig.transparent : False # setting that controls whether figures are saved with a - # transparent background by default - -# tk backend params -#tk.window_focus : False # Maintain shell focus for TkAgg - -# ps backend params -#ps.papersize : letter # auto, letter, legal, ledger, A0-A10, B0-B10 -#ps.useafm : False # use of afm fonts, results in small files -#ps.usedistiller : False # can be: None, ghostscript or xpdf - # Experimental: may produce smaller files. - # xpdf intended for production of publication quality files, - # but requires ghostscript, xpdf and ps2eps -#ps.distiller.res : 6000 # dpi -#ps.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) - -# pdf backend params -#pdf.compression : 6 # integer from 0 to 9 - # 0 disables compression (good for debugging) -#pdf.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) - -# svg backend params -#svg.image_inline : True # write raster image data directly into the svg file -#svg.image_noscale : False # suppress scaling of raster data embedded in SVG -#svg.fonttype : 'path' # How to handle SVG fonts: -# 'none': Assume fonts are installed on the machine where the SVG will be viewed. -# 'path': Embed characters as paths -- supported by most SVG renderers -# 'svgfont': Embed characters as SVG fonts -- supported only by Chrome, -# Opera and Safari - -# docstring params -#docstring.hardcopy = False # set this when you want to generate hardcopy docstring - -# Set the verbose flags. This controls how much information -# matplotlib gives you at runtime and where it goes. The verbosity -# levels are: silent, helpful, debug, debug-annoying. Any level is -# inclusive of all the levels below it. If your setting is "debug", -# you'll get all the debug and helpful messages. When submitting -# problems to the mailing-list, please set verbose to "helpful" or "debug" -# and paste the output into your report. -# -# The "fileo" gives the destination for any calls to verbose.report. -# These objects can a filename, or a filehandle like sys.stdout. -# -# You can override the rc default verbosity from the command line by -# giving the flags --verbose-LEVEL where LEVEL is one of the legal -# levels, e.g., --verbose-helpful. -# -# You can access the verbose instance in your code -# from matplotlib import verbose. -#verbose.level : silent # one of silent, helpful, debug, debug-annoying -#verbose.fileo : sys.stdout # a log filename, sys.stdout or sys.stderr - -# Event keys to interact with figures/plots via keyboard. -# Customize these settings according to your needs. -# Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '') - -#keymap.fullscreen : f # toggling -#keymap.home : h, r, home # home or reset mnemonic -#keymap.back : left, c, backspace # forward / backward keys to enable -#keymap.forward : right, v # left handed quick navigation -#keymap.pan : p # pan mnemonic -#keymap.zoom : o # zoom mnemonic -#keymap.save : s # saving current figure -#keymap.quit : ctrl+w, cmd+w # close the current figure -#keymap.grid : g # switching on/off a grid in current axes -#keymap.yscale : l # toggle scaling of y-axes ('log'/'linear') -#keymap.xscale : L, k # toggle scaling of x-axes ('log'/'linear') -#keymap.all_axes : a # enable all axes - -# Control location of examples data files -#examples.directory : '' # directory to look in for custom installation - -###ANIMATION settings -#animation.html : 'none' # How to display the animation as HTML in - # the IPython notebook. 'html5' uses - # HTML5 video tag. -#animation.writer : ffmpeg # MovieWriter 'backend' to use -#animation.codec : mpeg4 # Codec to use for writing movie -#animation.bitrate: -1 # Controls size/quality tradeoff for movie. - # -1 implies let utility auto-determine -#animation.frame_format: 'png' # Controls frame format used by temp files -#animation.ffmpeg_path: 'ffmpeg' # Path to ffmpeg binary. Without full path - # $PATH is searched -#animation.ffmpeg_args: '' # Additional arguments to pass to ffmpeg -#animation.avconv_path: 'avconv' # Path to avconv binary. Without full path - # $PATH is searched -#animation.avconv_args: '' # Additional arguments to pass to avconv -#animation.mencoder_path: 'mencoder' - # Path to mencoder binary. Without full path - # $PATH is searched -#animation.mencoder_args: '' # Additional arguments to pass to mencoder -#animation.convert_path: 'convert' # Path to ImageMagick's convert binary. - # On Windows use the full path since convert - # is also the name of a system tool. diff --git a/data/db/psql_commands/create_cleanupResults b/data/db/psql_commands/create_cleanupResults deleted file mode 100644 index 7e030b4e..00000000 --- a/data/db/psql_commands/create_cleanupResults +++ /dev/null @@ -1,22 +0,0 @@ -Create OR REPLACE FUNCTION cleanupResults(run integer = -1) RETURNS integer[] as $$ -global run -rn = run -if rn == -1: - r = ("SELECT MAX(index)as index from runs;") - res = plpy.execute(r) - rn = res[0]["index"] - -s = ("update tests set compiler = 'icpc' where compiler ~ " + - "'.*icpc.*' and run = " + str(rn)) -res = plpy.execute(s) -s = ("update tests set host = 'kingspeak' where host ~ " + - "'.*kingspeak.*' and run = " + str(rn)) -res2 = plpy.execute(s) -s = ("update tests set switches=trim(switches)") -res3 = plpy.execute(s) -s = ("update tests set compiler=trim(compiler)") -res4 = plpy.execute(s) -s = ("update tests set compiler='clang++' where compiler='clang++-3.6'") -return [res.nrows(), res2.nrows(), res3.nrows(), res4.nrows()] -$$ LANGUAGE plpython3u; - diff --git a/data/db/psql_commands/create_importFLiTResults b/data/db/psql_commands/create_importFLiTResults deleted file mode 100644 index d7f5268a..00000000 --- a/data/db/psql_commands/create_importFLiTResults +++ /dev/null @@ -1,17 +0,0 @@ - -CREATE OR REPLACE FUNCTION importFLiTResults(path text) RETURNS integer as $$ - r = ("SELECT MAX(index)as index from runs;") - res = plpy.execute(r) - run = res[0]["index"] - s = ("COPY tests " + - "(host, switches, optl, compiler, precision, sort, " + - "score0d, score0, score1d, score1, name, file) " + - "FROM '" + - path + - "' (DELIMITER ',')") - plpy.execute(s) - s = ("UPDATE tests SET run = " + str(run) + " WHERE run IS NULL;") - res = plpy.execute(s) - return res.nrows() -$$ LANGUAGE plpython3u; - diff --git a/data/db/psql_commands/create_import_switches.py b/data/db/psql_commands/create_import_switches.py deleted file mode 100644 index 7a61be29..00000000 --- a/data/db/psql_commands/create_import_switches.py +++ /dev/null @@ -1,17 +0,0 @@ -CREATE OR REPLACE FUNCTION importSwitches(path text) RETURNS integer as $$ -with open(path) as inf: - count = 0 - for line in inf: - spc = line.find(' ') - if spc == -1: - abbrev = line - swts = '' - else: - abbrev = line[0:spc] - swts = line[spc+1:-1] - q = ("INSERT INTO switch_conv VALUES " + - "('" + abbrev + "', '" + swts + "')") - plpy.execute(q) - count = count + 1 -return count -$$ LANGUAGE plpython3u; diff --git a/data/db/psql_commands/import_test b/data/db/psql_commands/import_test deleted file mode 100644 index 3aeed06f..00000000 --- a/data/db/psql_commands/import_test +++ /dev/null @@ -1 +0,0 @@ -testhost,-dummy,z++,t,zz,3abd1,3.222,4afc88,7.777,singularity diff --git a/data/db/python/__init__.py b/data/db/python/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/data/db/python/plotting.py b/data/db/python/plotting.py deleted file mode 100644 index 77bfd1bb..00000000 --- a/data/db/python/plotting.py +++ /dev/null @@ -1,128 +0,0 @@ -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -import numpy as np - -# note: the /etc/matplotlibrc (on Ubuntu 16) file has to be configured to use -# the 'Agg' backend (see the file for details). This is so it will work -# in the PostgreSql environment - -def format_coord(x, y): - col = int(x + 0.5) - row = int(y + 0.5) - if col >= 0 and col < numcols and row >= 0 and row < numrows: - z = X[row, col] - return 'x=%1.4f, y=%1.4f, z=%1.4f' % (x, y, z) - else: - return 'x=%1.4f, y=%1.4f' % (x, y) - - -def plot(x_ticks, y_ticks, z_data, file_name, title, labsize): - import matplotlib.pyplot as plt - import matplotlib.cm as cm - #plt.autoscale(enable=True, axis='both', tight=True) - fig, ax = plt.subplots() - #fig.suptitle(title, fontsize=8) - X = np.array(z_data) - - ax.imshow(X, cmap=cm.hot, interpolation='nearest') - - numrows, numcols = X.shape - ax.format_coord = format_coord - - plt.xticks(np.arange(len(x_ticks)), tuple(x_ticks), rotation='vertical') - - plt.yticks(np.arange(len(y_ticks)), tuple(y_ticks), rotation='horizontal') - - ax.tick_params(axis='both', which='major', labelsize=labsize) - ax.tick_params(axis='both', which='minor', labelsize=labsize) - # ax.set_xticklabels(xticklabels, fontsize=6) - # ax.set_xticklabels(xticklabels, fontsize=6) - # ax.set_yticklabels(yticklabels, fontsize=6) - #plt.xticks(np.arange(6), ('a', 'b', 'c', 'd', 'e', 'f')) - - plt.tight_layout() - - plt.savefig(file_name) - #plt.show() - - #pl.plot(x_ticks, y_ticks, z_data, fname) diff --git a/data/db/setup_db_host.sh b/data/db/setup_db_host.sh deleted file mode 100755 index 08661fbc..00000000 --- a/data/db/setup_db_host.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/bash - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -set -x - -exists () -{ - command -v "$1" >/dev/null 2>&1 -} - -python3_has () -{ - python3 -c "import $1" >/dev/null 2>&1 -} - -SCRIPT_DIR="$(pwd)/$(dirname $0)" - -# Check for psql install -if ! exists createdb || ! exists psql; then - # Install if not present - echo "Postgres does not seem to be installed." - echo "Attempting install now." - - # Try different package managers - if exists apt; then - sudo apt install postgresql postgresql-plpython3 - elif exists apt-get; then - sudo apt install postgresql postgresql-plpython3 - elif exists pacman; then - sudo pacman -S postgresql postgresql-lib-python3 - elif exists yum; then - sudo yum install postgresql-server #name-for-plpython3 - elif exists brew; then - brew install postgresql --with-python3 - brew services start postgresql - else - echo "Unable to find a suitable package manager." - echo "Please install Postgres and plpython3" - exit -1 - fi -fi - - -# Check for numpy install -if ! python3_has numpy; then - # Install if not present - echo "Numpy does not seem to be installed for python 3." - echo "Attempting install now." - - Try different package managers - if exists apt; then - sudo apt install python3-numpy - elif exists apt-get; then - sudo apt install python3-numpy - elif exists pacman; then - sudo pacman -S python3-numpy - elif exists yum; then - sudo yum install python3-numpy - elif exists brew; then - brew install numpy -with-ptyhon3 - else - echo "Unable to find a suitable package manager." - echo "Please install numpy for python3" - exit -1 - fi -fi - - -# Check for matplotlib install -if ! python3_has matplotlib; then - # Install if not present - echo "Matplotlib does not seem to be installed for python 3." - echo "Attempting install now." - - Try different package managers - if exists apt; then - sudo apt install python3-matplotlib - elif exists apt-get; then - sudo apt install python3-matplotlib - elif exists pacman; then - sudo pacman -S python3-matplotlib - elif exists yum; then - sudo yum install python3-matplotlib - elif exists brew; then - brew tap homebrew/science - brew install homebrew/science/matplotlib -with-ptyhon3 - else - echo "Unable to find a suitable package manager." - echo "Please install Postgres and plpython3" - exit -1 - fi -fi - -# Check if user exists -# from http://stackoverflow.com/questions/8546759/how-to-check-if-a-postgres-user-exists -if psql -t -c '\du' | cut -d \| -f 1 | grep -qw `whoami`; then - echo "User `whoami` already exists" -else - echo "Creating user `whoami`" - sudo -u postgres createuser --superuser `whoami` -fi - - -createdb flit "The database for collecting all FLiT results" -psql flit < "$SCRIPT_DIR/tables.sql" - -wait - -#add our config to postgres for matplotlib -PGDIR=$(psql flit -t -c 'select getpwd()') -if [ ! -e ${PGDIR}/matplotlibrc ]; then - sudo -u postgres cp ${SCRIPT_DIR}/matplotlibrc ${PGDIR}/matplotlibrc -else - if ! egrep '^backend[[:space:]]*:[[:space:]]*Agg$' ${PGDIR}/matplotlibrc; then - echo "FLiT reporting will fail without the setting 'backend : Agg' in ${PGDIR}/matplotlibrc. Please set before using FLiT" - fi -fi - -#now we need to add the user and postres to the flit group - -sudo addgroup flit -sudo usermod -aG flit sawaya -sudo usermod -aG flit postgres -sudo service postgresql restart diff --git a/data/db/tables-psql.sql b/data/db/tables-psql.sql deleted file mode 100644 index c47ca15d..00000000 --- a/data/db/tables-psql.sql +++ /dev/null @@ -1,974 +0,0 @@ --- -- LICENSE BEGIN -- --- --- Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. --- --- Produced at the Lawrence Livermore National Laboratory --- --- Written by --- Michael Bentley (mikebentley15@gmail.com), --- Geof Sawaya (fredricflinstone@gmail.com), --- and Ian Briggs (ian.briggs@utah.edu) --- under the direction of --- Ganesh Gopalakrishnan --- and Dong H. Ahn. --- --- LLNL-CODE-743137 --- --- All rights reserved. --- --- This file is part of FLiT. For details, see --- https://pruners.github.io/flit --- Please also read --- https://github.com/PRUNERS/FLiT/blob/master/LICENSE --- --- Redistribution and use in source and binary forms, with or --- without modification, are permitted provided that the following --- conditions are met: --- --- - Redistributions of source code must retain the above copyright --- notice, this list of conditions and the disclaimer below. --- --- - Redistributions in binary form must reproduce the above --- copyright notice, this list of conditions and the disclaimer --- (as noted below) in the documentation and/or other materials --- provided with the distribution. --- --- - Neither the name of the LLNS/LLNL nor the names of its --- contributors may be used to endorse or promote products derived --- from this software without specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND --- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, --- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF --- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL --- SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. --- --- Additional BSD Notice --- --- 1. This notice is required to be provided under our contract --- with the U.S. Department of Energy (DOE). This work was --- produced at Lawrence Livermore National Laboratory under --- Contract No. DE-AC52-07NA27344 with the DOE. --- --- 2. Neither the United States Government nor Lawrence Livermore --- National Security, LLC nor any of their employees, makes any --- warranty, express or implied, or assumes any liability or --- responsibility for the accuracy, completeness, or usefulness of --- any information, apparatus, product, or process disclosed, or --- represents that its use would not infringe privately-owned --- rights. --- --- 3. Also, reference herein to any specific commercial products, --- process, or services by trade name, trademark, manufacturer or --- otherwise does not necessarily constitute or imply its --- endorsement, recommendation, or favoring by the United States --- Government or Lawrence Livermore National Security, LLC. The --- views and opinions of authors expressed herein do not --- necessarily state or reflect those of the United States --- Government or Lawrence Livermore National Security, LLC, and --- shall not be used for advertising or product endorsement --- purposes. --- --- -- LICENSE END -- - - - - --- --- PostgreSQL database dump --- - --- Dumped from database version 9.5.6 --- Dumped by pg_dump version 9.5.6 - -SET statement_timeout = 0; -SET lock_timeout = 0; -SET client_encoding = 'SQL_ASCII'; -SET standard_conforming_strings = on; -SET check_function_bodies = false; -SET client_min_messages = warning; -SET row_security = off; - --- --- Name: flit; Type: DATABASE; Schema: -; Owner: - --- - -CREATE DATABASE flit WITH TEMPLATE = template0 ENCODING = 'SQL_ASCII' LC_COLLATE = 'C' LC_CTYPE = 'C'; - - -\connect flit - -SET statement_timeout = 0; -SET lock_timeout = 0; -SET client_encoding = 'SQL_ASCII'; -SET standard_conforming_strings = on; -SET check_function_bodies = false; -SET client_min_messages = warning; -SET row_security = off; - --- --- Name: flit; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON DATABASE flit IS 'The database for collecting all FLiT results'; - - --- --- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; - - --- --- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; - - --- --- Name: plpython3u; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: - --- - -CREATE OR REPLACE PROCEDURAL LANGUAGE plpython3u; - - -SET search_path = public, pg_catalog; - --- --- Name: breakdowntest(text, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION breakdowntest(name text, run integer) RETURNS integer - LANGUAGE plpython3u - AS $$ - - quer = ("select distinct trunc(score0d, 15) as score, precision, " + - "compiler, optl, array(select distinct switches from tests " + - "where name = t1.name and score0 = t1.score0 and precision " + - "= t1.precision and compiler = t1.compiler and run = t1.run " + - "and optl = t1.optl) from tests as t1 where name = '" + - name + "' and run = " + str(run) + " order by score, compiler") - res = plpy.execute(quer) - return res.nrows() -$$; - - --- --- Name: cleanupresults(integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION cleanupresults(run integer DEFAULT '-1'::integer) RETURNS integer[] - LANGUAGE plpython3u - AS $$ -global run -rn = run -if rn == -1: - r = ("SELECT MAX(index)as index from runs;") - res = plpy.execute(r) - rn = res[0]["index"] - -s = ("update tests set compiler = 'icpc' where compiler ~ " + - "'.*icpc.*' and run = " + str(rn)) -res = plpy.execute(s) -s = ("update tests set host = 'kingspeak' where host ~ " + - "'.*kingspeak.*' and run = " + str(rn)) -res2 = plpy.execute(s) -s = ("update tests set switches=trim(switches)") -res3 = plpy.execute(s) -s = ("update tests set compiler=trim(compiler)") -res4 = plpy.execute(s) -s = ("update tests set compiler='clang++' where compiler='clang++-3.6'") -return [res.nrows(), res2.nrows(), res3.nrows(), res4.nrows()] -$$; - - --- --- Name: createschmoo(integer, text[], text[], text[], text, integer, text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION createschmoo(run integer, prec text[], compilers text[], optls text[], host text, labsize integer, fname text) RETURNS text - LANGUAGE plpython3u - AS $$ -from plpy import spiexceptions -from sys import path -from os import environ -path.append('/tmp/flitDbDir/python') -import plotting as pl - -host_str = '' -if len(host) > 0: - host_str = " and host = '" + host + "'" - -prec_str = "" -if len(prec) > 0: - prec_str = " and (precision = '" - for t in prec: - prec_str += t + "' or precision = '" - prec_str = prec_str[:-17] + ")" - -optl_str = "" -if len(optls) > 0: - optl_str = " and (optl = '" - for t in optls: - optl_str += t + "' or optl = '" - optl_str = optl_str[:-12] + ")" - -comp_str = "" -if len(compilers) > 0: - comp_str = " and (compiler = '" - for c in compilers: - comp_str += c + "' or compiler = '" - comp_str = comp_str[:-16] + ")" - -quer = ("select distinct name from tests as t1 where exists " + - "(select 1 from tests where t1.name = name and t1.precision " + - "= precision and t1.score0 != score0 and t1.run = run " + - "and t1.compiler = compiler and t1.optl = optl and t1.host = host) " + - "and run = " + str(run) + prec_str + optl_str + comp_str + - host_str + " order by name") -tests = plpy.execute(quer) - -tests_str = "" -if len(tests) > 0: - tests_str = " and (name = '" - for t in tests: - tests_str += t['name'] + "' or name = '" - tests_str = tests_str[:-12] + ")" - -querx = ("select distinct switches, compiler, optl, precision, host " + - "from tests where " + - "run = " + str(run) + - host_str + prec_str + comp_str + optl_str + tests_str + - " UNION " + - "select distinct switches, compiler, optl, precision, host " + - "from tests where " + - "run = " + str(run) + - host_str + prec_str + comp_str + tests_str + " and switches = ''" + - " and optl = '-O0'" + - " order by compiler, optl, switches") -x_axis = plpy.execute(querx) -xa_count = len(x_axis) - -quer = ("select distinct name from tests where run = " + str(run) + - prec_str + tests_str + comp_str + " order by name") - -y_axis = plpy.execute(quer) -ya_count = len(y_axis) -x_ticks = [] -y_ticks = [] -z_data = [] - -x_count = 0 -y_count = 0 - -for x in x_axis: - x_ticks.append(x['switches'] + ' ' + - x['optl']) - if len(compilers) > 1: - x_ticks[-1] += ' ' + x['compiler'][0] -for t in y_axis: - y_ticks.append(t['name']) - y_count += 1 - quers = ("select distinct score0, switches, compiler, " + - "optl, host from tests where run = " + str(run) + " and name = '" + - t['name'] + "'" + prec_str + comp_str + " and optl = '-O0'" + - host_str + - " and switches = '' UNION select distinct score0, switches, " + - "compiler, optl, host from " + - " tests where run = " + str(run) + - " and name = '" + t['name'] + "'" + prec_str + comp_str + - optl_str + host_str + - " order by compiler, optl, switches") - scores = plpy.execute(quers) - eq_classes = {} - line_classes = [] - color = 0 - for x in scores: - if not x['score0'] in eq_classes: - eq_classes[x['score0']] = color - color += 1 - for x in x_axis: - quer = ("select score0 from tests where name = '" + - t['name'] + "' and precision = '" + x['precision'] + - "' and switches = '" + x['switches'] + - "' and compiler = '" + x['compiler'] + - "' and optl = '" + x['optl'] + "' and run = " + str(run) + - " and host = '" + x['host'] + "'") - score = plpy.execute(quer) - x_count += 1 - try: - line_classes.append(eq_classes[score[0]['score0']]) - except KeyError: - return "key error fetching color: " + quer + " " + quers - z_data.append(line_classes) - -pl.plot(x_ticks, y_ticks, z_data, fname, ', '.join(compilers) + - ' @ precision(s): ' + - ', '.join(prec), labsize) - -return str(len(z_data)) - -$$; - - --- --- Name: createswitchestable(text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION createswitchestable(csv_path text) RETURNS integer - LANGUAGE plpython3u - AS $$ -from plpy import spiexceptions - -count = 0 -with open(csv_path) as csv: - for line in csv: - vals = line.split(',') - name = vals[0] - descr = vals[1] - quer = ("insert into switch_desc (name, descr) values('" + - name + "','" + descr + "')") - plpy.execute(quer) - count += 1 -return count -$$; - - --- --- Name: createtimeplot(integer, text[], text[], text[], text, integer, text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION createtimeplot(run integer, prec text[], compilers text[], optls text[], host text, labsize integer, fname text) RETURNS text - LANGUAGE plpython3u - AS $$ -from plpy import spiexceptions -from sys import path -import matplotlib.pyplot as plt -import matplotlib.cm as cm -import numpy as np -#import plotting as pl - -plt.autoscale(enable=True, axis='both', tight=False) - -host_str = '' -if len(host) > 0: - host_str = " and host = '" + host + "'" - -prec_str = "" -if len(prec) > 0: - prec_str = " and (precision = '" - for t in prec: - prec_str += t + "' or precision = '" - prec_str = prec_str[:-17] + ")" - -optl_str = "" -if len(optls) > 0: - optl_str = " and (optl = '" - for t in optls: - optl_str += t + "' or optl = '" - optl_str = optl_str[:-12] + ")" - -comp_str = "" -if len(compilers) > 0: - comp_str = " and (compiler = '" - for c in compilers: - comp_str += c + "' or compiler = '" - comp_str = comp_str[:-16] + ")" - - -quer = ("select distinct name from tests where " - + "run = " + str(run) + prec_str + optl_str + comp_str + host_str - + " order by name") - -tests = plpy.execute(quer) - - -for t in tests: - quer = ("select nanosec, score0, switches, optl, compiler, precision from tests where " - + "run = " + str(run) + prec_str + optl_str + comp_str + host_str - + " and name = '" + t['name'] + "' order by nanosec") - x_data = plpy.execute(quer) - color = 0 - x_axis = [] - colors = {} - x_labels = [] - values = [] - x_colors = [] - cstrings = ['black', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink', 'red'] - #cmap = cm.get_cmap('Accent') - colors.clear() - for x in x_data: - score = x['score0'] - if not score in colors: - colors[score] = color - color += 1 - x_labels.append(x['compiler'] + '_' + - x['switches'] + '_' + - x['optl']) - x_colors.append(colors[score]) - values.append(x['nanosec']) - fig, ax = plt.subplots() - ax.plot(np.arange(len(x_labels)), values) - ax.set_xticks([i + .5 for i in range(0, len(x_labels))]) - ax.set_xticklabels(x_labels, rotation=270) - #ncolor = np.asarray(x_colors) / np.amax(np.asarray(x_colors)) - for xtick, c in zip(ax.get_xticklabels(), x_colors): - xtick.set_color(cstrings[c]) - ax.tick_params(axis='both', which='major', labelsize=labsize) - ax.tick_params(axis='both', which='minor', labelsize=labsize) - plt.tight_layout() - plt.savefig(fname + '/' + t['name'] + '_' + x['precision'] + - '_time.pdf') - -return str(len(values)) - -$$; - - --- --- Name: dofullflitimport(text, text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION dofullflitimport(path text, label text) RETURNS integer[] - LANGUAGE plpython3u - AS $$ -import datetime - -query = ("INSERT INTO runs (rdate, label) " - "VALUES ('" + str(datetime.datetime.now()) + - "','" + label + "')") -plpy.execute(query) -query = ("SELECT MAX(index) from runs") -res = plpy.execute(query) -run = res[0]['max'] -query = ("SELECT importflitresults2('" + path + "', " + - str(run) + ")") -res = plpy.execute(query) -query = ("SELECT importopcoderesults('" + path + "/pins'," + - str(run) + ")") -res2 = plpy.execute(query) - -return [res[0]['importflitresults2'][0],res[0]['importflitresults2'][1], - res2[0]['importopcoderesults'][0],res2[0]['importopcoderesults'][1]] - -$$; - - --- --- Name: dumpswitcheslatex(text, text[]); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION dumpswitcheslatex(tex_path text, switches text[]) RETURNS integer - LANGUAGE plpython3u - AS $$ -from plpy import spiexceptions - -count = 0 -quer = ("select * from switch_desc") -switchesq = plpy.execute(quer) - -with open(tex_path, 'w+') as tp: - tp.write(' \\begin{tabular}{r|l}\n\tSwitch & Description\\\\ \n\t\\hline\n') - for sw in switchesq: - for s in switches: - if s == sw['name']: - tp.write('\t' + sw['name'] + ' & ' + sw['descr'].strip() + - '\\\\ \n') - count += 1 - break - tp.write('\\end{tabular}\n') -return count -$$; - - --- --- Name: getcurrentuser(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION getcurrentuser() RETURNS text - LANGUAGE plpython3u - AS $$ -from subprocess import check_output -return check_output('/usr/bin/whoami').decode("utf-8") - -$$; - - --- --- Name: getpwd(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION getpwd() RETURNS text - LANGUAGE plpython3u - AS $$ - -import os - -return os.getcwd() - -$$; - - --- --- Name: importopcoderesults(text, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION importopcoderesults(path text, run integer) RETURNS integer[] - LANGUAGE plpython3u - AS $$ -import glob -from plpy import spiexceptions -import os -count = 0 -skipped = 0 -for f in glob.iglob(path + '/*'): - fels = os.path.basename(f).split('_') - if len(fels) != 6: - continue - if fels[0] == 'INTEL': - compiler = 'icpc' - elif fels[0] == 'GCC': - compiler = 'g++' - elif fels[0] == 'CLANG': - compiler = 'clang++' - dynamic = False - host = fels[1] - flags = fels[2] - optl = '-' + fels[3] - precision = fels[4] - name = fels[5] - tq = ("SELECT index from tests where " + - "name = '" + name + "' and " + - "host = '" + host + "' and " + - "precision = '" + precision + "' and " + - "optl = '" + optl + "' and " + - "compiler = '" + compiler + "' and " + - "switches = (select switches from switch_conv where abbrev = '" + flags + "') and " + - "run = " + str(run)) - res = plpy.execute(tq) - if res.nrows() != 1: - dup = res.nrows() > 1 - skq = ("insert into skipped_pin (name, host, precision, optl, " + - "compiler, switches, run, dup)" + - " select '" + name + "','" + host + "','" + precision + "','" + - optl + "','" + compiler + "',switch_conv.switches," + str(run) + - "," + str(dup) + " from switch_conv where abbrev = '" + flags + "'") - plpy.execute(skq) - skipped = skipped + 1 - continue - tindx = res[0]["index"] - with open(f) as inf: - for line in inf: - l = line.split() - if len(line.lstrip()) > 0 and line.lstrip()[0] == '#': - if 'dynamic' in line: - dynamic = True - continue - if len(l) < 4: - continue - opq = ("INSERT INTO opcodes VALUES(" + - str(l[0]) + ", '" + l[1] +"')") - try: - plpy.execute(opq) - except spiexceptions.UniqueViolation: - pass - - cntq = ("INSERT INTO op_counts (test_id, opcode, " + - "count, pred_count, dynamic) "+ - "VALUES(" + str(tindx) + ", " + str(l[0]) + - ", " + str(l[2]) + ", " + str(l[3]) + ", " + str(dynamic) + ")") - plpy.execute(cntq) - count = count + 1 -return [count, skipped] -$$; - - --- --- Name: importflitresults(text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION importflitresults(path text) RETURNS integer - LANGUAGE plpython3u - AS $$ - r = ("SELECT MAX(index)as index from runs;") - res = plpy.execute(r) - run = res[0]["index"] - s = ("COPY tests " + - "(host, switches, optl, compiler, precision, sort, " + - "score0d, score0, score1d, score1, name, file) " + - "FROM '" + - path + - "' (DELIMITER ',')") - plpy.execute(s) - s = ("UPDATE tests SET run = " + str(run) + " WHERE run IS NULL;") - res = plpy.execute(s) - return res.nrows() -$$; - - --- --- Name: importflitresults2(text, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION importflitresults2(path text, run integer) RETURNS integer[] - LANGUAGE plpython3u - AS $$ -import glob -from plpy import spiexceptions -import os -count = 0 -skipped = 0 -for f in glob.iglob(path + '/*_out_'): - with open(f) as inf: - for line in inf: - elms = line.split(',') - host = elms[0].strip() - switches = elms[1].strip() - optl = elms[2].strip() - compiler = elms[3].strip() - prec = elms[4].strip() - sort = elms[5].strip() - score0d = elms[6].strip() - score0 = elms[7].strip() - score1d = elms[8].strip() - score1 = elms[9].strip() - name = elms[10].strip() - nseconds = elms[11].strip() - filen = elms[12].strip() - quer = ("insert into tests " - "(host, switches, optl, compiler, precision, sort, " - "score0d, score0, score1d, score1, name, nanosec, file, run) " - "VALUES ('" + - host + "','" + - switches + "','" + - optl + "','" + - compiler + "','" + - prec + "','" + - sort + "'," + - score0d + ",'" + - score0 + "'," + - score1d + ",'" + - score1 + "','" + - name + "'," + - nseconds + ",'" + - filen + "'," + - str(run) + ")") - try: - plpy.execute(quer) - except (spiexceptions.InvalidTextRepresentation, - spiexceptions.UndefinedColumn, - spiexceptions.NumericValueOutOfRange): - quer = ("insert into tests " - "(host, switches, optl, compiler, precision, sort, " - "score0d, score0, score1d, score1, name, nanosec, file, run) " - "VALUES ('" + - host + "','" + - switches + "','" + - optl + "','" + - compiler + "','" + - prec + "','" + - sort + "'," + - str(0) + ",'" + - score0 + "'," + - str(0) + ",'" + - score1 + "','" + - name + "'," + - nseconds + ",'" + - filen + "'," + - str(run) + ")") - #try: - plpy.execute(quer) - #except: - # skipped = skipped + 1 - # continue - count = count + 1 -return [count, skipped] -$$; - - --- --- Name: importswitches(text); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION importswitches(path text) RETURNS integer - LANGUAGE plpython3u - AS $$ -with open(path) as inf: - count = 0 - for line in inf: - spc = line.find(' ') - if spc == -1: - abbrev = line - swts = '' - else: - abbrev = line[0:spc] - swts = line[spc+1:-1] - q = ("INSERT INTO switch_conv VALUES " + - "('" + abbrev + "', '" + swts + "')") - plpy.execute(q) - count = count + 1 -return count -$$; - - -SET default_tablespace = ''; - -SET default_with_oids = false; - --- --- Name: clusters; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE clusters ( - testid integer NOT NULL, - number integer -); - - --- --- Name: op_counts; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE op_counts ( - test_id integer NOT NULL, - opcode integer NOT NULL, - count integer, - pred_count integer, - dynamic boolean NOT NULL -); - - --- --- Name: opcodes; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE opcodes ( - index integer NOT NULL, - name text -); - - --- --- Name: runs; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE runs ( - index integer NOT NULL, - rdate timestamp without time zone, - label text -); - - --- --- Name: run_index_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE run_index_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: run_index_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE run_index_seq OWNED BY runs.index; - - --- --- Name: skipped_pin; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE skipped_pin ( - switches character varying(512), - "precision" character varying(1), - sort character varying(2), - score0 character varying(32), - score0d numeric(1000,180), - host character varying(50), - compiler character varying(50), - name character varying(255), - index integer, - score1 character varying(32), - score1d numeric(1000,180), - run integer, - file character varying(512), - optl character varying(10), - dup boolean -); - - --- --- Name: switch_conv; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE switch_conv ( - abbrev text NOT NULL, - switches text -); - - --- --- Name: switch_desc; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE switch_desc ( - name character varying(100), - descr text -); - - --- --- Name: tests; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE tests ( - switches character varying(512), - "precision" character varying(1), - sort character varying(2), - score0 character varying(32), - score0d numeric(1000,180), - host character varying(50), - compiler character varying(50), - name character varying(255), - index integer NOT NULL, - score1 character varying(32), - score1d numeric(1000,180), - run integer, - file character varying(512), - optl character varying(10), - nanosec numeric(20,0) -); - - --- --- Name: tests_colname_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE tests_colname_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: tests_colname_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE tests_colname_seq OWNED BY tests.index; - - --- --- Name: index; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY runs ALTER COLUMN index SET DEFAULT nextval('run_index_seq'::regclass); - - --- --- Name: index; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY tests ALTER COLUMN index SET DEFAULT nextval('tests_colname_seq'::regclass); - - --- --- Name: clusters_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY clusters - ADD CONSTRAINT clusters_pkey PRIMARY KEY (testid); - - --- --- Name: op_counts_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY op_counts - ADD CONSTRAINT op_counts_pkey PRIMARY KEY (test_id, opcode, dynamic); - - --- --- Name: opcodes_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY opcodes - ADD CONSTRAINT opcodes_pkey PRIMARY KEY (index); - - --- --- Name: runs_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY runs - ADD CONSTRAINT runs_pkey PRIMARY KEY (index); - - --- --- Name: switch_conv_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY switch_conv - ADD CONSTRAINT switch_conv_pkey PRIMARY KEY (abbrev); - - --- --- Name: switchdesc; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY switch_desc - ADD CONSTRAINT switchdesc UNIQUE (name); - - --- --- Name: tests_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY tests - ADD CONSTRAINT tests_pkey PRIMARY KEY (index); - - --- --- Name: op_counts_opcode_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY op_counts - ADD CONSTRAINT op_counts_opcode_fkey FOREIGN KEY (opcode) REFERENCES opcodes(index); - - --- --- Name: op_counts_test_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY op_counts - ADD CONSTRAINT op_counts_test_id_fkey FOREIGN KEY (test_id) REFERENCES tests(index); - - --- --- Name: tests_run_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY tests - ADD CONSTRAINT tests_run_fkey FOREIGN KEY (run) REFERENCES runs(index); - - --- --- PostgreSQL database dump complete --- - diff --git a/data/db/tables-sqlite.sql b/data/db/tables-sqlite.sql index d7b56df6..5401eb36 100644 --- a/data/db/tables-sqlite.sql +++ b/data/db/tables-sqlite.sql @@ -126,8 +126,8 @@ CREATE TABLE IF NOT EXISTS tests ( optl varchar, -- optimization level (e.g. "-O2") switches varchar, -- compiler flag(s) (e.g. "-ffast-math") precision varchar, -- precision (f = float, d = double, e = extended) - comparison varchar, -- metric of comparison - hex value - comparison_d real, -- metric of comparison of result vs ground truth + comparison_hex varchar, -- metric of comparison - hex value + comparison real, -- metric of comparison of result vs ground truth file varchar, -- filename of test executable nanosec integer check(nanosec >= 0), -- timing for the function diff --git a/data/tests/Empty.cpp b/data/tests/Empty.cpp index 3b8da6bb..8b0689bb 100644 --- a/data/tests/Empty.cpp +++ b/data/tests/Empty.cpp @@ -83,18 +83,6 @@ #include -template -GLOBAL -void Empty_kernel(const T* tiList, size_t n, double* results) { -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - const T* ti = tiList + (idx*n); - results[idx] = ti[0]; -} - /** An example test class to show how to make FLiT tests * * You will want to rename this file and rename the class. Then implement @@ -106,7 +94,7 @@ class Empty : public flit::TestBase { Empty(std::string id) : flit::TestBase(std::move(id)) {} /** Specify how many floating-point inputs your algorithm takes. - * + * * Can be zero. If it is zero, then getDefaultInput should return an empty * std::vector, which is as simple as "return {};" */ @@ -139,9 +127,6 @@ class Empty : public flit::TestBase { * Which one is used depends on the type of Variant that is returned from the * run_impl function. The value returned by compare will be the value stored * in the database for later analysis. - * - * Note: when using the CUDA kernel functionality, only long double return - * values are valid for now. */ virtual long double compare(long double ground_truth, long double test_results) const override { @@ -158,20 +143,6 @@ class Empty : public flit::TestBase { } protected: - /** Return a kernel pointer to the CUDA kernel equivalent of run_impl - * - * The default base implementation of this function is simply to return - * null_ptr, which will cause it to call run_impl even when compiled under - * CUDA. - * - * If you do not have or do not want to have a CUDA version of your code, - * then you can delete this virtual function and use the base implementation. - * - * See the documentation above Empty_kernel() for details about what the - * kernel is expected to have. - */ - virtual flit::KernelFunction* getKernel() override { return Empty_kernel; } - /** Call or implement the algorithm here. * * You return a flit::Variant which can represent one of a number of diff --git a/documentation/README.md b/documentation/README.md index b35124e9..0daf08a5 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -6,12 +6,17 @@ * [Litmus Tests](litmus-tests.md) * [FLiT Command-Line](flit-command-line.md) * [FLiT Configuration File](flit-configuration-file.md) - * [Available Compiler Flags](available-compiler-flags.md) + * [Available Compiler Flags](available-compiler-flags.md) * [Writing Test Cases](writing-test-cases.md) + * [MPI Support](mpi-support.md) + * [CUDA Support](cuda-support.md) + * [Run Wrapper and HPC Support](run-wrapper-and-hpc-support.md) +* [Compiling Your Tests](compiling-your-tests.md) * [Test Executable](test-executable.md) +* [Benchmarks](benchmarks.md) * [Database Structure](database-structure.md) * [Analyze Results](analyze-results.md) -* **Extra Tools** - * [Autogenerated Tests](autogenerated-tests.md) - * [Test Input Generator](test-input-generator.md) +* Extra Tools + * [Autogenerated Tests](autogenerated-tests.md) + * [Test Input Generator](test-input-generator.md) diff --git a/documentation/benchmarks.md b/documentation/benchmarks.md new file mode 100644 index 00000000..1a909f25 --- /dev/null +++ b/documentation/benchmarks.md @@ -0,0 +1,33 @@ +# Test Executable + +[Prev](test-executable.md) +| +[Table of Contents](README.md) +| +[Next](database-structure.md) + +These benchmarks give insights into the usefulness of FLiT. Each benchmark has +its own goals, either to demonstrate how FLiT can be useful, or to give +insights into specific tools and functionalities. + +The benchmarks are found in the top-level directory `benchmarks`. + +These benchmarks are also part of the installation, and can be copied from +there to exercise FLiT's capabilities. They are installed in + +`$(PREFIX)/share/flit/benchmarks` + +Here is a brief summary of each benchmark: + +* **Random Benchmark**: A benchmark to test the standard library functionality + with random number generation. + +Please look at the code and comments within each benchmark directory for more +information. + +[Prev](test-executable.md) +| +[Table of Contents](README.md) +| +[Next](database-structure.md) + diff --git a/documentation/compiling-your-tests.md b/documentation/compiling-your-tests.md new file mode 100644 index 00000000..7f1b3e51 --- /dev/null +++ b/documentation/compiling-your-tests.md @@ -0,0 +1,264 @@ +# Compiling Your Tests + +[Prev](run-wrapper-and-hpc-support.md) +| +[Table of Contents](README.md) +| +[Next](test-executable.md) + + +Probably the hardest aspect of integrating any testing framework into your +project is getting the tests to compile against the rest of your code base. +This is especially true for FLiT. Since much of the FLiT framework is built +into the auto-generated `Makefile`, it is important for you to give this +auto-generated `Makefile` enough information to compile your source code. + +This has been done and tested with two separate open-source projects, and here +I give the details of these two examples, hopefully to give you insight into +how to accomplish this for your own project. + +## Explaining the `custom.mk` File + +The `custom.mk` file is included by the generated `Makefile`. It gives you a +portal to modify some of the `Makefile` behaviors. It is a bad idea to modify +the generated `Makefile` because it may get regenerated and overwrite your +changes. Instead put changes in this `custom.mk` file. + +The `custom.mk` file is already populated with variables that you may want to +use. Simply add to these variables to compile your application. + +- `SOURCE`: This variable contains source code to compile other than the tests + that are in the `tests` directory. +- `CC_REQUIRED`: Compiler flags to use across the board, for the dev build, + ground-truth build, and all other builds. Here is where you set macro + variables, include paths, and perhaps warning flags. +- `LD_REQUIRED`: Linker flags to use across the board, for the dev build, + ground-truth build, and all other builds. Here is where you include library + paths (with `-L`), link in libraries (with `-l`), and maybe even some rpath + magic (with `-Wl,-rpath=`). +- `DEV_CFLAGS`: Extra compiler flags specifically for the dev build. This will + be added to the `CC_REQUIRED` when compiling the dev target. +- `DEV_LDFLAGS`: Extra linker flags specifically for the dev build. This will + be added to the `LD_REQUIRED` when compiling the dev target. +- `RUN_WRAPPER`: a program to wrap all invocations of test executable runs. + This gives the user the opportunity to control test executions if desired. + + +## MFEM Example + +[MFEM](http://mfem.org) is a modular parallel C++ library for finite element +methods. The source code can be found on +[Github](https://github.com/mfem/mfem.git). Here, I will go through my fork of +the MFEM code base where I implemented FLiT tests. This forked project can be +pulled with + +```bash +git clone --branch flit-examples https://github.com/mikebentley15/mfem.git +``` + +The tests are then located in `mfem/examples/flit-tests`. The tests are +actually the examples found in `mfem/examples`, and taking their `main()` +function and modifying it to become a FLiT test case. Not all of the examples +could be converted in this way. Examples 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, +15, 16, and 17 were able to be converted while examples 11, 12, and 13 were +not. + +This project was easier to compile than I though it would be. A `custom.mk` +file that would work to compile this would be: + +```make +SOURCE += $(wildcard ../../fem/*.cpp) +SOURCE += $(wildcard ../../general/*.cpp) +SOURCE += $(wildcard ../../linalg/*.cpp) +SOURCE += $(wildcard ../../mesh/*.cpp) + +CC_REQUIRED += -I../.. +``` + +It turns out that not all of those source files were required for the given +examples, meaning we will be compiling more than is necessary. Using trial and +error, I determined exactly which files need to be included to successfully +compile and no less: + +```make +SOURCE += ../../fem/bilinearform.cpp +SOURCE += ../../fem/bilininteg.cpp +SOURCE += ../../fem/coefficient.cpp +SOURCE += ../../fem/datacollection.cpp +SOURCE += ../../fem/eltrans.cpp +SOURCE += ../../fem/estimators.cpp +SOURCE += ../../fem/fe.cpp +SOURCE += ../../fem/fe_coll.cpp +SOURCE += ../../fem/fespace.cpp +SOURCE += ../../fem/geom.cpp +SOURCE += ../../fem/gridfunc.cpp +SOURCE += ../../fem/hybridization.cpp +SOURCE += ../../fem/intrules.cpp +SOURCE += ../../fem/linearform.cpp +SOURCE += ../../fem/lininteg.cpp +SOURCE += ../../fem/nonlinearform.cpp +SOURCE += ../../fem/nonlininteg.cpp +SOURCE += ../../fem/staticcond.cpp # 17/24 of the fem files +SOURCE += ../../general/array.cpp +SOURCE += ../../general/error.cpp +SOURCE += ../../general/gzstream.cpp +SOURCE += ../../general/socketstream.cpp +SOURCE += ../../general/stable3d.cpp +SOURCE += ../../general/table.cpp +SOURCE += ../../general/tic_toc.cpp # 7/12 of the general files +SOURCE += ../../linalg/blockmatrix.cpp +SOURCE += ../../linalg/blockoperator.cpp +SOURCE += ../../linalg/blockvector.cpp +SOURCE += ../../linalg/densemat.cpp +SOURCE += ../../linalg/matrix.cpp +SOURCE += ../../linalg/ode.cpp +SOURCE += ../../linalg/operator.cpp +SOURCE += ../../linalg/solvers.cpp +SOURCE += ../../linalg/sparsemat.cpp +SOURCE += ../../linalg/sparsesmoothers.cpp +SOURCE += ../../linalg/vector.cpp # 11/17 of the linalg files +SOURCE += ../../mesh/element.cpp +SOURCE += ../../mesh/hexahedron.cpp +SOURCE += ../../mesh/mesh.cpp +SOURCE += ../../mesh/mesh_operators.cpp +SOURCE += ../../mesh/mesh_readers.cpp +SOURCE += ../../mesh/ncmesh.cpp +SOURCE += ../../mesh/nurbs.cpp +SOURCE += ../../mesh/point.cpp +SOURCE += ../../mesh/quadrilateral.cpp +SOURCE += ../../mesh/segment.cpp +SOURCE += ../../mesh/tetrahedron.cpp +SOURCE += ../../mesh/triangle.cpp +SOURCE += ../../mesh/vertex.cpp # 12/16 of the mesh files + +CC_REQUIRED += -I../.. +``` + +Reducing the files to the minimal set increases performance by approximately +40%. That's significant. So it may be worthwhile to do this for your project +as well. + + +## Laghos Example + +[Laghos](https://github.com/CEED/Laghos)(LAGrangian High-Order Solver) is an +open-source miniapp that solves the time-dependent Euler equations of +compressible gas dynamics in a moving Lagrangian frame. + +It was reported that experimental work in one of their branches had a +vulnerability when compiled with the IBM compiler between the optimization +levels `-O2` and `-O3`. So it was necessary to get it to compile under FLiT in +order to diagnose the problem with [`flit +bisect`](flit-command-line.md#flit-bisect). + +Again, I forked this project in order to add FLiT tests. For this example, I +copied the `main()` function into a single FLiT test that returned the `|e|` +value after one iteration. You can pull my fork with + +```bash +git clone --branch raja-dev-flit https://github.com/mikebentley15/Laghos.git +``` + +I created the `custom.mk` file by studying the main `Makefile` for the Laghos +project. I would also run the main `Makefile` with verbosity turned on (which +in this case is done with `make v=1`) so that I could see the compiler flags +sent to the compilers. This particular `Makefile` made assumptions about +specific environment variables that would be set, but to have default values +within the `Makefile`. + +```make +CUB_DIR ?= ./cub +CUDA_DIR ?= /usr/local/cuda +MFEM_DIR ?= $(HOME)/home/mfem/mfem-master +RAJA_DIR ?= $(HOME)/usr/local/raja/last +MPI_HOME ?= $(HOME)/usr/local/openmpi/3.0.0 +``` + +Next was to gather all relevant source files to be compiled, which in this case +was all of them except for the file with the original `main()` function, which +is `laghos.cpp`. FLiT has its own `main()` and the functionality of the Laghos +`main()` has been put into the test called `LaghosTest`. + +Again, this list was gathered from the Laghos `Makefile`. + +```make +RAJA := ../raja +KERNELS := $(RAJA)/kernels + +KERNEL_FILES := +KERNEL_FILES += $(wildcard $(KERNELS)/*.cpp) +KERNEL_FILES += $(wildcard $(KERNELS)/blas/*.cpp) +KERNEL_FILES += $(wildcard $(KERNELS)/force/*.cpp) +KERNEL_FILES += $(wildcard $(KERNELS)/geom/*.cpp) +KERNEL_FILES += $(wildcard $(KERNELS)/maps/*.cpp) +KERNEL_FILES += $(wildcard $(KERNELS)/mass/*.cpp) +KERNEL_FILES += $(wildcard $(KERNELS)/quad/*.cpp) +KERNEL_FILES += $(wildcard $(KERNELS)/share/*.cpp) + +RAJA_FILES := +RAJA_FILES += $(wildcard $(RAJA)/config/*.cpp) +RAJA_FILES += $(wildcard $(RAJA)/fem/*.cpp) +RAJA_FILES += $(wildcard $(RAJA)/general/*.cpp) +RAJA_FILES += $(wildcard $(RAJA)/linalg/*.cpp) +RAJA_FILES += $(wildcard $(RAJA)/tests/*.cpp) + +SOURCE += $(wildcard ../*.cpp) +SOURCE += $(KERNEL_FILES) +SOURCE += $(RAJA_FILES) +SOURCE := $(filter-out ../laghos.cpp,$(SOURCE)) +``` + +The next step is to gather required compiler flags. This again was done by +executing the Laghos `Makefile` with verbosity turned on. The flags that were +extracted are below: + +```make +CC_REQUIRED += -D__LAMBDA__ +CC_REQUIRED += -D__TEMPLATES__ +CC_REQUIRED += -I$(CUDA_DIR)/samples/common/inc +CC_REQUIRED += -I$(MFEM_DIR) +CC_REQUIRED += -I$(MFEM_DIR)/../hypre-2.10.0b/src/hypre/include +CC_REQUIRED += -I$(MPI_HOME)/include +# Note: The local cub directory needs to be included before raja because some +# files shadow the same header files found in raja. +CC_REQUIRED += -I../cub +CC_REQUIRED += -I.. +CC_REQUIRED += -I$(RAJA_DIR)/include +CC_REQUIRED += -fopenmp +CC_REQUIRED += -m64 +``` + +As you can see from the note above is that we have some shadowing of header +files with this compilation. I do not recommend creating projects that have +shadowing, but if you do, the order of include directories matters. + +Next, we need to specify the linker flags. This again was gathered by looking +at the compilation flags used by the Laghos `Makefile` when running it. + +```make +LD_REQUIRED += -L$(MFEM_DIR) -lmfem +LD_REQUIRED += -L$(MFEM_DIR)/../hypre-2.10.0b/src/hypre/lib -lHYPRE +LD_REQUIRED += -L$(MFEM_DIR)/../metis-4.0 -lmetis +LD_REQUIRED += -lrt +LD_REQUIRED += $(RAJA_DIR)/lib/libRAJA.a +LD_REQUIRED += -Wl,-rpath -Wl,$(CUDA_DIR)/lib64 +LD_REQUIRED += -L$(CUDA_DIR)/lib64 -lcuda -lcudart -lcudadevrt -lnvToolsExt +LD_REQUIRED += -ldl +``` + +Again, the order here may matter. I didn't test that, but rather just used the +same order as the Laghos `Makefile`. + +And with that, the FLiT test was able to compile against the Laghos source +code. Note, there is setup necessary to actually run this example, +specifically all of the dependencies of Laghos for this experimental +development branch. Since I believe that may be too far beyond the scope of +this documentation, it is omitted. + + +[Prev](run-wrapper-and-hpc-support.md) +| +[Table of Contents](README.md) +| +[Next](test-executable.md) + diff --git a/documentation/cuda-support.md b/documentation/cuda-support.md new file mode 100644 index 00000000..60132c46 --- /dev/null +++ b/documentation/cuda-support.md @@ -0,0 +1,26 @@ +# CUDA Support + +[Prev](mpi-support.md) +| +[Table of Contents](README.md) +| +[Next](run-wrapper-and-hpc-support.md) + +FLiT historically had limited CUDA support, so much so that it was eventually +stripped out for not being of enough utility and being left in disrepair. It +may be good to have full CUDA support with reproducibility tests written with +CUDA kernels, but that is a long way off at this point. + +Instead, a much more attainable goal is to build infrastructure to wrap a +compiler wuth the `nvcc` compiler to allow for tests and code bases that +utilize CUDA kernels. This has not yet been implemented, but is on the backlog +of tasks (see [issue #164](https://github.com/PRUNERS/FLiT/issues/164)). + +Unfortunately at this point, FLiT does not have CUDA support. + + +[Prev](mpi-support.md) +| +[Table of Contents](README.md) +| +[Next](run-wrapper-and-hpc-support.md) diff --git a/documentation/database-structure.md b/documentation/database-structure.md index 666e075d..9032f548 100644 --- a/documentation/database-structure.md +++ b/documentation/database-structure.md @@ -1,6 +1,6 @@ # Database Structure -[Prev](test-executable.md) +[Prev](benchmarks.md) | [Table of Contents](README.md) | @@ -42,8 +42,8 @@ CREATE TABLE tests ( optl varchar, -- optimization level (e.g. "-O2") switches varchar, -- compiler flag(s) (e.g. "-ffast-math") precision varchar, -- precision (f = float, d = double, e = extended) - comparison varchar, -- metric of comparison - hex value - comparison_d real, -- metric of comparison of result vs ground truth + comparison_hex varchar, -- metric of comparison - hex value + comparison real, -- metric of comparison of result vs ground truth file varchar, -- filename of test executable nanosec integer check(nanosec >= 0), -- timing for the function diff --git a/documentation/flit-command-line.md b/documentation/flit-command-line.md index 0882a375..75a895b6 100644 --- a/documentation/flit-command-line.md +++ b/documentation/flit-command-line.md @@ -21,14 +21,12 @@ flit --help Possible subcommands: -* [flit help](#flit-help): display help for a specific subcommand +* [flit help](#flit-help): Display help for a specific subcommand * [flit init](#flit-init): Initializes a flit test directory for use * [flit update](#flit-update): Updates the Makefile based on `flit-config.toml` -* [flit check](#flit-check): Verifies the correctness of a config file * [flit make](#flit-make): Run flit tests locally and add results to the database -* [flit run](#flit-run): Run flit on the configured remote machine(s) * [flit import](#flit-import): Imports test results into an SQLite3 database -* [flit analyze](#flit-analyze): Performs analysis on a previous flit run +* [flit bisect](#flit-bisect): Assign variability blame to files and functions ## flit help @@ -84,20 +82,6 @@ automatically call `flit update` to update itself if `flit-config.toml` has changed. You should only call it directly if you want to manually examine the autogenerated `Makefile`. -## flit check - -_not yet implemented_ - -This command only verifies the correctness of the configurations you have for -your flit tests. As part of this verification, this command checks to see if -it is possible to establish the remote connections, such as the connection to -the machines to run the software, the connection to the database machine, and -the connection to the database machine from the run machine. You may need to -provide a few SSH passwords to perform this check. - -Since this subcommand is not yet implemented, it may change in nature when it -does finally get implemented. - ## flit make Run the full set of tests through the autogenerated Makefile. You could do @@ -112,15 +96,6 @@ this manually, but this does a few things conveniently for you, such as Again, you can do these things manually and have more control. But for most users, this will be the most direct and convenient way to run locally. -## flit run - -_not yet implemented_ - -Run flit on the configured remote machine(s). Note that you may need to -provide a password for SSH, but that should be taken care of pretty early on -in the process. The results will be sent to the database computer for later -analysis. - ## flit import Imports flit results into the database configured in `flit-config.toml`. It @@ -144,13 +119,36 @@ the created `litmus-test-run` directory. You are free to examine the results using the `sqlite3` interactive tool or any other method you have for running queries on an SQLite3 database. -## flit analyze +## flit bisect + +When FLiT runs identify compilations that cause some tests to exhibit +variability, one may want to investigate further and understand where the +compiler introduced overly aggressive optimizations. + +The `flit bisect` tool is capable of assigning blame to individual source files +and can often go further to assign blame to individual functions within the +blamed source files. You can run `flit bisect` directly giving it a specific +compilation, precision, and test case, or you can tell it to automatically run +for all differences in a given SQLite3 database. + +Here is an example of giving a single test case known to show variability: + +```bash +flit init --directory litmus-test-run --litmus-tests +cd litmus-test-run +flit bisect --precision double "gcc -O3 -funsafe-math-optimizations" subnormal +``` -_not yet implemented_ +And here is an example of giving a full SQLite3 database -Runs analysis on a previous flit run. The analysis will be of the current flit -repository and will create a directory called analysis inside of the flit -directory. +```bash +flit init --directory litmus-test-run --litmus-tests +cd litmus-test-run +rm tests/Empty.cpp +make run -j8 +flit import --new-run results/*.csv +flit bisect --auto-sqlite-run results.sqlite --parallel 8 --jobs 8 +``` [Prev](litmus-tests.md) | diff --git a/documentation/flit-configuration-file.md b/documentation/flit-configuration-file.md index 1e8258b4..72b88e03 100644 --- a/documentation/flit-configuration-file.md +++ b/documentation/flit-configuration-file.md @@ -13,10 +13,12 @@ Here I have an example configuration file. I will go through it section by section. If you want to see the full configuration file, it is at the end of this page. -_Note: there are no default values for these fields. You must specify all -fields for an entry to be valid. If in doubt, you can use [flit -check](flit-command-line.md#flit-check) to verify your configuration file is -valid._ +_Note: this is not just an example configuration file, it also contains all of +the default values too. When your project gets initialized using_ +[`flit init`](flit-command-line.md#flit-init)_, +that configuration file will also contain the default values. You are welcome +to delete or comment out the values, which will cause the default values to be +used._ ```toml [database] @@ -30,6 +32,45 @@ supported, but has been replaced with SQLite3. For now, only `sqlite3` is supported for the `type`. The only thing that needs to be specified is `filepath`, which can be a relative or absolute path. +```toml +[run] + +timing = true +timing_loops = -1 +timing_repeats = 3 +enable_mpi = false +mpirun_args = '' +``` + +Here we have information about how to execute the tests. More specifically +some options that control the timing. You can turn timing off entirely, or you +can change the defaults of the timing if you find it is taking too long to run +with the default timing procedure. + +These options are only for the full run done by either calling `flit make` or +`make run`. Some of these options may be used by `flit bisect` as well, but +not the timing ones since `flit bisect` does not care so much about timing. + +* `timing`: `false` means to turn off the timing feature. The full test run + will be much faster with this option. This is related to the `--timing` and + `--no-timing` flags from the [test executable](test-executable.md#Timing). +* `timing_loops`: The number of loops to run before averaging. For values less + than zero, the amount of loops to run will be automatically determined. This + is the same as the `--timing-loops` option flag from the [test + executable](test-executable.md#Timing). +* `timing_repeats`: How many times to repeat timing. The minimum timing value + will be kept. This is the same as the `--timing-repeats` option flag from + [test executable](test-executable.md#Timing). +* `enable_mpi`: Turns on compiling and running tests with MPI support. See the + [MPI Support](mpi-support.md) page for more information. +* `mpirun_args`: Arguments to pass to `mpirun`. This is where you specify how + many processes to run, for example `-n 16` to run 16 instances of the tests + under MPI. + +**A note about MPI:** FLiT requires the tests to be deterministic. If the +tests employ MPI, it is the test creator's responsibility to ensure that the +test produces identical results every time. + ```toml [[hosts]] @@ -51,19 +92,19 @@ path is always with respect to the user's home directory. ```toml [hosts.dev_build] -compiler_name = 'clang++' +compiler_name = 'g++' optimization_level = '-O2' -switches = '-mavx' +switches = '-funsafe-math-optimizations' ``` Each host has a developer build that can be performed. The purpose of the developer build is to try out the tests that you have developed without committing yourself to a full FLiT run. -The `compiler` field here needs to match the `name` of one of the compilers specified -later in the `[[hosts.compilers]]` list. The `optimization_level` and -`switches` need not be in the `optimization_levels` and `switches` for -the compiler with the matching name. +The `compiler` field here needs to match the `name` of one of the compilers +specified later in the `[[hosts.compilers]]` list. The `optimization_level` +and `switches` need not be in the `optimization_levels` and `switches` for the +compiler with the matching name. This does exactly one compilation with the compiler and flags that are specified. This compilation is done using `make dev` and generates an @@ -95,128 +136,36 @@ the compiler with the matching name. binary = 'g++' name = 'g++' - type = 'gcc' - optimization_levels = [ - '-O0', - '-O3', - ] - switches = [ - '', - '-fassociative-math', - '-mavx2 -mfma', - ] ``` Here we specify the first compiler for the first host. Since binary here is a simple name, it will get the executable `g++` from the system `PATH`. If you really mean you want to have a compiler that is located in your home directory, -you can do `./g++`. - -The `type` parameter can be one of - -* `gcc` -* `clang` -* `intel` -* `cuda` - -The `optimization_levels` and `switches` will be combined as a Cartesian -product and each possible pairing will become a compilation performed by FLiT. -For a list of all possible flags for each compiler type, see [Available -Compiler Flags](available-compiler-flags.md). - -```toml - [[hosts.compilers]] - - binary = 'my-installs/g++-7.0/bin/g++' - name = 'g++-7.0' - type = 'gcc' - optimization_levels = [ - '-O3', - ] - switches = [ - '', - '-fassociative-math', - '-mavx2 -mfma', - '-funsafe-math-optimizations', - ] -``` +you can do `./g++`. The name field is a human-readable unique name for this +compiler. For example, the binary field can have an absolute path where the +name can be something like `gcc-7.4`. -Here it is demonstrated that you can specify a second version of `g++` -with different optimization levels and switches from the first -version. It is simply required that the compiler name be unique for -this host. - -```toml - [[hosts.compilers]] - - binary = 'clang++' - name = 'clang' - type = 'clang' - optimization_levels = [ - '-O0', - '-O1', - '-O2', - '-O3', - ] - switches = [ - '', - '-fassociative-math', - '-mavx', - '-fexcess-precision=fast', - '-ffinite-math-only', - '-mavx2 -mfma', - '-march=core-avx2', - ] -``` +## Full Configuration File -We also specify a third compiler `clang++`, again with different flags. So for -the host `my.hostname.com`, we have three compilers configured: `g++`, -`g++-7.0`, and `clang`. +Combining all of the above sections together, here is the full example (and +default) configuration file: ```toml -[[hosts]] - -name = 'other.hostname.com' -flit_path = 'my-installs/flit/bin/flit' -config_dir = 'project/flit-tests' - -[hosts.dev_build] - -compiler_name = 'intel-17.0' -optimization_level = '-O2' -switches = '-mavx' - -[hosts.ground_truth] - -compiler_name = 'intel-17.0' -optimization_level = '-O0' -switch = '' - - [[hosts.compilers]] +[database] - binary = 'icpc' - name = 'intel-17.0' - type = 'intel' - optimization_levels = [ - '-O0', - ] - switches = [ - '', - ] -``` +type = 'sqlite' +filepath = 'results.sqlite' -Here it is demonstrated that you can specify another host. This one is called -`other.hostname.com` with a single compiler named `intel-17.0`. -## Full Configuration File +[run] -Combining all of the above sections together, here is the full example configuration file: +timing = true +timing_loops = -1 +timing_repeats = 3 -```toml -[database] +enable_mpi = false +mpirun_args = '' -type = 'sqlite' -filepath = 'results.sqlite' [[hosts]] @@ -224,11 +173,13 @@ name = 'my.hostname.com' flit_path = '/usr/bin/flit' config_dir = 'project/flit-tests' + [hosts.dev_build] -compiler_name = 'clang++' +compiler_name = 'g++' optimization_level = '-O2' -switches = '-mavx' +switches = '-funsafe-math-optimizations' + [hosts.ground_truth] @@ -236,86 +187,11 @@ compiler_name = 'g++' optimization_level = '-O0' switches = '' + [[hosts.compilers]] binary = 'g++' name = 'g++' - type = 'gcc' - optimization_levels = [ - '-O0', - '-O3', - ] - switches = [ - '', - '-fassociative-math', - '-mavx2 -mfma', - ] - - [[hosts.compilers]] - - binary = 'my-installs/g++-7.0/bin/g++' - name = 'g++-7.0' - type = 'gcc' - optimization_levels = [ - '-O3', - ] - switches = [ - '', - '-fassociative-math', - '-mavx2 -mfma', - '-funsafe-math-optimizations', - ] - - [[hosts.compilers]] - - binary = 'clang++' - name = 'clang' - type = 'clang' - optimization_levels = [ - '-O0', - '-O1', - '-O2', - '-O3', - ] - switches = [ - '', - '-fassociative-math', - '-mavx', - '-fexcess-precision=fast', - '-ffinite-math-only', - '-mavx2 -mfma', - '-march=core-avx2', - ] - -[[hosts]] - -name = 'other.hostname.com' -flit_path = 'my-installs/flit/bin/flit' -config_dir = 'project/flit-tests' - -[hosts.dev_build] - -compiler_name = 'intel-17.0' -optimization_level = '-O2' -switches = '-mavx' - -[hosts.ground_truth] - -compiler_name = 'intel-17.0' -optimization_level = '-O0' -switch = '' - - [[hosts.compilers]] - - binary = 'icpc' - name = 'intel-17.0' - type = 'intel' - optimization_levels = [ - '-O0', - ] - switches = [ - '', - ] ``` diff --git a/documentation/installation.md b/documentation/installation.md index 6de0a724..1bcdd8b4 100644 --- a/documentation/installation.md +++ b/documentation/installation.md @@ -6,48 +6,39 @@ Instruction Contents: -* [Roles](#roles) * [Prerequisites](#prerequisites) - * [Shared Prerequisites](#shared-prerequisites) - * [Runner Prerequisites](#runner-prerequisites) - * [Database Prerequisites](#database-prerequisites) + * [Compilers](#compilers) + * [Optional Dependencies](#optional-dependencies) * [FLiT Setup](#flit-setup) * [Database Setup](#database-setup) -* [SSH Keys (Optional)](#ssh-keys-optional) - -## Roles - -FLiT is designed to build and execute its test suite on a variety of hosts and -compilers. There are 3 roles used in a FLiT architecture: - -* **Launcher**: Where you start a large run which remotely executes on - **Runner** boxes -* **Runner**: Compiles different versions of reproducibility tests and executes - them to generate test results. You can have more than one of these. -* **Database**: Stores the results for later analysis - -Each role requires slightly different setup. A particular computer may only -satisfy one role, or it may satisfy multiple roles. You can potentially have -all three roles on a single machine, which is the simplest use case. +* [Uninstallation](#uninstallation) ## Prerequisites -### Shared Prerequisites +Stuff you should already have: -The following prerequisites are required for all three roles: +* [bash](https://www.gnu.org/software/bash) +* [binutils](https://www.gnu.org/software/binutils) +* [coreutils](https://www.gnu.org/software/coreutils/coreutils.html) +* hostname + +Stuff you may need to get * [git](https://git-scm.com) -* [bash](https://www.gnu.org/software/bash) * [python3](https://www.python.org) * The [toml](https://github.com/uiri/toml) module (for [TOML](https://github.com/toml-lang/toml) configuration files) * [make](https://www.gnu.org/software/make) * [gcc](https://gcc.gnu.org) version 4.9 or higher +* [sqlite3](https://sqlite.org) version 3.0 or higher. + You can use the one that comes with python, or install as a standalone. For Debian-based systems: ```bash -sudo apt install bash build-essential git python3 python3-toml +sudo apt install \ + bash binutils build-essential coreutils git hostname \ + python3 python3-toml ``` For homebrew on OSX (besides installing [Xcode](https://developer.apple.com/xcode)) @@ -58,33 +49,35 @@ pip3 install toml ``` If you install python version 3.0 or later, then you will need to have a -symbolic link called `python3` in your `PATH` pointing to that python executable. +symbolic link called `python3` in your `PATH` pointing to that python +executable. -### Runner Prerequisites +### Compilers -The test runner can run multiple compilers. For now, only one compiler is -supported from each of the types: GCC, Clang, Intel's `icpc`, and NVIDIA's `nvcc`. -Simply have the one you want used as the first in your system PATH. You do not -need all four of those, only those ones installed will be used. But all of -them need to support C++11. +The GCC compiler is the only one required for installation of FLiT since it is +used to compiler the FLiT shared library. Other than that, you are free to +install another version of GCC, as well as Clang and the Intel compiler. If +you are missing either Clang or the Intel compiler, FLiT will still work as +expected. -If this is not on the same machine as the Launcher, then the Database machine -will need an SSH server running. +### Optional Dependencies -```bash -sudo apt install openssh-server -``` +FLiT has [MPI support](mpi-support.md) which you may want to use. To compile +and install FLiT, MPI does not need to be installed. If you later choose the +use MPI, you only need it installed when you go to compile the tests that +require it. -### Database Prerequisites +If you choose to use MPI support, you likely know what you need. FLiT requires +that both `mpic++` and `mpirun` are found in the system `PATH`. On Ubuntu, +OpenMPI is installed with -Postgres used to be the supported database for FLiT. That has since been -changed to using SQLite3. Because of this, all you need is `sqlite3` installed, -which you should already have installed because `python3` already requires it. +```bash +sudo apt install openmpi-bin libopenmpi-dev +``` ## FLiT Setup -All three roles will need FLiT available and compiled. It can be optionally -installed as well. +You will need FLiT available and compiled. It can be optionally installed. ```bash git clone https://github.com/PRUNERS/FLiT.git @@ -107,8 +100,8 @@ make install PREFIX=~/my-installs/ ``` If you do not want to install somewhere and want to use the flit command-line -tool from the git repository, simply make a symbolic link to the flit.py -script. Here I presume that `$HOME/bin` is in your `PATH` variable +tool from the cloned git repository, simply make a symbolic link to the +`flit.py` script. Here I presume that `$HOME/bin` is in your `PATH` variable ```bash ln -s ~/FLiT/scripts/flitcli/flit.py ~/bin/flit @@ -121,28 +114,21 @@ use the command-line tool. There should be nothing to setup since `sqlite3` should already be present. -Creating sqlite3 databases is currently working for the **Runner** machines, -but the central **Database** system is not currently supported. We plan to fix -this functionality and support a separate **Database** system. +## Uninstallation -## SSH Keys (Optional) +You can also uninstall as easily as you installed. If you used a custom +`PREFIX` value, then that custom `PREFIX` value should also be used. For +example if you installed with -The automation for executing the reproducibility FLiT tests on multiple hosts -heavily relies on SSH. It would make your life easier to have SSH keys paired -so that you do not need to enter a password when logging in remotely to -**Runner** machines. - -If the roles are separated onto different machines, the automation will attempt -to make the following connections: +```bash +make install PREFIX=~/my-installs/ +``` -* **Launcher** -> **Runner** -* **Launcher** -> **Database** -* **Runner** -> **Database** +then you would uninstall with -so these are the connections you may want to setup SSH keys for. See -[Ubuntu's help -documentation](https://help.ubuntu.com/community/SSH/OpenSSH/Keys) for setting -up SSH keys. +```bash +make uninstall PREFIX=~/my-installs/ +``` [Table of Contents](README.md) | diff --git a/documentation/litmus-tests.md b/documentation/litmus-tests.md index c5e1f101..15098706 100644 --- a/documentation/litmus-tests.md +++ b/documentation/litmus-tests.md @@ -15,11 +15,8 @@ or in `/share/flit/litmus-tests` in the install. They can be copied to your test directory using the `flit init` command-line tool (see [flit init](flit-command-line.md#flit-init)). -Most litmus tests have a CUDA version as well. You may use these tests as -examples or play with them to gain insights into how the compiler alters simple -examples. The community is encouraged to contribute back interesting test -cases that can be added to these litmus tests. Simply create a **Pull Request** on -GitHub. +The community is encouraged to contribute back interesting test cases that can +be added to these litmus tests. Simply create a **Pull Request** on GitHub. [Prev](installation.md) | diff --git a/documentation/mpi-support.md b/documentation/mpi-support.md new file mode 100644 index 00000000..af4c7ad6 --- /dev/null +++ b/documentation/mpi-support.md @@ -0,0 +1,102 @@ +# MPI Support + +[Prev](writing-test-cases.md) +| +[Table of Contents](README.md) +| +[Next](cuda-support.md) + + +FLiT has built-in support for tests that utilize MPI. Before going into the +details of this, a word of caution: + +_**Warning**: FLiT requires test results to be exactly deterministic in order to +function properly and to give meaningful and trustworthy results. By using +MPI, it is highly likely that nondeterminism can be introduced by concurrency. +It is the responsability of the test engineer to ensure the code under test is +deterministic. FLiT gives no guarantee for nondeterministic code._ + + +## Compiling FLiT with MPI Support + +To compile FLiT with MPI support is actually not necessary. The actual +compiled FLiT shared library has no need to contain any MPI code, so there is +no need to recompile FLiT to have MPI support. This also means that an MPI +implementation does not need to be installed in order to compile and install +FLiT. This may change in future versions, but as of now, you can simply enable +MPI support in the tests. + +This has an added benefit of not requiring to recompile FLiT if you change your +implementation of MPI you want to use. FLiT will not need to be recompiled, +just the tests. + + +## Enabling MPI Support + +To enable MPI support, you simply need to add (or edit) two lines in your +`flit-config.toml` file (see [FLiT Configuration +File](flit-configuration-file.md)). For example: + +```toml +[run] +enable_mpi = true +mpirun_args = '-n 4' +``` + +With the enabling of MPI, the generated Makefile will automatically pull +compiler and linker flags from `mpic++`. The `mpic++` executable will be +pulled from the system `PATH` variable, so simply make sure your `PATH` is +pointing to the desired executable. + +The `mpirun_args` is a place where you can specify any options you wish for +`mpirun`. Again the `mpirun` executable is expected to be found using your +system `PATH` variable. + + +## Initializing and Finalizing the MPI Environment + +Since the MPI standard recommends to initialize the MPI environment as close to +the beginning of the application as possible, when MPI support is enabled for +your tests, the FLiT framework will automatically call `MPI_Init()` and +`MPI_Finalize()` for you. Please do not call these functions from within your +tests. + + +## MPI Information + +There is a global variable you can have access to from within your tests that +FLiT provides, if you'd like. You can access this functionality directly +through the MPI interface instead. The global variable is `flit::mpi`, and it +is a pointer to a struct that can give you the world size, your world rank, and +a few other things. See `src/MpiEnvironment.h` in the FLiT source code for +more details. One of the benefits of this approach is that you can use this +global pointer even if MPI is not enabled and you can have logic based on the +rank and size of the MPI world. + + +## Conditional Compilation + +If you want your tests to conditionally use MPI, there is a macro-defined +variable you can condition off of to disable or enable certain code. That +variable is `FLIT_USE_MPI`. For example + +```c++ +T grid[1024][1024]; +int nrows = 1024 / mpi->size; +for (int row = mpi->rank * nrows; row < (mpi->rank + 1) * nrows; row++) { + for (int col = 0; col < 1024; col++) { + // some computation to populate or update grid + // ... + } +} +#ifdef FLIT_USE_MPI +MPI_Send(...); +#endif // FLIT_USE_MPI +``` + + +[Prev](writing-test-cases.md) +| +[Table of Contents](README.md) +| +[Next](cuda-support.md) diff --git a/documentation/run-wrapper-and-hpc-support.md b/documentation/run-wrapper-and-hpc-support.md new file mode 100644 index 00000000..0365d697 --- /dev/null +++ b/documentation/run-wrapper-and-hpc-support.md @@ -0,0 +1,45 @@ +# Run Wrapper and HPC Support + +[Prev](cuda-support.md) +| +[Table of Contents](README.md) +| +[Next](compiling-your-tests.md) + + +Within the `custom.mk` file, there is a variable called `RUN_WRAPPER`. This +`RUN_WRAPPER` is a program that is to wrap around all test executable runs. +For example, if you set + +```make +RUN_WRAPPER = @echo +``` + +then the tests will not be executed, but instead will only be printed to show +what would be executed. Alternatively, you can create your own custom wrapper +script such as `wrapper.sh`: + +```bash +#!/bin/bash + +echo "$@" >> test-execution.log +time "$@" +``` + +This will give you freedom to log, to time, or to even then run them in +parallel with Slurm (using `srun` or `sbatch`). You can also do things like +monitor memory usage or use an automated checker for memory leaks. Overall it +can be a useful feature to tie in your own custom functionality on top of the +test executables. + +Note, it is not good to launch too many small jobs using srun, but the amount +of jobs that FLiT generates is only approximately 300 or so, depending on how +many compilers are found in your PATH. That may or may not be too many for +your needs. + + +[Prev](cuda-support.md) +| +[Table of Contents](README.md) +| +[Next](compiling-your-tests.md) diff --git a/documentation/test-executable.md b/documentation/test-executable.md index e245ad0e..d2e7149a 100644 --- a/documentation/test-executable.md +++ b/documentation/test-executable.md @@ -1,10 +1,10 @@ # Test Executable -[Prev](writing-test-cases.md) +[Prev](compiling-your-tests.md) | [Table of Contents](README.md) | -[Next](database-structure.md) +[Next](benchmarks.md) After you have [configured your test environment](flit-configuration-file.md) and [written your test files](writing-test-cases.md), you can autogenerate a @@ -62,7 +62,7 @@ $ flit init --directory flit-litmus --litmus-tests $ cd flit-litmus $ make dev -j10 $ ./devrun Paranoia -name,host,compiler,optl,switches,precision,score,score_d,resultfile,comparison,comparison_d,file,nanosec +name,host,compiler,optl,switches,precision,score_hex,score,resultfile,comparison_hex,comparison,file,nanosec Paranoia,bihexal,g++,-O2,-funsafe-math-optimizations,d,0x4002a000000000000000,10,NULL,NULL,NULL,devrun,1000028414 Paranoia,bihexal,g++,-O2,-funsafe-math-optimizations,e,0x4002a000000000000000,10,NULL,NULL,NULL,devrun,1000030686 Paranoia,bihexal,g++,-O2,-funsafe-math-optimizations,f,0x4002a000000000000000,10,NULL,NULL,NULL,devrun,1000043012 @@ -122,7 +122,9 @@ zeroMinusX ### Execute Only Particular Precisions -In addition to only executing a particular test, you can limit which precision to execute instead of doing all of them. This is with the option of `--precision`. There are four potential values for this option, +In addition to only executing a particular test, you can limit which precision +to execute instead of doing all of them. This is with the option of +`--precision`. There are four potential values for this option, - `float`: 32-bit floating-point only - `double`: 64-bit floating-point only @@ -133,7 +135,7 @@ In the following example, the TrianglePHeron example is executed only for 32-bit ```bash $ ./devrun --precision float TrianglePHeron -name,host,compiler,optl,switches,precision,score,score_d,resultfile,comparison,comparison_d,file,nanosec +name,host,compiler,optl,switches,precision,score_hex,score,resultfile,comparison_hex,comparison,file,nanosec TrianglePHeron,bihexal,g++,-O2,-funsafe-math-optimizations,f,0x3ff3e400000000000000,0.00043487548828125,NULL,NULL,NULL,devrun,6137 ``` @@ -150,7 +152,7 @@ $ ./devrun --no-timing --verbose --precision double SinInt SinInt: score = 1 SinInt: score - 1.0 = 0 SinInt-d: # runs = 1 -name,host,compiler,optl,switches,precision,score,score_d,resultfile,comparison,comparison_d,file,nanosec +name,host,compiler,optl,switches,precision,score_hex,score,resultfile,comparison_hex,comparison,file,nanosec SinInt,bihexal,g++,-O2,-funsafe-math-optimizations,d,0x3fff8000000000000000,1,NULL,NULL,NULL,devrun,0 ``` diff --git a/documentation/writing-test-cases.md b/documentation/writing-test-cases.md index 634a3f0b..a805086a 100644 --- a/documentation/writing-test-cases.md +++ b/documentation/writing-test-cases.md @@ -4,7 +4,7 @@ | [Table of Contents](README.md) | -[Next](test-executable.md) +[Next](mpi-support.md) When you initialize a test directory using `flit init`, a test file called `Empty.cpp` will be placed in the `tests` directory. This test is as the name @@ -14,6 +14,50 @@ intended to be used as a template for creating tests. To add a test, simply copy `Empty.cpp` and place it in the `tests` directory with an ending of `cpp`. Rename the class inside, and you're good to go. + +## Test Case Requirements + +The tests you write in the FLiT framework are different from unit tests or even +verification tests. We will call them **reproducibility tests** or **flit +tests**. One key difference is that, unlike unit tests, a golden value does +not need to be known a priori. Instead, the return value from the ground-truth +compilation will be used as the base comparison value. + +This is also covered by the comments within the `Empty.cpp` file given to you. +Each test class has the following pure virtual functions (which means functions +you must implement for it to compile): + +- `getInputsPerRun()`: This function simply returns the number of + floating-point inputs your test takes. +- `getDefaultInput()`: This function returns the default input your test takes, + in the form of a `std::vector`. If you want different inputs for `float`, + `double`, and `long double`, give a template specialization of this function + for each of those precisions. You can also use this function to provide + data-driven tests. If your test takes 3 inputs, and this function returns 9 + values, then the test will be run 3 times, once for each set of inputs. +- `run_impl()`: This is where the actual test lives. It receives a vector of + floating-point values as input that will be exactly as long as what + `getInputsPerRun()` returns. The test returns a `flit::Variant` object, + which of the time of this writing can handle `long double` and `std::string`. + +There are some optional functions that you can override as well. The default +implementation is provided for you in `Empty.cpp` so you can see if you would +like to override that behavior. + +- `compare(long double, long double)`: This is a custom comparison value that + is used to compare the results from the ground-truth compilation and all + other compilations. If your test returns a floating-point value, then this + compare function is the one that is used. Common examples of comparisons + here are absolute error and relative error. +- `compare(string, string)`: This is a custom comparison value that is used to + compare the results from the ground-truth compilation and all other + compilations. If your test returns a `std::string`, then this compare + function is the one that is used. There was no good default, so it is highly + recommended to implement your own. For example, your strings may represent a + grid of values, in which case you could convert them back to grids and + perform an $\ell_2$ norm between the two grids. + + ## Disabling Test Cases Since all files ending with `.cpp` in the `tests` directory and the parent @@ -28,6 +72,7 @@ mv tests/BrokenTest.cpp disabled That's it. + ## Only Using Particular Precisions You may have code you want tested that only has implemented one precision, for @@ -64,8 +109,78 @@ precision, and have the other precisions disabled. That way, you will not have misleading information of your test case using `float` or `long double` precision taking up space in your results database. + +## Writing Tests With More Template Parameters + +There may be times when you want to write tests that have more than one +template parameter. For example, you may want an integer template parameter +that specifies the size of the problem to solve. This section will guide you +to be able to leverage templates to create many tests in a few number of lines +of code. + +As an example, let us take the example of code that takes the dot product, but with different sizes of vectors. + +```c++ +#include + +#include +#include +#include +#include + +#include + +// Define a highly templatized class to make many tests +template +class DotProduct : public flit::TestBase { +public: + DotProduct(std::string id) : flit::TestBase(std::move(id)) {} + virtual size_t getInputsPerRun() override { return Len * 2; } + virtual std::vector getDefaultInput() override { + // Could come up with a better mechanism to generate inputs + std::vector inputs(getInputsPerRun()); + size_t seed = 42; + std::minstd_rand engine(seed); + std::uniform_real_distribution dist( + T(), std::sqrt(std::numeric_limits::max()) / 2); + for (T &x : inputs) { + x = dist(engine); + } + return inputs; + } +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + std::vector a(ti.begin(), ti.begin() + Len); + std::vector b(ti.begin() + Len, ti.end()); + long double val{0.0}; + for (int i = 0; i < Len; i++) { + val += a[i] * b[i]; + } + return val; + } +}; + +#define DOT_PRODUCT_REGISTRATION(len) \ + template \ + class DotProduct_Len##len : public DotProduct { \ + using DotProduct::DotProduct; \ + }; \ + REGISTER_TYPE(DotProduct_Len##len) + +// Create 8 tests with different vector sizes +DOT_PRODUCT_REGISTRATION(3) +DOT_PRODUCT_REGISTRATION(4) +DOT_PRODUCT_REGISTRATION(5) +DOT_PRODUCT_REGISTRATION(6) +DOT_PRODUCT_REGISTRATION(10) +DOT_PRODUCT_REGISTRATION(100) +DOT_PRODUCT_REGISTRATION(1000) +DOT_PRODUCT_REGISTRATION(10000) +``` + + [Prev](available-compiler-flags.md) | [Table of Contents](README.md) | -[Next](test-executable.md) +[Next](mpi-support.md) diff --git a/gensrc/testcase.py b/gensrc/testcase.py index f13c7e6a..bc1f74e5 100644 --- a/gensrc/testcase.py +++ b/gensrc/testcase.py @@ -90,32 +90,11 @@ # - input_count: how many inputs the test will take # - default_input: populate ti.vals vector. # - vars_initialize: initialize scope variable for the test using ti.vals -# - cu_vars_initialize: initialize scope variables for the test in CUDA using # tiList[idx].vals -# - func_body: test body that is shared between cuda and non-cuda. Populate score +# - func_body: test body template_string = ''' #include "flit.h" -template -GLOBAL -void -{name}Kernel(const T* const* tiList, double* results) {{ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - double score = 0.0; - - {cu_vars_initialize} - - {{ - {func_body} - }} - - results[idx] = score; -}} - template class {name} : public flit::TestBase {{ public: @@ -132,10 +111,6 @@ class {name} : public flit::TestBase {{ }} protected: - virtual flit::KernelFunction* getKernel() override {{ - return {name}Kernel; - }} - virtual flit::Variant run_impl(const std::vector& ti) override {{ T score = 0.0; @@ -179,8 +154,6 @@ def __init__(self, name, default_input_vals): 'ti.push_back({0});'.format(x) for x in default_input_vals] self.vars_initialize_lines = [ 'T in_{0} = ti[{0}];'.format(i+1) for i in range(self.input_count)] - self.cu_vars_initialize_lines = [ - 'T in_{0} = tiList[idx][{0}];'.format(i+1) for i in range(self.input_count)] # Create an environment for the function body env = Environment({ @@ -213,7 +186,6 @@ def __str__(self): input_count=self.input_count, default_input='\n '.join(self.default_input_lines), vars_initialize='\n '.join(self.vars_initialize_lines), - cu_vars_initialize='\n '.join(self.cu_vars_initialize_lines), func_body='\n '.join(self.func_body_lines), ) diff --git a/images/flit.svg b/images/flit.svg index 0a920e63..fed70ced 100644 --- a/images/flit.svg +++ b/images/flit.svg @@ -1,31 +1,31 @@ - - - - FLiT Logo - - - - image/svg+xml - - FLiT Logo - - - - - - - - - - - - - - - - - - - - - + + + + FLiT Logo + + + + image/svg+xml + + FLiT Logo + + + + + + + + + + + + + + + + + + + + + diff --git a/inputGen/CUHelpers.cpp b/inputGen/CUHelpers.cpp deleted file mode 120000 index 4413c875..00000000 --- a/inputGen/CUHelpers.cpp +++ /dev/null @@ -1 +0,0 @@ -../src/CUHelpers.cpp \ No newline at end of file diff --git a/inputGen/groundtruth.cpp b/inputGen/groundtruth.cpp index 24a728e7..f09955db 100644 --- a/inputGen/groundtruth.cpp +++ b/inputGen/groundtruth.cpp @@ -91,11 +91,9 @@ namespace { runGroundtruth_impl(std::string testName, std::function randGen) { - using flit::Vector; - auto test = flit::getTests()[testName]->get(); auto input = test->getDefaultInput(); - input = Vector(test->getInputsPerRun(), randGen).getData(); + input = std::vector(test->getInputsPerRun(), randGen); auto scores = test->run(input); // Return only the first score. Ignore the key diff --git a/inputGen/main.cpp b/inputGen/main.cpp index a5b1ccbe..4b5bfbf9 100644 --- a/inputGen/main.cpp +++ b/inputGen/main.cpp @@ -122,7 +122,7 @@ runTestbed(const std::string &testName, const std::vector &inputs) { auto retval = testbed(testName, inputs); dlclose(handle); - + return retval; } diff --git a/inputGen/testbed.cpp b/inputGen/testbed.cpp index cf159eea..a3184cf5 100644 --- a/inputGen/testbed.cpp +++ b/inputGen/testbed.cpp @@ -93,8 +93,6 @@ namespace { runTestbed_impl(const std::string &testName, const std::vector &inputvals) { - using flit::Vector; - auto test = flit::getTests()[testName]->get(); auto scores = test->run(inputvals); diff --git a/litmus-tests/disabled/simple_convex_hull.cpp b/litmus-tests/disabled/simple_convex_hull.cpp index d496ec4a..748acb49 100644 --- a/litmus-tests/disabled/simple_convex_hull.cpp +++ b/litmus-tests/disabled/simple_convex_hull.cpp @@ -96,12 +96,8 @@ #endif #ifndef OFT -#if defined(__CUDA__) || defined(__aarch64__) -#define OFT double -#else #define OFT long double #endif -#endif long N = 0; diff --git a/litmus-tests/disabled/simple_convex_hull.h b/litmus-tests/disabled/simple_convex_hull.h index 45daba0d..3ee4e671 100644 --- a/litmus-tests/disabled/simple_convex_hull.h +++ b/litmus-tests/disabled/simple_convex_hull.h @@ -97,12 +97,8 @@ #endif #ifndef OFT -#if defined(__CUDA__) || defined(__aarch64__) -#define OFT double -#else #define OFT long double #endif -#endif #define WFT float @@ -282,7 +278,7 @@ extern std::vector Decisions; Simple Convex Hull */ template -void SimpleComputeConvexhull () { // (FILE *outfile) { +void SimpleComputeConvexhull () { // (FILE *outfile) { // assert(outfile != NULL); std::vector chedges; diff --git a/litmus-tests/tests/DistributivityOfMultiplication.cpp b/litmus-tests/tests/DistributivityOfMultiplication.cpp index b230f21f..d416c9ff 100644 --- a/litmus-tests/tests/DistributivityOfMultiplication.cpp +++ b/litmus-tests/tests/DistributivityOfMultiplication.cpp @@ -87,28 +87,6 @@ #include #include -#ifdef __CUDA__ -#include -#endif - -template -GLOBAL -void -DistOfMultKernel(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - const T* ti = tiList + (idx*n); - T a = ti[0]; - T b = ti[1]; - T c = ti[2]; - - auto distributed = (a * c) + (b * c); - results[idx] = distributed; -} - template class DistributivityOfMultiplication : public flit::TestBase { public: @@ -119,10 +97,6 @@ class DistributivityOfMultiplication : public flit::TestBase { virtual std::vector getDefaultInput() override; protected: - virtual flit::KernelFunction* getKernel() override { - return DistOfMultKernel; - } - virtual flit::Variant run_impl(const std::vector& ti) override { T a = ti[0]; T b = ti[1]; diff --git a/litmus-tests/tests/DoHariGSBasic.cpp b/litmus-tests/tests/DoHariGSBasic.cpp index a04e9e29..02e23b35 100644 --- a/litmus-tests/tests/DoHariGSBasic.cpp +++ b/litmus-tests/tests/DoHariGSBasic.cpp @@ -79,42 +79,15 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include #include -template -GLOBAL -void -DoHGSBTestKernel(const T* tiList, size_t n, double* result){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - - const T* vals = tiList + (idx*n); - - flit::VectorCU a(vals, 3); - flit::VectorCU b(vals + 3, 3); - flit::VectorCU c(vals + 6, 3); - - auto r1 = a.getUnitVector(); - auto r2 = (b - r1 * (b ^ r1)).getUnitVector(); - auto r3 = (c - r1 * (c ^ r1) - - r2 * (c ^ r2)).getUnitVector(); - - T o12 = r1 ^ r2; - T o13 = r1 ^ r3; - T o23 = r2 ^ r3; - - double score = std::abs(o12) + std::abs(o13) + std::abs(o23); - - result[idx] = score; -} - template class DoHariGSBasic: public flit::TestBase { public: @@ -124,17 +97,15 @@ class DoHariGSBasic: public flit::TestBase { virtual std::vector getDefaultInput() override; protected: - virtual flit::KernelFunction* getKernel() override { return DoHGSBTestKernel; } - virtual flit::Variant run_impl(const std::vector& ti) override { using flit::operator<<; long double score = 0.0; //matrix = {a, b, c}; - flit::Vector a = {ti[0], ti[1], ti[2]}; - flit::Vector b = {ti[3], ti[4], ti[5]}; - flit::Vector c = {ti[6], ti[7], ti[8]}; + Vector a = {ti[0], ti[1], ti[2]}; + Vector b = {ti[3], ti[4], ti[5]}; + Vector c = {ti[6], ti[7], ti[8]}; auto r1 = a.getUnitVector(); //crit = r1[0]; @@ -175,9 +146,7 @@ namespace { template T getSmallValue(); template<> inline float getSmallValue() { return pow(10, -4); } template<> inline double getSmallValue() { return pow(10, -8); } -#ifndef __CUDA__ template<> inline long double getSmallValue() { return pow(10, -10); } -#endif } // end of unnamed namespace template @@ -190,7 +159,7 @@ std::vector DoHariGSBasic::getDefaultInput() { 1, e, 0, // vec b 1, 0, e, // vec c }; - + return ti; } diff --git a/litmus-tests/tests/DoHariGSImproved.cpp b/litmus-tests/tests/DoHariGSImproved.cpp index 31caeedb..ffa1d421 100644 --- a/litmus-tests/tests/DoHariGSImproved.cpp +++ b/litmus-tests/tests/DoHariGSImproved.cpp @@ -79,39 +79,14 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include #include -template -GLOBAL -void -DoHGSITestKernel(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - const T* vals = tiList + (idx*n); - flit::VectorCU a(vals, 3); - flit::VectorCU b(vals + 3, 3); - flit::VectorCU c(vals + 6, 3); - - auto r1 = a.getUnitVector(); - auto r2 = (b - r1 * (b ^ r1)).getUnitVector(); - auto r3 = (c - r1 * (c ^ r1)); - r3 = (r3 - r2 * (r3 ^ r2)).getUnitVector(); - - T o12 = r1 ^ r2; - T o13 = r1 ^ r3; - T o23 = r2 ^ r3; - - double score = std::abs(o12) + std::abs(o13) + std::abs(o23); - - results[idx] = score; -} - template class DoHariGSImproved: public flit::TestBase { public: @@ -121,14 +96,13 @@ class DoHariGSImproved: public flit::TestBase { virtual std::vector getDefaultInput() override; protected: - virtual flit::KernelFunction* getKernel() override { return DoHGSITestKernel; } virtual flit::Variant run_impl(const std::vector& ti) override { long double score = 0.0; //matrix = {a, b, c}; - flit::Vector a = {ti[0], ti[1], ti[2]}; - flit::Vector b = {ti[3], ti[4], ti[5]}; - flit::Vector c = {ti[6], ti[7], ti[8]}; + Vector a = {ti[0], ti[1], ti[2]}; + Vector b = {ti[3], ti[4], ti[5]}; + Vector c = {ti[6], ti[7], ti[8]}; auto r1 = a.getUnitVector(); auto r2 = (b - r1 * (b ^ r1)).getUnitVector(); @@ -160,9 +134,7 @@ namespace { template T getSmallValue(); template<> inline float getSmallValue() { return pow(10, -4); } template<> inline double getSmallValue() { return pow(10, -8); } -#ifndef __CUDA__ template<> inline long double getSmallValue() { return pow(10, -10); } -#endif } // end of unnamed namespace template diff --git a/litmus-tests/tests/DoMatrixMultSanity.cpp b/litmus-tests/tests/DoMatrixMultSanity.cpp index 657f47a4..1cf3f76d 100644 --- a/litmus-tests/tests/DoMatrixMultSanity.cpp +++ b/litmus-tests/tests/DoMatrixMultSanity.cpp @@ -79,6 +79,10 @@ * purposes. * * -- LICENSE END -- */ + +#include "Matrix.h" +#include "Vector.h" + #include #include @@ -87,21 +91,6 @@ #include #include -template -GLOBAL -void -DoMatrixMultSanityKernel(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - const T* ti = tiList + (idx*n); - auto b = flit::VectorCU(ti, n); - auto c = flit::MatrixCU::Identity(n) * b; - results[idx] = c.L1Distance(b); -} - template class DoMatrixMultSanity: public flit::TestBase { public: @@ -110,18 +99,14 @@ class DoMatrixMultSanity: public flit::TestBase { virtual size_t getInputsPerRun() override { return 16; } virtual std::vector getDefaultInput() override { - return flit::Vector::getRandomVector(getInputsPerRun()).getData(); + return Vector::getRandomVector(getInputsPerRun()).getData(); } protected: - virtual flit::KernelFunction* getKernel() override { - return DoMatrixMultSanityKernel; - } - virtual flit::Variant run_impl(const std::vector& ti) override { auto dim = ti.size(); - flit::Vector b(ti); - auto c = flit::Matrix::Identity(dim) * b; + Vector b(ti); + auto c = Matrix::Identity(dim) * b; bool eq = (c == b); flit::info_stream << id << ": Product is: " << c << std::endl; flit::info_stream << id << ": A * b == b? " << eq << std::endl; diff --git a/litmus-tests/tests/DoOrthoPerturbTest.cpp b/litmus-tests/tests/DoOrthoPerturbTest.cpp index 1768c2b4..3c4d5d13 100644 --- a/litmus-tests/tests/DoOrthoPerturbTest.cpp +++ b/litmus-tests/tests/DoOrthoPerturbTest.cpp @@ -79,6 +79,9 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include @@ -91,52 +94,6 @@ namespace { const int ulp_inc = 1; } -template -GLOBAL -void -DoOPTKernel(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - - const T* ti = tiList + (idx*n); - double score = 0.0; - cuvector orthoCount(n, 0.0); - // we use a double literal above as a workaround for Intel 15-16 compiler - // bug: - // https://software.intel.com/en-us/forums/intel-c-compiler/topic/565143 - flit::VectorCU a(ti, n); - flit::VectorCU b = a.genOrthoVector(); - - T backup; - - for(decltype(n) r = 0; r < n; ++r){ - T &p = a[r]; - backup = p; - for(int i = 0; i < iters; ++i){ - auto tmp = flit::as_int(p); - p = flit::as_float(++tmp); //yeah, this isn't perfect - //p = std::nextafter(p, std::numeric_limits::max()); - auto watchPoint = FLT_MIN; - watchPoint = a ^ b; - - bool isOrth = watchPoint == 0; //a.isOrtho(b); - if(isOrth){ - orthoCount[r]++; - // score should be perturbed amount - if(i != 0) score += std::abs(p - backup); - }else{ - // if falsely not detecting ortho, should be the dot prod - if(i == 0) score += std::abs(watchPoint); //a ^ b); - } - } - p = backup; - } - results[idx] = score; -} - template class DoOrthoPerturbTest : public flit::TestBase { public: @@ -152,8 +109,6 @@ class DoOrthoPerturbTest : public flit::TestBase { } protected: - virtual flit::KernelFunction* getKernel() override { return DoOPTKernel; } - virtual flit::Variant run_impl(const std::vector& ti) override { using flit::operator<<; @@ -163,8 +118,8 @@ class DoOrthoPerturbTest : public flit::TestBase { // we use a double literal above as a workaround for Intel 15-16 compiler // bug: // https://software.intel.com/en-us/forums/intel-c-compiler/topic/565143 - flit::Vector a(ti); - flit::Vector b = a.genOrthoVector(); + Vector a(ti); + Vector b = a.genOrthoVector(); T backup; diff --git a/litmus-tests/tests/DoSimpleRotate90.cpp b/litmus-tests/tests/DoSimpleRotate90.cpp index 22a07ff7..2e79993e 100644 --- a/litmus-tests/tests/DoSimpleRotate90.cpp +++ b/litmus-tests/tests/DoSimpleRotate90.cpp @@ -79,32 +79,15 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include #include -template -GLOBAL -void -DoSR90Kernel(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - const T* ti = tiList + (idx*n); - flit::VectorCU A(ti, n); - - flit::VectorCU expected(A.size()); - expected[0]=-A[1]; expected[1]=A[0]; expected[2]=A[2]; - - auto done = A.rotateAboutZ_3d(M_PI/2); - - results[idx] = done.L1Distance(expected); -} - template class DoSimpleRotate90: public flit::TestBase { public: @@ -116,11 +99,9 @@ class DoSimpleRotate90: public flit::TestBase { } protected: - virtual flit::KernelFunction* getKernel() override { return DoSR90Kernel; } - virtual flit::Variant run_impl(const std::vector& ti) override { - flit::Vector A(ti); - flit::Vector expected = {-A[1], A[0], A[2]}; + Vector A(ti); + Vector expected = {-A[1], A[0], A[2]}; flit::info_stream << "Rotating A: " << A << ", 1/2 PI radians" << std::endl; A = A.rotateAboutZ_3d(M_PI/2); flit::info_stream << "Resulting vector: " << A << std::endl; diff --git a/litmus-tests/tests/DoSkewSymCPRotationTest.cpp b/litmus-tests/tests/DoSkewSymCPRotationTest.cpp index 468dc2d0..5954f05e 100644 --- a/litmus-tests/tests/DoSkewSymCPRotationTest.cpp +++ b/litmus-tests/tests/DoSkewSymCPRotationTest.cpp @@ -79,34 +79,16 @@ * purposes. * * -- LICENSE END -- */ + +#include "Matrix.h" +#include "Vector.h" + #include #include #include -template -GLOBAL -void -DoSkewSCPRKernel(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - const T* vals = tiList + (idx*n); - auto A = flit::VectorCU(vals, 3).getUnitVector(); - auto B = flit::VectorCU(vals + 3, 3).getUnitVector(); - auto cross = A.cross(B); - auto sine = cross.L2Norm(); - auto cos = A ^ B; - auto sscpm = flit::MatrixCU::SkewSymCrossProdM(cross); - auto rMatrix = flit::MatrixCU::Identity(3) + - sscpm + (sscpm * sscpm) * ((1 - cos)/(sine * sine)); - auto result = rMatrix * A; - results[idx] = result.L1Distance(B); -} - template class DoSkewSymCPRotationTest: public flit::TestBase { public: @@ -116,17 +98,15 @@ class DoSkewSymCPRotationTest: public flit::TestBase { virtual size_t getInputsPerRun() override { return 6; } virtual std::vector getDefaultInput() override { auto n = getInputsPerRun(); - return flit::Vector::getRandomVector(n).getData(); + return Vector::getRandomVector(n).getData(); } protected: - virtual flit::KernelFunction* getKernel() override { return DoSkewSCPRKernel;} - virtual flit::Variant run_impl(const std::vector& ti) override { flit::info_stream << "entered " << id << std::endl; long double L1Score = 0.0; - flit::Vector A = { ti[0], ti[1], ti[2] }; - flit::Vector B = { ti[3], ti[4], ti[5] }; + Vector A = { ti[0], ti[1], ti[2] }; + Vector B = { ti[3], ti[4], ti[5] }; A = A.getUnitVector(); B = B.getUnitVector(); flit::info_stream << "A (unit) is: " << std::endl << A << std::endl; @@ -139,11 +119,11 @@ class DoSkewSymCPRotationTest: public flit::TestBase { auto cos = A ^ B; // flit::info_stream << "cosine: " << std::endl << crit << std::endl; flit::info_stream << "cosine: " << std::endl << cos << std::endl; - auto sscpm = flit::Matrix::SkewSymCrossProdM(cross); + auto sscpm = Matrix::SkewSymCrossProdM(cross); flit::info_stream << "sscpm: " << std::endl << sscpm << std::endl; - auto rMatrix = flit::Matrix::Identity(3) + + auto rMatrix = Matrix::Identity(3) + sscpm + (sscpm * sscpm) * ((1 - cos)/(sine * sine)); - // auto rMatrix = flit::Matrix::Identity(3) + + // auto rMatrix = Matrix::Identity(3) + // sscpm + (sscpm * sscpm) * ((1 - crit)/(sine * sine)); auto result = rMatrix * A; flit::info_stream << "rotator: " << std::endl << rMatrix << std::endl; diff --git a/litmus-tests/tests/KahanSum.cpp b/litmus-tests/tests/KahanSum.cpp index 6048c8f6..418c5411 100644 --- a/litmus-tests/tests/KahanSum.cpp +++ b/litmus-tests/tests/KahanSum.cpp @@ -129,9 +129,7 @@ namespace { //template<> std::vector getToRepeat() { return { 1.0, 1.0e8, -1.0e8 }; } template<> std::vector getToRepeat() { return { 1.0e4, PI, EXP, -1.0e4 }; } template<> std::vector getToRepeat() { return { 1.0e11, PI, EXP, -1.0e11 }; } -#ifndef __CUDA__ template<> std::vector getToRepeat() { return { 1.0e14, PI, EXP, -1.0e14 }; } -#endif } // end of unnamed namespace template diff --git a/src/Matrix.h b/litmus-tests/tests/Matrix.h similarity index 95% rename from src/Matrix.h rename to litmus-tests/tests/Matrix.h index fd162d92..8cf129a9 100644 --- a/src/Matrix.h +++ b/litmus-tests/tests/Matrix.h @@ -78,20 +78,22 @@ * shall not be used for advertising or product endorsement * purposes. * - * -- LICENSE END -- - */ + * -- LICENSE END -- */ #ifndef FLIT_MATRIX_H #define FLIT_MATRIX_H #include "Vector.h" +#include + #include // for std::initializer_list #include // for std::cout #include // for std::ostream #include // for std::vector -namespace flit { + +template class Vector; template class Matrix { @@ -123,9 +125,9 @@ class Matrix { for(uint x = 0; x < data.size(); ++x){ for(uint y = 0; y < data[0].size(); ++y){ if(data[x][y] != rhs.data[x][y]){ - info_stream << "in: " << __func__ << std::endl; - info_stream << "for x,y: " << x << ":" << y << std::endl; - info_stream << "this = " << data[x][y] << "; rhs = " << rhs.data[x][y] << std::endl; + flit::info_stream << "in: " << __func__ << std::endl; + flit::info_stream << "for x,y: " << x << ":" << y << std::endl; + flit::info_stream << "this = " << data[x][y] << "; rhs = " << rhs.data[x][y] << std::endl; retVal = false; break; } @@ -213,7 +215,7 @@ class Matrix { print() const { std::cout << *this; } -}; +}; // end of class Matrix template std::ostream& operator<<(std::ostream& os, Matrix const &m){ @@ -226,6 +228,4 @@ std::ostream& operator<<(std::ostream& os, Matrix const &m){ return os; } -} // end of namespace flit - #endif // FLIT_MATRIX_H diff --git a/litmus-tests/tests/RandHelper.cpp b/litmus-tests/tests/RandHelper.cpp new file mode 100644 index 00000000..f48036e8 --- /dev/null +++ b/litmus-tests/tests/RandHelper.cpp @@ -0,0 +1,99 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- */ + +#include "RandHelper.h" + +const std::vector float_rands = createRandSeq(RAND_VECT_SIZE); +const std::vector double_rands = createRandSeq(RAND_VECT_SIZE); +const std::vector long_rands = createRandSeq(RAND_VECT_SIZE); + +template<> +const std::vector& +getRandSeq() { return float_rands; } + +template<> +const std::vector& +getRandSeq() { return double_rands; } + +template<> +const std::vector& +getRandSeq() { return long_rands; } diff --git a/src/CUHelpers.h b/litmus-tests/tests/RandHelper.h similarity index 57% rename from src/CUHelpers.h rename to litmus-tests/tests/RandHelper.h index 82215863..61fd7fe0 100644 --- a/src/CUHelpers.h +++ b/litmus-tests/tests/RandHelper.h @@ -78,153 +78,39 @@ * shall not be used for advertising or product endorsement * purposes. * - * -- LICENSE END -- - */ + * -- LICENSE END -- */ -#ifndef CU_HELPERS_HPP -#define CU_HELPERS_HPP - -#if defined(__CPUKERNEL__) || !defined( __CUDA__) -#define HOST_DEVICE -#define HOST -#define DEVICE -#define GLOBAL -#else -#include -#include -#define HOST_DEVICE __host__ __device__ -#define HOST __host__ -#define DEVICE __device__ -#define GLOBAL __global__ -#endif -#include "flitHelpers.h" -#include "cuvector.h" +#ifndef RAND_HELPER_H +#define RAND_HELPER_H +#include #include -#include - -namespace flit { - -// TODO: test out trying to replace csqrt() with std::sqrt() -template -T -csqrt(T /*val*/){ return 0; } - -template<> -HOST_DEVICE -inline -float -csqrt(float val) { return sqrtf(val); } - -template<> -HOST_DEVICE -inline -double -csqrt(double val) { return sqrt(val);} - -template -T -cpow(T /*a*/, T /*b*/){ return 0; } - -template<> -HOST_DEVICE -inline -float -cpow(float a, float b) { return powf(a,b); } - -template<> -HOST_DEVICE -inline -double -cpow(double a, double b) { return pow(a,b); } - -template -T -ccos(T /*val*/){ return 0; } - -template<> -HOST_DEVICE -inline -float -ccos(float val){ return cosf(val); } - - -template<> -HOST_DEVICE -inline -double -ccos(double val){ return cos(val); } - -template -T -csin(T /*val*/){ return 0; } - -template<> -HOST_DEVICE -inline -float -csin(float val){ return sinf(val); } - -template<> -HOST_DEVICE -inline -double -csin(double val){ return sin(val); } - -void -initDeviceData(); - -DEVICE -const float* getRandSeqCU(); - -DEVICE -const uint_fast32_t* get16ShuffledCU(); //an array with 0-15 shuffled - -template -HOST_DEVICE -T -abs(T val){ - if(val > 0) return val; - else return val * (T)-1; -} +static const int RAND_SEED = 1; +static const int RAND_VECT_SIZE = 256; extern const std::vector float_rands; extern const std::vector double_rands; extern const std::vector long_rands; -extern const std::vector shuffled_16; - -GLOBAL void loadDeviceData(float* fsource, uint_fast32_t* ssource); - -inline void -initDeviceData() { -#ifdef __CPUKERNEL__ - cuda_float_rands = flit::float_rands.data(); - cuda_16_shuffle = flit::shuffled_16.data(); -#endif // __CPUKERNEL__ -#if defined(__CUDA__) && !defined(__CPUKERNEL__) - auto fsize = sizeof(float) * flit::float_rands.size(); - auto ssize = sizeof(uint_fast32_t) * flit::shuffled_16.size(); - float* tfloat; - uint_fast32_t* ssource; - checkCudaErrors(cudaMalloc(&tfloat, - fsize)); - checkCudaErrors(cudaMemcpy(tfloat, - flit::float_rands.data(), - fsize, - cudaMemcpyHostToDevice)); - checkCudaErrors(cudaMalloc(&ssource, - ssize)); - checkCudaErrors(cudaMemcpy(ssource, - flit::shuffled_16.data(), - ssize, - cudaMemcpyHostToDevice)); - loadDeviceData<<<1,1>>>(tfloat, ssource); - checkCudaErrors(cudaDeviceSynchronize()); -#endif // defined(__CUDA__) && !defined(__CPUKERNEL__) +template +const std::vector +createRandSeq(size_t size, int32_t seed = RAND_SEED){ + // there may be a bug with float uniform_real_dist + // it is giving very different results than double or long double + std::vector ret(size); + std::mt19937 gen; + gen.seed(seed); + std::uniform_real_distribution dist(-6.0, 6.0); + for(auto& i: ret) i = T(dist(gen)); + return ret; } -} // end of namespace flit +// this section provides a pregenerated random +// sequence that can be used by tests + +template +std::vector const & +getRandSeq(); -#endif // CU_HELPERS_HPP +#endif // RAND_HELPER_H diff --git a/litmus-tests/tests/ReciprocalMath.cpp b/litmus-tests/tests/ReciprocalMath.cpp index d2730b9a..b0b31204 100644 --- a/litmus-tests/tests/ReciprocalMath.cpp +++ b/litmus-tests/tests/ReciprocalMath.cpp @@ -81,10 +81,6 @@ * -- LICENSE END -- */ #include -#include - -#include - template class ReciprocalMath : public flit::TestBase { public: @@ -98,27 +94,19 @@ class ReciprocalMath : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector& ti) override { - T a = ti[0]; - T b = ti[1]; - T c = ti[2]; - T d = ti[3]; - T m = ti[4]; - - a = a/m; - b = b/m; - c = c/m; - d = d/m; - - const T score = a + b + c + d; - - flit::info_stream << id << ": score = " << score << std::endl; - - return score; + // float division is expensive. For optimization, the compiler may replace + // a = b / r + // with + // recip = 1 / r + // a = b * recip + // Usually worthwhile only if you divide by the same value repeatedly + T r = ti[4]; + T a = ti[0] / r; + T b = ti[1] / r; + T c = ti[2] / r; + T d = ti[3] / r; + return a + b + c + d; } - -protected: - using flit::TestBase::id; }; - REGISTER_TYPE(ReciprocalMath) diff --git a/litmus-tests/tests/RotateAndUnrotate.cpp b/litmus-tests/tests/RotateAndUnrotate.cpp index d93c5231..3c0b191d 100644 --- a/litmus-tests/tests/RotateAndUnrotate.cpp +++ b/litmus-tests/tests/RotateAndUnrotate.cpp @@ -79,6 +79,9 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include @@ -86,24 +89,6 @@ #include -template -GLOBAL -void -RaUKern(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - auto theta = M_PI; - const T* ti = tiList + (idx*n); - auto A = flit::VectorCU(ti, n); - auto orig = A; - A = A.rotateAboutZ_3d(theta); - A = A.rotateAboutZ_3d(-theta); - results[idx] = A.L1Distance(orig); -} - template class RotateAndUnrotate: public flit::TestBase { public: @@ -111,15 +96,13 @@ class RotateAndUnrotate: public flit::TestBase { virtual size_t getInputsPerRun() override { return 3; } virtual std::vector getDefaultInput() override { - return flit::Vector::getRandomVector(3).getData(); + return Vector::getRandomVector(3).getData(); } protected: - virtual flit::KernelFunction* getKernel() override { return RaUKern; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto theta = M_PI; - auto A = flit::Vector(ti); + auto A = Vector(ti); auto orig = A; flit::info_stream << "Rotate and Unrotate by " << theta << " radians, A is: " << A << std::endl; A.rotateAboutZ_3d(theta); diff --git a/litmus-tests/tests/RotateFullCircle.cpp b/litmus-tests/tests/RotateFullCircle.cpp index d1a0fb98..65baaa48 100644 --- a/litmus-tests/tests/RotateFullCircle.cpp +++ b/litmus-tests/tests/RotateFullCircle.cpp @@ -79,6 +79,9 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include @@ -89,25 +92,6 @@ namespace { const int iters = 200; } // end of unnamed namespace -template -GLOBAL -void -RFCKern(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - const T* ti = tiList + (idx*n); - auto A = flit::VectorCU(ti, n); - auto orig = A; - T theta = 2 * M_PI / iters; - for(int r = 0; r < iters; ++r){ - A = A.rotateAboutZ_3d(theta); - } - results[idx] = A.L1Distance(orig); -} - template class RotateFullCircle: public flit::TestBase { public: @@ -116,14 +100,12 @@ class RotateFullCircle: public flit::TestBase { virtual size_t getInputsPerRun() override { return 3; } virtual std::vector getDefaultInput() override { auto n = getInputsPerRun(); - return flit::Vector::getRandomVector(n).getData(); + return Vector::getRandomVector(n).getData(); } protected: - virtual flit::KernelFunction* getKernel() override {return RFCKern; } - virtual flit::Variant run_impl(const std::vector& ti) override { - flit::Vector A = flit::Vector(ti); + Vector A(ti); auto orig = A; T theta = 2 * M_PI / iters; flit::info_stream << "Rotate full circle in " << iters diff --git a/litmus-tests/tests/Shewchuk.h b/litmus-tests/tests/Shewchuk.h index aede5d77..e1a8822c 100644 --- a/litmus-tests/tests/Shewchuk.h +++ b/litmus-tests/tests/Shewchuk.h @@ -139,23 +139,23 @@ class Shewchuk { // Note: this does not set or return the cache. Only sum() does that. T sum2() { - T x, y, lo, yr, hi = 0.0; + T x, y, lo, yr, hi = 0.0; auto p = m_partials; auto n = p.size(); // This code was copied verbatim from Python's math.fsum() implementation - if (n > 0) { + if (n > 0) { hi = p[--n]; /* sum_exact(ps, hi) from the top, stop when the sum becomes inexact. */ - while (n > 0) { + while (n > 0) { x = hi; y = p[--n]; //assert(fabs(y) < fabs(x)); - hi = x + y; - yr = hi - x; + hi = x + y; + yr = hi - x; lo = y - yr; - if (lo != 0.0) + if (lo != 0.0) break; } /* Make half-even rounding work across multiple partials. @@ -165,8 +165,8 @@ class Shewchuk { error fixed-up, math.fsum() can guarantee commutativity. */ if (n > 0 && ((lo < 0.0 && p[n-1] < 0.0) || (lo > 0.0 && p[n-1] > 0.0))) { - y = lo * 2.0; - x = hi + y; + y = lo * 2.0; + x = hi + y; yr = x - hi; if (y == yr) { hi = x; diff --git a/litmus-tests/tests/ShewchukSum.cpp b/litmus-tests/tests/ShewchukSum.cpp index ecac3a90..727dbddb 100644 --- a/litmus-tests/tests/ShewchukSum.cpp +++ b/litmus-tests/tests/ShewchukSum.cpp @@ -91,7 +91,7 @@ template class ShewchukSum : public flit::TestBase { public: ShewchukSum(std::string id) : flit::TestBase(std::move(id)) {} - + virtual size_t getInputsPerRun() override { return 1000; } virtual std::vector getDefaultInput() override; @@ -124,9 +124,7 @@ namespace { template std::vector getToRepeat(); template<> std::vector getToRepeat() { return { 1.0, 1.0e8, 1.0, -1.0e8 }; } template<> std::vector getToRepeat() { return { 1.0, 1.0e100, 1.0, -1.0e100 }; } -#ifndef __CUDA__ template<> std::vector getToRepeat() { return { 1.0, 1.0e200, 1.0, -1.0e200 }; } -#endif } // end of unnamed namespace template diff --git a/litmus-tests/tests/TrianglePHeron.cpp b/litmus-tests/tests/TrianglePHeron.cpp index 133aae35..992e2855 100644 --- a/litmus-tests/tests/TrianglePHeron.cpp +++ b/litmus-tests/tests/TrianglePHeron.cpp @@ -89,15 +89,6 @@ namespace { int g_iters = 200; } -template -DEVICE -T getCArea(const T a, - const T b, - const T c){ - T s = (a + b + c ) / 2; - return flit::csqrt((T)s * (s-a) * (s-b) * (s-c)); -} - template T getArea(const T a, const T b, @@ -106,36 +97,6 @@ T getArea(const T a, return sqrt(s * (s-a) * (s-b) * (s-c)); } -template -GLOBAL -void -TrianglePHKern(const T* tiList, size_t n, double* results) { -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - auto start = tiList + (idx*n); - T maxval = start[0]; - T a = maxval; - T b = maxval; - T c = maxval * flit::csqrt((T)2.0); - const T delta = maxval / T(g_iters); - const T checkVal = (T)0.5 * b * a; - - double score = 0.0; - - for(T pos = 0; pos <= a; pos += delta){ - b = flit::csqrt(flit::cpow(pos, (T)2.0) + - flit::cpow(maxval, (T)2.0)); - c = flit::csqrt(flit::cpow(a - pos, (T)2.0) + - flit::cpow(maxval, (T)2.0)); - auto crit = getCArea(a,b,c); - score += std::abs(crit - checkVal); - } - results[idx] = score; -} - template class TrianglePHeron: public flit::TestBase { public: @@ -147,8 +108,6 @@ class TrianglePHeron: public flit::TestBase { } protected: - virtual flit::KernelFunction* getKernel() override {return TrianglePHKern; } - virtual flit::Variant run_impl(const std::vector& ti) override { T maxval = ti[0]; // start as a right triangle diff --git a/litmus-tests/tests/TrianglePSylv.cpp b/litmus-tests/tests/TrianglePSylv.cpp index ee96fa11..eadcf7ef 100644 --- a/litmus-tests/tests/TrianglePSylv.cpp +++ b/litmus-tests/tests/TrianglePSylv.cpp @@ -89,55 +89,15 @@ namespace { const int iters = 200; } // end of unnamed namespace -template -DEVICE -T getCArea(const T a, const T b, const T c) { - return flit::cpow(T(2.0), T(-2)) * - flit::csqrt(T((a + (b + c)) * - (a + (b - c)) * - (c + (a - b)) * - (c - (a - b)))); -} - template T getArea(const T a, const T b, const T c) { return pow(T(2.0), T(-2)) * sqrt(T((a + (b + c)) * - (a + (b - c)) * + (a + (b - c)) * (c + (a - b)) * (c - (a - b)))); } -template -GLOBAL -void -TrianglePSKern(const T* tiList, size_t n, double* results){ -#ifdef __CUDA__ - auto idx = blockIdx.x * blockDim.x + threadIdx.x; -#else - auto idx = 0; -#endif - const T* ti = tiList + (idx*n); - T maxval = ti[0]; - T a = maxval; - T b = maxval; - T c = maxval * flit::csqrt(T(2.0)); - const T delta = maxval / T(iters); - const T checkVal = T(0.5) * b * a; - - double score = 0.0; - - for(T pos = 0; pos <= a; pos += delta){ - b = flit::csqrt(flit::cpow(pos, T(2.0)) + - flit::cpow(maxval, T(2.0))); - c = flit::csqrt(flit::cpow(a - pos, T(2.0)) + - flit::cpow(maxval, T(2.0))); - auto crit = getCArea(a,b,c); - score += std::abs(crit - checkVal); - } - results[idx] = score; -} - template class TrianglePSylv: public flit::TestBase { public: @@ -149,8 +109,6 @@ class TrianglePSylv: public flit::TestBase { } protected: - virtual flit::KernelFunction* getKernel() override {return TrianglePSKern; } - virtual flit::Variant run_impl(const std::vector& ti) override { T maxval = ti[0]; // start as a right triangle diff --git a/src/Vector.h b/litmus-tests/tests/Vector.h similarity index 96% rename from src/Vector.h rename to litmus-tests/tests/Vector.h index 287df938..4a9a28a7 100644 --- a/src/Vector.h +++ b/litmus-tests/tests/Vector.h @@ -78,13 +78,15 @@ * shall not be used for advertising or product endorsement * purposes. * - * -- LICENSE END -- - */ + * -- LICENSE END -- */ #ifndef FLIT_VECTOR_H #define FLIT_VECTOR_H -#include "flitHelpers.h" +#include "Matrix.h" +#include "RandHelper.h" + +#include #include // for std::generate #include // for std::sqrt @@ -95,10 +97,7 @@ #include // for std::move #include // for std::vector -namespace flit { - -template -class Matrix; +template class Matrix; template class Vector { @@ -191,7 +190,7 @@ class Vector { Vector retVal(size()); std::vector seq(size()); iota(seq.begin(), seq.end(), 0); //load with seq beg w 0 - + shuffle(seq.begin(), seq.end(), std::mt19937(RAND_SEED)); //do pairwise swap for(uint i = 0; i < size(); i += 2){ @@ -208,10 +207,10 @@ class Vector { Matrix t = {{(T)cos(rads), (T)-sin(rads), 0}, {(T)sin(rads), (T)cos(rads), 0}, {0, 0, 1}}; - info_stream << "rotation matrix is: " << t << std::endl; + flit::info_stream << "rotation matrix is: " << t << std::endl; Vector tmp(*this); tmp = t * tmp; - info_stream << "in rotateAboutZ, result is: " << tmp << std::endl; + flit::info_stream << "in rotateAboutZ, result is: " << tmp << std::endl; return tmp; } @@ -279,7 +278,7 @@ class Vector { L2Norm() const { Vector squares(size()); T retVal = 0; - std::vector prods(data); + std::vector prods(data); reduce(prods, [&retVal](T e){retVal += e*e;}); return std::sqrt(retVal); } @@ -326,6 +325,4 @@ std::ostream& operator<<(std::ostream& os, Vector const &a){ return os; } -} // end of namespace flit - #endif // FLIT_VECTOR_H diff --git a/litmus-tests/tests/langois.cpp b/litmus-tests/tests/langois.cpp index 83c639cd..4b1dd1a2 100644 --- a/litmus-tests/tests/langois.cpp +++ b/litmus-tests/tests/langois.cpp @@ -83,6 +83,8 @@ // an EFT (error-free transformation) // see http://perso.ens-lyon.fr/nicolas.louvet/LaLo07b.pdf +#include "RandHelper.h" + #include #include @@ -131,19 +133,17 @@ class langDotFMA: public flit::TestBase { virtual std::vector getDefaultInput() override { return {}; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { FLIT_UNUSED(ti); using stype = typename std::vector::size_type; stype size = 16; - auto rand = flit::getRandSeq(); + auto rand = getRandSeq(); auto x = std::vector(rand.begin(), rand.begin() + size); auto y = std::vector(rand.begin() + size, rand.begin() + 2*size); std::vector s(size); - s[0] = x[0] * y[0]; + s[0] = x[0] * y[0]; for(stype i = 1; i < size; ++i){ s[i] = std::fma(x[i], y[i], s[i-1]); } @@ -166,13 +166,11 @@ class langCompDotFMA: public flit::TestBase { virtual std::vector getDefaultInput() override { return {}; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { FLIT_UNUSED(ti); using stype = typename std::vector::size_type; stype size = 16; - auto rand = flit::getRandSeq(); + auto rand = getRandSeq(); auto x = std::vector(rand.begin(), rand.begin() + size); auto y = std::vector(rand.begin() + size, @@ -204,13 +202,11 @@ class langCompDot: public flit::TestBase { virtual std::vector getDefaultInput() override { return {}; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { FLIT_UNUSED(ti); using stype = typename std::vector::size_type; stype size = 16; - auto rand = flit::getRandSeq(); + auto rand = getRandSeq(); auto x = std::vector(rand.begin(), rand.begin() + size); auto y = std::vector(rand.begin() + size, diff --git a/litmus-tests/tests/tinys.cpp b/litmus-tests/tests/tinys.cpp index 1570ff7d..b41e40cd 100644 --- a/litmus-tests/tests/tinys.cpp +++ b/litmus-tests/tests/tinys.cpp @@ -79,6 +79,10 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" +#include "RandHelper.h" + #include #include @@ -98,8 +102,6 @@ class FtoDecToF: public flit::TestBase { } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { std::numeric_limits nlim; // from https://en.wikipedia.org/wiki/IEEE_floating_point @@ -127,8 +129,6 @@ class subnormal: public flit::TestBase { return { std::numeric_limits::min() }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { return ti[0] - ti[0] / 2; } @@ -145,17 +145,15 @@ class dotProd: public flit::TestBase { virtual std::vector getDefaultInput() override { return {}; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { FLIT_UNUSED(ti); auto size = 16; - auto rand = flit::getRandSeq(); + auto rand = getRandSeq(); - flit::Vector A(std::vector(rand.begin(), + Vector A(std::vector(rand.begin(), rand.begin() + size)); - flit::Vector B(std::vector(rand.begin() + size, + Vector B(std::vector(rand.begin() + size, rand.begin() + 2*size)); return A ^ B; } @@ -174,11 +172,9 @@ class simpleReduction: public flit::TestBase { virtual std::vector getDefaultInput() override { return {}; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { FLIT_UNUSED(ti); - auto vals = flit::getRandSeq(); + auto vals = getRandSeq(); auto sublen = vals.size() / 4 - 1; T sum = 0; for(uint32_t i = 0; i < sublen; i += 4){ @@ -230,8 +226,6 @@ class addTOL : public flit::TestBase { } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = ti[0] + ti[1] + ti[2]; return res; @@ -251,8 +245,6 @@ class addSub: public flit::TestBase { return { T(1.0) }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { std::numeric_limits nls; auto man_bits = nls.digits; @@ -272,14 +264,12 @@ class divc: public flit::TestBase { virtual size_t getInputsPerRun() override { return 2; } virtual std::vector getDefaultInput() override { return { - flit::getRandSeq()[0], - flit::getRandSeq()[1], + getRandSeq()[0], + getRandSeq()[1], }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = ti[0] / ti[1]; return res; @@ -295,12 +285,10 @@ class zeroMinusX: public flit::TestBase { virtual size_t getInputsPerRun() override { return 1; } virtual std::vector getDefaultInput() override { - return { flit::getRandSeq()[0] }; + return { getRandSeq()[0] }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = T(0.0) - ti[0]; return res; @@ -316,12 +304,10 @@ class xMinusZero: public flit::TestBase { virtual size_t getInputsPerRun() override { return 1; } virtual std::vector getDefaultInput() override { - return { flit::getRandSeq()[0] }; + return { getRandSeq()[0] }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = ti[0] - T(0.0); return res; @@ -337,11 +323,9 @@ class zeroDivX: public flit::TestBase { virtual size_t getInputsPerRun() override { return 1; } virtual std::vector getDefaultInput() override { - return { flit::getRandSeq()[0] }; + return { getRandSeq()[0] }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = (T)0.0 / ti[0]; return res; @@ -357,11 +341,9 @@ class xDivOne: public flit::TestBase { virtual size_t getInputsPerRun() override { return 1; } virtual std::vector getDefaultInput() override { - return { flit::getRandSeq()[0] }; + return { getRandSeq()[0] }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { T res = ti[0] / T(1.0); return res; @@ -377,11 +359,9 @@ class xDivNegOne: public flit::TestBase { virtual size_t getInputsPerRun() override { return 1; } virtual std::vector getDefaultInput() override { - return { flit::getRandSeq()[0] }; + return { getRandSeq()[0] }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { T res = ti[0] / T(-1.0); return res; @@ -398,13 +378,11 @@ class negAdivB: public flit::TestBase { virtual size_t getInputsPerRun() override { return 2; } virtual std::vector getDefaultInput() override { return { - flit::getRandSeq()[0], - flit::getRandSeq()[1], + getRandSeq()[0], + getRandSeq()[1], }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = -(ti[0] / ti[1]); return res; @@ -421,13 +399,11 @@ class negAminB: public flit::TestBase { virtual size_t getInputsPerRun() override { return 2; } virtual std::vector getDefaultInput() override { return { - flit::getRandSeq()[0], - flit::getRandSeq()[1], + getRandSeq()[0], + getRandSeq()[1], }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = -(ti[0] - ti[1]); return res; @@ -443,12 +419,10 @@ class xMinusX: public flit::TestBase { virtual size_t getInputsPerRun() override { return 1; } virtual std::vector getDefaultInput() override { - return { flit::getRandSeq()[0] }; + return { getRandSeq()[0] }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = ti[0] - ti[0]; return res; @@ -465,13 +439,11 @@ class negAplusB: public flit::TestBase { virtual size_t getInputsPerRun() override { return 2; } virtual std::vector getDefaultInput() override { return { - flit::getRandSeq()[0], - flit::getRandSeq()[1], + getRandSeq()[0], + getRandSeq()[1], }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = -(ti[0] + ti[1]); return res; @@ -488,14 +460,12 @@ class aXbDivC: public flit::TestBase { virtual size_t getInputsPerRun() override { return 3; } virtual std::vector getDefaultInput() override { return { - flit::getRandSeq()[0], - flit::getRandSeq()[1], - flit::getRandSeq()[2], + getRandSeq()[0], + getRandSeq()[1], + getRandSeq()[2], }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = ti[0] * (ti[1] / ti[2]); return res; @@ -512,14 +482,12 @@ class aXbXc: public flit::TestBase { virtual size_t getInputsPerRun() override { return 3; } virtual std::vector getDefaultInput() override { return { - flit::getRandSeq()[0], - flit::getRandSeq()[1], - flit::getRandSeq()[2], + getRandSeq()[0], + getRandSeq()[1], + getRandSeq()[2], }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = ti[0] * (ti[1] * ti[2]); return res; @@ -536,14 +504,12 @@ class aPbPc: public flit::TestBase { virtual size_t getInputsPerRun() override { return 3; } virtual std::vector getDefaultInput() override { return { - flit::getRandSeq()[0], - flit::getRandSeq()[1], - flit::getRandSeq()[2], + getRandSeq()[0], + getRandSeq()[1], + getRandSeq()[2], }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { auto res = ti[0] + (ti[1] + ti[2]); return res; @@ -562,14 +528,12 @@ class xPc1EqC2: public flit::TestBase { const T eps = std::numeric_limits::min(); const T next = std::nextafter(eps, std::numeric_limits::infinity()); return { - flit::getRandSeq()[0], + getRandSeq()[0], eps, next, }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { bool res = ti[0] + ti[1] == ti[2]; return res ? 1.0 : 0.0; @@ -588,14 +552,12 @@ class xPc1NeqC2: public flit::TestBase { const T eps = std::numeric_limits::min(); const T next = std::nextafter(eps, std::numeric_limits::infinity()); return { - flit::getRandSeq()[0], + getRandSeq()[0], eps, next, }; } protected: - virtual flit::KernelFunction* getKernel() override { return nullptr; } - virtual flit::Variant run_impl(const std::vector& ti) override { bool res = (ti[0] + ti[1] != ti[2]); return res ? 1.0 : 0.0; diff --git a/pgm/BayesNetworkExamples.r b/pgm/BayesNetworkExamples.r deleted file mode 100644 index 1d6341c6..00000000 --- a/pgm/BayesNetworkExamples.r +++ /dev/null @@ -1,176 +0,0 @@ -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -#################################### -## Simple chain example: x -> y -> z -#################################### -x = createCPT(list("x"), probs = c(0.3, 0.7), levelsList = list(c("T", "F"))) -y.x = createCPT(list("y", "x"), probs = c(0.8, 0.4, 0.2, 0.6), - levelsList = list(c("T", "F"), c("T", "F"))) -z.y = createCPT(list("z", "y"), probs = c(0.5, 0.6, 0.5, 0.4), - levelsList = list(c("T", "F"), c("T", "F"))) - -(xyzNet = list("x" = x, "y" = y.x, "z" = z.y)) - -## Some simple operations you might try to check your code -productFactor(x, y.x) -productFactor(productFactor(x, y.x), z.y) -marginalizeFactor(productFactor(x, y.x), "x") -marginalizeFactor(productFactor(y.x, z.y), "z") - -## Notice in the observe function, you just need to delete rows that are -## inconsistent with the given observations. Factors do not need to be combined -## or normalized in this step. -observe(xyzNet, "x", "T") -observe(xyzNet, c("x", "y"), c("T", "T")) - -## Marginalize must first combine all factors involving the variable to -## marginalize. Again, this operation may lead to factors that aren't -## probabilities. -marginalize(xyzNet, "x") -marginalize(xyzNet, "y") -marginalize(xyzNet, "z") -marginalize(xyzNet, c("x", "z")) - -############################# -## Bishop book (Ch 8) example -############################# -b = createCPT(list("battery"), probs = c(0.9, 0.1), levelsList = list(c(1, 0))) -f = createCPT(list("fuel"), probs = c(0.9, 0.1), levelsList = list(c(1, 0))) -g.bf = createCPT(list("gauge", "battery", "fuel"), - probs = c(0.8, 0.2, 0.2, 0.1, 0.2, 0.8, 0.8, 0.9), - levelsList = list(c(1, 0), c(1, 0), c(1, 0))) - -carNet = list("battery" = b, "fuel" = f, "gauge" = g.bf) - -## Some examples: -## Notice that different order of operations give the same answer -## (rows/columns may be permuted) -productFactor(productFactor(b, f), g.bf) -productFactor(productFactor(g.bf, f), b) - -marginalizeFactor(productFactor(g.bf, b), "gauge") -productFactor(marginalizeFactor(g.bf, "gauge"), b) - -productFactor(marginalizeFactor(productFactor(g.bf, b), "battery"), f) -marginalizeFactor(productFactor(productFactor(g.bf, f), b), "battery") - -marginalizeFactor(productFactor(marginalizeFactor(productFactor(g.bf, b), "battery"), f), "gauge") -marginalizeFactor(productFactor(marginalizeFactor(productFactor(g.bf, b), "battery"), f), "fuel") - -## Examples computed in book (see pg. 377) -infer(carNet, c("battery", "fuel"), NULL, NULL) ## (8.30) -infer(carNet, c("battery"), "fuel", 0) ## (8.31) -infer(carNet, c("battery"), "gauge", 0) ## (8.32) -infer(carNet, NULL, c("gauge", "battery"), c(0, 0)) ## (8.33) - - -########################################################################### -## Kevin Murphy's Example: http://www.cs.ubc.ca/~murphyk/Bayes/bnintro.html -########################################################################### -c = createCPT(list("cloudy"), probs = c(0.5, 0.5), - levelsList = list(c("F", "T"))) -r.c = createCPT(list("rain", "cloudy"), probs = c(0.8, 0.2, 0.2, 0.8), - levelsList = list(c("F", "T"), c("F", "T"))) -s.c = createCPT(c("sprinkler", "cloudy"), probs = c(0.5, 0.9, 0.5, 0.1), - levelsList = list(c("F", "T"), c("F", "T"))) -w.sr = createCPT(list("wet", "sprinkler", "rain"), - probs = c(1, 0.1, 0.1, 0.01, 0, 0.9, 0.9, 0.99), - levelsList = list(c("F", "T"), c("F", "T"), c("F", "T"))) - -grassNet = list("cloudy" = c, "rain" = r.c, "sprinkler" = s.c, "wet" = w.sr) - -## Test your infer() method by replicating the computations on the website!! -infer(grassNet, c('cloudy', 'rain'), c('wet'), 'T') -infer(grassNet, c('cloudy', 'sprinkler'), c('wet'), 'T') -infer(grassNet, c('cloudy', 'rain', 'sprinkler'), NULL, NULL) - -########################################################################### -## Class example -########################################################################### -traffic = createCPT(list("traffic"), probs = c(0.5, 0.5), levelsList = list(c("F", "T"))) -alarm = createCPT(list("alarm"), probs = c(0.5, 0.5), levelsList = list(c("F", "T"))) -late = createCPT(list("late", "alarm", "traffic"), - probs = c(0.8, 0.2, 0.8, 0.6, 0.2, 0.8, 0.2, 0.4), - levelsList = list(c("F", "T"), c("F", "T"), c("F", "T"))) - -lateNet = list(traffic, alarm, late) diff --git a/pgm/BayesianNetworks.r b/pgm/BayesianNetworks.r deleted file mode 100644 index 375615aa..00000000 --- a/pgm/BayesianNetworks.r +++ /dev/null @@ -1,369 +0,0 @@ -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -## Function to create a conditional probability table -## Conditional probability is of the form p(x1 | x2, ..., xk) -## varnames: vector of variable names (strings) -## -- NOTE: first variable listed will be x1, remainder will be parents, x2, ..., xk -## probs: vector of probabilities for the flattened probability table -## levelsList: a list containing a vector of levels (outcomes) for each variable -## See the BayesNetExamples.r file for examples of how this function works -createCPT = function(varnames, probs, levelsList) -{ - ## Check dimensions agree - if(length(probs) != prod(sapply(levelsList, FUN=length))) - return(NULL) - - ## Set up table with appropriate dimensions - m = length(probs) - n = length(varnames) - g = matrix(0, m, n) - - ## Convert table to data frame (with column labels) - g = as.data.frame(g) - names(g) = varnames - - ## This for loop fills in the entries of the variable values - k = 1 - for(i in n:1) - { - levs = levelsList[[i]] - g[,i] = rep(levs, each = k, times = m / (k * length(levs))) - k = k * length(levs) - } - - return(data.frame(probs = probs, g)) -} - -## Build a CPT from a data frame -## Constructs a conditional probability table as above, but uses frequencies -## from a data frame of data to generate the probabilities. -createCPT.fromData = function(x, varnames) -{ - levelsList = list() - - for(i in 1:length(varnames)) - { - name = varnames[i] - levelsList[[i]] = sort(unique(x[,name])) - } - - m = prod(sapply(levelsList, FUN=length)) - n = length(varnames) - g = matrix(0, m, n) - - ## Convert table to data frame (with column labels) - g = as.data.frame(g) - names(g) = varnames - - ## This for loop fills in the entries of the variable values - k = 1 - for(i in n:1) - { - levs = levelsList[[i]] - g[,i] = rep(levs, each = k, times = m / (k * length(levs))) - k = k * length(levs) - } - - ## This is the conditional probability column - probs = numeric(m) - numLevels = length(levelsList[[1]]) - skip = m / numLevels - - ## This chunk of code creates the vector "fact" to index into probs using - ## matrix multiplication with the data frame x - fact = numeric(ncol(x)) - lastfact = 1 - for(i in length(varnames):1) - { - j = which(names(x) == varnames[i]) - fact[j] = lastfact - lastfact = lastfact * length(levelsList[[i]]) - } - ## Compute unnormalized counts of subjects that satisfy all conditions - a = as.matrix(x - 1) %*% fact + 1 - for(i in 1:m) - probs[i] = sum(a == i) - - ## Now normalize the conditional probabilities - for(i in 1:skip) - { - denom = 0 ## This is the normalization - for(j in seq(i, m, skip)) - denom = denom + probs[j] - for(j in seq(i, m, skip)) - { - if(denom != 0) - probs[j] = probs[j] / denom - } - } - - return(data.frame(probs = probs, g)) -} - -# This is almost the same as the function above but implemented differently -# Note: the first name in varnames is considered the dependent variable -# which is conditioned on all of the other varnames. -# This implementation is slower than the one above, but it is easier -# for me to understand. -createCPT.fromData2 = function(x, varnames) -{ - n = nrow(x) - joint = aggregate(list(probs = rep(1/n, n)), by=x[varnames], FUN='sum') - others = marginalizeFactor(joint, varnames[1]) - names(others)[names(others) == 'probs'] = 'probs.others' - merged = merge(joint, others, by=varnames[-1]) - merged$probs = merged$probs / merged$probs.others - merged = merged[c('probs', varnames)] - return(merged) -} - -## Rows of A that match the columns and values of frameRow -## A: A frame -## toMatch: A list of name -> value pairs -## namesToMatch: a list of corresponding names if toMatch is a vector -## -## All of the columns of frameRow need to exist in A since they are all -## used to check which row numbers are to be returned. -matchingRows = function(A, toMatch) -{ - rows = TRUE - for (name in names(toMatch)) - rows = rows & (A[name] == toMatch[[name]]) - which(rows) -} - -## Product of two factors -## A, B: two factor tables -## -## Should return a factor table that is the product of A and B. -## You can assume that the product of A and B is a valid operation. -productFactor = function(A, B) -{ - # Rename the column name for probs in both tables - names(A)[names(A) == 'probs'] = 'probs.A' - names(B)[names(B) == 'probs'] = 'probs.B' - - # Find the common column names - commonNames = setdiff(intersect(names(A), names(B)), c('probs')) - - # Merge the two tables and product their probabilities - merged = merge(A, B, by=commonNames) - merged$probs = merged$probs.A * merged$probs.B - - # Reorder columns and throw away the probs.A and probs.B columns - columns = setdiff(names(merged), c('probs', 'probs.A', 'probs.B')) - columns = c('probs', columns) - merged = merged[columns] - return(merged) -} - -## Marginalize a variable from a factor -## A: a factor table -## margVar: a string of the variable name to marginalize -## -## Should return a factor table that marginalizes margVar out of A. -## You can assume that margVar is on the left side of the conditional. -marginalizeFactor = function(A, margVar) -{ - remainingVars = setdiff(names(A), c('probs', margVar)) - if (length(remainingVars) > 0 ) - { - marginalized = aggregate(A['probs'], by = A[remainingVars], FUN = 'sum') - # Reorder columns - marginalized = marginalized[c('probs', setdiff(names(marginalized), 'probs'))] - } - else - marginalized = data.frame(probs = 1) - return(marginalized) -} - -## Marginalize a list of variables -## bayesnet: a list of factor tables -## margVars: a vector of variable names (as strings) to be marginalized -## -## Should return a Bayesian network (list of factor tables) that results -## when the list of variables in margVars is marginalized out of bayesnet. -marginalize = function(bayesnet, margVars) -{ - for (i in seq_len(length(margVars))) - { - # Create a map of (margvar) -> (indexes of tables having margvar) - varTblIdxMap = sapply( - margVars, # One entry per margVar - function (x) as.vector(which( # Convert list of bools to vector of ints where TRUE - sapply( # Tally which tables have margVar - bayesnet, - function (y) x %in% names(y) # margVar %in% names(tbl) is a single TRUE or FALSE - ) - )), - simplify = FALSE # Keep the result as a list, not a vector - ) - # Sort the map by the number of tables containing that variable - varTblIdxMap = varTblIdxMap[order(sapply(varTblIdxMap, length))] - - # Take the top one - margVar = names(varTblIdxMap)[1] - tableIdx = varTblIdxMap[[1]] - - # Remove the margVar from the list - idx = which(margVars == margVar) - margVars = margVars[-idx] - - # If there are tables to marginalize for this variable, then do it - if (length(tableIdx) > 0) - { - # Grab the tables out and remove them from the bayesnet - # Remove the tables from the bayesnet - tables = bayesnet[tableIdx] - bayesnet = bayesnet[-tableIdx] - - # Merge the tables together to one joint table - merged = Reduce(productFactor, tables) - - # Marginalize the factor out - merged = marginalizeFactor(merged, margVar) - - # Add the marginalized joint dist back to the bayesnet - bayesnet[[length(bayesnet) + 1]] = merged - } - } - return(bayesnet) -} - -## Observe values for a set of variables -## bayesnet: a list of factor tables -## obsVars: a vector of variable names (as strings) to be observed -## obsVals: a vector of values for corresponding variables (in the same order) -## -## Set the values of the observed variables. Other values for the variables -## should be removed from the tables. You do not need to normalize the factors -## to be probability mass functions. -observe = function(bayesnet, obsVars, obsVals) -{ - # Construct a list of var -> val - toFind = as.list(obsVals) - names(toFind) = obsVars - - # For each table, only keep the rows that match toFind - for(i in 1:length(bayesnet)) - { - tbl = bayesnet[[i]] - - subVars = obsVars[obsVars %in% names(tbl)] - subToFindNames = intersect(names(toFind), names(tbl)) - if (length(subToFindNames) > 0) - { - rowsToKeep = matchingRows(tbl, toFind[subToFindNames]) - bayesnet[[i]] = tbl[rowsToKeep,] - } - } - return(bayesnet) -} - -## Run inference on a Bayesian network -## bayesnet: a list of factor tables -## margVars: a vector of variable names to marginalize -## obsVars: a vector of variable names to observe -## obsVals: a vector of values for corresponding variables (in the same order) -## -## This function should run marginalization and observation of the sets of -## variables. In the end, it should return a single joint probability table. The -## variables that are marginalized should not appear in the table. The variables -## that are observed should appear in the table, but only with the single -## observed value. The variables that are not marginalized or observed should -## appear in the table with all of their possible values. The probabilities -## should be normalized to sum to one. -infer = function(bayesnet, margVars, obsVars, obsVals) -{ - # Observe & Marginalize - bayesnet = observe(bayesnet, obsVars, obsVals) - bayesnet = marginalize(bayesnet, margVars) - - # Combine the remaining tables - joint = Reduce(productFactor, bayesnet) - - # Normalize the table - joint$probs = joint$probs / sum(joint$probs) - - return(joint) -} diff --git a/pgm/filter.py b/pgm/filter.py deleted file mode 100755 index 997b1e8c..00000000 --- a/pgm/filter.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -import csv -import sys -import argparse - -class Run(object): - def __init__(self, csv_file): - self.csv = csv_file - self.fields_to_exclude = [ - 'score0d', - 'score1', - 'score1d', - 'sort', - 'run', - 'host', - 'file', - 'index', - ] - self.field_to_diff = 'score0' - self.compare_against = { - 'optl': '-O0', - 'switches': '', - } - - self.rows = [] - self.fields = [] - self.__read_csv() - - self.other_fields = set(self.fields).difference( - set(self.compare_against.keys() + [self.field_to_diff])) - - self.distinct_vals = {} - for key in self.fields: - self.distinct_vals[key] = sorted(set(x[key] for x in self.rows)) - - self.compare_rows = {} - self.__find_compare_rows() - - self.filtered = [] - self.__filter() - - def __read_csv(self): - with open(self.csv, 'r') as fin: - reader = csv.DictReader(fin) - self.rows = [x for x in reader] - self.fields = [x for x in sorted(self.rows[0].keys()) - if x not in self.fields_to_exclude] - - def __row_to_other_key(self, row): - vals = [row[k] for k in self.other_fields] - return tuple(sorted(vals)) - - def __find_compare_rows(self): - for row in self.rows: - if all(row[k] == v for k, v in self.compare_against.iteritems()): - key = self.__row_to_other_key(row) - self.compare_rows[key] = row - - def __filter(self): - for row in self.rows: - newrow = {} - for key in self.fields: - if key == self.field_to_diff: - other_key = self.__row_to_other_key(row) - gt_val = self.compare_rows[other_key][self.field_to_diff] - newrow[key] = 1 if gt_val == row[self.field_to_diff] else 0 - else: - newrow[key] = self.distinct_vals[key].index(row[key]) - self.filtered.append(newrow) - - def write_distinct_vals(self, outfile): - with open(outfile, 'w') as optout: - writer = csv.writer(optout, lineterminator='\n') - for name in self.distinct_vals.keys(): - writer.writerow(['num', name]) - i = 0 - for val in self.distinct_vals[name]: - writer.writerow([i, val]) - i += 1 - optout.write('\n') - - def write_filtered(self, outcsv): - with open(outcsv, 'w') as fout: - writer = csv.DictWriter(fout, self.fields, lineterminator='\n') - writer.writerow(dict(zip(self.fields, - sorted(["'" + x + "'" for x in self.fields])))) - writer.writerows(self.filtered) - -def main(arguments): - 'Main entry point' - parser = argparse.ArgumentParser( - description=''' - Converts incsv into a format - that can be used by the R - code and saves it as outfolder. - ''') - parser.add_argument('incsv') - parser.add_argument('outcsv') - parser.add_argument('-o', '--out-opt-file') - args = parser.parse_args(args=arguments) - - run = Run(args.incsv) - - if args.out_opt_file is not None: - run.write_distinct_vals(args.out_opt_file) - - run.write_filtered(args.outcsv) - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/plans/bisect-plan.md b/plans/bisect-plan.md new file mode 100644 index 00000000..d58662b6 --- /dev/null +++ b/plans/bisect-plan.md @@ -0,0 +1,220 @@ +# FLiT Bisect Plan + +The user adds custom build specifications to `custom.mk`. This file should be +leveraged in the autogenerated Makefiles, as well as the customization in the +`flit-config.toml` file. + +Here are the following design choices for accomplishing such a task: + +1. compile using Python and skip Makefiles altogether + - Too much work and not enough benefit. Also unmaintainable +2. Generate a new `Makefile` similar to the already generated `Makefile`. This + could either be within the current directory or within `/tmp`. +3. Change the original generated `Makefile` to include an arbitrary `.mk` file + based on a variable that is assigned in the call to `make`. + - This approach seems more reasonable since the recursive `Makefile` change + has been delivered, because we do not have any overhead until we are + compiling a particular mode. + +## Generate Source Files + +The sources we need to compile will either be located in the autogenerated +`Makefile` (using the `$(wildcard)` GNU make function), or in `custom.mk`. We +want the user to be able to specify additional source files in `custom.mk`, so +therefore, we need to query the `Makefile` for the list of source files. + +There is a cool hack from [eric melski's blog](https://blog.melski.net/2010/11/30/makefile-hacks-print-the-value-of-any-variable/): + +```make +print-%: + @echo '$*=$($*)' +``` + +or the expanded version: + +```make +print-%: + @echo '$*=$($*)' + @echo ' origin = $(origin $*)' + @echo ' flavor = $(flavor $*)' + @echo ' value = $(value $*)' +``` + +These rules can actually be placed in another `Makefile` and included separately + +```bash +$ make -f printvar.mk -f Makefile print-SOURCE +``` + +## Identify the problem source file + +Assuming that linking is not where the problem is introduced, but instead +during compilation, we can identify the problem source file. This is done +using autogenerated Makefiles. The algorithm is framed such that you have a +bag of eggs, and you can smell that there is at least one bad egg in the bag. +Given the ability to smell a bag, we want to smell as few times as possible to +identify all bad eggs. + +The algorithm is described as follows. You have some bags you can use during +the algorithm + +1. **Test bag:** bag that we smell. May have the bad egg we want to find +2. **Alternative bag:** bag that may have the bad egg we want to find +3. **Ignore bag:** could have bad eggs, but not the one we are looking for +4. **Bad bag:** where to put found bad eggs + +In the simplest case, there is only one bad egg. Let us cover that case first. + +1. Put all eggs into the **test bag**. +2. If the **test bag** is empty, then return the **bad bag** +3. Smell the **test bag**. If it does not smell bad, then swap the contents of + the **test bag** and the **alternative bag**. +4. Place the eggs from the **alternative bag** into the **ignore bag**. +5. If the **test bag** only has one egg, then place it into the **bad bag**. + Put all eggs from the **ignore bag** into the **test bag** to find the next + bad egg. Go to step 2 +6. Put half of the eggs from the **test bag** into the **alternative bag**. + Go to step 2 + +This algorithm actually has logic to find all bad eggs, one at a time. Each +egg takes $O(\log n)$ time to find, which makes this algorithm $O(k \log n)$ +time, where $k$ is the number of bad eggs and $n$ is the total number of eggs. + +There is a slight optimization that can be done by adding one more bag called +**good bag**. In step 3, instead of swapping the contents of the **test bag** +and the **alternative bag**, simply place the contents of the **test bag** into +the **good bag** and place the contents of the **alternative bag** into the +**test bag**. This optimization makes subsequent passes not need to check +those that were already identified as good eggs. + +## Identify interacting source files + +However, the algorithm above does not work if you need more than one of the bad +eggs to be in the same bag for it to smell bad enough to detect. Can we update +the algorithm to handle cases where more than one bad egg is needed in the same +bag to trigger a bad smell? + + +TODO: try to come up with and test an algorithm for this. + + + +## Find problem symbol + +We want to be able to find the problem symbol within the set of bad files. +There are a few approaches to doing this. Each has its advantages and +drawbacks. All approaches are amenable to using the bisect approach. + +1. Split the source code into two files +2. Use compiler-specific pragmas to disable optimizations +3. Use LLVM to disable optimizations for target function on the intermediate + representation. +4. Mix and match the compiled symbols from the good and bad compilations + + +### Split source code + +This approach has the advantage that it is straightforward when performed +manually. Simply cut and paste functions from one file into the other and +compile and test. It is easy to understand and easy to manually perform. + +This approach has a few downsides: + +1. Difficult to automate: requires C++ parsing, which is not simple +2. Need to deal with static functions, having a copy in each file +3. Having these functions split may influence inlining optimizations + + +TODO: are there other optimizations this approach limits? + + + +### Compiler-specific pragmas + +A similar approach to this involves using pragmas in the code to disable +optimizations for particular functions. This approach has an additional +drawback that it is not compiler agnostic, meaning we would need to do it +differently depending on the type of compiler we are using. + + +### LLVM disable optimizations + +Instead of modifying the source code, we could tell the LLVM compiler to not +optimize specific functions that are represented in the LLVM intermediate +representation. + +The benefits of this approach are that only the functions we do not want +optimized are not optimized. This means that those functions that are +optimized can make use of inlining and everything else. And we will be able to +target these function before optimization occurs. + +The downsides are that it only works for LLVM, and it will take a long time to +develop an LLVM plugin. + + +### Mix and match compiled symbols + +This approach has the advantage of allowing the compiler to optimize the same +way as it always has, but simply take the symbols we want after the fact. That +should make this a more robust method. + +This approach has a few downsides: + +1. Very complex: difficult to get it to compile into something that can run +2. Inlining can give confusing results and either hide which function is + actually to blame or return the wrong function entirely. +3. May not even be possible without writing my own tool. + + +TODO: make tests that check this functionality with +TODO- (1) both shared, +TODO- (2) gt shared only, +TODO- (3) trouble shared only, and +TODO- (4) inlining. + + +I have actually found a way that works, but may have additional drawbacks. Let +me describe first the approach that was able to correctly identify the dot +product within the `Vector` class in MFEM for `Example08`. + +1. Recompile both the good object file and the bad object file with `-fPIC` +2. Create a list of all symbols in the bad object file: + `nm .o | cut -c19- > all-symbols.txt` +3. Split those symbols into the test set (`trouble-symbols.txt`) and the + alternative set (`good-symbols.txt`) +4. Mark all symbols in the test set as local within the good object file: + `objcopy --localize-symbols=trouble-symbols.txt .o -copy.o` +5. Only keep symbols in the test set as local within the bad object file: + `objcopy --strip-all --keep-symbols=trouble-symbols.txt .o -copy.o` +6. Create a shared library with the one bad object file: + `g++ -shared -o lib/lib-copy.so obj/-copy.o` +7. Create a shared library with the one good object file: + `g++ -shared -o lib/lib-copy.so obj/-copy.o` +8. Link the shared libraries in the correct order + `g++ -Llib -Wl,-rpath=$(pwd)/lib -l -l` + +This alternative approach has the downside of requiring `-fPIC` when compiling +the object files of interest. This particular flag tells the compiler to +generate position-independent code. This also has the byproduct that inlining +is disabled for all externally visible symbols, since the compiler cannot +ensure that certain functions won't get overridden with something like +`LD_PRELOAD`. + +Quoted from Thiago Macieira [here](https://www.macieira.org/blog/2012/01/sorry-state-of-dynamic-libraries-on-linux/) + + > The `-fPIC` option doesn't enable only position-independent code. It also + > enables ELF symbol interposition, which is when another module "steals" the + > symbol. That happens normally by way of the copy relocations, but can also + > happen if an `LD_PRELOAD`'ed module were to override those symbols. So the + > compiler and linker must produce code that deals with that possibility. + +It may be possible to compile in the trouble object file and then only link +against the good shared library, telling the linker to prefer symbols from the +shared library over those in the executable. Or perhaps we could turn certain +symbols local and that would have the same effect. This needs to be +investigated. + +We also need to deal with relocation tables, which has a description found +[here](https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-54839.html). + + diff --git a/plans/clang-versions.md b/plans/clang-versions.md new file mode 100644 index 00000000..5fbafed8 --- /dev/null +++ b/plans/clang-versions.md @@ -0,0 +1,23 @@ +# Compiler Versions + +When I ran the experiment during the summer (April 2017), I used Clang version 4.0.0, which was release on 13 March 2017. For the run being done on 21 March 2018, I am using Clang version 5.0.1 which was released on 21 December 2017. I would like to use Clang version 6.0.0 that was released on 08 March 2018. I get the release dates from the [LLVM Releases page](http://releases.llvm.org). + + +| Run Date | Clang | GCC | Intel | +|---------------|--------|--------|---------| +| 13 March 2017 | v4.0.0 | v4.9.2 | v16.0.1 | +| 21 March 2018 | v5.0.1 | v7.3.1 | v18.0.1 | + + +| Version | Release Date | +|--------------|------------------| +| Clang 4.0.0 | 13 March 2017 | +| Clang 5.0.1 | 21 December 2017 | +| Clang 6.0.0 | 08 March 2018 | +| GCC 4.9.2 | 30 October 2014 | +| GCC 7.3.1 | 25 January 2018 | +| Intel 16.0.1 | 21 October 2015 | +| Intel 18.0.1 | 18 October 2017 | + +As of this writing (21 March 2018), the latest version of each compiler is GCC +7.3.1, Intel 18.0.1, and Clang 6.0.0. diff --git a/plans/intel-linker.md b/plans/intel-linker.md new file mode 100644 index 00000000..8ab45eeb --- /dev/null +++ b/plans/intel-linker.md @@ -0,0 +1,43 @@ +# Intel Linker + +When linking executables using the Intel compiler, by default, the following +static libraries are used instead of system dynamic libraries: + +- `libdecimal.a` +- `libimf.a` +- `libipgo.a` +- `libirc_s.a` +- `libirc.a` +- `libirng.a` +- `libsvml.a` + +If any of these libraries override functionality in shared libraries that are +installed on the system, there is a possibility that it can cause +reproducibility problems. This static linking is performed by default, even if +`-O0` is used. + +For example, `libimf.a` redefines many of the math functions found in +`libm.so`. + +These libraries are not the same as the Intel MKL. Yet inside of `libimf.a`, +we have definitions of functions such as `sin()`, `cos()`, and `exp()`. When +these libraries cause reproducibility issues, it is not clear which symbols are +to blame, and I do not think there is a safe way to isolate these symbols. + + +## Bisect Identify Problem Library + +I cannot guarantee that I can identify which symbol within the library is +causing problems, but at the very least, I can identify which of the static +libraries are to blame by doing the bisect approach. It may be good as a first +approach to simply identify **if** extra static libraries are used and identify +**if** the static libraries cause variability. Then, if that is true, then we +can try to identify **which** static library is to blame. + +It turns out that I cannot isolate which of the static libraries are to blame +because they depend on each other. Furthermore, if an object file is compiled +with the intel compiler, it has a very large likelihood of requiring at least +`libirc.a`, if not most of the other libraries. I have not yet found a way to +separate out compilation with the linking of these static libraries. We cannot +compile with intel and then _not_ link with these static libraries, it will +fail to compile. diff --git a/plotting/extractor.py b/plotting/extractor.py deleted file mode 100755 index d01d5596..00000000 --- a/plotting/extractor.py +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env python - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -'Extracts test run data into csv files' - -from __future__ import print_function - -import argparse -import csv -import sys - -try: - import pg - using_pg = True -except ImportError: - import psycopg2 - import psycopg2.extras - using_pg = False - -def connect_to_database(): - 'Returns a database handle for the framework being used' - dbname = 'flit' - host = 'localhost' - user = 'flit' - passwd = 'flit123' - if using_pg: - return pg.DB(dbname=dbname, host=host, user=user, passwd=passwd) - else: - conn_string = "dbname='{dbname}' user='{user}' host='{host}' password='{passwd}'" \ - .format(dbname=dbname, host=host, user=user, passwd=passwd) - conn = psycopg2.connect(conn_string) - return conn.cursor(cursor_factory=psycopg2.extras.DictCursor) - -def run_query(handle, query, *args, **kwargs): - 'Runs the query and returns the result as a list of dictionaries' - if using_pg: - return handle.query(query, *args, **kwargs).dictresults() - else: - handle.execute(query, *args, **kwargs) - return [dict(x) for x in handle.fetchall()] - -def query_results_to_file(filename, query): - 'Writes results from a PyGresQL query object to a csv file.' - with open(filename, 'w') as outfile: - writer = csv.DictWriter(outfile, sorted(query[0].keys())) - writer.writeheader() - writer.writerows(query) - -def main(arguments): - 'Main entry point' - parser = argparse.ArgumentParser(description=''' - Extracts test run data into csv files. Saves runs to run-N.csv. - The default behavior is to only extract the most recent run. - ''') - parser.add_argument('runs', metavar='N', type=int, nargs='*', - help='A run to extract to csv. Saved as run-N.csv') - parser.add_argument('-l', '--list', action='store_true', - help='List the avilable runs for download') - args = parser.parse_args(args=arguments) - - db = connect_to_database() - runs = args.runs - if len(runs) == 0: - query_runs = run_query(db, 'select index from runs;') - idx = query_runs[-1]['index'] - runs.append(idx) - if args.list: - print('\n'.join([str(x['index']) for x in query_runs])) - return 0 - - for run in runs: - filename = 'run-{0:02}.csv'.format(run) - sys.stdout.write('writing ' + filename + ' ...') - sys.stdout.flush() - query_tests = run_query(db, 'select * from tests where run = \'{0}\';'.format(run)) - query_results_to_file(filename, query_tests) - sys.stdout.write(' done\n') - sys.stdout.flush() - #print(query_tests) - return 0 - -if __name__ == '__main__': - main(sys.argv[1:]) - diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py new file mode 100755 index 00000000..9eecd9ba --- /dev/null +++ b/plotting/plot_speedup_histogram.py @@ -0,0 +1,295 @@ +#!/usr/bin/env python3 + +# -- LICENSE BEGIN -- +# +# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. +# +# Produced at the Lawrence Livermore National Laboratory +# +# Written by +# Michael Bentley (mikebentley15@gmail.com), +# Geof Sawaya (fredricflinstone@gmail.com), +# and Ian Briggs (ian.briggs@utah.edu) +# under the direction of +# Ganesh Gopalakrishnan +# and Dong H. Ahn. +# +# LLNL-CODE-743137 +# +# All rights reserved. +# +# This file is part of FLiT. For details, see +# https://pruners.github.io/flit +# Please also read +# https://github.com/PRUNERS/FLiT/blob/master/LICENSE +# +# Redistribution and use in source and binary forms, with or +# without modification, are permitted provided that the following +# conditions are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the disclaimer below. +# +# - Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the disclaimer +# (as noted below) in the documentation and/or other materials +# provided with the distribution. +# +# - Neither the name of the LLNS/LLNL nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. +# +# Additional BSD Notice +# +# 1. This notice is required to be provided under our contract +# with the U.S. Department of Energy (DOE). This work was +# produced at Lawrence Livermore National Laboratory under +# Contract No. DE-AC52-07NA27344 with the DOE. +# +# 2. Neither the United States Government nor Lawrence Livermore +# National Security, LLC nor any of their employees, makes any +# warranty, express or implied, or assumes any liability or +# responsibility for the accuracy, completeness, or usefulness of +# any information, apparatus, product, or process disclosed, or +# represents that its use would not infringe privately-owned +# rights. +# +# 3. Also, reference herein to any specific commercial products, +# process, or services by trade name, trademark, manufacturer or +# otherwise does not necessarily constitute or imply its +# endorsement, recommendation, or favoring by the United States +# Government or Lawrence Livermore National Security, LLC. The +# views and opinions of authors expressed herein do not +# necessarily state or reflect those of the United States +# Government or Lawrence Livermore National Security, LLC, and +# shall not be used for advertising or product endorsement +# purposes. +# +# -- LICENSE END -- + +''' +Plots the best speedup vs compilation as a bar chart. The x-axis is the test +name, and the y-axis is the speedup. There is one bar per compiler (for +fastest safe compilation) and one bar for all unsafe compilations. +''' + +import argparse +import csv +import numpy as np +import os +import sqlite3 +import sys + +from plot_timing import read_sqlite + +# This matplot command makes possible the use of pyplot without X11 +import matplotlib +#matplotlib.use('Agg') +import matplotlib.pyplot as plt + +def calc_speedups(rows, test_names, baseline=None): + ''' + Calculates the safe speedup and the unsafe speedup for each test_name, + compiler combination. + + @param rows: (list[dict{str: str}]) Database rows + @param test_names: (list[str]) tests to calculate speedups. Output + speedups will be in the same order as this list. + @param baseline: (tuple(compiler,optl,switches)) + Which compilation to use as the baseline timing. If None (which is the + default), then this will choose the slowest compilation per test. If + provided, the compilation must exist in the provided rows for each name + in test_names. + + @return (safe_speedups, unsafe_speedups) + + - safe_speedups: (dict{compiler -> list[speedup for test_name i]}) + Safe speedups, defined by row['comparison'] == 0.0 + - unsafe_speedups: (dist{compiler -> list[speedup for test_name i]}) + Unsafe speedups, defined by not safe. + + If there are no safe runs or no unsafe runs for a given compiler, then the + speedup returned is zero. + ''' + compilers = sorted(set(x['compiler'] for x in rows)) + + test_row_map = {x: [row for row in rows if row['name'] == x] + for x in test_names} + safe_speedups = {x: [] for x in compilers} + unsafe_speedups = {x: [] for x in compilers} + for test_name in test_names: + test_rows = test_row_map[test_name] + compiler_row_map = {x: [row for row in test_rows + if row['compiler'] == x] + for x in compilers} + if baseline is None: + baseline_time = max([int(x['nanosec']) for x in test_rows]) + else: + matching_compilations = [ + int(x['nanosec']) for x in test_rows + if [x['compiler'],x['optl'],x['switches']] == baseline] + assert len(matching_compilations) > 0, baseline + baseline_time = max(matching_compilations) + fastest_safe = [] + fastest_unsafe = [] + for compiler in compilers: + compiler_rows = compiler_row_map[compiler] + safe_times = [int(x['nanosec']) for x in compiler_rows + if float(x['comparison']) == 0.0] + unsafe_times = [int(x['nanosec']) for x in compiler_rows + if float(x['comparison']) != 0.0] + + if len(safe_times) > 0: + safe_speedup = baseline_time / min(safe_times) + else: + safe_speedup = 0 + + if len(unsafe_times) > 0: + unsafe_speedup = baseline_time / min(unsafe_times) + else: + unsafe_speedup = 0 + + safe_speedups[compiler].append(safe_speedup) + unsafe_speedups[compiler].append(unsafe_speedup) + return safe_speedups, unsafe_speedups + +def plot_histogram(rows, test_names=[], outdir='.', baseline=None): + ''' + Plots the timing metrics from the rows and for the given test_names. The + resultant plots will be placed in outdir. + + If test_names is empty, then all tests in the rows will be plotted. + ''' + # Make sure test_names are found in the rows. + # Also, if test_names is empty, plot all tests + all_test_names = set(x['name'] for x in rows) + if len(test_names) == 0: + test_names = sorted(all_test_names) + assert all(x in all_test_names for x in test_names), \ + 'unfound test names detected' + + # Make sure outdir exists + try: + os.makedirs(outdir) + except FileExistsError: + pass + + safe_speedups, unsafe_speedups = calc_speedups(rows, test_names, baseline) + compilers = safe_speedups.keys() + + width = 1 / (len(compilers) + 2) # The bar width + ind = np.arange(len(test_names)) # The x locations for the groups + + #fig = plt.figure(num=1, figsize=(2 + len(test_names), 6)) + #ax = fig.add_axes() + fig, ax = plt.subplots() + fig.set_figwidth(2 + len(test_names)) + fig.set_figheight(6) + bar_colormap = matplotlib.colors.LinearSegmentedColormap( + 'myblues', + { + 'red': [(0.0, 0x70/256, 0x70/256), + (0.5, 0.0, 0.0), + (1.0, 0.0, 0.0)], + 'green': [(0.0, 0xdb/256, 0xdb/256), + (0.5, 0xad/256, 0xad/256), + (1.0, 0x5b/256, 0x5b/256)], + 'blue': [(0.0, 1.0, 1.0), + (0.5, 0xda/256, 0xda/256), + (1.0, 0xa9/256, 0xa9/256)] + }) + #bar_colors = plt.cm.Blues(np.linspace(1.0, 0.5, len(compilers))) + bar_colors = bar_colormap(np.linspace(0.0, 1.0, len(compilers))) + compiler_rects = [ax.bar(ind + width*i, safe_speedups[comp], width, + color=bar_colors[i]) + for i, comp in enumerate(compilers)] + unsafe_rect = ax.bar(ind + width*len(compilers), + [max(unsafe_speedups[comp][i] for comp in compilers) + for i in range(len(test_names))], + width, + color='r') + + if baseline is None: + ax.set_ylabel('Speedup from Slowest') + else: + ax.set_ylabel('Speedup from "' + ' '.join(baseline).strip() + '"') + ax.yaxis.grid(which='major') # Have horizontal grid lines + ax.set_axisbelow(True) # Grid lines behind the bars + ax.set_xticks(ind - width) + ax.set_xticklabels(test_names) + + legend = ax.legend( + compiler_rects + [unsafe_rect], + [x + ' fastest safe' for x in compilers] + ['fastest unsafe']) + legend.get_frame().set_alpha(1.0) + + plt.setp(ax.xaxis.get_majorticklabels(), rotation=-45, ha='left') + + dx = 0.5 * (1 - width) + offset = matplotlib.transforms.ScaledTranslation(dx, 0, fig.dpi_scale_trans) + + for label in ax.xaxis.get_majorticklabels(): + label.set_transform(label.get_transform() + offset) + + plt.tight_layout() + figfile = os.path.join(outdir, 'speedup-histogram.svg') + plt.savefig(figfile, format='svg') + plt.cla() + print('Created', figfile) + +def main(arguments): + 'Main entry point, calls plot_timing()' + parser = argparse.ArgumentParser() + parser.add_argument('-o', '--outdir', default='.', + help='Specify output directory for generated plots') + parser.add_argument('-r', '--run', default=None, type=int, + help='Which run to use from the sqlite database') + # TODO: If all precisions, then make one histogram for each + #parser.add_argument('-p', '--precision', default='all', + # choices=['all', 'f', 'd', 'e'], + # help='Which precision to draw. By default does all precisions') + parser.add_argument('-b', '--baseline', action='store', + help=''' + Compilation to use as the baseline timing. The default + behavior is to use the slowest speed for each test. If + specified, this should have the compiler, optimization level, + and switches in that order. For example, + "g++ -O2 -funsafe-math-optimizations". + ''') + parser.add_argument('sqlite', help='Database with data to plot') + parser.add_argument('test', nargs='*', + help=''' + Which tests to include in the histogram. By default, includes + all tests. + ''') + args = parser.parse_args(arguments) + + # Split the compilation into separate components + if args.baseline is not None: + split_baseline = args.baseline.strip().split(maxsplit=2) + split_baseline.extend([''] * (3 - len(split_baseline))) + else: + split_baseline = None + + rows = read_sqlite(args.sqlite, args.run) + #if args.precision != 'all': + # rows = [x for x in rows if x['precision'] == args.precision] + plot_histogram(rows, args.test, args.outdir, split_baseline) + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/plotting/plot_timing.py b/plotting/plot_timing.py index 87647570..cb395da8 100755 --- a/plotting/plot_timing.py +++ b/plotting/plot_timing.py @@ -91,7 +91,7 @@ ''' import argparse -import csv +import csv import numpy as np import os import sqlite3 @@ -142,10 +142,10 @@ def plot_timing(rows, test_names=[], outdir='.'): test_names = sorted(all_test_names) assert all(x in all_test_names for x in test_names), \ 'unfound test names detected' - + # Make sure outdir exists try: - os.mkdir(outdir) + os.makedirs(outdir) except FileExistsError: pass @@ -172,10 +172,10 @@ def plot_timing(rows, test_names=[], outdir='.'): data['fastest'] = min(data['times']) data['slowest'] = max(data['times']) # TODO: instead of calculating the speedup using the slowest - # TODO: time, use the ground-truth time. + # TODO- time, use the ground-truth time. data['speedup'] = data['slowest'] / data['times'] data['xlab'] = [to_x_label(row) for row in data['rows']] - data['iseql'] = [float(row['comparison_d']) == 0.0 + data['iseql'] = [float(row['comparison']) == 0.0 for row in data['rows']] key = (name, host, p) test_data[key] = data @@ -197,7 +197,7 @@ def plot_timing(rows, test_names=[], outdir='.'): eql_speeds = [speedup[i] for i in eql_idxs] not_eql_speeds = [speedup[i] for i in not_eql_idxs] - plt.figure(num=1, figsize=(12.5,5), dpi=80) + plt.figure(num=1, figsize=(3 + 0.13*len(speedup), 5), dpi=80) plt.plot(speedup) plt.plot(eql_idxs, eql_speeds, 'b.', label='same answer as ground truth') @@ -210,6 +210,7 @@ def plot_timing(rows, test_names=[], outdir='.'): plt.tight_layout() newname = '{0}-{1}-{2}.svg'.format(name, host, p) plt.savefig(os.path.join(outdir, newname), format='svg') + print('Created', os.path.join(outdir, newname)) plt.cla() def main(arguments): diff --git a/plotting/plots/pyplot-intel-diff-by-flag.png b/plotting/plots/pyplot-intel-diff-by-flag.png deleted file mode 100644 index 3a2bcd0b..00000000 Binary files a/plotting/plots/pyplot-intel-diff-by-flag.png and /dev/null differ diff --git a/plotting/stats.ipynb b/plotting/stats.ipynb deleted file mode 100644 index 2e35a964..00000000 --- a/plotting/stats.ipynb +++ /dev/null @@ -1,569 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Statistics for FLiT Test Results\n", - "\n", - "This file is playing around with generating statistics for the FLiT test results. It also attempts to plot.\n", - "\n", - "$$\n", - " \\int_{-\\infty}^\\infty e^{-x^2 \\sin x} dx\n", - "$$" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import csv\n", - "with open('./latest-run.csv', 'r') as infile:\n", - " reader = csv.DictReader(infile)\n", - " rows = [x for x in reader]" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "['compiler',\n", - " 'file',\n", - " 'host',\n", - " 'index',\n", - " 'name',\n", - " 'precision',\n", - " 'run',\n", - " 'score0',\n", - " 'score0d',\n", - " 'score1',\n", - " 'score1d',\n", - " 'sort',\n", - " 'switches']" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(rows[0].keys())" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "names = set(x['name'] for x in rows)\n", - "switches = set(x['switches'] for x in rows)\n", - "compilers = set(x['compiler'] for x in rows)\n", - "precisions = set(x['precision'] for x in rows)\n", - "sorts = set(x['sort'] for x in rows)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'DoHariGSBasic',\n", - " 'DoHariGSImproved',\n", - " 'DoMatrixMultSanity',\n", - " 'DoOrthoPerturbTest',\n", - " 'DoSimpleRotate90',\n", - " 'DoSkewSymCPRotationTest',\n", - " 'RotateAndUnrotate',\n", - " 'RotateFullCircle',\n", - " 'TrianglePHeron',\n", - " 'TrianglePSylv'}" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "names" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'',\n", - " '-O0',\n", - " '-O1',\n", - " '-O2',\n", - " '-O3',\n", - " '-fassociative-math ',\n", - " '-fcx-fortran-rules ',\n", - " '-fcx-limited-range ',\n", - " '-fexcess-precision=fast ',\n", - " '-fexcess-precision=standard',\n", - " '-ffast-math',\n", - " '-ffinite-math-only',\n", - " '-ffloat-store ',\n", - " '-ffp-contract=on ',\n", - " '-fma ',\n", - " '-fmerge-all-constants ',\n", - " '-fno-trapping-math ',\n", - " '-fp-model fast=1',\n", - " '-fp-model fast=2',\n", - " '-fp-model=double',\n", - " '-fp-model=extended',\n", - " '-fp-model=precise',\n", - " '-fp-model=source',\n", - " '-fp-model=strict',\n", - " '-fp-port ',\n", - " '-fp-trap=common',\n", - " '-freciprocal-math ',\n", - " '-frounding-math ',\n", - " '-fsignaling-nans ',\n", - " '-fsingle-precision-constant',\n", - " '-ftz ',\n", - " '-funsafe-math-optimizations',\n", - " '-mavx',\n", - " '-mfpmath=sse -mtune=native',\n", - " '-mp1 ',\n", - " '-no-fma',\n", - " '-no-ftz',\n", - " '-no-prec-div',\n", - " '-prec-div '}" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "switches" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{' clang++-3.6', 'g++', 'icpc -mlong-double-80'}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "compilers" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'d', 'e', 'f'}" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "precisions" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'bi', 'gt', 'lt', 'us'}" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorts" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def stats_by_compiler(rows, compiler):\n", - " '''\n", - " Returns a dictionary of { switch -> # tests } where switch is the set\n", - " of switches specified in the row and the tests are compared against\n", - " the row with no switches. This is done keeping everything else\n", - " constant including 'host', 'precision' and 'sort'.\n", - "\n", - " The maximum count is the number of tests tested for that compiler\n", - " which is the 'name' column, so the number of unique 'name' elements\n", - " in the rows.\n", - " '''\n", - " names = set(x['name'] for x in rows)\n", - " switches = set(x['switches'] for x in rows)\n", - " compiler_rows = [x for x in rows if x['compiler'] == compiler]\n", - " switch_counts = {}\n", - " switch_totals = {}\n", - " for switch in switches:\n", - " switch_counts[switch] = 0\n", - " switch_totals[switch] = sum(\n", - " 1 for x in compiler_rows if x['switches'] == switch)\n", - " groups = {}\n", - " for name in names:\n", - " groups[name] = [x for x in compiler_rows if x['name'] == name]\n", - " for name in names:\n", - " base_rows = [x for x in groups[name] if x['switches'] == '']\n", - " for switch in switches:\n", - " switch_rows = [x for x in groups[name]\n", - " if x['switches'] == switch]\n", - " for switch_row in switch_rows:\n", - " base_matches = [x for x in base_rows\n", - " if x['host'] == switch_row['host']\n", - " and x['precision'] == switch_row['precision']\n", - " and x['sort'] == switch_row['sort']\n", - " ]\n", - " assert len(base_matches) == 1, len(base_matches)\n", - " match = base_matches[0]\n", - " if switch_row['score0'] != match['score0']:\n", - " switch_counts[switch] += 1\n", - " break\n", - " return switch_counts" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'': 0,\n", - " '-O0': 0,\n", - " '-O1': 0,\n", - " '-O2': 0,\n", - " '-O3': 0,\n", - " '-fassociative-math ': 0,\n", - " '-fcx-fortran-rules ': 0,\n", - " '-fcx-limited-range ': 0,\n", - " '-fexcess-precision=fast ': 0,\n", - " '-fexcess-precision=standard': 0,\n", - " '-ffast-math': 0,\n", - " '-ffinite-math-only': 0,\n", - " '-ffloat-store ': 0,\n", - " '-ffp-contract=on ': 0,\n", - " '-fma ': 0,\n", - " '-fmerge-all-constants ': 0,\n", - " '-fno-trapping-math ': 0,\n", - " '-fp-model fast=1': 0,\n", - " '-fp-model fast=2': 0,\n", - " '-fp-model=double': 0,\n", - " '-fp-model=extended': 0,\n", - " '-fp-model=precise': 0,\n", - " '-fp-model=source': 0,\n", - " '-fp-model=strict': 0,\n", - " '-fp-port ': 0,\n", - " '-fp-trap=common': 0,\n", - " '-freciprocal-math ': 0,\n", - " '-frounding-math ': 0,\n", - " '-fsignaling-nans ': 0,\n", - " '-fsingle-precision-constant': 0,\n", - " '-ftz ': 0,\n", - " '-funsafe-math-optimizations': 0,\n", - " '-mavx': 0,\n", - " '-mfpmath=sse -mtune=native': 0,\n", - " '-mp1 ': 0,\n", - " '-no-fma': 0,\n", - " '-no-ftz': 0,\n", - " '-no-prec-div': 0,\n", - " '-prec-div ': 0}" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "stats_by_compiler(rows, 'g++')" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'': 0,\n", - " '-O0': 0,\n", - " '-O1': 0,\n", - " '-O2': 0,\n", - " '-O3': 0,\n", - " '-fassociative-math ': 0,\n", - " '-fcx-fortran-rules ': 0,\n", - " '-fcx-limited-range ': 0,\n", - " '-fexcess-precision=fast ': 0,\n", - " '-fexcess-precision=standard': 0,\n", - " '-ffast-math': 0,\n", - " '-ffinite-math-only': 0,\n", - " '-ffloat-store ': 0,\n", - " '-ffp-contract=on ': 0,\n", - " '-fma ': 0,\n", - " '-fmerge-all-constants ': 0,\n", - " '-fno-trapping-math ': 0,\n", - " '-fp-model fast=1': 0,\n", - " '-fp-model fast=2': 0,\n", - " '-fp-model=double': 0,\n", - " '-fp-model=extended': 0,\n", - " '-fp-model=precise': 0,\n", - " '-fp-model=source': 0,\n", - " '-fp-model=strict': 0,\n", - " '-fp-port ': 0,\n", - " '-fp-trap=common': 0,\n", - " '-freciprocal-math ': 0,\n", - " '-frounding-math ': 0,\n", - " '-fsignaling-nans ': 0,\n", - " '-fsingle-precision-constant': 0,\n", - " '-ftz ': 0,\n", - " '-funsafe-math-optimizations': 0,\n", - " '-mavx': 0,\n", - " '-mfpmath=sse -mtune=native': 0,\n", - " '-mp1 ': 0,\n", - " '-no-fma': 0,\n", - " '-no-ftz': 0,\n", - " '-no-prec-div': 0,\n", - " '-prec-div ': 0}" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "stats_by_compiler(rows, ' clang++-3.6')" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'': 0,\n", - " '-O0': 3,\n", - " '-O1': 2,\n", - " '-O2': 0,\n", - " '-O3': 0,\n", - " '-fassociative-math ': 0,\n", - " '-fcx-fortran-rules ': 0,\n", - " '-fcx-limited-range ': 0,\n", - " '-fexcess-precision=fast ': 0,\n", - " '-fexcess-precision=standard': 0,\n", - " '-ffast-math': 0,\n", - " '-ffinite-math-only': 0,\n", - " '-ffloat-store ': 0,\n", - " '-ffp-contract=on ': 0,\n", - " '-fma ': 0,\n", - " '-fmerge-all-constants ': 0,\n", - " '-fno-trapping-math ': 0,\n", - " '-fp-model fast=1': 0,\n", - " '-fp-model fast=2': 0,\n", - " '-fp-model=double': 5,\n", - " '-fp-model=extended': 6,\n", - " '-fp-model=precise': 3,\n", - " '-fp-model=source': 3,\n", - " '-fp-model=strict': 3,\n", - " '-fp-port ': 0,\n", - " '-fp-trap=common': 0,\n", - " '-freciprocal-math ': 0,\n", - " '-frounding-math ': 3,\n", - " '-fsignaling-nans ': 0,\n", - " '-fsingle-precision-constant': 0,\n", - " '-ftz ': 0,\n", - " '-funsafe-math-optimizations': 0,\n", - " '-mavx': 1,\n", - " '-mfpmath=sse -mtune=native': 0,\n", - " '-mp1 ': 0,\n", - " '-no-fma': 0,\n", - " '-no-ftz': 0,\n", - " '-no-prec-div': 2,\n", - " '-prec-div ': 0}" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "icpc_stats = stats_by_compiler(rows, 'icpc -mlong-double-80')\n", - "icpc_stats" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "%matplotlib inline\n", - "from matplotlib import pyplot as plt\n", - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": { - "collapsed": false, - "scrolled": false - }, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZcAAAFPCAYAAACBC4NPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXeYJFX1ht9vd1lyTgqSlSwqGSNJgiCICJIFFBXFjJhQ\nEFAUFVD0hwFRMoKKBMlhSIooooASRTIiEiQsCCzn98e5zdY2M7szs9XdNb3f+zz1dFfoqq/vvXXP\njecqIjDGGGPqZFyvBRhjjOk/bFyMMcbUjo2LMcaY2rFxMcYYUzs2LsYYY2rHxsUYY0ztjNq4SFpa\n0ouSajdQkt4i6Za67zsjSDpX0q5dfuZNkt5avkvSzyQ9KumacmxvSQ9JekLS/N3UZkaHpC9I+kn5\n3rF3aJDnDkh6f4fufYikhyU90KH7ry/p3k7cu066GZ8zSlvecqCkE+p+xnQDQdJdkiZJerJsT0h6\nRZ0iSoQs29qPiCsjYsU6n1F51oCkZ8p/eVjSr4bzfyLiHRExrAiY3otcSYStMP2XpLMlbdz2zFUj\n4oqy+2ZgY2DxiFhX0izAd4CNImKeiHhsONrGCm3x9LikyyWtOgP3W17S6SXOH5f0V0mf6nZGEBGH\nRsRenbh3ySSer6SrJyXt23p02ep+5pLAp4EVI2Kxmu45VX5QJ5J2l3TlMK+t3ahJ2knSn0rcPFAK\nrW+q8xnDoS1v6chkx+G8WAFsGRFzl22eiPhXB7SoA/ccjAA+GhFzA8sD8wFHdOAZw2HeomM14CLg\nDEnvG+LapYC7IuKZsv8KYDbg5tEIHAOlq2o8LQAMAKMqXUlaDvgDcDewakTMB2wHrAHMXYvaLiNp\n/CCHAzil8q7OHRHf7rCUJYFHIuKRkf5Q0oRpnR69pGYi6dNkXnMIsAiwBPADYKte6mKUYV1aU4b+\nbURMcwP+CWw4yPGlgReBcWV/MeAs4BHgduADlWvXBn4PPAY8ABwFzFLOXVHu8xTwJPnSrw/cW/n9\nXcBngL8CjwOnArNWzu9X7nsf8IFyv2WH+D+XAXtW9j8K3Fi+vxH4Y3nGtcB6lesGgPeX77sDVwHf\nAh4F7gQ2K+e+BrwAPFP+z/emF3aV458B/tX2vzcC3l/u90K558klvF4s+xeX61ckjdQjwC3AdpV7\n/Rw4Gji3/HbDEme/Av5d/sPHKtcfCJwGHAc8AdwErFE5vwTw6/Lb/wBHVc7tCfy9hM35wJKVc0cA\nDwH/BW4AVhlmPK0M/K98fwXwNLBA5fzqRcv4Qe51InD2dNL5VsDfyDR6GVkSr8bDvkXvk8BPgUWB\n88r/uAiYry1u9wLuJ9PlZ9rC9YQh3qF5y71bafngyrndgauBw0t4HzTIf3jp3tMKT2A54NJyn4dL\n+MzbFpbXl3g/DfgFcPAg99wYmARMLuFy7DDDcr8Sls/w8ndgyPyArCE9VMJn98pvZgW+TRYe/kWm\n89mGCIfdgSunl7cAcxZ9rf/2BJnuBHweuKOE3y+A+af1Xlfi9klg22mkwVmBI0u6uZ98VyaWc+uX\nNPFZMp0/ALwLeAdwG/nOf74tLfyy/J8ngOuA1dr+94aDpRtgXeB3Jf7+ArytLR88hEyLkxgin42I\nYRuXjaaXQZZE8X1gIvC6EgAbVBLr2mRNaSky4/lE5V5TGQNeblz+CVxTInf+8vsPlXObAQ8CKwGz\nky/K5KH+NJnYW0ZiIfIlO44sHT8G7Fx07kBmjvNXftd6OXcHniMzfQEfBu4fKmOcXthVji9bjq9Q\n+d+tBPA+pn4plmoL/znJF/B9Rf/ryYxjpXL+5+TLs17Zn51McPsDE4BlgH8Am1QS3DMlfAV8Hfh9\nOTeefBm/U+4zK/Cmcm5rsnCxQtHxJeDqcm5T4E/APGV/BeAVw4iniaTRHqic/y3w4cr+EcB3h7jX\ng8D7phEfy5OZ2Ublv322/IcJlXj4HbAwaZAfAv5MpvNZgUuAr7TF7UklbFYl34WNyvkDGNq4nEFm\njLOXZ/0B+GAlzT1PFobGMUjmyciMy0bALOQ7cDlwRCWs7wY+VsJiG+B/DGLMyvVvY+p3dXpheVcJ\nu8WpFBDb7jlYfvB8+X/jgc3JwsW8lbj/DdkKMRdZyP36EPfenanfo2nlLVP9t3LsEyUtLFbC74fA\nydN6ryv51PODnatcc1C590Jlu7oV7pUw2L+EwQdI43YS+e6vTGb2S1XSwnPAu8v1nyELkOMHyVte\nSjclXv7DlMLyxmV/wbI/UOJwJTIdThjy/wx1ovKH7yIt7mNl+3V7QJKl2BeAOSu/+zrwsyHu+cnW\nfaaRmNqNy06V/W8CR5fvxwJfq5xbrv1+bc8eIBPmY2RJ4ARgQWBX4Jq2a39HyZR4uXG5vXLdHOWZ\ni7RnjENoeCns2o7PVo6vV/nfG1aeeeVQ9wDeC1zRdr8fMSXT+znw88q5dYC7267/AlNKnwcCF1bO\nrQxMKt/XIzPMwV6i85i6xjGuhPeSwAbAreXZQ75kg8TTs+Vzw8r59wJXle/jSQOy5hD3eo5iNIc4\n/2Xg1Mq+Stp4ayUedqyc/yXwg8r+PsAZbfGyfFt6PWaQF/mlOCRrQs9SMRrAjsCllfi/e6j/ULn3\n/5jyrj5KMd5Mo8BDloD/XL6/Fbiv7fyVDG1c1mfqd3U4Ybn7dP7HYPnBpGqaIQ382uX+T7Vdvx5w\n5xD33p2XG5eh8pap/ls59ve2dPjKkr7GMW3jsjPw4HT+9x2UTL3sbwL8sy0MVPbnLs9aq3L9n4Ct\nKmnhd23x8ABTCoFDGZfPAce36Tof2K2Sjg6c1v9obdNq82wRwNYRcek0rlkMeDQinq4cuwdYE7Iz\nlazOr0FmxBNKQIyEaj/PM2SkUj6vrZy7bzr3CbL559jqQUmLFc1V7ib/2zT1RMSk0vQ4F5nptp4z\nUhYvn4+O4rdLAetIqnbsTwCOr+i5v+36xdquH0/WQFs8VPk+CZit9NUsQWZ0Lw6h47uSvtN2fLGI\nuEzS98l25qUk/RrYNyKeHOQ+U8WTpDcDZ0l6W0TcCJwJHC1pabI58L8RMVSaeoSh4xEyDb0U9xER\npSN38co11bB4pm3/WTLuq1Q7gu8BXjuN50OG2yzAg5Vm7HFMnSaH07n8i4jYbVoXSFoU+C45SGTu\n8pxWmluMqdNJ67nDbZcfTliOppP8kbb0NokM84XJPOW6SriJkY2Ebc9bppVWlib7RqtaXiALB9Pi\nEWAhSeOGeG8oz727sn9Pm5ZHouTwRSe8PF1W0+FLeWGJh/uY9n+DTIfbSXpn5dgEsoWnxbDir65O\n3QeABSRV/9iSTPlzR5MW/9URMS/ZVFLXsx8kM7sWSwx14XS4nwzYKkvx8hdtOIzGsEA2QTwUEbeO\n4rf3AJdHxPyVbe6I+OgQuu4hS0XV6+eJiC2H8R/uBZYcolP5HrIpp3rfOSPiGoCIOCoi1iRrQsuT\nzSbTJSKuIkt2m5T9Z4HTgV3KdvzQv+ZiYNtpnH+AStyXTsolmHbcTy+zXbLt+/TS0b1krWPBSrjN\nGxFVozS9dBXD0AXZqjCZHNwwL1lrb72PDzK1IWjpH26aHk5Yjvb9GIz/kJnqypVwmy8i5qnh3oPp\nvIesXVTT9xwR8eB07vV7Mn63mcY1D5DGq8WS5dhoeSkvLIXCVw3jfveQtZj2fOSwyjXDir9aMviI\nuJdsQjpU0qySViM7dU8sl8xFNq1NkrQisHfbLR4im7NGQuslOg3YQ9KKkuYgq+XD/W2Vc4HlJe0o\naYKk95Il4nNGqAuG/38EWZKUtA/wFbJpajScQ+rfRdIsZVurhPdLz6pwLfCkpP0kzS5pvKRVJa05\nxPXtv30Q+IakOSTNJumN5dwPgS9KWrn8t3klbVe+rylpnTKMehJZ4p88jedMKYpK65EG6abK+eOB\nPcgO5GmNJDsAeKOkw0qpHUmvlnSCpHnINLSFpA2Lts8Ubb+bxj2nx/4lXFchm2J+Ma2LS+Z0IXC4\npLkljZO0nMpchGEy3NrFXGST4xOSFmdqA/97YLKkfcp7sDWw1gg01BGWw84PSi3gJ8CRkhYGkLS4\npE1G8Lxp6ViwpJEWPwS+XoZgI2lhSdMd7RUR/yXf7x9I2rq8N7NI2lzSN8tlp5DpZiFJC5XrZ2T+\nyRqStimj8j5JxsM10/nNicA7JW1S8oTZypDsaoFjWOlsRo1L1YLtSFrdB8hRRF+pNKXtC+xEjlr4\nMTmCofrbA4HjJD0m6T1Mf0z+S+cj4nzge2Rb4G3kywFZShiObsp9HgW2JF+G/xTNW5bjQz5/iHt+\nF3iPcsLjkdPQ8bikp8iRM5sB74mIn09D85DPjIinyFL9DmQp8UHgULKD9mW/Ly/llmTH/51k5/+P\ngXkGu776vIiYDLwTeDVZ0rkX2L6c+w3Zbn2qpP8CN5Id+ZR7/5hsgrmLDOdvDfF/Ab5f5gM8SRqS\nL0XEBZX/cDXZ7nxdKeAMSkTcSbbDLw38TdLjZL/JH4GnIuI2svZzVAmHLYB3RsQL09AWbd/bw+py\nsqZ1MfCtiLh4iGur33cj46s10u50sqN5qGcMpmk4pcqvkoNs/gucTY4YbMVtqxP4/UwZ4HIO2a8w\nredSfj+asGznQEaWH3yODOtrSpq7iKwVD6V1uHnLLWSGf2d5l19BvttnARdKeoLMb9Zu+/3gN444\nnBzxtj/ZfH4P8BFyIAfkKKw/kfnBDeX7IdO49/T+x5lk3+SjZDy+u7y70/rP95GDcr5Y0fgZpjYo\nw6q5tDqHuoak+YBjgFVIkXu2mkxquv9KZIY2cRptm6ZPkHQxOVrn2Ole3AVKH9Cd5Ciavkh/kv4A\n/F9EHNdrLWZ4SDqA7IboqleRKr2YSPdd4NyIWImcPDiqSYBVStVvVqULlG8CZ/XLi22GRtJaZAl8\nmk1OZmRIequkV5RmsfeRw6nP77UuMyJ6Pgm1q8ZF0rzAW1qlzIh4obRFzigfJNtH7yDHgrf36Zg+\nQ9JxZPPHJ9tGKTaB7jYH1M8K5OS5x4BPkc21D037J6ZhDLeJtGN0tVlM0uvJuRd/JyegXUdOppzU\nNRHGGGM6TreNy5pkB9gbI+KPpbP7iYj4SuWasV7qM8aYnhARPW8Oa9HtPpf7yNm/fyz7vyTbzKci\nZnA7oIZ7wPS9F0xvO+CAA2b4Hv2goSk6mqChKTqsoVk66tDQNLrtbvxfwL3KGfuQfmv+1k0Nxhhj\nOs9w3L/UzceAkyRNJB0l7tEDDcYYYzpI141LRPyVkc34HTHrd/LmI2D99dfvtYRGaIBm6GiCBmiG\nDmuYQhN0NEFD3XR9EuX0kNQIRYJGtmMaY8xgSCJm4g59Y4wxMwE2LsYYY2rHxsUYY0zt2LgYY4yp\nHRsXY4wxtWPjYowxpnZsXIwxxtSOjYsxxpjasXExxhhTOzYuxhhjasfGxRhjTO3YuBhjjKkdGxdj\njDG1Y+NijDGmdmxcjDHG1I6NizHGmNqxcTHGGFM7Ni7GGGNqx8bFGGNM7di4GGOMqR0bF2OMMbVj\n42KMMaZ2bFyMMcbUjo2LMcaY2rFxMcYYUzs2LsYYY2rHxsUYY0ztTOjFQyXdBTwBTAaej4i1e6HD\nGGNMZ+iJcQECWD8iHu3R840xxnSQXjaLqYfPNsYY00F6ZVwCuFjSnyTt1SMNxhhjOkSvmsXeFBEP\nSloYuEjSLRFxZevkgZUL1y9bL5B6X7mKiF5LMMY0kIGBAQYGBnotY0jU68xL0gHAUxHxnbLfiOxU\nZPWq5xoaERrGmKYjiYjofYm40PVmMUlzSJq7fJ8T2AS4sds6jDHGdI5eNIstCpxRmpwmACdFxIU9\n0GGMMaZD9LxZrB03i7VpaERoGGOazkzfLGaMMab/sXExxhhTOzYuxhhjasfGxRhjTO3YuBhjjKkd\nGxdjjDG1Y+NijDGmdmxcjDHG1I6NizHGmNqxcTHGGFM7Ni7GGGNqx8bFGGNM7di4GGOMqR0bF2OM\nMbVj42KMMaZ2bFyMMcbUjo2LMcaY2rFxMcYYUzs2LsYYY2rHxsUYY0zt2LgYY4ypHRsXY4wxtWPj\nYowxpnZsXIwxxtSOjYsxxpjasXExxhhTOzYuxhhjasfGxRhjTO3YuBhjjKmdnhgXSeMlXS/p7F48\n3xhjTGfpVc3lE8DfgejR840xxnSQURkXSZ+UNK+Sn5ZayKbD/O2rgHcAxwAazfONMcY0m9HWXPaM\niP8CmwALALsC3xjmb48APgu8OMpnG2OMaTgTRvm7Vo1jC+CEiLhJmn4lRNKWwL8j4npJ6w913YGV\n7+uXzRhjzBQGBgYYGBjotYwhUcTIuz0k/RxYDFgWWI00UpdFxBrT+d3XyVrOC8BswDzAryJit8o1\no1BUP6L3HUICRhM/xpiZD0lERGO6GkZrXMYBbwD+ERGPS1oQWDwibhjBPd4G7BsR72w73ojs1MbF\nGDOWaJpxGW2fy0URcV1EPA4QEY+QfSkjxTmnMcb0ISPqc5E0OzAHsLCkBSqn5gEWH8m9IuJy4PKR\n/MYYY8zYYKQd+h8i56gsBlxXOf4k8P26RBljjBnbjLbP5WMRcVQH9LjPpV1DI0LDGNN0+qXP5SFJ\ncwNI+rKkX0tavUZdxhhjxjCjNS5fjognJb0Z2Ag4FvhhfbKMMcaMZUZrXCaXzy2Bn0TEOcAs9Ugy\nxhgz1hmtcblf0o+B9wK/lTTbDNzLGGNMnzHaDv05gU2BGyPidkmvBF4bERfOsCB36E+toRGhYYxp\nOn3RoR8RTwMPA28uh14A7qhLlDHGmLHNaGsuBwJrACtExPKSFgdOi4g3zbAg11ym1tCI0DDGNJ2+\nqLkA2wBbA08DRMT9wNx1iTLGGDO2Ga1x+V9EvLQeS+mDMcYYY4DRG5fTJf0ImE/SB4FLyJUljTHG\nmNH1uQBI2oRciRLggoi4qBZB7nOZWkMjQsMY03Sa1ucy2g79b0bE56Z3bFSCbFym1tCI0DDGNJ2m\nGZfRNottMsixd8yIEGOMMf3DSNdz2Rv4CLCcpBsrp+YGrq5TmDHGmLHLiJrFJM0LzA98A/gc2XID\n8GRZjXLGBblZbGoNjQgNY0zTaVqz2Kg79DuFjUubhkaEhjGm6TTNuNjZpDHGmNqxcTHGGFM7Ni7G\nGGNqZ1TGRdKTg2z3STpD0rJ1izTGGDO2GNFQ5ArfBe4FTin7OwDLAdeTSx6vP8PKjDHGjFlGO0P/\nhohYre3YXyLi9ZL+GhGvG7UgjxabWkMjQsMY03T6ZbTYJEnvlTSubNsDz5Zzzg2NMWYmZ7TGZWdg\nV+DfZdsN2EXS7MA+NWkzxhgzRvEkyiFws5gxZizRtGaxUXXoS1oE2AtYunKPiIg9a9JljDFmDDPa\n0WJnAlcAFwGtFSmHVcSWNBtwOTArMBE4MyK+MEodxhhjGshoR4v9JSJeP+qHSnNExCRJE4CrgH0j\n4qpyrhENQW4WM8aMJZrWLDbaDv1zJG0x2odGxKTydSIwHnh0tPcyxhjTPEZbc3kKmAN4Dni+HI6I\nmGeYvx8H/JmceHl0ROxXOdeIsrprLsaYsUTTai6j6nOJiLlm5KER8SLw+rI+zAWS1o+Igdb5AyvX\nrs/MPd1fakxaMeZluPDTOwYGBhgYGOi1jCEZ6WJhK0XEzZJWH+x8RPx5xAKkLwPPRMS3y34jkmtj\nai491gDN0NEEDdAMHU3QAK5ZN42xXnP5NDkE+XAGT98bTO8GkhYCXoiIx8uky7cDXx2hDmOMMQ1m\nxH0upb9kvYi4elQPlF4LHEcOJhgHnBAR36qcb0RZqAmlwyZogGboaIIGaIaOJmgA11yaRtNqLj0Z\nijydezciuTbhBW6CBmiGjiZogGboaIIGsHFpGk0zLqMdinyxpPfIvc3GGGMGYUaHIk+m4g15uEOR\np3PvRpSFmlA6bIIGaIaOJmiAZuhoggZwzaVpNK3m0pOhyMYYY/qb0S5zPE7SrpK+UvaXlLR2vdKM\nMcaMVUbb5/J/wHrATmX/qXLMGGOMGbVX5HUi4g2SrgeIiEclzVKjLmOMMWOY0dZcnpM0vrUjaWGm\nuN43xhgzkzNa43IUcAawiKSvA1cDh9amyhhjzJhmpL7Flo2IO8v3lYCNyqlLIuLmWgR5KHKjNEAz\ndDRBAzRDRxM0gIciN42mDUUeqXG5LiLWkHRJRGw0/V+MQpCNS6M0QDN0NEEDNENHEzSAjUvTaJpx\nGWmH/nhJXwJWkPRpMn21iIg4vD5pxhhjxioj7XN5LzkrfzwwNzBXZZu7XmnGGGPGKiOtuWwWEd+Q\nNDEiDuqIImOMMWOekdZc9iyf29QtxBhjTP8w0prL3yXdDiwu6ca2cxERq9WkyxhjzBhmNIuFvQK4\nEHgnU3foExF3zbAgjxZrlAZoho4maIBm6GiCBvBosabRtNFio3K530lsXJqlAZqhowkaoBk6mqAB\nbFyaRtOMy4iaxSSdHhHbDdIkBm4WM8YYUxjpJMrFIuIBSUsPdt7NYv2nAZqhowkaoBk6mqABXHNp\nGk2rubhZbAia8AI3QQM0Q0cTNEAzdDRBA9i4NI2mGZeRNos9xdDpupZljo0xxox9RmRcWssbSzoE\neAA4sZzaGVisXmnGGGPGKqNqFpN0Q3vn/WDHRiXIzWKN0gDN0NEEDdAMHU3QAG4WaxpNaxYb7Xou\nT0vaRdL4su1MLnVsjDHGjNq47ARsDzxUtu3LMWOMMcajxYaiCU0PTdAAzdDRBA3QDB1N0ABuFmsa\n/dIsZowxxgyJjYsxxpja6bpxkbSEpMsk/U3STZI+3m0NxhhjOsuojIuk/SvfZxvhz58HPhURqwDr\nAh+VtNJodBhjjGkmIzIukj4v6Y3AdpXDvxvJPSLiXxHxl/L9KeBmPAHTGGP6ipEuFnYLaViWkXQV\naRgWkrRiRNwy0ocXB5hvAP4w0t8aY4xpLiM1Lo8DXwDWL9tKwCbA54qBWW+4N5I0F/BL4BOlBvMS\nB1a+tx5kjGkeUmNGvvacbg/LHhgYYGBgoKvPHAkjdbl/KLA2sBbwM+AGYN+IGFGfiaRZgHOA8yLi\nyLZzjRg534S5BE3QAM3Q0QQN0AwdTdAAzdDRBA3QjDk/TZvnMlrfYn8F3g+sARwC3AY8GhHvHMZv\nBRwHPBIRnxrkvI1LgzRAM3Q0QQM0Q0cTNEAzdDRBA9i4DMZojcthEbFf+X59RLxB0sIR8fAwfvtm\n4Aqy1tN6+Bci4vxy3salQRqgGTqaoAGaoaMJGqAZOpqgAWxcBmOG3b9Iel1E/LUmPTYuDdMAzdDR\nBA3QDB1N0ADN0NEEDWDjMhj2LTYETUi0TdAAzdDRBA3QDB1N0ADN0NEEDWDjMhh2/2KMMaZ2bFyM\nMcbUjo2LMcaY2rFxMcYYUzs2LsYYY2rHxsUYY0zt2LgYY4ypHRsXY4wxtWPjYowxpnZsXIwxxtSO\njYsxxpjasXExxhhTOzYuxhhjasfGxRhjTO3YuBhjjKkdGxdjjDG1Y+NijDGmdmxcjDHG1I6NizHG\nmNqxcTHGGFM7Ni7GGGNqx8bFGGNM7di4GGOMqR0bF2OMMbVj42KMMaZ2bFyMMcbUjo2LMcaY2um6\ncZF0rKSHJN3Y7WcbY4zpDr2oufwM2KwHzzXGGNMlum5cIuJK4LFuP9cYY0z3cJ+LMcaY2pnQawGD\ncWDl+/plM8aYJiOp1xIaReONizHGjAWix89vmmlzs5gxxpja6cVQ5FOA3wHLS7pX0h7d1mCMMaaz\nKKLXlbmpkdQIRaIZ1dxea4Bm6GiCBmiGjiZogGboaIIGaIYOARHRmNYxN4sZY4ypHRsXY4wxtWPj\nYowxpnZsXIwxxtSOjYsxxpjasXExxhhTOzYuxhhjasfGxRhjTO3YuBhjjKkdGxdjjDG1Y+NijDGm\ndmxcjDHG1I6NizHGmNqxcTHGGFM7Ni7GGGNqx8bFGGNM7di4GGOMqR0bF2OMMbVj42KMMaZ2bFyM\nMcbUjo2LMcaY2rFxMcYYUzs2LsYYY2rHxsUYY0zt2LgYY4ypHRsXY4wxtWPjYowxpnZsXIwxxtRO\n142LpM0k3SLpdkmf68QzBjpx01Ew0GsBNEMDNEPHQK8FFAZ6LQBrqDLQawE0Q0PddNW4SBoPfB/Y\nDFgZ2FHSSnU/Z6DuG46SgV4LoBkaoBk6BnotoDDQawFYQ5WBXgugGRrqpts1l7WBOyLiroh4HjgV\n2LrLGowxxnSYbhuXxYF7K/v3lWPGGGP6CEVE9x4mbQtsFhF7lf1dgHUi4mOVa7onyBhj+oiIUK81\ntJjQ5efdDyxR2V+CrL28RJMCxxhjzOjodrPYn4DXSFpa0kTgvcBZXdZgjDGmw3S15hIRL0jaB7gA\nGA/8NCJu7qYGY4wxnaerfS7GGGNmDjxD3xhjTO3YuBhjjKkdGxdjKkjyaEVjamCmMC6SxpXPCeVz\nGUmLSjpY0gozk44maGiKjoqG8S2jEqUTUtKc3dBQ1dJLw9aw+GhpmKN8dj1ceh0fTdMxGvreuJRM\nYn9Ji5fRassAlwHnAK8CfiRpoZlBRxM0NEVH0fClomFyRISkxSW9W9LHgXMlrdxJDUXHwpKWj4gX\ni4ZXSVpd0g8kfVLShl3Q0JT42F/Sq4qGVwNflLRCCRd1I5NtQnwMoWMFSWt349l10ffGJSKeBv4D\nXCJpSWAe0gXNisAXgQ8Cs8wMOpqgoSk6KhqulDR/OfwG4GTS393/AR9olZ47yOLACSUDWwz4NPAJ\ncprAJOAHkjrqf69B8fEIcLakNwI7A1sBB0naJLo3rLXn8VHRcaKkNSTNA+wJfEHSll14di309VBk\nSao0c+xAGtPtyImbVwMBjIuIW9uv7zcdTdDQFB1tGrYErgHmA3YA1gdeHRFLS1oAeDwiXqzz+YPo\n2Y7MTO8G/gucFxG/L+fWAI4Gto2Ie4e+y6if3bT4+CywDBkONwJ/B34DbBURN9T53Gno6Vl8lGeo\n1FY2BfYD/gi8BrgJ2BD4TUR8pxPPrpO+rrlUqtOzAo+SJaGrI+JnEXEb8EngPEnL97uOJmhoio6i\nYXz5fg4wJ/BhYOWI2LgYlk2BVSPiRVX6ZOqkhMO4iDgdOBBYALigkpHNCtwKPAl0pEmoKfEBIOk1\nZBg8QoZlgLBVAAAgAElEQVTDyRHxF+B2snmuo/0vI4yPbuSdfwauBZ4HjoqIA4DPAsuXgk+j6Wvj\nAi8l3LmBjwJ/iYhvA0j6MbABWUI7XNJWnax6N0FHEzQ0RUdETC7PXI5s+likfCJpfeBEYG9Jq7f6\nZDqgIciaAcC25djVRcPEiPgfMBF4gcxgOkIT4qMg0nPHQEQMFA1HkZn8+eWaVqe/6jY0I4iP5yjx\noXRjVSvF4M8K7AXMBVzcCg/gK8BbyP6pD9T97FqJiJliI5s6Wt+PIqv8i5f9bYGLgdkpTYX9rKMJ\nGpqig+xXOBV4RdnfBPgncDiwB9lktlLl+o5oAT4AfLl8n1A5fg1wdPm+GLAp8Po+jo8FKt+PAH4L\nLEk6ud0XOAjYoJNxMZ34uAo4uXxfEPgcsHmHNCwCvLmyfxpwfUkHCwB3ABt3KgxmWH+vBXTlT06d\nOI4EHgC2qRzbADimC5lpz3U0QUOTdJRnTSyf7wBuA3apnHtl0dIyPuqEpmLkbgK2LxnH4sAfgJ+T\npdeDgOPJ/odbgXf1Y3y07g98jzSsSwNbAN8Cfg28n+wLeVuHdQwWH1cDZ1bDDPgyMBlYo8N6zicd\n/7bCZxXSR+NKnXzujGx93ywG6TATQNJJ5GqYJwGPlWOLAj8Fbo8Sa/2sowkamqSj8KJyqO2PgEMj\n4kRJE0vz2KHAIcBvJb0rCnULiIhbyE7kjwOnkJ3GfwA+Qmb2cwE/iIh3AZ8Ctq6zWagp8VG5/8nA\nThFxF1lbuwf4UET8lDQ0b+pk/8sg8fED8v9XR4otSPZT/YyMn44g6VXAHMDaERGS1gJ2ImtR90ta\nRNKbOvX8UdNr69atjSyBnkdG0rrk2jLfJUsnn61cNxEYX76PK5+1ldaaoKMJGpqko/KcxarfyWaZ\nA8naysrAlcCSHU6n8wMLU5qHyJLxd8gRVK0w+DCZoY2r+dmNiI/qvYDlyRrM/JV4ORf4QCfjoS0+\nFgEWGiSsvljipiPNYkPoWQ/4etlWKMeWBH4FfLpbOoaltdcCuvpnp676v5ms6m9c9i8Alm27ftny\nWWtG1gQdTdDQFB2D3asYlXOB2cv+CsDlwBLT+l3NYbMgObDgra1wAjYrmf1bOvTMnsdH2/2XKsZl\nObLf5TPAN4BlOx3+Q6UT4BWDGZZO6iELOLMBB5A12VcBq5fw2K5ccyWVpsxebz0X0PU/PESbOfAl\nsvNw7rJ/GPAMsEonEk4TdDRBQ5N0tOnZv/LSvgrYHfhu2V8N2LALafWtwPmV/c3JmsXOXfj/TYqP\n95BNQNeSzZQ7AbOWcxM7HQ8VHQeRNckPFcOyRTXMuqRhEeDVZE36mRInlwBfKPHx3m6Fx3S19lpA\nrzcqTQuUkRnAN4HHyVLCadVE1M86mqChKTrIGsKdZMnwWLIzey2yxPw/YL8uhMMSwN+AfYCPATcD\nOwJzdfrZTYiPqpEjO9SXKt9XJUf4LVe5dnVgmfbf1axndeBfwBXAG6o6uxkf5Zn7AMeU73OQo8jO\nL4ZnQWCTbmt6mcZeC2jCRmk/Lt8PIEfKtEYH7UEOwZyj7Hck4TZFRxM09FpHJUPbgOzM34NsClkK\neAjYt3LtvNXfdCAcXk+6ojkCeGMnntHk+BjqPmQN4pfkvJgVyAEHZ7fCqIPxsQrwBLBbJ58zDB3L\nk5NLP1LSxo+A3cu5o6mMautZmum1gCZt5CiUx5kytn/FElGXAbtR2lc7naCaoKMJGnqlY7DMkWwa\n+xeVGgvZufodYMUuptGeZGZNSRdMXYtaEliHbK76E9lEdD2wWYfD4LXAur2Mh6JjBeCH5b9/gJyD\ntCI50m6RXuvra99iI0XSRsAtEXF/cUWxE1nlvIksJfyGnMB1c7/raIKGJuio+HnaDNg+IvZUuoZf\ng+wLmIdsOpszIh7uhO+tJtGU+CjfVyS9Ckwgh2nfJGkXciDCx4Hn+zkuACQtQjpaPTkinpa0F+m2\n6BMlfpYAXhkRJ3Vb24RuP7CplER7Sfm+AtmBC3Bh5fiV5IgNig+i2h0aNkFHEzQ0RUclc3oE2Ezp\nsXc54HVkk8ynyY73D0n6fETc1pp/0W8ZW5PiQ9IbSD9oW5EDL26SNC856OH2iHiuuGZ5rp8NfkT8\nW9IxpQC0KpkePyJpZ9IBacvz96IR8VA3tc0UkyiHQ1vie5F0MT5QeWlOBBYFWp5ZZy3Ha/Vx1AQd\nTdDQJB0lc/oj2bewB1lTeY4cofN2svQ8B3Boy/9WP2ZmDYqP1cgJjguR3goeUToi3ZFsujxN6S7/\nFEnrlYx3TC64NRzK/xtH+hx7Zfn8KDmybl/gBOBSSSuXcOoKbhYbAkkLRsQj5fvxZFvmusC7yRnM\nS5GjNS7qZMmoCTqaoKGXOqo1kVI63BP4PDlzfAdyUa3LyH6ZE4CNIuKBOp7dZHoYHwuTmebhZAf7\n90lPxX8lR0xdC/yiPH8AODXS+3Vfo1zc7svkAJCbI+I/5fjs5OCHraN4YugKdXfi9MvGFMN7EvAP\npjSBnADsTba33wms1+86mqChCToqzx8HvIv0dfVeSucpObP+CmDptut72gnfj/FBmedSvq9ADhMe\nR87g/1XRILIU/wWmTELt2AjHpm1M8Zm3I2lwNyFH1XVlmLL7XIYgSqwAPyad5S1MlsoOIdt0n5G0\nEjmpqWOLazVBRxM0NEFH616Ra7zcRZYGByLbvRcgX+BTIv1hQS5A9lgnwqIJ9DI+IuJ/lRplayGz\nV5KG7o6I2Kscu530+7WXpBsi4up+biJrIWlHYAdJj5MFoXFkP+E/gehUP+lU9Nq6NnmjUsIh5zyc\nVtlfnvTOulnbbyb0o44maGiKDqaU2FslwwXJkVIHkSXj95OZ3EXAO8o1m5CjdnqervstPir3XQv4\naWV/a7J57HdkLepvrfjo942szb0LWImsTW7ZbQ2uuUyDKLFUeBxYTtLryI7Mg4GvArdLei/FsWFE\nXAxTt0f3g44maGiKjoqGFyTNQs6t+G1EfEXSoeSCU5eTnc0HS1qG7J/5NelCv29oQnyUe7UGXfyx\n7M8OrEmu5rgCcC/pPv+zkq4Anm7T3ldE1uZuVY6Y25SssQCdG93Zjjv0h0GrOi/p3aRfoblJr7T/\nKvv/BCaRkbg7OTxyRWDPiHi2n3Q0QUOTdBQtq0YOhV2RzEyPiIhryrnjirZzyBUd5yPnX9xdp4Ze\n06T4KHrmJWfs70auGvkbct2VCyKXC36Z9ro1NIESDt8EDouIO7v68F5X38bCBlP5OJqTKS4/fkSO\nHGp16G5KenD9BfAm6neJ3nMdTdDQFB2V57fczu9Kjkxqnd+a7Oj+JNnmPY7seN4B+qtTuQnx0aZn\nIXLk2Jplfxlydc13kDPZV2OKr7K+7uQn+7xm7fpze/3Hx8rWnvjImdm/AlarHDsZuIUchtmpl6bn\nOpqgoUk6Ks9al3QuuQo5Wup0YO9ybg1yWOwiwCyD6R/rWwPj413knJv3lP2FSV9cJwGXAn+h9EX0\nW1wMJ346vbnPZZhEiZ0KCwKvIUs9SDqIXA71fRFxraR5JI2PiMeq8yT6QUcTNDRJR3mWIuIaSZ8k\nl+hdnXTw+EPlpL9DgYsiR5bN0voZ2T/TFzQlPir3+o2kF4B1JF1GelZYllzG4ARJawPfl3R/RFw/\no89tOnWl9eHiPpcZQNI7yRnby5IdmLuTayy8pxxbAPhJRJzZ4cmFPdfRBA291FHNHCW9FnhTRLQM\ny5Fkh/93ygTAq8gM9pq6jVzTaEh8TIiIFyR9h+wL+nCUDm2lO59/RJddo8wU9KqKNpY3pm5ffiPZ\nWfhG0gXIIcCD5AzuecnRK+v0q44maGiKjjYNIucVXAN8qhxbmByaews5kmqT1rW9TtP9GB9tesaT\nK1huVfZnazvf0Sa6mXHruYCxvFVenlbn5Y7A70k34FeSJbYvAW8v52cl3ZMv2m86mqChSTrKvdel\nrD1PdjDfTY4ka527H1i+1+m4k1vD4uMdxbCvXzk2T/kc327k+9Hod3Nzn8sMECUFRsR/y6Hngd9E\nxB8k7QkcX479WtKs5Ezm8WTzQF/paIKGJulo9cEA15SmsFuAn0XEvhVdVwAP1/ncptGw+DhX0ovA\nNpKuJUeMHS9po4i4t1w3jpwc+2xLuxklvbZu/bSR60jcTCkZkX6ONiOHoP6MXNhnyZlBRxM0NEUH\nsCHw3cr+68jZ/N8im4/GUZpp6PPScq/ig6mb6ap+yT5BOnpckmy2Ows4kSmjyFYDFup1uI3FrecC\n+mWrJNx3UnEzAUwkncX9lIr7DzrnAqPnOpqgoSk62o0F8AZyouUPyXVP9gR+AlxA6Q8Y7Hf9sDUh\nPlo6mHrZ5lVIB6THkCP83kp6XdiWnID4jer13oa3ebRYTQwyWujfwGPkJLIXgIMj4h5J25LNApPL\nMMzJ/aajCRqapKOiZ25gP9IV/IfL9kngfeSw3V2BfSPi9n6cNd7A+BgX6YR0EdI1zw8j4sRy7vuk\nw8vHyYLA48CLEfHvTmjpR7xYWE1UM4KIuJF8cY4lw/iA8tKMI6vfZ7deGtW8eE8TdDRBQ5N0VDQ8\nCZxG1lxeDexFjpK6LCJ+CVwH/L5kvH1HA+Oj5V/rdcCDFcOyLunw8UngGxFxCzkhdNvSL2SGQ6+r\nTv28Aa8lS6kiJ9WdQ7rG+BzwW0pVmw5V/5ukowkaGqZjI+DIyv4s5NonJ/cyzXZ7a0J8kMblLrLJ\nckdyqPRR5NDx5YFvA68A5up1eI2lzaPFOkhk6azFnyVdTDrTeyc5M/tMSVtHTvDqWDNIE3Q0QUMT\ndEiaC1gCuAfYTtLpZMb6feCPEbFTuW5CdHPVwB7RgPhQRPxV0j7kvJvVyP6vQ8lmsT2ZsgjZA8BT\n/dhk2QlsXLpAq203Io4szc5nkV5hJwInSNo5Itf57mSiHa6OTj1/GBpOlLRTVUOnwqSHOmYh+xj2\nJzPQHcjmsTMiYs+KUZlqQat+z9CGER87x5RZ9bWGRbnfOZL+AXwM+BppWPYmh0kfRtauzpa0GdlP\n1LdxURc2Ll0gstOw+vIEuZDUJmRJaTzwQuuFqXZ8dlnHOGBypaNzYkQ81yUNbwdeV4zsgmTn6WPQ\nmYy1Vzoi/Wh9nFzX5TzSM/BJEbGPch2UgyR9PIpLfknrAJMi4sZOpYsmML34IFdPrD0squ9cRNws\n6VPA4uRAi8fIjv7HSX9xP4229Wf63ejPCB4t1kVUWaRH0ofJBYtOkLQpsB7ZaXh+RFzYyUQ7DR3b\nAOsDi5Ku439Trlk8Iu7voIYPFg0nSdoS+BRp6I6MzvsiG4mO2hZZkvQa0g28IuKCyvH9gO0jYk2l\nY8UvAY8AP4iI6/o9MxskbT4VEScqfbQdAvyHDoeFcl2e3YAzIyd7vhr4LPAZ4FmyUL5UlOWVzeDY\nuHSZ9gxK0k7krORTyclcxwD7R8S5XdaxK3AEUzLU9wG7AMcBkyNis05qkDRXRDwl6ZtkSfHX5Br1\nn4mIC+t+9gh1/KrouEC5wuHkumt0kmaJiOfL93lJ1/xfIRe4uoFcOnm/iPhtnc9tIoOkzTXImsSc\nwF/JOSn7RcQ5HdQwT0Q8Ub6fTLru+So5D2Y+clXNjam0OJip8VDkLtP20qxIdiLuQpZiFwU+QI5a\n6aaO15F9AJtHxAkRcRw5audK0hVG7YalpaHVvEF6xwW4kJzUdjvwBbLJ8CUq13dLx21FxyOSliJr\nmG/VFLf5dWl4XjkMFzL+v0Qu0XtQRBxONqOtImkOyHDoRFg0hGj9N0mrA/uSRuVLEfFV4MvABh0V\nMMWwvI30A3cL2Q80D+lJYIuIeN6GZWhsXHrLJOD60vy0N/nS/AaYveQdHTcyhReBSyLXIG+xJ3Br\nRLwNpmRmncjQJC1ArnuycURcUg6/oZRML5U0p6QlKtd3JFMdREcUHWeTXnyvJkuuT7dqGTUTkuYD\nPki6SDkjIu4sx7YH3gb8SNIWUeiAhp7T+m/K+SafJl3zXxsRN5dLtic7+ltx1rE0QS4PsATwSuC4\niPhoRFxbarf9atzrIRowHnpm3YAVgGuBtcr+ksD3y/fFyGah2bugYw1ymOW6ZHX/PHJhK8hRM28C\nVir7HXFLAmxJugTZomjZsOg5mlzR8UqytNjpsKjquJ9cqnghYBvg3KLtTR0Oi2WApcv3+ciJl6eT\nbf2vJZvJlul1+u1wPKxDFrT2I5dEfl05/jVyJcmFyRreEcDrOxEfTOk2WKjtuN3zD2PzaLEeEhG3\nSjoEOE7S1yNnCO9TTq8BLBARz2jKYkedGud/naTdSJfknwIui4jNJb2fbH5YBFhQ0sFROvnrfD5A\n5FDQyWSp9GBypM5BZFPEdWTz2AmS/h4R/6xTwxA63gt8nVxrZGuyOex7pHFZQ9J9EXF3XaOWqrT+\nX6mxnAg8GRE7lmNLAU8BTwyivZ9qMveR801+QRr730i6gxyivS9pZD8ErAWsKumoiDirQ1qmGiEW\nNQ3q6HdsXHpEJUM4S9LTwMIt4yFpGdI9yM2SvgLMJenXkSsXLgf8KyKerlNLRFws6XngLRGxlaQN\nyBnTJ0XEeZJWBQ6XdFlMcZ8+w5T/q6LhPEkDxaBuD/yT9DH1cNF5W13PHYGOTUjDMhAR5xcdSwAf\nl3RMTGmq6QTLAv+rGJatyBUcfxARj0haFpi/FA5a2vvCwETE/ZJ+Gjlw4rcl7iMi7lAOSd6UnIj6\nEab0VZ4F9Rnb1u/7JUy7jY1Lj2jLzC4pnbknK/0oLU42C5wJPEqO93+1cjjm2sC3JN1WR6Jv3aPo\nuJwpHaWtyWJXlv05yc7uFytGsJbMrO0e/yufrwGeqBiWL5JNIfeWtvhHI6JWY9Ouo2RSOwP/jSl+\npzYnM/i1gDdIOiwizpe0NPBM1LRcbgnbP5OeeZH0brIGdTU52AJgfuAISd8uhZS+6gOIiOfKf1JE\n3A4g6a3ATuQ6ON8rRnYicINyfZg7I2Kg38JiLOIO/R4ShfL9RXJ9j/3IDP4UcqTQlyPiIrID8ygy\nU721U6UpSeOVI5IWAa6L7LhciVwx8MRI54tbSVq9ExoqTQ5XAe+WtLmkY8ha1D7kCK5dgA9JmlUd\ndGpY/t+vyFFa80p6Oznh9HbSwHysaJyPdJ//wboytYrRH6f02rs92UR3LvBGSZ8j+2O2JSdertKP\nJezyilSboR4mCz3fjYiHJb2ZdBezTTn3LUlb9WNYjDVsXBpCq6QaEXeR1fwVgRvLuXczpQ9gB0lv\nrPv5FSM3OSImkW3dR0j6AjkH507gKklbAB8H1mzXX5eWSi3qc8BbyHT6CWB2MpN9mpzY+D9yWdyO\nUHScRY7e2pbMwO4nnUveEhF/I125fLZo+lrdmVoxcv8mw+JnpJH9IVPckmxODpN9qRVC0malgNB3\nlGbIL0fEfyQtRI4mO5WsxU0m42kz1TxU3IwcN4s1hEEypacj519sB3wU+FFEnCLpNOClppdOdOaW\nTPV8SbuQ7f4HkCPINiAn850SEceUa18VEffVnakWDWeTpdLWsc+Q634cFRH3lhrVoZL2jYg7Kr+r\nO4P/h6QJZG3u1xFxV6kxLU8O2Z4HeCymTMTsRCf/3aXp9F3A/0XE4ZIuAC4ml0v+u6T3kZNfbwEu\n66c+mCoxxaHnU2Qz6rHAGeTgh3HkMO7qPK5+HPDQfKIBQ9a8vXwDFimfJ5MO/GYv+xPJ2cofAt5e\njtU+BLP9nmQfyHXAByvH9iFf7EXL/sfo0BBZcnncP1DcnpMZ+2nkSoGzt/TWHRZtGlpxMI6sWf4f\n8N2yv3zRuNpQYViThs2Bv5BNg6eQq1iuXs6dTboneXfl+ll6lYY7uZXwfSVwKbBeObYscHyJiwXJ\nJtTXdDI+vA29uVmsYVSalx4ube1Lk+urP6P0R/VL0rD8HvimpM2ivD11EYU2PVsAf4uIH5fje5HO\nLgci4iFJnyBnss9Zp5YKk8g+hgWUk0sPI0uoXyZLqX+Q9KaIiIrmunm2fK5ADod9LiI+QS6DeyS5\nsuSxShfxnfB5pYg4jyxc7ExO7vthRPxZ0nHkpM+tgYOVE09fC9ykdMDZV5Qk+iA5z+UnknaLiDsj\nYjdyTZajyDRyYqUPxp383aTX1s3btDeyr+WU8v0c0tfX1aS32LeRTQETmLKoUqcm9r2FbG5Zh1zr\n4lhgh3Jud3JewmZlf3ydOphSK9mULJ0/Sc45mUj2udxEzqA/Eti0C3GyCtn/MSvpWeFsykQ7si/q\nUqZMglwGmLuucKiExfLAxuX78eSIwvnK/izkyLq7gS92Ml30amsLi3eU9DCBNCzHl3iYleyj+j2w\ncrl2VdLpZM//Q79vdlzZUKrtxMqlVQM4OyI2lbQoOab/NuCfEfEVSfNFxOOdaGevDD3emPQMuzTw\nlYg4XdLHyBFul5KZ/amRHoRrW/u8LSzWIodJH1Kedx3pd+qD5DDttwDfjohJnWxr15QleI8AromI\nX6g4n1TOCXot2WyzC+nl+I6anjtV/CrnfBwYEZtXjq0EXA7cCrwnsmbZd4uPtaWLVny0arLfiuJc\ntITRTeQgiFWB5YBfdiJdmCm4WayhRKHsPk82Cc0tacPIuRTbkyNkLlE6wDxT0krlRVPdTUMlU7uY\nNC4HF8OyFznYYJuIeB9wArC/pAXLiz57GaY7Q7TComj4IzlqbiKZeV4bETtHTir9PTlMeDtJ63Y6\n81B6SH4lOUqpdWxcRNxEdvJ/E7ggcuJfLe/aIP/pKXIOVMsH3ApkzfZM4EDgfEmb95thgZe9Iyjn\nu7wSuDdyjswsJT7+QBqVi8iJl2fYsHSBXledvA1/I/1e3UJ6L24dW5H04Hs5uVTu5h169lQdomS/\nz9PA3m1aTijf5yD7Jb5OTc1CbXre2npW2X872Vx3Benh+R90p4lss/KsN1N8TpErTD5RdFxN8R3X\nQQ3bkE2Gy5PuaT5fOXckWRjoefrtxkbOQ7qT9DTROrYuaVg+1ZaGx9FnzYVN2jwUeQxQqf6fI+kF\ncmb4hWR78mHkmiMXkO3sp0t6W5QZzXUR5W2scDvpBv7OyrGfA1cUvXuQzjdvIDvja6PUYK4gDUmL\ndci+mN0ihwpfBXxW0g3AQ9EBf1CVIdt7AytGxFVKFy0nAntExK8knUll6HjdzweIiDNKqf0+soP/\nG+X82mT/y1868fymUeLjwhIfGwBXljA4lHxHjgXWU87Vuig8k7+juM9ljNDWvjyOHKn1IzJDPzEi\nnizHTyYXG7tDNa6c2K6l6FiPnGx5Ejm44NaI2EPphmNNMvP/ZaTTzY5oKXoWAM4HPhw5cqrV9zFf\nRDxe1Q319cG0xckE0nvy1cAHIuIyTb0AWMfnnEh6TUxxk7Im8G7Sq/XBUdzo9DODxMeq5DtyLNnJ\nvwA5KOZ0YFdg35gJFl/rFa65jBGqGVPk5MrZyEz95EiXLJAv0uzAXWV/NmBSNZOrS0vJLH8vaXfS\no8AVkQ4f9yBrEedExNml+2eRiPh3BzvYg1w1sr0U+irlUrkTyE73i+ssqbbFyQslTv5LjlyDnPD5\nsmvrpmK47iz7a5H+t8YBX58ZDAsMGR8nkLWWZ8nw+B/ZVHgJsJekP0Z6QDA145rLGKRSc3hpRJak\nH5GTyDYj5zqsRa7N8uOI+K3SseILEXFfXRpgKh9Ys5Oz91ci+4AuINdi+Q+57sbhEXFup0rwkrYh\n57x8NtIR6HrknKBrSJ9t3yNL8GdP4zZ16Nga2Ijsb+rJSoWlU/9TpG+6B7r9/CZQeUcmkF6tZ4uI\ni8posgci4qdl4Mkj1d+AZ/LXhUeLjUFaib9iWI4h1395BzlL/j1k+/svgH1LhncisGOdo5baXsJF\nScMyEBFnkv6e3kf2zXwAOEzSOnW/uK2RcRFxBpmhjpc0P/AD4HBy1NbCwG5k011HqOg4kzRwz/Uq\nk4qIW4FPzKyGBaZ6R14ga64/UC7nfQPZ6Q8wWdKXJH1M0iY2KvXiZrH+4FhyrscCZCntG2T/xyTl\n+i8HkIbmZ53q9yid6F8DHip9LrORLjjOIWsvR9KBGdKtJrqSsV8OIGle0pvAd0qH+vHkxM4bO1Vz\narvnc3Xff6REOvWc6SnxfZmkfckmstuB25TeL84nm8v2Bo4pzcfug6kJG5cxTnl5fle+rw1MiIjr\ny/6y5GJKpwE/iYhHW7+B+qv/rZKypGeBqyLisWJoTiQXP9u6zudVnlud6yByTtCySncwV0vakazF\nfLUbpVOXgJtFeUfOUo4cnFAGu1xKjqJbqmx7A3sBNi41YeMyxmnLyJ4kl3xdgWwOOox0rng4EMrJ\nlpMj4vZKab8TGeF9wH6SLoyIayW9k1zn/Irp/XBGKf/nbkmHkqXRAyLiNEnbR07s7NioNdM8WjXb\n8v0uAElzA49ExJ6SXkUWvu4D/t2NUX0zC+5z6RPKS/Enss/lO2RH9l/IWsOm5OiYXYBTJW05SJ9J\nnTquIJvijpa0LTnP5Py6nzXU84uGc8h1Z5aXNGurf8qGZeZjkJrtXORIwo3KAJcdySZlu4SpEY8W\n6xOqTV3KZYA3IEdJrUqOXNqQ7Fi/nlz7YteoeaLlIDpWI0dMdXKd+elpqM3HmekflBMpDwc+Ezk5\neUIZvuyaS03YuPQRbZnqxEj/SseT3nG/R3rvPZ/0FntYRDxW/W1dL5VfUNNU2t6RTcg5WUdHxH96\nq6z/cJ9LH1HN0KN4hAXuBf4Uud74ruREy4eBJ5ROJSdHxJOttuk6jIINi2kqbaMLL5R0uUfWdQbX\nXPocSe8ghyZ/OnKG+nzkYlerkqNjniNd1J+lXITrX5GLMBljzKhxzaWPKaWzcyXNQjpxfDbSueL6\n5ITCfci5J4dKmkzOsL8eOLhnoo0xfYFrLn1MW/vyYsCjZMf+98lVI28r151KDl3+c0Ts3yu9xpj+\nwTWXPqZtjH9rguO8wE8j4jZJcwKvI13jXxARXyvXuEPeGDND2Lj0OYMYiQeBb0v6C7m41+uBq21Y\njAVmMCEAAABwSURBVDF14maxmYiW4ZC0Ibl64cbASRFxSPV8T0UaY/oC11xmMooBuVTS48B/bViM\nMZ3ANZeZkHZDYsNijKkbGxdjjDG1Y8eVxhhjasfGxRhjTO3YuBhjjKkdGxdjjDG1Y+NijDGmdmxc\njDHG1M7/A2lmw7jlQbVWAAAAAElFTkSuQmCC\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "items = sorted([x for x in icpc_stats.items() if x[1] > 0],\n", - " key=lambda x: x[1], reverse=True)\n", - "ind = np.arange(len(items)) # x-location of each of the groups\n", - "width = 1 # Width of the bars\n", - "\n", - "fig, ax = plt.subplots()\n", - "ax.bar(ind, [x[1] for x in items], width, color='r')\n", - "ax.set_ylabel('# differing tests')\n", - "ax.set_title('Floating Point Differences By Compiler Flag for the Intel Compiler')\n", - "ax.set_xticks(ind + width/2)\n", - "ax.set_xticklabels([x[0] for x in items], rotation=-45, ha='left')\n", - "\n", - "\n", - "plt.show()" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "[('-fp-model=extended', 6),\n", - " ('-fp-model=double', 5),\n", - " ('-fp-model=source', 3),\n", - " ('-fp-model=strict', 3),\n", - " ('-frounding-math ', 3),\n", - " ('-O0', 3),\n", - " ('-fp-model=precise', 3),\n", - " ('-no-prec-div', 2),\n", - " ('-O1', 2),\n", - " ('-mavx', 1)]" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "items" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3+" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/plotting/stats_generator.py b/plotting/stats_generator.py index d5393eb4..3d697467 100755 --- a/plotting/stats_generator.py +++ b/plotting/stats_generator.py @@ -91,6 +91,8 @@ def main(arguments): 'Main entry point' # Parse arguments + # TODO: rework this since FLiT has been updated since the creation. + # TODO: finish generating important statistics parser = argparse.ArgumentParser( description=''' Generates statistics from a given test results csv file. The csv @@ -117,7 +119,7 @@ def main(arguments): print(name, len(scores[name])) print() - + total_switches = set(x['switches'] for x in rows) for switch in total_switches: @@ -125,13 +127,13 @@ def main(arguments): for name in names: switches = set(x['switches'] for x in groups[name]) ## TODO: Find a base score to compare against... - ## TODO: Without that, we don't have anything to plot on the switches front - ## TODO: Maybe we could have the base be - ## TODO: - the most common score. - ## TODO: - the empty switch for gcc - ## TODO: - something else + ## TODO- Without that, we don't have anything to plot on the switches front + ## TODO- Maybe we could have the base be + ## TODO- - the most common score. + ## TODO- - the empty switch for gcc + ## TODO- - something else #for switch in switches: - # switch_counts[switch] += len(set(x['score0'] for x in + # switch_counts[switch] += len(set(x['score0'] for x in if __name__ == '__main__': main(sys.argv[1:]) diff --git a/plotting/tex/plot-intel-diff-by-flag.tex b/plotting/tex/plot-intel-diff-by-flag.tex deleted file mode 100644 index 3cbcb932..00000000 --- a/plotting/tex/plot-intel-diff-by-flag.tex +++ /dev/null @@ -1,225 +0,0 @@ -% -- LICENSE BEGIN -- -% -% Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -% -% Produced at the Lawrence Livermore National Laboratory -% -% Written by -% Michael Bentley (mikebentley15@gmail.com), -% Geof Sawaya (fredricflinstone@gmail.com), -% and Ian Briggs (ian.briggs@utah.edu) -% under the direction of -% Ganesh Gopalakrishnan -% and Dong H. Ahn. -% -% LLNL-CODE-743137 -% -% All rights reserved. -% -% This file is part of FLiT. For details, see -% https://pruners.github.io/flit -% Please also read -% https://github.com/PRUNERS/FLiT/blob/master/LICENSE -% -% Redistribution and use in source and binary forms, with or -% without modification, are permitted provided that the following -% conditions are met: -% -% - Redistributions of source code must retain the above copyright -% notice, this list of conditions and the disclaimer below. -% -% - Redistributions in binary form must reproduce the above -% copyright notice, this list of conditions and the disclaimer -% (as noted below) in the documentation and/or other materials -% provided with the distribution. -% -% - Neither the name of the LLNS/LLNL nor the names of its -% contributors may be used to endorse or promote products derived -% from this software without specific prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -% CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -% INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -% MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -% DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -% SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -% -% Additional BSD Notice -% -% 1. This notice is required to be provided under our contract -% with the U.S. Department of Energy (DOE). This work was -% produced at Lawrence Livermore National Laboratory under -% Contract No. DE-AC52-07NA27344 with the DOE. -% -% 2. Neither the United States Government nor Lawrence Livermore -% National Security, LLC nor any of their employees, makes any -% warranty, express or implied, or assumes any liability or -% responsibility for the accuracy, completeness, or usefulness of -% any information, apparatus, product, or process disclosed, or -% represents that its use would not infringe privately-owned -% rights. -% -% 3. Also, reference herein to any specific commercial products, -% process, or services by trade name, trademark, manufacturer or -% otherwise does not necessarily constitute or imply its -% endorsement, recommendation, or favoring by the United States -% Government or Lawrence Livermore National Security, LLC. The -% views and opinions of authors expressed herein do not -% necessarily state or reflect those of the United States -% Government or Lawrence Livermore National Security, LLC, and -% shall not be used for advertising or product endorsement -% purposes. -% -% -- LICENSE END -- - -\documentclass[border=10pt]{standalone} -\usepackage{pgfplots} -\pgfplotsset{width=7cm, compat=1.8} -\usepackage{pgfplotstable} -\renewcommand*{\familydefault}{\sfdefault} -\usepackage{sfmath} -\usepackage{graphicx} - -\begin{document} - -\begin{tikzpicture} - \centering - \begin{axis}[ - ybar, - axis on top, - title={Tests with differences (out of 10) for Compiler flags on Intel's icpc compiler}, - height=7cm, - width=15.5cm, - bar width=0.8cm, - ymajorgrids, - tick align=inside, - major grid style={draw=white}, - ymin=0, - axis x line*=bottom, - axis y line*=right, - y axis line style={opacity=0}, - yticklabel style={opacity=0}, - tickwidth=0pt, - enlarge x limits=true, - symbolic x coords={ - -O0, - -O1, - -fp-model=double, - -fp-model=extended, - -fp-model=precise, - -fp-model=source, - -fp-model=strict, - -frounding-math, - -mavx, - -no-prec-div, - }, - xtick=data, - xticklabel style={ rotate=-30, anchor=west, yshift=-0.2cm , font=\ttfamily }, - nodes near coords={ - \pgfmathprintnumber[precision=0]{\pgfplotspointmeta} - }, - ] - \addplot [draw=none, fill=blue!30] coordinates { - (-fp-model=extended, 6) - (-fp-model=double, 5) - (-fp-model=source, 3) - (-fp-model=strict, 3) - (-frounding-math, 3) - (-O0, 3) - (-fp-model=precise, 3) - (-no-prec-div, 2) - (-O1, 2) - (-mavx, 1) - }; - \end{axis} - This is compared with having no command-line arguments at all (except - -mlong-double-80 which was used for all runs) -\end{tikzpicture} - - - -%\begin{tikzpicture} -% \centering -% \begin{axis}[ -% ybar, -% axis on top, -% title={Cumulative Progress of Works}, -% height=7cm, -% width=15.5cm, -% bar width=0.4cm, -% ymajorgrids, -% tick align=inside, -% major grid style={draw=white}, -% enlarge y limits={value=.1,upper}, -% ymin=0, -% ymax=100, -% axis x line*=bottom, -% axis y line*=right, -% y axis line style={opacity=0}, -% tickwidth=0pt, -% enlarge x limits=true, -% legend style={ -% at={(0.5,-0.2)}, -% anchor=north, -% legend columns=-1, -% /tikz/every even column/.append style={column sep=0.5cm} -% }, -% ylabel={Percentage (\%)}, -% symbolic x coords={ -% Sep-11, -% Oct-11, -% Nov-11, -% Dec-11, -% Jan-12, -% Feb-12, -% Mar-12, -% Apr-12, -% }, -% xtick=data, -% nodes near coords={ -% \pgfmathprintnumber[precision=0]{\pgfplotspointmeta} -% }, -% ] -% \addplot [draw=none, fill=blue!30] coordinates { -% (Sep-11, 75.4064) -% (Oct-11, 72.7961) -% (Nov-11, 94.4597) -% (Dec-11, 66.6786) -% (Jan-12, 67.5600) -% (Feb-12, 88.2339) -% (Mar-12, 78.6138) -% (Apr-12, 58.9129) -% }; -% \addplot [draw=none,fill=red!30] coordinates { -% (Sep-11, 75.4064) -% (Oct-11, 89.7961) -% (Nov-11, 94.4597) -% (Dec-11, 76.6786) -% (Jan-12, 77.5600) -% (Feb-12, 78.2339) -% (Mar-12, 88.6138) -% (Apr-12, 78.9129) }; -% \addplot [draw=none, fill=green!30] coordinates { -% (Sep-11, 75.4064) -% (Oct-11, 89.7961) -% (Nov-11, 94.4597) -% (Dec-11, 76.6786) -% (Jan-12, 77.5600) -% (Feb-12, 78.2339) -% (Mar-12, 88.6138) -% (Apr-12, 78.9129) }; -% -% \legend{First Fix,Second Fix,Third Fix} -% \end{axis} -%\end{tikzpicture} - - -\end{document} diff --git a/scripts/MakeCollectPin b/scripts/MakeCollectPin deleted file mode 100644 index f1be146d..00000000 --- a/scripts/MakeCollectPin +++ /dev/null @@ -1,121 +0,0 @@ -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -#this will (normally) be called in the context of 'results' (-C results) -#otherwise, PINPATH should be set - -PINPATH ?= ../pin/pin - -OUTDIR := opcounts - -SOURCE := $(wildcard *_O0) -SOURCE += $(wildcard *_O1) -SOURCE += $(wildcard *_O2) -SOURCE += $(wildcard *_O3) - -TESTS := $(shell egrep -h 'REGISTER_TYPE(.*)' ../src/tests/* | sed 's/.*(\(.*\))/\1/g') - -PRECISIONS := f d e - -TARGETS := $(foreach p, $(PRECISIONS), \ - $(foreach t, $(TESTS), \ - $(foreach f, $(SOURCE), \ - $(strip $f)_$(strip $p)_$(strip $t)))) - -.phony : all - -all : $(TARGETS) - -define RULE -$1 : $2 - -PRECISION=$(strip $3) \ - TEST=$(strip $4) \ - $(PINPATH)/pin -t \ - $(PINPATH)/source/tools/SimpleExamples/obj-intel64/opcodemix.so \ - -o $$@ -- ./$$< -endef - -$(foreach p, $(PRECISIONS), \ - $(foreach t, $(TESTS), \ - $(foreach f, $(SOURCE), \ - $(eval $(call RULE, $(strip $f)_$(strip $p)_$(strip $t), \ - $(strip $f), $(strip $p), $(strip $t)))))) diff --git a/scripts/README b/scripts/README deleted file mode 100644 index 8ed43357..00000000 --- a/scripts/README +++ /dev/null @@ -1 +0,0 @@ -use hostCollectEnviro.source for testing hostCollect.sh diff --git a/scripts/flitcli/README.md b/scripts/flitcli/README.md index 4f8793f3..2143cf92 100644 --- a/scripts/flitcli/README.md +++ b/scripts/flitcli/README.md @@ -11,7 +11,8 @@ things: ## FLiT Subcommands -To add an additional subcommand, there are only a few things you need to do. For this documentation, let us use the example subcommand of squelch. +To add an additional subcommand, there are only a few things you need to do. +For this documentation, let us use the example subcommand of squelch. 1. Create a file in this same directory called `flit_squelch.py`. The subcommand should not be too long in length, otherwise it makes it hard to diff --git a/scripts/flitcli/config/flit-default-future.toml.in b/scripts/flitcli/config/flit-default-future.toml.in index 80185f06..a0873550 100644 --- a/scripts/flitcli/config/flit-default-future.toml.in +++ b/scripts/flitcli/config/flit-default-future.toml.in @@ -92,7 +92,22 @@ type = 'sqlite' # configuration file. filepath = 'results.sqlite' -# For now, only one host is supported, all others are ignored + +[run] + +# Set this to false to not do any timing at all +timing = true + +# The number of loops to run with the timing. For values < 0, the number of +# loops to run will be determined automatically. +timing_loops = -1 + +# How many times to repeat the timing. The minimum of the repeated timings +# will be kept. +timing_repeats = 3 + + +# For now, only the first host is supported, all others are ignored [[hosts]] # TODO: add documentation here for each element. @@ -135,7 +150,7 @@ switches = '' # database and analysis. name = 'g++' # TODO: implement these supported types - # There are a few supported types: [ gcc, intel, clang, cuda ] + # There are a few supported types: [ gcc, intel, clang ] type = 'gcc' optimization_levels = [ '-O0', @@ -156,5 +171,5 @@ switches = '' '' # ... ] - + diff --git a/scripts/flitcli/config/flit-default.toml.in b/scripts/flitcli/config/flit-default.toml.in index 170def42..c7c5d054 100644 --- a/scripts/flitcli/config/flit-default.toml.in +++ b/scripts/flitcli/config/flit-default.toml.in @@ -92,7 +92,31 @@ type = 'sqlite' # configuration file. filepath = 'results.sqlite' -# For now, only one host is supported, all others are ignored + +[run] + +# Set this to false to not do any timing at all +timing = true + +# The number of loops to run with the timing. For values < 0, the number of +# loops to run will be determined automatically. +timing_loops = -1 + +# How many times to repeat the timing. The minimum of the repeated timings +# will be kept. +timing_repeats = 3 + +# The tests can be run with MPI to test MPI applications +# Warning: FLiT assumes tests are deterministic. It is your responsability to +# ensure that your test will always produce the same result even using +# MPI. +# The mpirun_args are for any flags passed to mpirun. For example, you can do +# mpirun_args = '-n 16 --verbose' +enable_mpi = false +mpirun_args = '' + + +# For now, only the first host is supported, all others are ignored [[hosts]] name = '{hostname}' diff --git a/scripts/flitcli/config/version.txt b/scripts/flitcli/config/version.txt index 605ce39b..1c5979fc 100644 --- a/scripts/flitcli/config/version.txt +++ b/scripts/flitcli/config/version.txt @@ -1 +1 @@ -v2.0-alpha.3 +v2.0-beta.1 diff --git a/scripts/flitcli/flit.py b/scripts/flitcli/flit.py index 207644e2..399aaaf6 100755 --- a/scripts/flitcli/flit.py +++ b/scripts/flitcli/flit.py @@ -125,7 +125,7 @@ def generate_help_documentation(subcom_map): Generates and returns both the formatted help for the general flit executable, but also for the help subcommand. They are returned as a tuple. - + >>> help_str, help_subcom_str = generate_help_documentation(dict()) ''' parser = argparse.ArgumentParser( @@ -164,7 +164,7 @@ def main(arguments): script_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, script_dir) import flitconfig as conf - + subcom_map = import_helper_modules(script_dir) help_str, help_subcommand_str = generate_help_documentation(subcom_map) @@ -194,7 +194,7 @@ def main(arguments): if help_subcommand in ('-h', '--help', 'help'): print(help_subcommand_str) return 0 - + elif help_subcommand not in all_subcommands: sys.stderr.write('Error: invalid subcommand: {0}.\n' \ .format(subcommand)) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py new file mode 100644 index 00000000..fbcffa45 --- /dev/null +++ b/scripts/flitcli/flit_bisect.py @@ -0,0 +1,1351 @@ +# -- LICENSE BEGIN -- +# +# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. +# +# Produced at the Lawrence Livermore National Laboratory +# +# Written by +# Michael Bentley (mikebentley15@gmail.com), +# Geof Sawaya (fredricflinstone@gmail.com), +# and Ian Briggs (ian.briggs@utah.edu) +# under the direction of +# Ganesh Gopalakrishnan +# and Dong H. Ahn. +# +# LLNL-CODE-743137 +# +# All rights reserved. +# +# This file is part of FLiT. For details, see +# https://pruners.github.io/flit +# Please also read +# https://github.com/PRUNERS/FLiT/blob/master/LICENSE +# +# Redistribution and use in source and binary forms, with or +# without modification, are permitted provided that the following +# conditions are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the disclaimer below. +# +# - Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the disclaimer +# (as noted below) in the documentation and/or other materials +# provided with the distribution. +# +# - Neither the name of the LLNS/LLNL nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. +# +# Additional BSD Notice +# +# 1. This notice is required to be provided under our contract +# with the U.S. Department of Energy (DOE). This work was +# produced at Lawrence Livermore National Laboratory under +# Contract No. DE-AC52-07NA27344 with the DOE. +# +# 2. Neither the United States Government nor Lawrence Livermore +# National Security, LLC nor any of their employees, makes any +# warranty, express or implied, or assumes any liability or +# responsibility for the accuracy, completeness, or usefulness of +# any information, apparatus, product, or process disclosed, or +# represents that its use would not infringe privately-owned +# rights. +# +# 3. Also, reference herein to any specific commercial products, +# process, or services by trade name, trademark, manufacturer or +# otherwise does not necessarily constitute or imply its +# endorsement, recommendation, or favoring by the United States +# Government or Lawrence Livermore National Security, LLC. The +# views and opinions of authors expressed herein do not +# necessarily state or reflect those of the United States +# Government or Lawrence Livermore National Security, LLC, and +# shall not be used for advertising or product endorsement +# purposes. +# +# -- LICENSE END -- + +''' +Implements the bisect subcommand, identifying the problematic subset of source +files that cause the variability. +''' + +from collections import namedtuple +import argparse +import csv +import datetime +import glob +import hashlib +import logging +import multiprocessing as mp +import os +import re +import shutil +import sqlite3 +import subprocess as subp +import sys + +import flitconfig as conf +import flitutil as util + +brief_description = 'Bisect compilation to identify problematic source code' + +def hash_compilation(compiler, optl, switches): + 'Takes a compilation and returns a 10 digit hash string.' + return hashlib.sha1((compiler + optl + switches).encode()).hexdigest()[:10] + +def create_bisect_dir(parent): + ''' + Create a unique bisect directory named bisect-## where ## is the lowest + integer that doesn't collide with an already existing file or directory. + + @param parent: the parent directory of where to create the bisect dir + @return the bisect directory name without parent prepended to it + + >>> import tempfile + >>> import shutil + >>> import os + + >>> tmpdir = tempfile.mkdtemp() + >>> create_bisect_dir(tmpdir) + 'bisect-01' + >>> os.listdir(tmpdir) + ['bisect-01'] + + >>> create_bisect_dir(tmpdir) + 'bisect-02' + >>> sorted(os.listdir(tmpdir)) + ['bisect-01', 'bisect-02'] + + >>> create_bisect_dir(tmpdir) + 'bisect-03' + >>> sorted(os.listdir(tmpdir)) + ['bisect-01', 'bisect-02', 'bisect-03'] + + >>> create_bisect_dir(os.path.join(tmpdir, 'bisect-01')) + 'bisect-01' + >>> sorted(os.listdir(tmpdir)) + ['bisect-01', 'bisect-02', 'bisect-03'] + >>> os.listdir(os.path.join(tmpdir, 'bisect-01')) + ['bisect-01'] + + >>> shutil.rmtree(tmpdir) + ''' + num = 0 + while True: + num += 1 + bisect_dir = 'bisect-{0:02d}'.format(num) + try: + os.mkdir(os.path.join(parent, bisect_dir)) + except FileExistsError: + pass # repeat the while loop and try again + else: + return bisect_dir + +def create_bisect_makefile(directory, replacements, gt_src, + trouble_src=tuple(), + split_symbol_map=None): + ''' + Returns the name of the created Makefile within the given directory, having + been populated with the replacements, gt_src, and trouble_src. It is then + ready to be executed by 'make bisect' from the top-level directory of the + user's flit tests. + + @param directory: (str) path where to put the created Makefile + @param replacements: (dict) key -> value. The key is found in the + Makefile_bisect_binary.in and replaced with the corresponding value. + @param gt_src: (list) which source files would be compiled with the + ground-truth compilation within the resulting binary. + @param trouble_src: (list) which source files would be compiled with the + trouble compilation within the resulting binary. + @param split_symbol_map: + (dict fname -> list [list good symbols, list bad symbols]) + Files to compile as a split between good and bad, specifying good and + bad symbols for each file. + + Within replacements, there are some optional fields: + - cpp_flags: (list) (optional) List of c++ compiler flags to give to + each compiler when compiling object files from source files. + - link_flags: (list) (optional) List of linker flags to give to the + ground-truth compiler when performing linking. + + @return the bisect makefile name without directory prepended to it + ''' + if split_symbol_map is None: + split_symbol_map = {} # default to an empty dictionary + repl_copy = dict(replacements) + repl_copy['TROUBLE_SRC'] = '\n'.join(['TROUBLE_SRC += {0}'.format(x) + for x in trouble_src]) + repl_copy['BISECT_GT_SRC'] = '\n'.join(['BISECT_GT_SRC += {0}'.format(x) + for x in gt_src]) + repl_copy['SPLIT_SRC'] = '\n'.join(['SPLIT_SRC += {0}'.format(x) + for x in split_symbol_map]) + if 'cpp_flags' in repl_copy: + repl_copy['EXTRA_CC_FLAGS'] = '\n'.join([ + 'CC_REQUIRED += {0}'.format(x) + for x in repl_copy['cpp_flags']]) + del repl_copy['cpp_flags'] + if 'link_flags' in repl_copy: + repl_copy['EXTRA_LD_FLAGS'] = '\n'.join([ + 'LD_REQUIRED += {0}'.format(x) + for x in repl_copy['link_flags']]) + del repl_copy['link_flags'] + + + # Find the next unique file name available in directory + num = 0 + while True: + num += 1 + makefile = 'bisect-make-{0:02d}.mk'.format(num) + makepath = os.path.join(directory, makefile) + try: + with open(makepath, 'x'): + pass # we just want to create the empty file + except FileExistsError: + pass + else: + break + + repl_copy['makefile'] = makepath + repl_copy['number'] = '{0:02d}'.format(num) + logging.info('Creating makefile: %s', makepath) + util.process_in_file( + os.path.join(conf.data_dir, 'Makefile_bisect_binary.in'), + makepath, + repl_copy, + overwrite=True) + + # Create the obj directory + if len(split_symbol_map) > 0: + try: + os.mkdir(os.path.join(directory, 'obj')) + except FileExistsError: + pass # ignore if the directory already exists + + # Create the txt files containing symbol lists within the obj directory + for split_srcfile, split_symbols in split_symbol_map.items(): + split_basename = os.path.splitext(os.path.basename(split_srcfile))[0] + split_base = os.path.join(directory, 'obj', split_basename) + trouble_symbols_fname = split_base + '_trouble_symbols_' \ + + repl_copy['number'] + '.txt' + gt_symbols_fname = split_base + '_gt_symbols_' \ + + repl_copy['number'] + '.txt' + gt_symbols, trouble_symbols = split_symbols + + with open(gt_symbols_fname, 'w') as gt_fout: + gt_fout.writelines('\n'.join(str(x) for x in gt_symbols)) + with open(trouble_symbols_fname, 'w') as trouble_fout: + trouble_fout.writelines('\n'.join(str(x) for x in trouble_symbols)) + + return makefile + +def build_bisect(makefilename, directory, + target='bisect', + verbose=False, + jobs=None): + ''' + Creates the bisect executable by executing a parallel make. + + You may alternatively specify a different target than bisect, for example + 'bisect-clean' to specify to clean the unnecessary files for the build, + 'bisect-smallclean' to clean unnecessary things without needing to + recompile for the next bisect step, or + 'distclean' to clean everything, including the generated makefile. + + @param makefilename: the filepath to the makefile + @param directory: where to execute make + @param target: Makefile target to run + @param verbose: False means block output from GNU make and running + @param jobs: number of parallel jobs. Defaults to #cpus + + @return None + ''' + logging.info('Building the bisect executable') + if jobs is None: + jobs = mp.cpu_count() + kwargs = dict() + if not verbose: + kwargs['stdout'] = subp.DEVNULL + kwargs['stderr'] = subp.DEVNULL + subp.check_call( + ['make', '-C', directory, '-f', makefilename, '-j', str(jobs), target], + **kwargs) + +def update_gt_results(directory, verbose=False, + jobs=mp.cpu_count()): + ''' + Update the ground-truth.csv results file for FLiT tests within the given + directory. + + @param directory: where to execute make + @param verbose: False means block output from GNU make and running + ''' + kwargs = dict() + if not verbose: + kwargs['stdout'] = subp.DEVNULL + kwargs['stderr'] = subp.DEVNULL + gt_resultfile = util.extract_make_var( + 'GT_OUT', os.path.join(directory, 'Makefile'))[0] + logging.info('Updating ground-truth results - %s', gt_resultfile) + print('Updating ground-truth results -', gt_resultfile, end='', flush=True) + subp.check_call( + ['make', '-j', str(jobs), '-C', directory, gt_resultfile], **kwargs) + print(' - done') + logging.info('Finished Updating ground-truth results') + +def is_result_bad(resultfile): + ''' + Returns True if the results from the resultfile is considered 'bad', + meaning it is a different answer from the ground-truth. + + @param resultfile: path to the results csv file after comparison + @return True if the result is different from ground-truth + ''' + with open(resultfile, 'r') as fin: + parser = csv.DictReader(fin) + # should only have one row + for row in parser: + # identical to ground truth means comparison is zero + return float(row['comparison']) != 0.0 + +SymbolTuple = namedtuple('SymbolTuple', 'src, symbol, demangled, fname, lineno') +SymbolTuple.__doc__ = ''' +Tuple containing information about the symbols in a file. Has the following +attributes: + src: source file that was compiled + symbol: mangled symbol in the compiled version + demangled: demangled version of symbol + fname: filename where the symbol is actually defined. This usually + will be equal to src, but may not be in some situations. + lineno: line number of definition within fname. +''' + +def extract_symbols(file_or_filelist, objdir): + ''' + Extracts symbols for the given file(s) given. The corresponding object is + assumed to be in the objdir with the filename replaced with the GNU Make + pattern %.cpp=%_gt.o. + + @param file_or_filelist: (str or list(str)) source file(s) for which to get + symbols. + @param objdir: (str) directory where object files are compiled for the + given files. + + @return a list of SymbolTuple objects + ''' + symbol_tuples = [] + + # if it is not a string, then assume it is a list of strings + if not isinstance(file_or_filelist, str): + for fname in file_or_filelist: + symbol_tuples.extend(extract_symbols(fname, objdir)) + return symbol_tuples + + # now we know it is a string, so assume it is a filename + fname = file_or_filelist + fbase = os.path.splitext(os.path.basename(fname))[0] + fobj = os.path.join(objdir, fbase + '_gt.o') + + # use nm and objdump to get the binary information we need + symbol_strings = subp.check_output([ + 'nm', + '--extern-only', + '--defined-only', + fobj, + ]).decode('utf-8').splitlines() + demangled_symbol_strings = subp.check_output([ + 'nm', + '--extern-only', + '--defined-only', + '--demangle', + fobj, + ]).decode('utf-8').splitlines() + objdump_strings = subp.check_output([ + 'objdump', '--disassemble-all', '--line-numbers', fobj, + ]).decode('utf-8').splitlines() + + # create the symbol -> (fname, lineno) map + symbol_line_mapping = dict() + symbol = None + for line in objdump_strings: + if len(line.strip()) == 0: # skip empty lines + continue + if line[0].isdigit(): # we are at a symbol + symbol = line.split()[1][1:-2] + continue + if symbol is None: # if we don't have an active symbol + continue # then skip + srcmatch = re.search(':[0-9]+$', line) + if srcmatch is not None: + deffile = line[:srcmatch.start()] + defline = int(line[srcmatch.start()+1:]) + symbol_line_mapping[symbol] = (deffile, defline) + symbol = None # deactivate the symbol to not overwrite + + + # generate the symbol tuples + for symbol_string, demangled_string in zip(symbol_strings, + demangled_symbol_strings): + symbol = symbol_string.split(maxsplit=2)[2] + demangled = demangled_string.split(maxsplit=2)[2] + try: + deffile, defline = symbol_line_mapping[symbol] + except KeyError: + deffile, defline = None, None + symbol_tuples.append( + SymbolTuple(fname, symbol, demangled, deffile, defline)) + + return symbol_tuples + +def bisect_search(is_bad, elements): + ''' + Performs the bisect search, attempting to minimize the bad list. We could + go through the list one at a time, but that would cause us to call is_bad() + more than necessary. Here we assume that calling is_bad() is expensive, so + we want to minimize calls to is_bad(). This function has + O(k*log(n))*O(is_bad) + where n is the size of the questionable_list and k is + the number of bad elements in questionable_list. + + Note: A key assumption to this algorithm is that all bad elements are + independent. That may not always be true, so there are redundant checks + within the algorithm to verify that this assumption is not vialoated. If + the assumption is found to be violated, then an AssertionError is raised. + + @param is_bad: a function that takes two arguments (maybe_bad_list, + maybe_good_list) and returns True if the maybe_bad_list has a bad + element + @param elements: contains bad elements, but potentially good elements too + + @return minimal bad list of all elements that cause is_bad() to return True + + Here's an example of finding all negative numbers in a list. Not very + useful for this particular task, but it is demonstrative of how to use it. + >>> call_count = 0 + >>> def is_bad(x,y): + ... global call_count + ... call_count += 1 + ... return min(x) < 0 + >>> x = bisect_search(is_bad, [1, 3, 4, 5, -1, 10, 0, -15, 3]) + >>> sorted(x) + [-15, -1] + + as a rough performance metric, we want to be sure our call count remains + low for the is_bad() function. + >>> call_count + 9 + + See what happens when it has a pair that only show up together and not + alone. Only if -6 and 5 are in the list, then is_bad returns true. + The assumption of this algorithm is that bad elements are independent, + so this should throw an exception. + >>> def is_bad(x,y): + ... return max(x) - min(x) > 10 + >>> x = bisect_search(is_bad, [-6, 2, 3, -3, -1, 0, 0, -5, 5]) + Traceback (most recent call last): + ... + AssertionError: Assumption that bad elements are independent was wrong + ''' + # copy the incoming list so that we don't modify it + quest_list = list(elements) + known_list = [] + + bad_list = [] + while len(quest_list) > 0 and is_bad(quest_list, known_list): + + # find one bad element + quest_copy = quest_list + no_test = list(known_list) + last_result = False + while len(quest_copy) > 1: + # split the questionable list into two lists + half_1 = quest_copy[:len(quest_copy) // 2] + half_2 = quest_copy[len(quest_copy) // 2:] + last_result = is_bad(half_1, no_test + half_2) + if last_result: + quest_copy = half_1 + no_test.extend(half_2) + # TODO: possible optimization. + # TODO- if the length of half_2 is big enough, test + # TODO- is_bad(half_2, no_test + half_1) + # TODO- and if that returns False, then mark half_2 as known so + # TODO- that we don't need to search it again. + else: + # optimization: mark half_1 as known, so that we don't need to + # search it again + quest_list = quest_list[len(half_1):] + known_list.extend(half_1) + # update the local search + quest_copy = half_2 + no_test.extend(half_1) + + bad_element = quest_list.pop(0) + + # double check that we found a bad element before declaring it bad + if last_result or is_bad([bad_element], known_list + quest_list): + bad_list.append(bad_element) + + # add to the known list to not search it again + known_list.append(bad_element) + + # Perform a sanity check. If we have found all of the bad items, then + # compiling with all but these bad items will cause a good build. + # This will fail if our hypothesis class is wrong + good_list = list(set(elements).difference(bad_list)) + assert not is_bad(good_list, bad_list), \ + 'Assumption that bad elements are independent was wrong' + + return bad_list + +def parse_args(arguments, prog=sys.argv[0]): + ''' + Builds a parser, parses the arguments, and returns the parsed arguments. + + @param arguments: (list of str) arguments given to the program + @param prog: (str) name of the program + ''' + parser = argparse.ArgumentParser( + prog=prog, + description=''' + Compiles the source code under both the ground-truth + compilation and a given problematic compilation. This tool + then finds the minimal set of source files needed to be + compiled under the problematic compilation flags so that the + same answer is given. This allows you to narrow down where the + reproducibility problem lies. + + The log of the procedure will be kept in bisect.log. Note that + this file is overwritten if you call flit bisect again. + ''', + ) + + # These positional arguments only make sense if not doing an auto run + parser.add_argument('compilation', + help=''' + The problematic compilation to use. This should + specify the compiler, optimization level, and + switches (which can be empty). An example value + for this option would be "gcc -O2 + -funsafe-math-optimizations" or + "/opt/intel/bin/icpc -O1". The value will be split + into three groups using space separators, the first + is the compiler, the second is the optimization + level, and the third (if present) is the switches. + You will likely want to have this argument in + quotes since it will contain spaces. + ''') + parser.add_argument('testcase', + help=''' + The testcase to use. You will need to specify one + of the tests. You can find the list of test cases + by calling 'make dev' and then calling the created + executable './devrun --list-tests'. + ''') + # TODO: get the default test case to work + #help=''' + # The testcase to use. If there is only one test + # case, then the default behavior is to use that + # test case. If there are more than one test case, + # then you will need to specify one of them. You + # can find the list of test cases by calling 'make + # dev' and then calling the created executable + # './devrun --list-tests'. + # ''') + + parser.add_argument('-C', '--directory', default='.', + help='The flit test directory to run the bisect tool') + parser.add_argument('-p', '--precision', action='store', required=True, + choices=['float', 'double', 'long double'], + help=''' + Which precision to use for the test. This is a + required argument, since it becomes difficult to + know when a difference happens with multiple + precision runs. The choices are 'float', 'double', + and 'long double'. + ''') + parser.add_argument('-a', '--auto-sqlite-run', action='store', + required=False, + help=''' + Automatically run bisect on all of the non-zero + comparison values in the given sqlite3 file. If + you specify this option, then do not specify the + precision or the compilation or the testcase. + Those will be automatically procured from the + sqlite3 file. The results will be stored in a csv + file called auto-bisect.csv. + ''') + parser.add_argument('--parallel', type=int, default=1, + help=''' + How many parallel bisect searches to perform. This + only makes sense with --auto-sqlite-run, since + there are multiple bisect runs to perform. Each + bisect run is sequential. This is distinct from + the --jobs argument. This one specifies how many + instances of bisect to run, whereas --jobs + specifies how many compilation processes can be + spawned in parallel. + ''') + parser.add_argument('-v', '--verbose', action='store_true', + help=''' + Give verbose output including the output from the + Makefiles. The default is to be quiet and to only + output short updates. + ''') + processors = mp.cpu_count() + parser.add_argument('-j', '--jobs', type=int, default=processors, + help=''' + The number of parallel jobs to use for the call to + GNU make when performing the compilation. Note, + this is not used when executing the tests, just in + compilation. + ''') + parser.add_argument('-d', '--delete', action='store_true', + help=''' + Automatically delete intermediate binaries and + output files. This allows for much bigger + automatic runs where there is a concern for disk + space. However, this option is not solely for the + --auto-sqlite-run option. This will keep the + generated makefiles (e.g. + bisect-01/bisect-make-01.mk), the output + comparisons (e.g. + bisect-01/runbisect-01-out-comparison.csv), and the + log (e.g. bisect-01/bisect.log). The things that + will not stay around are the executables (e.g. + bisect-01/runbisect-01), the saved output values + (e.g. runbisect-01-out_testcase_d.dat and + runbusect-01-out), or the object files (e.g. + bisect-01/obj/*). + ''') + + args = parser.parse_args(arguments) + + # Split the compilation into separate components + split_compilation = args.compilation.strip().split(maxsplit=2) + args.compiler = split_compilation[0] + args.optl = '' + args.switches = '' + if len(split_compilation) > 1: + args.optl = split_compilation[1] + if len(split_compilation) > 2: + args.switches = split_compilation[2] + + return args + +def search_for_linker_problems(args, bisect_path, replacements, sources, libs): + ''' + Performs the search over the space of statically linked libraries for + problems. + + Linking will be done with the ground-truth compiler, but with the static + libraries specified. During this search, all source files will be compiled + with the ground-truth compilation, but the static libraries will be + included in the linking. + + Doing a binary search here actually breaks things since including some + static libraries will require including others to resolve the symbols in + the included static libraries. So, instead this function just runs with + the libraries included, and checks to see if there are reproducibility + problems. + ''' + def bisect_libs_build_and_check(trouble_libs, dummy_libs): + ''' + Compiles all source files under the ground truth compilation and + statically links in the trouble_libs. + + @param trouble_libs: static libraries to compile in + @param dummy_libs: static libraries to ignore and not include + This variable is not used, but necessary for the interface. + + @return True if the compilation has a non-zero comparison between this + mixed compilation and the full ground-truth compilation. + ''' + repl_copy = dict(replacements) + repl_copy['link_flags'] = list(repl_copy['link_flags']) + repl_copy['link_flags'].extend(trouble_libs) + makefile = create_bisect_makefile(bisect_path, repl_copy, sources, + [], dict()) + makepath = os.path.join(bisect_path, makefile) + + print(' Create {0} - compiling and running'.format(makepath), + end='', flush=True) + logging.info('Created %s', makepath) + logging.info('Checking:') + for lib in trouble_libs: + logging.info(' %s', lib) + + try: + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs) + finally: + if args.delete: + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs, target='bisect-smallclean') + resultfile = util.extract_make_var('BISECT_RESULT', makepath, + args.directory)[0] + resultpath = os.path.join(args.directory, resultfile) + result_is_bad = is_result_bad(resultpath) + + result_str = 'bad' if result_is_bad else 'good' + sys.stdout.write(' - {0}\n'.format(result_str)) + logging.info('Result was %s', result_str) + + return result_is_bad + + print('Searching for bad intel static libraries:') + logging.info('Searching for bad static libraries included by intel linker:') + #bad_libs = bisect_search(bisect_libs_build_and_check, libs) + #return bad_libs + if bisect_libs_build_and_check(libs, []): + return libs + return [] + +def search_for_source_problems(args, bisect_path, replacements, sources): + ''' + Performs the search over the space of source files for problems. + ''' + def bisect_build_and_check(trouble_src, gt_src): + ''' + Compiles the compilation with trouble_src compiled with the trouble + compilation and with gt_src compiled with the ground truth compilation. + + @param trouble_src: source files to compile with trouble compilation + @param gt_src: source files to compile with ground truth compilation + + @return True if the compilation has a non-zero comparison between this + mixed compilation and the full ground truth compilation. + ''' + makefile = create_bisect_makefile(bisect_path, replacements, gt_src, + trouble_src, dict()) + makepath = os.path.join(bisect_path, makefile) + + print(' Created {0} - compiling and running'.format(makepath), end='', + flush=True) + logging.info('Created %s', makepath) + logging.info('Checking:') + for src in trouble_src: + logging.info(' %s', src) + + try: + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs) + finally: + if args.delete: + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs, target='bisect-smallclean') + resultfile = util.extract_make_var('BISECT_RESULT', makepath, + args.directory)[0] + resultpath = os.path.join(args.directory, resultfile) + result_is_bad = is_result_bad(resultpath) + + result_str = 'bad' if result_is_bad else 'good' + sys.stdout.write(' - {0}\n'.format(result_str)) + logging.info('Result was %s', result_str) + + return result_is_bad + + print('Searching for bad source files:') + logging.info('Searching for bad source files under the trouble' + ' compilation') + bad_sources = bisect_search(bisect_build_and_check, sources) + return bad_sources + +def search_for_symbol_problems(args, bisect_path, replacements, sources, + bad_source): + ''' + Performs the search over the space of symbols within bad source files for + problems. + + @param args: parsed command-line arguments + @param bisect_path: directory where bisect is being performed + @param replacements: dictionary of values to use in generating the Makefile + @param sources: all source files + @param bad_source: the one bad source file to search for bad symbols + + @return a list of identified bad symbols (if any) + ''' + def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): + ''' + Compiles the compilation with all files compiled under the ground truth + compilation except for the given symbols for the given files. + + In order to be able to isolate these symbols, the files will need to be + compiled with -fPIC, but that is handled by the generated Makefile. + + @param trouble_symbols: (list of SymbolTuple) symbols to use + from the trouble compilation + @param gt_symbols: (list of SymbolTuple) symbols to use from + the ground truth compilation + + @return True if the compilation has a non-zero comparison between this + mixed compilation and the full ground truth compilation. + ''' + all_sources = list(sources) # copy the list of all source files + symbol_sources = [x.src for x in trouble_symbols + gt_symbols] + trouble_src = [] + gt_src = list(set(all_sources).difference(symbol_sources)) + symbol_map = {x: [ + [y.symbol for y in gt_symbols if y.src == x], + [z.symbol for z in trouble_symbols if z.src == x], + ] + for x in symbol_sources} + + makefile = create_bisect_makefile(bisect_path, replacements, gt_src, + trouble_src, symbol_map) + makepath = os.path.join(bisect_path, makefile) + + print(' Created {0} - compiling and running'.format(makepath), end='', + flush=True) + logging.info('Created %s', makepath) + logging.info('Checking:') + for sym in trouble_symbols: + logging.info( + '%s', + ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' + .format(sym=sym)) + + try: + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs) + finally: + if args.delete: + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs, target='bisect-smallclean') + resultfile = util.extract_make_var('BISECT_RESULT', makepath, + args.directory)[0] + resultpath = os.path.join(args.directory, resultfile) + result_is_bad = is_result_bad(resultpath) + + result_str = 'bad' if result_is_bad else 'good' + sys.stdout.write(' - {0}\n'.format(result_str)) + logging.info('Result was %s', result_str) + + return result_is_bad + + print('Searching for bad symbols in:', bad_source) + logging.info('Searching for bad symbols in: %s', bad_source) + logging.info('Note: inlining disabled to isolate functions') + logging.info('Note: only searching over globally exported functions') + logging.debug('Symbols:') + symbol_tuples = extract_symbols(bad_source, + os.path.join(args.directory, 'obj')) + for sym in symbol_tuples: + message = ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' \ + .format(sym=sym) + logging.info('%s', message) + + # Check to see if -fPIC destroyed any chance of finding any bad symbols + if not bisect_symbol_build_and_check(symbol_tuples, []): + message_1 = ' Warning: -fPIC compilation destroyed the optimization' + message_2 = ' Cannot find any trouble symbols' + print(message_1) + print(message_2) + logging.warning('%s', message_1) + logging.warning('%s', message_2) + return [] + + bad_symbols = bisect_search(bisect_symbol_build_and_check, symbol_tuples) + return bad_symbols + +def compile_trouble(directory, compiler, optl, switches, verbose=False, + jobs=mp.cpu_count(), delete=True): + ''' + Compiles the trouble executable for the given arguments. This is useful to + compile the trouble executable as it will force the creation of all needed + object files for bisect. This can be used to precompile all object files + needed for bisect. + ''' + # TODO: much of this was copied from run_bisect(). Refactor code. + trouble_hash = hash_compilation(compiler, optl, switches) + + # see if the Makefile needs to be regenerated + # we use the Makefile to check for itself, sweet + subp.check_call(['make', '-C', directory, 'Makefile'], + stdout=subp.DEVNULL, stderr=subp.DEVNULL) + + # trouble compilations all happen in the same directory + trouble_path = os.path.join(directory, 'bisect-precompile') + try: + os.mkdir(trouble_path) + except FileExistsError: + pass # not a problem if it already exists + + replacements = { + 'bisect_dir': 'bisect-precompile', + 'datetime': datetime.date.today().strftime("%B %d, %Y"), + 'flit_version': conf.version, + 'precision': '', + 'test_case': '', + 'trouble_cc': compiler, + 'trouble_optl': optl, + 'trouble_switches': switches, + 'trouble_id': trouble_hash, + 'link_flags': [], + 'cpp_flags': [], + 'build_gt_local': 'false', + } + makefile = create_bisect_makefile(trouble_path, replacements, []) + makepath = os.path.join(trouble_path, makefile) + + # Compile the trouble executable simply so that we have the object files + build_bisect(makepath, directory, verbose=verbose, + jobs=jobs, target='trouble') + + # Remove this prebuild temporary directory now + if delete: + shutil.rmtree(trouble_path) + +def run_bisect(arguments, prog=sys.argv[0]): + ''' + The actual function for running the bisect command-line tool. + + Returns five things, (bisect_num, libs, sources, symbols, returncode). + - bisect_num: (int) which bisect run this is. Means the bisect results are + stored in args.directory + '/bisect-' + str(bisect_num) + - libs: (list of strings) problem libraries + - sources: (list of strings) problem source files + - symbols: (list of SymbolTuples) problem functions + - returncode: (int) status, zero is success, nonzero is failure + + If the search fails in a certain part, then all subsequent items return + None. For example, if the search fails in the sources search, then the + return value for sources and symbols are both None. If the search fails in + the symbols part, then only the symbols return value is None. + ''' + args = parse_args(arguments, prog) + + trouble_hash = hash_compilation(args.compiler, args.optl, args.switches) + + # see if the Makefile needs to be regenerated + # we use the Makefile to check for itself, sweet + subp.check_call(['make', '-C', args.directory, 'Makefile'], + stdout=subp.DEVNULL, stderr=subp.DEVNULL) + + # create a unique directory for this bisect run + bisect_dir = create_bisect_dir(args.directory) + bisect_num = int(bisect_dir.replace('bisect-', '').lstrip('0')) + bisect_path = os.path.join(args.directory, bisect_dir) + + # keep a bisect.log of what was done, but need to remove all handlers, + # otherwise logging.basicConfig() does nothing. + log = logging.getLogger() + for handler in log.handlers[:]: + log.removeHandler(handler) + logging.basicConfig( + filename=os.path.join(bisect_path, 'bisect.log'), + filemode='w', + format='%(asctime)s bisect: %(message)s', + #level=logging.INFO) + level=logging.DEBUG) + + logging.info('Starting the bisect procedure') + logging.debug(' trouble compiler: "%s"', args.compiler) + logging.debug(' trouble optimization level: "%s"', args.optl) + logging.debug(' trouble switches: "%s"', args.switches) + logging.debug(' trouble testcase: "%s"', args.testcase) + logging.debug(' trouble hash: "%s"', trouble_hash) + + # get the list of source files from the Makefile + sources = util.extract_make_var('SOURCE', 'Makefile', + directory=args.directory) + logging.debug('Sources') + for source in sources: + logging.debug(' %s', source) + + replacements = { + 'bisect_dir': bisect_dir, + 'datetime': datetime.date.today().strftime("%B %d, %Y"), + 'flit_version': conf.version, + 'precision': args.precision, + 'test_case': args.testcase, + 'trouble_cc': args.compiler, + 'trouble_optl': args.optl, + 'trouble_switches': args.switches, + 'trouble_id': trouble_hash, + 'link_flags': [], + 'cpp_flags': [], + 'build_gt_local': 'false', + } + + update_gt_results(args.directory, verbose=args.verbose, jobs=args.jobs) + + # Find out if the linker is to blame (e.g. intel linker linking mkl libs) + bad_libs = [] + if os.path.basename(args.compiler) in ('icc', 'icpc'): + warning_message = 'Warning: The intel compiler may not work with bisect' + logging.info('%s', warning_message) + print(warning_message) + + if '/' in args.compiler: + compiler = os.path.realpath(args.compiler) + else: + compiler = os.path.realpath(shutil.which(args.compiler)) + + # TODO: find a more portable way of finding the static libraries + # TODO- This can be done by calling the linker command with -v to see + # TODO- what intel uses in its linker. The include path is in that + # TODO- output command. + # Note: This is a hard-coded approach specifically for the intel linker + # and what I observed was the behavior. + intel_dir = os.path.join(os.path.dirname(compiler), '..', '..') + intel_dir = os.path.realpath(intel_dir) + intel_lib_dir = os.path.join(intel_dir, 'compiler', 'lib', 'intel64') + libs = [ + os.path.join(intel_lib_dir, 'libdecimal.a'), + os.path.join(intel_lib_dir, 'libimf.a'), + os.path.join(intel_lib_dir, 'libipgo.a'), + os.path.join(intel_lib_dir, 'libirc_s.a'), + os.path.join(intel_lib_dir, 'libirc.a'), + os.path.join(intel_lib_dir, 'libirng.a'), + os.path.join(intel_lib_dir, 'libsvml.a'), + ] + try: + bad_libs = search_for_linker_problems(args, bisect_path, + replacements, sources, libs) + except subp.CalledProcessError: + print() + print(' Executable failed to run.') + print('Failed to search for bad libraries -- cannot continue.') + return bisect_num, None, None, None, 1 + + print(' bad static libraries:') + logging.info('BAD STATIC LIBRARIES:') + for lib in bad_libs: + print(' ' + lib) + logging.info(' %s', lib) + if len(bad_libs) == 0: + print(' None') + logging.info(' None') + + # For now, if the linker was to blame, then say there may be nothing + # else we can do. + if len(bad_libs) > 0: + message = 'May not be able to search further, because of intel ' \ + 'optimizations' + print(message) + logging.info('%s', message) + + # Compile all following executables with these static libraries + # regardless of their effect + replacements['link_flags'].extend(libs) + + # If the libraries were a problem, then reset what the baseline + # ground-truth is, especially since we updated the LINK_FLAGS in the + # generated Makefiles. + if len(bad_libs) > 0: + replacements['build_gt_local'] = 'true' + + try: + bad_sources = search_for_source_problems(args, bisect_path, + replacements, sources) + except subp.CalledProcessError: + print() + print(' Executable failed to run.') + print('Failed to search for bad sources -- cannot continue.') + logging.exception('Failed to search for bad sources.') + return bisect_num, bad_libs, None, None, 1 + + print(' bad sources:') + logging.info('BAD SOURCES:') + for src in bad_sources: + print(' ' + src) + logging.info(' %s', src) + if len(bad_sources) == 0: + print(' None') + logging.info(' None') + + + # Search for bad symbols one bad file at a time + # This will allow us to maybe find some symbols where crashes before would + # cause problems and no symbols would be identified + bad_symbols = [] + for bad_source in bad_sources: + try: + file_bad_symbols = search_for_symbol_problems( + args, bisect_path, replacements, sources, bad_source) + except subp.CalledProcessError: + print() + print(' Executable failed to run.') + print('Failed to search for bad symbols in {} -- cannot continue' \ + .format(bad_source)) + logging.exception('Failed to search for bad symbols in %s', + bad_source) + bad_symbols.extend(file_bad_symbols) + if len(file_bad_symbols) > 0: + print(' bad symbols in {}:'.format(bad_source)) + logging.info(' bad symbols in %s:', bad_source) + for sym in file_bad_symbols: + message = ' line {sym.lineno} -- {sym.demangled}' \ + .format(sym=sym) + print(message) + logging.info('%s', message) + + print('All bad symbols:') + logging.info('BAD SYMBOLS:') + for sym in bad_symbols: + message = ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' \ + .format(sym=sym) + print(message) + logging.info('%s', message) + if len(bad_symbols) == 0: + print(' None') + logging.info(' None') + + return bisect_num, bad_libs, bad_sources, bad_symbols, 0 + +def auto_bisect_worker(arg_queue, result_queue): + ''' + Runs a worker that runs bisect and returns the obtained results into the + result_queue. Runs until the arg_queue is empty. + + @param arg_queue: (multiprocessing.Queue) queue contining lists of + command-line arguments, each one associated with a single call to flit + bisect. This is where the work comes from. These elements are tuples + of + - arguments: (list of str) base of command-line arguments minus + positional + - row: (dict of str -> val) The row to run from the sqlite database. + - i: which job this is starting from i to rowcount + - rowcount: total number of rows that exist + @param result_queue: (multiprocessing.Queue or multiprocessing.SimpleQueue) + queue for putting the results after running them. This will contain a + dictionary with the following keys: + - compiler: (str) compiler used + - optl: (str) optimization level + - switches: (str) switches + - libs: (list of str) bad libraries found + - srcs: (list of str) bad source files found + - syms: (list of SymbolTuple) bad symbols found + - ret: (int) return code of running + + @return None + ''' + import queue + precision_map = { + 'f': 'float', + 'd': 'double', + 'e': 'long double', + } + try: + while True: + arguments, row, i, rowcount = arg_queue.get(False) + + compilation = ' '.join( + [row['compiler'], row['optl'], row['switches']]) + testcase = row['name'] + precision = precision_map[row['precision']] + row_args = list(arguments) + row_args.extend([ + '--precision', precision, + compilation, + testcase, + ]) + print() + print('Run', i, 'of', rowcount) + print('flit bisect', + '--precision', precision, + '"' + compilation + '"', + testcase) + + num, libs, srcs, syms, ret = run_bisect(row_args) + result_queue.put((row, num, libs, srcs, syms, ret)) + + except queue.Empty: + # exit the function + pass + +def parallel_auto_bisect(arguments, prog=sys.argv[0]): + ''' + Runs bisect in parallel under the auto mode. This is only applicable if + the --auto-sqlite-run option has been specified in the arguments. + + @return The sum of the return codes of each bisect call + + The results will be put into a file called auto-bisect.csv with the + following columns: + - testid: The id of the row from the tests table in the sqlite db + - compiler: Compiler name from the db + - optl: Optimization level used, options are '-O0', '-O1', '-O2', and + '-O3' + - switches: Optimization flags used + - precision: Precision checked, options are 'f', 'd', and 'e' for float, + double and extended respectively. + - testcase: FLiT test name run + - type: Type of result. Choices are, 'completed', 'lib', 'src', and + 'sim'. + - completed: + comma-separated list of completed phases. All phases are + 'lib', 'src', and 'sym'. This row is to help identify where + things errored out and failed to continue without parsing the + log files. + - lib: This row has a library reproducibility finding + - src: This row has a source file reproducibility finding + - sym: This row has a symbol reproducibility finding + - name: The value associated with the type from the type column. For + completed, this has a comma-separated list of completed + phases. For lib, the path to the blamed library. For src, + the path to the blamed source file. For sym, has the full + SymbolTuple() output string format, complete with source file, + line number, symbol name (before and after demangling), and + the filename where the symbol is located. + + Note: only for Intel compilations as the trouble compiler will the lib + check actually be performed. If the lib check is skipped, it will still + show up in the list of completed steps, since it is considered to be a null + step. + ''' + # prepend a compilation and test case so that if the user provided + # some, then an error will occur. + args = parse_args( + ['--precision', 'double', 'compilation', 'testcase'] + arguments, + prog) + sqlitefile = args.auto_sqlite_run + + try: + connection = util.sqlite_open(sqlitefile) + except sqlite3.DatabaseError: + print('Error:', sqlitefile, 'is not an sqlite3 file') + return 1 + + query = connection.execute( + 'select * from tests where comparison != 0.0') + rows = query.fetchall() + precision_map = { + 'f': 'float', + 'd': 'double', + 'e': 'long double', + } + + compilation_set = {(row['compiler'], row['optl'], row['switches']) + for row in rows} + + # see if the Makefile needs to be regenerated + # we use the Makefile to check for itself, sweet + subp.check_call(['make', '-C', args.directory, 'Makefile'], + stdout=subp.DEVNULL, stderr=subp.DEVNULL) + + print('Before parallel bisect run, compile all object files') + for i, compilation in enumerate(sorted(compilation_set)): + compiler, optl, switches = compilation + print(' ({0} of {1})'.format(i + 1, len(compilation_set)), + ' '.join((compiler, optl, switches)) + ':', + end='', + flush=True) + compile_trouble(args.directory, compiler, optl, switches, + verbose=args.verbose, jobs=args.jobs, + delete=args.delete) + print(' done', flush=True) + + # Update ground-truth results before launching workers + update_gt_results(args.directory, verbose=args.verbose, jobs=args.jobs) + + # Generate the worker queue + arg_queue = mp.Queue() + result_queue = mp.SimpleQueue() + i = 0 + rowcount = len(rows) + for row in rows: + i += 1 + arg_queue.put((arguments, dict(row), i, rowcount)) + + # Create the workers + workers = [] + for _ in range(args.parallel): + process = mp.Process(target=auto_bisect_worker, + args=(arg_queue, result_queue)) + process.start() + workers.append(process) + + return_tot = 0 + with open('auto-bisect.csv', 'w') as resultsfile: + writer = csv.writer(resultsfile) + writer.writerow([ + 'testid', + 'bisectnum', + 'compiler', + 'optl', + 'switches', + 'precision', + 'testcase', + 'type', + 'name', + 'return', + ]) + resultsfile.flush() + + # Process the results + for _ in range(rowcount): + row, num, libs, srcs, syms, ret = result_queue.get() + return_tot += ret + + entries = [] + completed = [] + if libs is not None: + entries.extend([('lib', x) for x in libs]) + completed.append('lib') + if srcs is not None: + entries.extend([('src', x) for x in srcs]) + completed.append('src') + if syms is not None: + entries.extend([('sym', x) for x in syms]) + completed.append('sym') + # prepend the completed items so it is first. + entries = [('completed', ','.join(completed))] + entries + + for entry in entries: + writer.writerow([ + row['id'], + num, + row['compiler'], + row['optl'], + row['switches'], + precision_map[row['precision']], + row['name'], + entry[0], + entry[1], + ret, + ]) + resultsfile.flush() + + # Join the workers + for process in workers: + process.join() + + # Remove the files that were precompiled + if args.delete: + for makepath in glob.iglob('bisect-*/bisect-make-01.mk'): + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs, target='bisect-clean') + + return return_tot + +def main(arguments, prog=sys.argv[0]): + ''' + A wrapper around the bisect program. This checks for the --auto-sqlite-run + stuff and runs the run_bisect multiple times if so. + ''' + + if '-a' in arguments or '--auto-sqlite-run' in arguments: + return parallel_auto_bisect(arguments, prog) + + _, _, _, _, ret = run_bisect(arguments, prog) + return ret + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/scripts/flitcli/flit_import.py b/scripts/flitcli/flit_import.py index f5c31f5a..4b078dbc 100644 --- a/scripts/flitcli/flit_import.py +++ b/scripts/flitcli/flit_import.py @@ -150,6 +150,7 @@ def main(arguments, prog=sys.argv[0]): print('Error: {0} not found. Run "flit init"'.format(tomlfile), file=sys.stderr) return 1 + util.fill_defaults(projconf) assert projconf['database']['type'] == 'sqlite', \ 'Only sqlite database supported' @@ -182,7 +183,7 @@ def main(arguments, prog=sys.argv[0]): latest_run = importee_run_ids[-1] import_run = args.run if args.run is not None else latest_run cur.execute('select name,host,compiler,optl,switches,precision,' - 'comparison,comparison_d,file,nanosec ' + 'comparison_hex,comparison,file,nanosec ' 'from tests where run = ?', (import_run,)) rows = [dict(x) for x in cur] else: @@ -206,8 +207,8 @@ def main(arguments, prog=sys.argv[0]): row['optl'], row['switches'], row['precision'], + row['comparison_hex'], row['comparison'], - row['comparison_d'], row['file'], row['nanosec'], )) @@ -220,8 +221,8 @@ def main(arguments, prog=sys.argv[0]): optl, switches, precision, + comparison_hex, comparison, - comparison_d, file, nanosec) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) diff --git a/scripts/flitcli/flit_init.py b/scripts/flitcli/flit_init.py index 24b0c500..125b48ba 100644 --- a/scripts/flitcli/flit_init.py +++ b/scripts/flitcli/flit_init.py @@ -87,7 +87,6 @@ import shutil import socket import sys -import toml import flitconfig as conf import flitutil @@ -119,16 +118,8 @@ def main(arguments, prog=sys.argv[0]): # write flit-config.toml flit_config_dest = os.path.join(args.directory, 'flit-config.toml') print('Creating {0}'.format(flit_config_dest)) - flitutil.process_in_file( - os.path.join(conf.config_dir, 'flit-default.toml.in'), - flit_config_dest, - { - 'flit_path': os.path.join(conf.script_dir, 'flit.py'), - 'config_dir': conf.config_dir, - 'hostname': socket.gethostname(), - 'flit_version': conf.version, - }, - overwrite=args.overwrite) + with open(flit_config_dest, 'w') as fout: + fout.write(flitutil.get_default_toml_string()) def copy_files(dest_to_src, remove_license=True): ''' @@ -137,7 +128,7 @@ def copy_files(dest_to_src, remove_license=True): declaration at the top of each file copied. @return None ''' - for dest, src in dest_to_src.items(): + for dest, src in sorted(dest_to_src.items()): realdest = os.path.join(args.directory, dest) print('Creating {0}'.format(realdest)) if not args.overwrite and os.path.exists(realdest): diff --git a/scripts/flitcli/flit_make.py b/scripts/flitcli/flit_make.py index d416e4ff..90deb059 100644 --- a/scripts/flitcli/flit_make.py +++ b/scripts/flitcli/flit_make.py @@ -102,14 +102,14 @@ def main(arguments, prog=sys.argv[0]): ) processors = multiprocessing.cpu_count() parser.add_argument('-j', '--jobs', type=int, default=processors, - help=''' - The number of parallel jobs to use for the call to - GNU make when performing the compilation. Note, - this is not used when executing the tests. This - is because in order to get accurate timing data, - one cannot in general run multiple versions of the - same code in parallel. - ''') + help=''' + The number of parallel jobs to use for the call to + GNU make when performing the compilation. Note, + this is not used when executing the tests. This + is because in order to get accurate timing data, + one cannot in general run multiple versions of the + same code in parallel. + ''') parser.add_argument('--exec-jobs', type=int, default=1, help=''' The number of parallel jobs to use for the call to diff --git a/scripts/flitcli/flit_update.py b/scripts/flitcli/flit_update.py index ade7ddd4..f3582db3 100644 --- a/scripts/flitcli/flit_update.py +++ b/scripts/flitcli/flit_update.py @@ -114,6 +114,7 @@ def main(arguments, prog=sys.argv[0]): print('Error: {0} not found. Run "flit init"'.format(tomlfile), file=sys.stderr) return 1 + flitutil.fill_defaults(projconf) makefile = os.path.join(args.directory, 'Makefile') if os.path.exists(makefile): @@ -149,8 +150,16 @@ def main(arguments, prog=sys.argv[0]): # TODO: use the compiler mnemonic rather than the path gt_compiler_bin = matching_gt_compilers[0]['binary'] if '/' in dev_compiler_bin: - gt_compiler_bin = os.path.realpath(gt_compiler_name) + gt_compiler_bin = os.path.realpath(gt_compiler_bin) + test_run_args = '' + if not projconf['run']['timing']: + test_run_args = '--no-timing' + else: + test_run_args = ' '.join([ + '--timing-loops', str(projconf['run']['timing_loops']), + '--timing-repeats', str(projconf['run']['timing_repeats']), + ]) flitutil.process_in_file( os.path.join(conf.data_dir, 'Makefile.in'), makefile, @@ -166,6 +175,9 @@ def main(arguments, prog=sys.argv[0]): 'flit_data_dir': conf.data_dir, 'flit_script_dir': conf.script_dir, 'flit_version': conf.version, + 'test_run_args': test_run_args, + 'enable_mpi': 'yes' if projconf['run']['enable_mpi'] else 'no', + 'mpirun_args': projconf['run']['mpirun_args'], }, overwrite=True) diff --git a/scripts/flitcli/flitutil.py b/scripts/flitcli/flitutil.py index 5d8c6e5a..d9ebc7f4 100644 --- a/scripts/flitcli/flitutil.py +++ b/scripts/flitcli/flitutil.py @@ -86,9 +86,114 @@ import flitconfig as conf +import copy import os +import socket import sqlite3 +import subprocess as subp import sys +import tempfile +import toml + +# cached values +_default_toml = None +_default_toml_string = None + +def get_default_toml_string(): + ''' + Gets the default toml configuration file for FLiT and returns the string. + ''' + global _default_toml_string + if _default_toml_string is None: + _default_toml_string = process_in_string( + os.path.join(conf.config_dir, 'flit-default.toml.in'), + { + 'flit_path': os.path.join(conf.script_dir, 'flit.py'), + 'config_dir': conf.config_dir, + 'hostname': socket.gethostname(), + 'flit_version': conf.version, + }) + return _default_toml_string + +def get_default_toml(): + ''' + Gets the default toml configuration file for FLIT and returns the + configuration object. + ''' + global _default_toml + if _default_toml is None: + _default_toml = toml.loads(get_default_toml_string()) + return _default_toml + +def fill_defaults(vals, defaults=None): + ''' + Given two combinations of dictionaries and lists (such as something + generated from a json file or a toml file), enforce the defaults where the + vals has missing values. + + - For dictionaries, missing keys will be populated with default values + - For lists, this will recursively fill the defaults on each list item with + the first list item in defaults (all other list items in defaults are + ignored) + + Modifies vals and also returns the vals dictionary. + + If defaults is None, then the dictionary returned from get_default_toml() + will be used. + + >>> fill_defaults({'a': 1}, {}) + {'a': 1} + + >>> fill_defaults({}, {'a': 1}) + {'a': 1} + + >>> fill_defaults({'a': 1}, {'a': 2}) + {'a': 1} + + >>> fill_defaults({'a': 2}, {'a': 1, 'b': 3}) + {'a': 2, 'b': 3} + + >>> fill_defaults([{}, {'a': 1}], [{'a': 2, 'b': 3}]) + [{'a': 2, 'b': 3}, {'a': 1, 'b': 3}] + ''' + if defaults is None: + defaults = get_default_toml() + if isinstance(vals, dict): + assert isinstance(defaults, dict) + for key in defaults: + if key not in vals: + vals[key] = copy.deepcopy(defaults[key]) + else: + fill_defaults(vals[key], defaults[key]) + elif isinstance(vals, list): + assert isinstance(defaults, list) + for x in vals: + fill_defaults(x, defaults[0]) + return vals + +def process_in_string(infile, vals, remove_license=True): + ''' + Process a file such as 'Makefile.in' where there are variables to + replace. Returns a string with the replacements instead of outputting to a + file. + + @param infile: input file. Usually ends in ".in" + @param vals: dictionary of key -> val where we search and replace {key} + with val everywhere in the infile. + @param remove_license: (default True) True means remove the License + declaration at the top of the file that has "-- LICENSE BEGIN --" at + the beginning and "-- LICENSE END --" at the end. All lines between + including those lines will be removed. False means ignore the license + section. If the license section is not there, then this will have no + effect (except for a slight slowdown for searching) + @return processed string + ''' + with open(infile, 'r') as fin: + if remove_license: + fin_content = ''.join(remove_license_lines(fin)) + else: + fin_content = fin.read() + return fin_content.format(**vals) def process_in_file(infile, dest, vals, overwrite=False, remove_license=True): ''' @@ -116,13 +221,9 @@ def process_in_file(infile, dest, vals, overwrite=False, remove_license=True): print('Warning: {0} already exists, not overwriting'.format(dest), file=sys.stderr) return - with open(infile, 'r') as fin: - if remove_license: - fin_content = ''.join(remove_license_lines(fin)) - else: - fin_content = fin.read() - with open(dest, 'w') as fout: - fout.write(fin_content.format(**vals)) + content = process_in_string(infile, vals, remove_license=remove_license) + with open(dest, 'w') as fout: + fout.write(content) def remove_license_lines(lines): ''' @@ -211,3 +312,40 @@ def is_sqlite(filename): header = fd.read(100) return header[:16] == b'SQLite format 3\000' + +def extract_make_var(var, makefile='Makefile', directory='.'): + ''' + Extracts the value of a particular variable within a particular Makefile. + + How it works with a valid file: + + >>> from tempfile import NamedTemporaryFile as NTF + >>> with NTF(mode='w+') as fout: + ... print('A := hello there sweetheart\\n', file=fout, flush=True) + ... A = extract_make_var('A', fout.name) + >>> A + ['hello', 'there', 'sweetheart'] + + If the variable is undefined, then simply an empty list is returned. + + >>> with NTF() as fout: extract_make_var('A', fout.name) + [] + + What if the file does not exist? It throws an exception: + + >>> extract_make_var('A', 'file-should-not-exist.mk') # doctest: +ELLIPSIS + Traceback (most recent call last): + ... + subprocess.CalledProcessError: Command ... returned non-zero exit status 2. + ''' + with tempfile.NamedTemporaryFile(mode='w+') as fout: + print('print-%:\n' + "\t@echo '$*=$($*)'\n", file=fout, flush=True) + output = subp.check_output( + ['make', '-f', makefile, '-f', fout.name, 'print-' + var, + '--directory', directory, '--no-print-directory'], + stderr=subp.STDOUT) + output = output.strip().decode('utf-8') + var_values = output.split('=', maxsplit=1)[1].split() + return var_values + diff --git a/scripts/hostCollect.sh b/scripts/hostCollect.sh deleted file mode 100755 index 03074443..00000000 --- a/scripts/hostCollect.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/bash -x - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -#the following vars should be selectively defined prior to execution -#CORES DO_PIN(or not) DB_USER DB_HOST DB_PASSWD - -#set -e - -echo CORES: ${CORES} -echo DO_PIN: ${DO_PIN} -echo DB_USER: ${DB_USER} -echo DB_HOST: ${DB_HOST} -echo FLIT_DIR: ${FLIT_DIR} -echo SLURMED: ${SLURMED} -echo CUDA_ONLY: ${CUDA_ONLY} - -mkdir -p results - -#do the full test suite -cd src - -if [ "$CUDA_ONLY" = "False" ]; then - unset CUDA_ONLY -fi - -make -j ${CORES} &> ../results/makeOut - -cd .. - -#do PIN -if [ "${DO_PIN}" = "True" ]; then - - #setup PIN tool - if [ -e pin ]; then - rm -fr pin - fi - mkdir pin - cd pin - wget http://software.intel.com/sites/landingpage/pintool/downloads/pin-3.0-76991-gcc-linux.tar.gz - tar xf pin* - rm *.gz - mv pin* pin - - pushd . - cd pin/source/tools/SimpleExamples - make obj-intel64/opcodemix.so - popd - - export PINPATH=$(pwd)/pin - - #run pin tests - cd ../results - make -j ${CORES} -f ../scripts/MakeCollectPin &>> makeOut - cd .. -fi - -cd results - -#zip up all outputs -ZIPFILE=$(hostname)_$(date +%m%d%y%H%M%S)_flit.tgz -tar zcf ${ZIPFILE} * - -if [ "${SLURMED}" != "None" ]; -then - scp ${ZIPFILE} ${DB_USER}@${DB_HOST}:~/flit_data -fi - -exit $? diff --git a/scripts/hostfile.py b/scripts/hostfile.py deleted file mode 100644 index d876a609..00000000 --- a/scripts/hostfile.py +++ /dev/null @@ -1,105 +0,0 @@ -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -#this is where the user configures her database and -#worker hosts. -#db_host: (user, fqdn) -#run_host: (user, fqdn, processes, SlurmScript, CUDA only, get opcode count) - -import os -import multiprocessing - -user = os.environ['USER'] -#cores = multiprocessing.cpu_count() - -DB_HOST = (user, 'ms0325.utah.cloudlab.us') -#DB_HOST = ('sawaya', 'bihexal.cs.utah.edu') -RUN_HOSTS = (('u0422778', 'kingspeak1.chpc.utah.edu', 56, - 'kingspeak_cpu_startup', False, False), - ('u0422778', 'kingspeak1.chpc.utah.edu', 12, - 'kingspeak_gpu_startup', True, False), - # ('sawaya', 'ms0138.utah.cloudlab.us', 8, - # None, False, False), -) - -#another possibility: -#RUN_HOSTS = ((user, 'localhost', cores, None, False, False),) diff --git a/scripts/kingspeak_cpu_startup b/scripts/kingspeak_cpu_startup deleted file mode 100755 index c5986074..00000000 --- a/scripts/kingspeak_cpu_startup +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash -x - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -#This script relies on the following env vars: -#TMPD FLIT_DIR BRANCH REPO - -#SBATCH --time=1:00:00 -#SBATCH -o /uufs/chpc.utah.edu/common/home/u0422778/slurm-flit-cpu-%j.out -#SBATCH -e /uufs/chpc.utah.edu/common/home/u0422778/slurm-flit-cpu-%j.err -#SBATCH -n 28 -#SBATCH -N 1 -#SBATCH --account ganesh-kp -#SBATCH --partition soc-kp - -set -e - -module load gcc/5.4.0 -module load git/2.10.0 -module unload xalt -module load binutils/2.26.51 -module load intel - -CLANG_ARCH=llvm_kp307_build.tgz -#setup working directory - -export TMPD=$(mktemp -d) -cd ${TMPD} -mkdir ${FLIT_DIR} -cd ${FLIT_DIR} -cp ${PDIR}/flit.tgz . -tar xf flit.tgz -cd .. - -cp ${HOME}/${CLANG_ARCH} . - -export PATH=${TMPD}/bin:${PATH} -export LD_LIBRARY_PATH=${TMPD}/lib:${LD_LIBRARY_PATH} - -tar xf ${CLANG_ARCH} - -cd ${FLIT_DIR} - -scripts/hostCollect.sh - -cd /tmp -rm -fr ${TMPD} -rm -fr ${PDIR} diff --git a/scripts/kingspeak_gpu_startup b/scripts/kingspeak_gpu_startup deleted file mode 100755 index e78e5a86..00000000 --- a/scripts/kingspeak_gpu_startup +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - - -#required: -#BRANCH REPO FLIT_DIR CORES DB_USER DB_HOST -#[maybe] CUDA_ONLY and DO_PIN - -#SBATCH --time=1:00:00 -#SBATCH --nodes=1 -#SBATCH --ntasks=3 -#SBATCH -o slurm-flit-gpu-%j.out -#SBATCH -e slurm-flit-gpu-%j.err -#SBATCH --account=kingspeak-gpu -#SBATCH --partition=kingspeak-gpu -#SBATCH --gres=gpu:titanx:1 - -set -e - -module load cuda -module load gcc - -#setup working directory - -export TMPD=$(mktemp -d) -cd ${TMPD} -mkdir ${FLIT_DIR} -cd ${FLIT_DIR} -cp ${PDIR}/flit.tgz . -tar xf flit.tgz - -scripts/hostCollect.sh - -cd /tmp -rm -fr ${TMPD} -rm -fr ${PDIR} diff --git a/scripts/run_all.py b/scripts/run_all.py deleted file mode 100755 index bec0a0e6..00000000 --- a/scripts/run_all.py +++ /dev/null @@ -1,404 +0,0 @@ -#!/usr/bin/env python3 - -# -- LICENSE BEGIN -- -# -# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. -# -# Produced at the Lawrence Livermore National Laboratory -# -# Written by -# Michael Bentley (mikebentley15@gmail.com), -# Geof Sawaya (fredricflinstone@gmail.com), -# and Ian Briggs (ian.briggs@utah.edu) -# under the direction of -# Ganesh Gopalakrishnan -# and Dong H. Ahn. -# -# LLNL-CODE-743137 -# -# All rights reserved. -# -# This file is part of FLiT. For details, see -# https://pruners.github.io/flit -# Please also read -# https://github.com/PRUNERS/FLiT/blob/master/LICENSE -# -# Redistribution and use in source and binary forms, with or -# without modification, are permitted provided that the following -# conditions are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the disclaimer below. -# -# - Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the disclaimer -# (as noted below) in the documentation and/or other materials -# provided with the distribution. -# -# - Neither the name of the LLNS/LLNL nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL -# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. -# -# Additional BSD Notice -# -# 1. This notice is required to be provided under our contract -# with the U.S. Department of Energy (DOE). This work was -# produced at Lawrence Livermore National Laboratory under -# Contract No. DE-AC52-07NA27344 with the DOE. -# -# 2. Neither the United States Government nor Lawrence Livermore -# National Security, LLC nor any of their employees, makes any -# warranty, express or implied, or assumes any liability or -# responsibility for the accuracy, completeness, or usefulness of -# any information, apparatus, product, or process disclosed, or -# represents that its use would not infringe privately-owned -# rights. -# -# 3. Also, reference herein to any specific commercial products, -# process, or services by trade name, trademark, manufacturer or -# otherwise does not necessarily constitute or imply its -# endorsement, recommendation, or favoring by the United States -# Government or Lawrence Livermore National Security, LLC. The -# views and opinions of authors expressed herein do not -# necessarily state or reflect those of the United States -# Government or Lawrence Livermore National Security, LLC, and -# shall not be used for advertising or product endorsement -# purposes. -# -# -- LICENSE END -- - -# this is the master run test -# by executing this file, after having configured -# hostfile.py (and any corresponding collect scripts), -# will -## configure DB server -## push tests out to workers -## run tests on workers -- pushing data to db server -## collect data into db - -import os -from subprocess import Popen, PIPE, check_output, STDOUT, CalledProcessError -import getpass -import sys -from datetime import datetime -import re -import time - -#local -import hostfile - -home_dir = os.path.dirname(os.path.realpath(__file__)) - -#vars -label = '' -DB_HOST_AUX = '/tmp/flitDbDir' -DBINIT = 'prepDBHost.py' -db_host = hostfile.DB_HOST -run_hosts = hostfile.RUN_HOSTS -FLIT_DIR = 'src' -REM_ENV = {'FLIT_DIR': FLIT_DIR} -SSHS = 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q ' -SSHL = ['ssh', '-o UserKnownHostsFile=/dev/null', '-o StrictHostKeyChecking=no', '-q'] -SCPS = 'scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q ' -SCPL = ['scp', '-o UserKnownHostsFile=/dev/null', '-o StrictHostKeyChecking=no', '-q'] -pwds = {} - -def usage(): - print('usage: ' + sys.argv[0] + ' "label"') - print('\tyou must populate ' + home_dir + '/hostfile.py with') - print('\trun and db host info (see file for details)') - -def makeEnvStr(env): - retVal = '' - for k,v in env.items(): - retVal += 'export ' + k + '=' + v + '; ' - return retVal - -def getJobNum(substr): - m = re.match(r".*Submitted batch job ([0-9]+)", - substr, re.DOTALL) - try: - return m.group(1) - except AttributeError: - return None - -def slurmWait(user, host, pw, jobn): - envir = os.environ.copy() - envir['SSHPASS'] = pw - try: - while user in check_output(['sshpass', '-e', *SSHL, - user + '@' + host, - 'squeue -j ' + jobn], - env=envir).decode("utf-8"): - print('.') - time.sleep(10) - except CalledProcessError: - pass - -def runOnAll(cmdStrs): - procs = [] - results = [] - for host in zip(run_hosts, cmdStrs): - pkey = host[0][0]+'@'+host[0][1] - local_env = os.environ.copy() - local_env['SSHPASS'] = pwds[pkey] - rem_env = REM_ENV.copy() - rem_env['CUDA_ONLY'] = str(host[0][4]) - rem_env['DO_PIN'] = str(host[0][5]) - rem_env['CORES'] = str(host[0][2]) - rem_env['DB_HOST'] = str(db_host[1]) - rem_env['DB_USER'] = str(db_host[0]) - rem_env['SLURMED'] = str(host[0][3]) - if host[1] is not None: - cmdStr = ('sshpass -e ' + - host[1].format(host[0][0], host[0][1], - host[0][3], - makeEnvStr(rem_env))) - print('executing: ' + cmdStr) - procs.append([Popen(cmdStr, - shell=True, stdout=PIPE, stderr=STDOUT, - env=local_env), - host[0][3], host[0][0], host[0][1], pwds[pkey]]) - for p in procs: - p[0].wait() - outs = p[0].stdout.read().decode("utf-8") - results.append(outs.strip()) - print(outs) - if p[1] is not None: #if it's slurm - jn = getJobNum(outs) - if jn is not None: - slurmWait(p[2], p[3], p[4], jn) - return results - -def getPasswords(): - print('please enter your credentials (pwds) for remote hosts, ' + - '[or empty for passphraseless ssh key auth]. No creds will be stored') - print(db_host) - print(run_hosts) - for host in ((db_host,) + run_hosts): - key = host[0] + '@' + host[1] - if key not in pwds: - pwds[key] = getpass.getpass( - 'Enter password for ' + host[0] + '@' + host[1] + ': ' - ) - -if len(sys.argv) == 2: - label = sys.argv[1] - -else: - usage() - exit(1) - - -#get passwords -getPasswords() - -#setup db -- we're doing this first because it's cheap and if it fails, -#the rest of the work will go to waste -print('preparing workspace on DB server, ' + db_host[1] + '...') -os.chdir(home_dir + '/../db') -print(check_output('tar zcf ' + home_dir + '/dbPy.tgz *', - shell=True). - decode("utf-8")) -os.chdir(home_dir) -new_env = os.environ.copy() -new_env['SSHPASS'] = pwds[db_host[0] + '@' + db_host[1]] -print(check_output('sshpass ' + SCPS + home_dir + '/dbPy.tgz ' + - db_host[0] + '@' + db_host[1] + ':', shell=True, - env=new_env). - decode("utf-8")) -os.remove('dbPy.tgz') -print(check_output(['sshpass', '-e', *SCPL, home_dir + '/' + DBINIT, - db_host[0] + '@' + db_host[1] + ':~/'], - env=new_env).decode("utf-8")) -print(check_output(['sshpass', '-e', *SSHL, db_host[0] + '@' + db_host[1], - ' ./' + DBINIT, DB_HOST_AUX], env=new_env).decode("utf-8")) - -# #get run# from db -print(check_output(['sshpass', '-e', *SSHL, - db_host[0] + '@' + db_host[1], - 'psql flit -t -c "insert into runs (rdate, label) ' + - 'values (\'' + str(datetime.now()) + '\', \'' + label + '\')"'], - env=new_env).decode("utf-8")) -run_num = int(check_output(['sshpass', '-e', *SSHL, - db_host[0] + '@' + db_host[1], - 'psql flit -t -c "select max(index) from runs"'], - env=new_env).decode("utf-8")) - -#create worker package (use to be git checkout) -print('creating worker package . . .') -olddir = os.getcwd() -os.chdir(home_dir + '/..') -print(check_output(['tar', 'zcf', 'flit.tgz', 'scripts', 'src']).decode("utf-8")) -os.chdir(olddir) -print('done.') - - - -cmds = [] -#transfer package to workers (or portal, if slurm script provided) -package_dirs = runOnAll([SSHS + ' {0}@{1} "echo \$(mktemp -d -p ~/)"'] * - len(run_hosts)) -print(*package_dirs, sep=',') -runOnAll([SCPS + home_dir + '/../flit.tgz {0}@{1}:' + d for d in package_dirs]) -for i, d in enumerate(package_dirs): - assert len(d) > 0, "got zero length directory from mktemp %r" % run_hosts[i][1] - -#this does all the work of running and collecting - -cmds = [] -copycs = [] -cleancs = [] -for host in zip(run_hosts, package_dirs): - if host[0][3] is None: #0-user 1-host 2-script 3-enviro - cmd = (SSHS + ' {0}@{1} "{3} cd ' + host[1] + ' && ' + - 'tar xf flit.tgz && scripts/hostCollect.sh"' - ) - copyc = (SCPS + '{0}@{1}:/' + host[1] + '/results/"*.tgz" .') - cleanc = None #DELME - #cleanc = ('ssh {0}@{1} "rm -fr ' + host[1] + '"') - else: - cmd = (SSHS + ' {0}@{1} "cd ' + host[1] + ' && ' + - 'tar xf flit.tgz scripts/' + host[0][3] + ' && ' + - 'cd .. && ' + - 'export PDIR=' + host[1] + ' {3} sbatch ' + - host[1] + '/scripts/' + host[0][3] + '"') - copyc = None - cleanc = None - cmds.append(cmd) - copycs.append(copyc) - cleancs.append(cleanc) -runOnAll(cmds) -runOnAll(copycs) -runOnAll(cleancs) - -new_env = os.environ.copy() -new_env['SSHPASS'] = pwds[db_host[0] + '@' + db_host[1]] - -# # #copy the result files that we copied to here (the launch host) -try: - print(check_output('sshpass -e ' + SCPS + home_dir + - '/*.tgz ' + db_host[0] + '@' + - db_host[1] + ':flit_data', - shell=True,env=new_env).decode("utf-8")) - print(check_output('rm *.tgz', shell=True).decode("utf-8")) -except CalledProcessError: - pass - - -#import to database -- need to unzip and then run importflitresults2 -cmd = ( - 'cd ~/flit_data && ' + - 'for f in *.tgz; do tar xf \$f; done && ' + - 'psql flit -c \\"select importflitresults2(\'\$(pwd)\',' + - str(run_num) + ')\\" ' - ) -if any(list(zip(*run_hosts))[5]): #any opcode collections - cmd += ( - '&& rm *O0 *O1 *O2 *O3 *out_ ' + - '&& psql flit -c \\"select importopcoderesults(\'\$(pwd)\',' + - str(run_num) + - ')\\" && echo \$? && echo \\"db importation complete\\"' - ) -print(check_output('sshpass -e ' + SSHS + db_host[0] + '@' + db_host[1] + - ' "' + cmd + '"', env=new_env, - shell=True).decode("utf-8")) - -#display report / exit message - - -#run_num = 1 - -plot_dir = (check_output(['sshpass', '-e', *SSHL, db_host[0] + '@' + db_host[1], - 'echo $HOME'], env=new_env).decode("utf-8").strip() + - '/flit_data/reports') - -#get list of hosts -- are often different than the interactive node used -#to submit the work - - -cmd = ('psql flit -t -c \\"select distinct host from tests where run = ' + - str(run_num) + '\\"') -rhosts = [s.strip() for s in check_output('sshpass -e ' + SSHS + db_host[0] + - '@' + db_host[1] + - ' "' + cmd + '"', - env=new_env, - shell=True). - decode("utf-8").split('\n') if len(s) > 0] -# print('rhosts is: ') -# print(*rhosts, sep=',') - -pcmd = ( - 'set -x && ' + - 'mkdir -p ~/flit_data/reports && ' + - 'cd ~/flit_data/reports && ' + - 'chmod 777 ~/flit_data/reports ' -) - -gcmd = ('set -x && ' - # 'unset MATPLOTLIBRC && ' - # 'export MATPLOTLIBRC=' + DB_HOST_AUX + ' && ' + - # 'echo \$MATPLOTLIBRC && ' -) - -for h in rhosts: - pcmd += ( - ' && touch f_nvcc_' + h + '.pdf ' + - '&& touch d_nvcc_' + h + '.pdf ' + - '&& touch f_all_' + h + '.pdf ' + - '&& touch d_all_' + h + '.pdf ' + - '&& touch e_all_' + h + '.pdf ' - ) - gcmd += ( - 'psql flit -c \\"select createschmoo(' + str(run_num) + ',' + - '\'{\\"f\\"}\',\'{\\"nvcc\\"}\',' + - '\'{\\"\\"}\',' + - '\'' + h + '\',5,\'' + plot_dir + '/f_nvcc_' + h + '.pdf\')\\" & ' + - 'psql flit -c \\"select createschmoo(' + str(run_num) + ',' + - '\'{\\"d\\"}\',\'{\\"nvcc\\"}\',' + - '\'{\\"\\"}\',' + - '\'' + h + '\',5,\'' + plot_dir + '/d_nvcc_' + h + '.pdf\')\\" & ' + - 'psql flit -c \\"select createschmoo(' + str(run_num) + ',' + - '\'{\\"f\\"}\',\'{\\"icpc\\", \\"g++\\", \\"clang++\\"}\',' + - '\'{\\"-O1\\", \\"-O2\\", \\"-O3\\"}\',' + - '\'' + h + '\',3,\'' + plot_dir + '/f_all_' + h + '.pdf\')\\" & ' + - 'psql flit -c \\"select createschmoo(' + str(run_num) + ',' + - '\'{\\"d\\"}\',\'{\\"icpc\\", \\"g++\\", \\"clang++\\"}\',' + - '\'{\\"-O1\\", \\"-O2\\", \\"-O3\\"}\',' + - '\'' + h + '\',3,\'' + plot_dir + '/d_all_' + h + '.pdf\')\\" & ' + - 'psql flit -c \\"select createschmoo(' + str(run_num) + ',' + - '\'{\\"e\\"}\',\'{\\"icpc\\", \\"g++\\", \\"clang++\\"}\',' + - '\'{\\"-O1\\", \\"-O2\\", \\"-O3\\"}\',' + - '\'' + h + '\',3,\'' + plot_dir + '/e_all_' + h + '.pdf\')\\" & ' - ) -pcmd += '&& chmod 777 * ' - -gcmd += ' wait' - -#print('cmd line: ' + cmd) - -print(check_output('sshpass -e ' + SSHS + db_host[0] + '@' + db_host[1] + - ' "' + pcmd + '"', env=new_env, - shell=True).decode("utf-8")) - -print(check_output('sshpass -e ' + SSHS + db_host[0] + '@' + db_host[1] + - ' "' + gcmd + '"', env=new_env, - shell=True).decode("utf-8")) - -print('Finished FLiT Run. You may review the reports at: ' + - db_host[0] + '@' + db_host[1] + ':' + plot_dir) diff --git a/scripts/watch-progress.sh b/scripts/watch-progress.sh new file mode 100755 index 00000000..062213f4 --- /dev/null +++ b/scripts/watch-progress.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +cd results +watch -n 2 \ + 'echo ...; \ + ls -tr | \ + tail -n 10; \ + echo; \ + echo -n "$(find . -name \*-out -type f -not -executable | wc -l)"; \ + echo -n " of "; \ + echo -n "$(find . -executable -type f | wc -l)"; \ + echo -n ", "; \ + echo -n "$(find . -name \*-out -type f -empty -not -executable | \ + tail -n +2 | \ + wc -l)"; \ + echo -n " were skipped - "; \ + echo -n "$(for file in $(find . -type f -name \*-comparison.csv); do \ + cat $file | \ + awk -F, \{print\ \$11\} | \ + tail -n +2; \ + done | + grep -v "^0$" | wc -l)"; \ + echo -n " bad answers found"; \ + echo' + + diff --git a/src/CUHelpers.cpp b/src/MpiEnvironment.cpp similarity index 90% rename from src/CUHelpers.cpp rename to src/MpiEnvironment.cpp index 5e7f6fee..838cead8 100644 --- a/src/CUHelpers.cpp +++ b/src/MpiEnvironment.cpp @@ -81,25 +81,11 @@ * -- LICENSE END -- */ -#include "CUHelpers.h" -#include "flitHelpers.h" +#include "MpiEnvironment.h" namespace flit { -DEVICE float* cuda_float_rands; -DEVICE uint_fast32_t* cuda_16_shuffle; - -DEVICE -const float* getRandSeqCU() { return cuda_float_rands; } - -DEVICE -const uint_fast32_t* get16ShuffledCU() { return cuda_16_shuffle; } - -GLOBAL -void -loadDeviceData(float* fsource, uint_fast32_t* ssource) { - cuda_float_rands = fsource; - cuda_16_shuffle = ssource; -} +MpiEnvironment *mpi = nullptr; } // end of namespace flit + diff --git a/src/MpiEnvironment.h b/src/MpiEnvironment.h new file mode 100644 index 00000000..5e789b5c --- /dev/null +++ b/src/MpiEnvironment.h @@ -0,0 +1,152 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#ifndef MPI_ENVIRONMENT_H +#define MPI_ENVIRONMENT_H + +#include "flitHelpers.h" + +#ifdef FLIT_USE_MPI +#include +#endif // FLIT_USE_MPI + +namespace flit{ + +/** A structure to encompass all necessities of the MPI environment for FLiT + * + * This is safe to use if MPI is disabled too. Be sure to read the + * documentation to understand how the behavior is different if MPI is + * disabled. + * + * At its construction, this struct initializes the MPI environment, so should + * be called as soon as possible to the beginning of the application (such as + * at the beginning of main()). At its destruction, it will call + * MPI_Finalize(), meaning the lifetime of this object needs to extend beyond + * all usages of the MPI runtime. + */ +struct MpiEnvironment { + bool enabled; + int rank; + int size; + + /// If mpi is enabled, initializes MPI, else does nothing + MpiEnvironment(int &argc, char** &argv) { +#ifdef FLIT_USE_MPI + enabled = true; + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); +#else // not defined(FLIT_USE_MPI) + FLIT_UNUSED(argc); + FLIT_UNUSED(argv); + enabled = false; + rank = 0; + size = 1; +#endif // FLIT_USE_MPI + } + + /// If mpi is enabled, calls MPI_Finalize(), else does nothing + ~MpiEnvironment() { +#ifdef FLIT_USE_MPI + MPI_Finalize(); +#endif // FLIT_USE_MPI + } + + /// If mpi is enabled, calls MPI_Abort(), else does nothing + void abort(int retcode) { +#ifdef FLIT_USE_MPI + MPI_Abort(MPI_COMM_WORLD, retcode); +#else + FLIT_UNUSED(retcode); +#endif // FLIT_USE_MPI + } + + /// Returns true if my rank is zero (i.e. I am the root MPI process) + bool is_root() { return rank == 0; } +}; + +extern MpiEnvironment *mpi; + +} // end of namespace flit + +#endif // MPI_ENVIRONMENT_H diff --git a/src/TestBase.h b/src/TestBase.h index d3057742..7eccd34a 100644 --- a/src/TestBase.h +++ b/src/TestBase.h @@ -88,14 +88,10 @@ #ifndef TEST_BASE_HPP #define TEST_BASE_HPP +#include "MpiEnvironment.h" +#include "Variant.h" #include "flitHelpers.h" - -#ifdef __CUDA__ -#include "CUHelpers.h" -#endif // __CUDA__ - #include "timeFunction.h" -#include "Variant.h" #include #include @@ -154,102 +150,11 @@ struct TestResult { std::ostream& operator<<(std::ostream& os, const TestResult& res); -/** Definition of a kernel function used by CUDA tests - * - * @param arr: array of input arrays, flattened, already allocated and populated - * @param n: length of each input, it is the stride - * @param results: array where to store results, already allocated - */ -template -using KernelFunction = void (const T*, size_t, double*); - -template -using CudaDeleter = void (T*); - -template -std::unique_ptr*> makeCudaArr(const T* vals, size_t length) { -#ifdef __CUDA__ - T* arr; - const auto arrSize = sizeof(T) * length; - - // Create the array - checkCudaErrors(cudaMalloc(&arr, arrSize)); - - // Store it in a smart pointer with a custom deleter - CudaDeleter* deleter = [](T* p) { checkCudaErrors(cudaFree(p)); }; - std::unique_ptr*> ptr(arr, deleter); - - // Copy over the vals array from hist into the device - if (vals != nullptr) { - checkCudaErrors(cudaMemcpy(ptr.get(), vals, arrSize, cudaMemcpyHostToDevice)); - } - - return ptr; -#else - FLIT_UNUSED(vals); - FLIT_UNUSED(length); - throw std::runtime_error("Should not use makeCudaArr without CUDA enabled"); -#endif -} - class TestDisabledError : public std::runtime_error { public: using std::runtime_error::runtime_error; }; -/** Calls a CUDA kernel function and returns the scores - * - * This function is expecting a non-nullptr kernel function with a test input - * sufficient to run the test exactly once. - * - * If we are not compiling under CUDA, then this does nothing and returns - * zeros. If we are compiling under CUDA, then we may run the kernel on the - * CPU or on the GPU based on the definition of __CPUKERNEL__. - * - * This function handles copying the test input to the kernel, allocating - * memory for the result storage, and copying the result type back to the host - * to be returned. - * - * @param kernel: kernel function pointer to call with split up inputs - * @param ti: inputs for all tests runs, to be split by stride - * @param stride: how many inputs per test run - */ -template -std::vector -runKernel(KernelFunction* kernel, const std::vector& ti, size_t stride) { -#ifdef __CUDA__ - size_t runCount; - if (stride < 1) { // the test takes no inputs - runCount = 1; - } else { - runCount = ti.size() / stride; - } - - std::unique_ptr cuResults(new double[runCount]); - // Note: __CPUKERNEL__ mode is broken by the change to run the kernel in - // multithreaded mode. Its compilation is broken. - // TODO: fix __CPUKERNEL__ mode for testing. -# ifdef __CPUKERNEL__ - kernel(ti.data(), stride, cuResults); -# else // not __CPUKERNEL__ - auto deviceVals = makeCudaArr(ti.data(), ti.size()); - auto deviceResult = makeCudaArr(nullptr, runCount); - kernel<<>>(deviceVals.get(), stride, deviceResult.get()); - auto resultSize = sizeof(double) * runCount; - checkCudaErrors(cudaMemcpy(cuResults.get(), deviceResult.get(), resultSize, - cudaMemcpyDeviceToHost)); -# endif // __CPUKERNEL__ - std::vector results(cuResults, cuResults + runCount); - return results; -#else // not __CUDA__ - // Do nothing - FLIT_UNUSED(kernel); - FLIT_UNUSED(ti); - FLIT_UNUSED(stride); - return {}; -#endif // __CUDA__ -} - template class TestBase { public: @@ -265,14 +170,25 @@ class TestBase { * the test is such that it needs to change the notion of running the test * from only a std::vector of inputs for each result pair. * + * @param ti Test input vector + * @param filebase basename for the result file + * @param shouldTime true means we should to timing + * @param timingLoops how many times to loop. A value less than one means + * automatically determine timing loops. + * @param timingRepeats how many times to repeat the timing. + * @param idx which test to run if it is data driven, zero-based indexing. A + * value less than one means to run them all. + * + * @return A vector of test results + * * @see getInputsPerRun */ virtual std::vector run(const std::vector& ti, const std::string &filebase, - const bool shouldTime, - const int timingLoops, - const int timingRepeats) { - FLIT_UNUSED(timingRepeats); + const bool shouldTime = true, + const int timingLoops = -1, + const int timingRepeats = 3, + const int idx = -1) { using std::chrono::high_resolution_clock; using std::chrono::duration; using std::chrono::duration_cast; @@ -301,18 +217,6 @@ class TestBase { runcount++; return this->run_impl(runInput); }; -#ifdef __CUDA__ - // Use the cuda kernel if it is available by replacing runner - auto kernel = getKernel(); - if (kernel != nullptr) { - runner = [kernel, stride, &runcount] (const std::vector& ti) { - // TODO: implement this timer better. - runcount++; - auto scorelist = runKernel(kernel, ti, stride); - return Variant{ scorelist[0] }; - } - } -#endif // __CUDA__ // Run the tests struct TimedResult { @@ -325,7 +229,16 @@ class TestBase { }; std::vector resultValues; - for (size_t i = 0; i < inputSequence.size(); i++) { + // Either only do the specified index, or all of them + std::vector indices; + if (idx < 0) { + indices.resize(inputSequence.size()); + std::iota(indices.begin(), indices.end(), 0); + } else { + indices.push_back(idx); + } + + for (auto i : indices) { auto& runInput = inputSequence.at(i); Variant testResult; int_fast64_t timing = 0; @@ -348,7 +261,8 @@ class TestBase { testResult = runner(runInput); } // If the test returns a dummy value, then do not record this run. - if (testResult.type() == Variant::Type::None) { + // Also, recording of values is only needed in the MPI root process + if (!mpi->is_root() || testResult.type() == Variant::Type::None) { continue; } std::string name = id; @@ -358,7 +272,8 @@ class TestBase { std::string resultfile; if (testResult.type() == Variant::Type::String) { resultfile = filebase + "_" + name + "_" + typeid(T).name() + ".dat"; - std::ofstream resultout(resultfile); + std::ofstream resultout; + flit::ofopen(resultout, resultfile); resultout << testResult.string(); testResult = Variant(); // empty the result to release memory } @@ -433,9 +348,6 @@ class TestBase { * Which one is used depends on the type of Variant that is returned from the * run_impl function. The value returned by compare will be the value stored * in the database for later analysis. - * - * Note: when using the CUDA kernel functionality, only long double return - * values are valid for now. */ virtual long double compare(long double ground_truth, long double test_results) const { @@ -452,27 +364,14 @@ class TestBase { } protected: - /** If this test implements a CUDA kernel, return the kernel pointer - * - * If compiling under CUDA and this returns a valid function pointer (meaning - * not nullptr), then this kernel function will be called instead of - * run_impl(). Otherwise, run_impl() will be called. - * - * This method is not pure virtual because it is not required to implement. - * If it is overridden to return something other than nullptr, then the - * kernel will be called when compiling under a CUDA environment. If when - * compiling under a CUDA environment, this returns nullptr, then the test - * reverts to calling run(). - */ - virtual KernelFunction* getKernel() { return nullptr; } - /** This is where you implement the test * * @param ti: Test input. The vals element will have exactly the amount of * test inputs required according to the implemented getInputsPerRun(). So * if that function returns 9, then the vector will have exactly 9 * elements. - * @return a single result. You can return any type supported by flit::Variant. + * @return a single result. You can return any type supported by + * flit::Variant. * * The returned value (whichever type is chosen) will be used by the public * virtual compare() method. @@ -493,7 +392,6 @@ class NullTest : public TestBase { virtual std::vector run( const std::vector&, const bool, const size_t) override { return {}; } protected: - virtual KernelFunction* getKernel() override { return nullptr; } virtual Variant run_impl(const std::vector&) override { return {}; } }; @@ -540,28 +438,6 @@ inline std::shared_ptr> TestFactory::get () { return std::get<2>(_tests); } -#ifdef __CUDA__ - -#define REGISTER_TYPE(klass) \ - class klass##Factory : public flit::TestFactory { \ - public: \ - klass##Factory() { \ - flit::registerTest(#klass, this); \ - } \ - protected: \ - virtual createType create() override { \ - return std::make_tuple( \ - std::make_shared>(#klass), \ - std::make_shared>(#klass), \ - /* empty test for long double */ \ - std::make_shared>(#klass) \ - ); \ - } \ - }; \ - static klass##Factory global_##klass##Factory; \ - -#else // not __CUDA__ - #define REGISTER_TYPE(klass) \ class klass##Factory : public flit::TestFactory { \ public: \ @@ -579,8 +455,6 @@ inline std::shared_ptr> TestFactory::get () { }; \ static klass##Factory global_##klass##Factory; \ -#endif // __CUDA__ - std::map& getTests(); inline void registerTest(const std::string& name, TestFactory *factory) { diff --git a/src/VectorCU.h b/src/VectorCU.h deleted file mode 100644 index 7ccdcaed..00000000 --- a/src/VectorCU.h +++ /dev/null @@ -1,302 +0,0 @@ -/* -- LICENSE BEGIN -- - * - * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. - * - * Produced at the Lawrence Livermore National Laboratory - * - * Written by - * Michael Bentley (mikebentley15@gmail.com), - * Geof Sawaya (fredricflinstone@gmail.com), - * and Ian Briggs (ian.briggs@utah.edu) - * under the direction of - * Ganesh Gopalakrishnan - * and Dong H. Ahn. - * - * LLNL-CODE-743137 - * - * All rights reserved. - * - * This file is part of FLiT. For details, see - * https://pruners.github.io/flit - * Please also read - * https://github.com/PRUNERS/FLiT/blob/master/LICENSE - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer below. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the disclaimer - * (as noted below) in the documentation and/or other materials - * provided with the distribution. - * - * - Neither the name of the LLNS/LLNL nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL - * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. - * - * Additional BSD Notice - * - * 1. This notice is required to be provided under our contract - * with the U.S. Department of Energy (DOE). This work was - * produced at Lawrence Livermore National Laboratory under - * Contract No. DE-AC52-07NA27344 with the DOE. - * - * 2. Neither the United States Government nor Lawrence Livermore - * National Security, LLC nor any of their employees, makes any - * warranty, express or implied, or assumes any liability or - * responsibility for the accuracy, completeness, or usefulness of - * any information, apparatus, product, or process disclosed, or - * represents that its use would not infringe privately-owned - * rights. - * - * 3. Also, reference herein to any specific commercial products, - * process, or services by trade name, trademark, manufacturer or - * otherwise does not necessarily constitute or imply its - * endorsement, recommendation, or favoring by the United States - * Government or Lawrence Livermore National Security, LLC. The - * views and opinions of authors expressed herein do not - * necessarily state or reflect those of the United States - * Government or Lawrence Livermore National Security, LLC, and - * shall not be used for advertising or product endorsement - * purposes. - * - * -- LICENSE END -- - */ - -#ifndef VECTOR_CU_H -#define VECTOR_CU_H - -#include "CUHelpers.h" -#include "cuvector.h" - -namespace flit { - -template -class MatrixCU; - -template -class VectorCU { - cuvector data; - friend class MatrixCU; -public: - using vsize_t = typename cuvector::cvs_t; - - HOST_DEVICE - explicit - VectorCU(vsize_t dim) : data(dim) {} - HOST VectorCU(std::initializer_list l) : data(l) {} - HOST_DEVICE VectorCU(const T* array, vsize_t size) : data(array, size) {} - - // copy support - HOST_DEVICE VectorCU(const VectorCU& rhs):data(rhs.data){} - HOST_DEVICE VectorCU(const cuvector& vals):data(vals){} - HOST_DEVICE VectorCU& operator=(const VectorCU& rhs) { data = rhs.data; return *this; } - HOST_DEVICE VectorCU& operator=(const cuvector& vals) { data = vals; return *this; } - - // move support - HOST_DEVICE VectorCU(VectorCU&& rhs):data(std::move(rhs.data)){} - HOST_DEVICE VectorCU(cuvector&& vals):data(std::move(vals)){} - HOST_DEVICE VectorCU& operator=(VectorCU&& rhs) { data = std::move(rhs.data); return *this; } - HOST_DEVICE VectorCU& operator=(cuvector&& vals) { data = std::move(vals); return *this; } - - HOST_DEVICE - T& - operator[](vsize_t index){ - return data[index]; - } - - HOST_DEVICE - T - operator[](vsize_t index) const { - return data[index]; - } - - HOST_DEVICE - inline vsize_t - size() const noexcept { - return data.size(); - } - - DEVICE - static - VectorCU - getRandomVector(vsize_t dim){ - VectorCU retVal(dim); - auto rands = getRandSeqCU(); - for(vsize_t x = 0; x < dim; ++x){ - retVal.data[x] = rands[x]; - } - return retVal; - } - - //predoncition: this only works with vectors of - //predetermined size, now 16 - DEVICE - VectorCU - genOrthoVector() const { - VectorCU retVal(data.size()); - auto shuff = get16ShuffledCU(); - for(vsize_t x = 0; x < data.size(); x += 2){ - retVal[shuff[x]] = data[shuff[x+1]]; - retVal[shuff[x+1]] = -data[shuff[x]]; - } - return retVal; - } - - HOST_DEVICE - VectorCU - rotateAboutZ_3d(T rads){ - MatrixCU t(3,3); - t[0][0]=ccos(rads); t[0][1]=-csin(rads); t[0][2]=0; - t[1][0]=csin(rads); t[1][1]=ccos(rads); t[1][2]=0; - t[2][0]=0; t[2][1]=0; t[2][2]=1; - return t * (*this); - } - - HOST_DEVICE - VectorCU - getUnitVector() const { - VectorCU retVal(*this); - return retVal * ((T)1.0 / (L2Norm())); - } - - HOST_DEVICE - bool - operator==(VectorCU const &b){ - if(this->data.size() != b.data.size()) return false; - for(vsize_t x = 0; x < b.data.size(); ++x){ - if(data[x] != b.data[x]) return false; - } - return true; - } - - HOST_DEVICE - T - L1Distance(VectorCU const &rhs) const { - T distance = 0; - for(vsize_t x = 0; x < data.size(); ++x){ - distance += std::abs(data[x] - rhs.data[x]); - } - return distance; - } - - HOST_DEVICE - T - operator^(VectorCU const &rhs) const { - T sum = 0.0; - for(vsize_t i = 0; i < data.size(); ++i){ - sum += data[i] * rhs.data[i]; - } - return sum; - } - - HOST_DEVICE - VectorCU - operator*(VectorCU const &rhs) const{ - VectorCU ret(data.size()); - for(vsize_t x = 0; x < data.size(); ++x){ - ret[x] = data[x] * rhs.data[x]; - } - return ret; - } - - HOST_DEVICE - VectorCU - operator*(T const& sca) const { - VectorCU ret(data.size()); - for(vsize_t x = 0; x < data.size(); ++x){ - ret[x] = data[x] * sca; - } - return ret; - } - - HOST_DEVICE - VectorCU - operator-(const VectorCU& rhs) const { - VectorCU retVal(data.size()); - for(vsize_t x = 0; - x < data.size(); - ++x){ - retVal.data[x] = data[x] - rhs.data[x]; - } - return retVal; - } - - HOST_DEVICE - T - LInfNorm() const { - T largest = 0; - for(vsize_t x = 0; - x < data.size(); - ++x){ - T tmp = abs(data[x]); - if(tmp > largest) largest = tmp; - } - return largest; - } - - HOST_DEVICE - T - LInfDistance(VectorCU const &rhs) const { - auto diff = operator-(rhs); - return diff.LInfNorm(); - } - - //TODO this assumes there is only float and double on - //CUDA (may change for half precision) - HOST_DEVICE - T - L2Norm() const { - VectorCU squares = (*this) * (*this); - T retVal = (T)0.0; - for(vsize_t x = 0; - x < data.size(); - ++x) retVal += squares.data[x]; - if(sizeof(T) == 4) return sqrtf(retVal); - else return sqrt(retVal); - } - - T - HOST_DEVICE - L2Distance(VectorCU const &rhs) const { - return ((*this) - rhs).L2Norm(); - } - - HOST_DEVICE - VectorCU - cross(VectorCU const &rhs) const { - VectorCU retVal(data.size()); - retVal.data[0] = data[1] * rhs.data[2] - rhs.data[1] * data[2]; - retVal.data[1] = rhs.data[0] * data[2] - data[0] * rhs.data[2]; - retVal.data[2] = data[0] * rhs.data[1] - rhs.data[0] * data[1]; - return retVal; - } - - HOST_DEVICE - bool - isOrtho(VectorCU const &rhs){ - return operator^(rhs) == (T)0; - } -}; - -} // end of namespace flit - -#endif // VECTOR_CU_H diff --git a/src/cuvector.h b/src/cuvector.h deleted file mode 100644 index 5b0e97c4..00000000 --- a/src/cuvector.h +++ /dev/null @@ -1,267 +0,0 @@ -/* -- LICENSE BEGIN -- - * - * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. - * - * Produced at the Lawrence Livermore National Laboratory - * - * Written by - * Michael Bentley (mikebentley15@gmail.com), - * Geof Sawaya (fredricflinstone@gmail.com), - * and Ian Briggs (ian.briggs@utah.edu) - * under the direction of - * Ganesh Gopalakrishnan - * and Dong H. Ahn. - * - * LLNL-CODE-743137 - * - * All rights reserved. - * - * This file is part of FLiT. For details, see - * https://pruners.github.io/flit - * Please also read - * https://github.com/PRUNERS/FLiT/blob/master/LICENSE - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer below. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the disclaimer - * (as noted below) in the documentation and/or other materials - * provided with the distribution. - * - * - Neither the name of the LLNS/LLNL nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL - * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. - * - * Additional BSD Notice - * - * 1. This notice is required to be provided under our contract - * with the U.S. Department of Energy (DOE). This work was - * produced at Lawrence Livermore National Laboratory under - * Contract No. DE-AC52-07NA27344 with the DOE. - * - * 2. Neither the United States Government nor Lawrence Livermore - * National Security, LLC nor any of their employees, makes any - * warranty, express or implied, or assumes any liability or - * responsibility for the accuracy, completeness, or usefulness of - * any information, apparatus, product, or process disclosed, or - * represents that its use would not infringe privately-owned - * rights. - * - * 3. Also, reference herein to any specific commercial products, - * process, or services by trade name, trademark, manufacturer or - * otherwise does not necessarily constitute or imply its - * endorsement, recommendation, or favoring by the United States - * Government or Lawrence Livermore National Security, LLC. The - * views and opinions of authors expressed herein do not - * necessarily state or reflect those of the United States - * Government or Lawrence Livermore National Security, LLC, and - * shall not be used for advertising or product endorsement - * purposes. - * - * -- LICENSE END -- - */ - -#ifndef CUVECTOR_H -#define CUVECTOR_H - -#include "CUHelpers.h" - -#include - -//This vector class is designed to be used on a CUDA -//enabled device. -//This class needs the following features: -// * uploading data from host -// * array operator -// * begin / end iterators -// * destructor (delete data) -// * constructors: -// * cuvector(std::initializer_list) -// * cuvector(size) -// * cuvector(size, T) -// * cuvector(&cuvector) -// * operator = -// * size() - -template -class cuvector { -public: - typedef uint32_t cvs_t; -private: - T* _data; - cvs_t vsize; //allocated and assigned - bool invalid = false; //true when couldn't allocate - cvs_t tsize; //total allocated - const cvs_t delta = 10; //grow size - - HOST_DEVICE void zero() { setall(0); } - HOST_DEVICE - void setall(T val){ - for(cvs_t i = 0; i < vsize; ++i) { - _data[i] = val; - } - } -public: - - HOST_DEVICE - cuvector() noexcept : vsize(0),tsize(0) {} - - HOST_DEVICE - cuvector(cvs_t size):vsize(size),tsize(0){ - _data = new T[vsize]; - invalid = _data == nullptr; - if (!invalid) { - zero(); - tsize = vsize; - } - } - - HOST_DEVICE - cuvector(cvs_t size, T val):vsize(size),tsize(0){ - _data = new T[vsize]; - invalid = _data == nullptr; - if (!invalid) { - setall(val); - tsize = vsize; - } - } - - HOST - cuvector(const std::initializer_list vals):cuvector(){ - for (auto val : vals) { - push_back(val); - } - } - - HOST_DEVICE - cuvector(const T* array, cvs_t size):vsize(size){ - _data = new T[vsize]; - invalid = _data == nullptr; - if (!invalid) { - for(cvs_t x = 0; x < vsize; ++x) { - _data[x] = array[x]; - } - tsize = vsize; - } - } - - // copy support - HOST_DEVICE cuvector(const cuvector& rhs) : cuvector(rhs._data, rhs.vsize) {} - HOST cuvector(const std::vector& rhs) : cuvector(rhs.data(), rhs.size()) {} - - // reuse the move assignment operator and copy constructor - HOST_DEVICE cuvector& operator=(const cuvector& rhs) { *this = cuvector(rhs); return *this; } - HOST cuvector& operator=(const std::vector& rhs) { *this = cuvector(rhs); return *this; } - - // move support - // Unfortunately, we cannot provide moves from std::vector - // for move constructor, reuse the move assignment operator - HOST_DEVICE cuvector(cuvector&& rhs) { *this = std::move(rhs); } - - HOST_DEVICE - cuvector& - operator=(cuvector&& rhs){ - // Delete the current data - if (tsize > 0) delete[] _data; - // Copy it over - this->vsize = rhs.vsize; - this->tsize = rhs.tsize; - this->_data = rhs._data; - this->invalid = rhs.invalid; - // Empty the rhs - rhs.vsize = rhs.tsize = 0; - rhs.invalid = false; - rhs._data = nullptr; - return *this; - } - - - HOST_DEVICE - ~cuvector(){ - if(tsize > 0) delete[] _data; - } - - HOST_DEVICE inline T* data() noexcept { return _data; } - HOST_DEVICE inline const T* data() const noexcept { return _data; } - - HOST_DEVICE - inline void - grow(){ - T* temp = new T[tsize + delta]; - if(temp == nullptr) - invalid = true; - else{ - for(cvs_t x = 0; x < vsize; ++x){ - temp[x] = _data[x]; - } - if(tsize > 0) delete[] _data; - tsize += delta; - _data = temp; - } - } - - HOST_DEVICE - inline void - push_back(T val){ - if(vsize == tsize) grow(); - if(!invalid){ - _data[vsize++] = val; - } - } - - template - HOST_DEVICE - inline void - emplace_back(Args&&... args){ - if(vsize == tsize) grow(); - if(!invalid){ - _data[vsize++] = T(std::forward(args)...); - } - } - - HOST_DEVICE - inline - bool - isValid() const noexcept {return !invalid;} - - HOST_DEVICE - inline - T - operator[](cvs_t index) const { - return _data[index]; - } - - HOST_DEVICE - inline - T& - operator[](cvs_t index){ - return _data[index]; - } - - HOST_DEVICE - inline - cvs_t - size() const noexcept {return vsize;} -}; - -#endif // CUVECTOR_H diff --git a/src/flit.cpp b/src/flit.cpp index 79aa6e83..f70543c6 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -145,7 +146,7 @@ class Csv { } operator bool() const { return static_cast(m_in); } - + private: static CsvRow parseRow(std::istream &in) { std::string line; @@ -188,6 +189,7 @@ std::string FlitOptions::toString() const { messanger << "Options:\n" << " help: " << boolToString(this->help) << "\n" + << " info: " << boolToString(this->info) << "\n" << " verbose: " << boolToString(this->verbose) << "\n" << " timing: " << boolToString(this->timing) << "\n" << " timingLoops: " << this->timingLoops << "\n" @@ -196,6 +198,8 @@ std::string FlitOptions::toString() const { << " precision: " << this->precision << "\n" << " output: " << this->output << "\n" << " compareMode: " << boolToString(this->compareMode) << "\n" + << " compareGtFile: " << this->compareGtFile << "\n" + << " compareSuffix: " << this->compareSuffix << "\n" << " tests:\n"; for (auto& test : this->tests) { messanger << " " << test << "\n"; @@ -212,6 +216,7 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { FlitOptions options; std::vector helpOpts = { "-h", "--help" }; + std::vector infoOpts = { "--info" }; std::vector verboseOpts = { "-v", "--verbose" }; std::vector timingOpts = { "-t", "--timing" }; std::vector loopsOpts = { "-l", "--timing-loops" }; @@ -220,6 +225,8 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { std::vector precisionOpts = { "-p", "--precision" }; std::vector outputOpts = { "-o", "--output" }; std::vector compareMode = { "-c", "--compare-mode" }; + std::vector compareGtFileOpts = { "-g", "--compare-gt" }; + std::vector compareSuffixOpts = { "-s", "--suffix" }; std::vector allowedPrecisions = { "all", "float", "double", "long double" }; @@ -229,6 +236,8 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { std::string current(argList[i]); if (isIn(helpOpts, current)) { options.help = true; + } else if (isIn(infoOpts, current)) { + options.info = true; } else if (isIn(verboseOpts, current)) { options.verbose = true; } else if (isIn(timingOpts, current)) { @@ -270,9 +279,20 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { options.output = argList[++i]; } else if (isIn(compareMode, current)) { options.compareMode = true; + options.timing = false; + } else if (isIn(compareGtFileOpts, current)) { + if (i+1 == argCount) { + throw ParseException(current + " requires an argument"); + } + options.compareGtFile = argList[++i]; + } else if (isIn(compareSuffixOpts, current)) { + if (i+1 == argCount) { + throw ParseException(current + " requires an argument"); + } + options.compareSuffix = argList[++i]; } else { options.tests.push_back(current); - if (!options.compareMode && !isIn(allowedTests, current)) { + if (!options.compareMode && !isIn(allowedTests, removeIdxFromName(current))) { throw ParseException("unknown test " + current); } } @@ -281,14 +301,12 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { // names passed on the command line in compareMode are compareFiles not tests if (options.compareMode) { options.tests.swap(options.compareFiles); - options.tests.emplace_back("all"); if (options.compareFiles.size() == 0) { throw ParseException("You must pass in some test results in compare" " mode"); } - } - - if (options.tests.size() == 0 || isIn(options.tests, std::string("all"))) { + } else if (options.tests.size() == 0 + || isIn(options.tests, std::string("all"))) { options.tests = getKeys(getTests()); } @@ -307,10 +325,40 @@ std::string usage(std::string progName) { " Runs the FLiT tests and outputs the results to the console in CSV\n" " format.\n" "\n" + "Positional Arguments:\n" + "\n" + " The name of the test as shown by the --list-tests\n" + " option. If this is not specified, then all tests\n" + " will be executed.\n" + "\n" + " When a test is data-driven, it generates multiple\n" + " test results. Each of these test results will be\n" + " appended with \"_idx\" followed by a number\n" + " indicating which data-driven input it used. You\n" + " may specify this same suffix when you specify the\n" + " test to only run particular data-driven inputs\n" + " instead of all of them.\n" + "\n" + " Example:\n" + " " << progName << " TestCase_idx3 TestCase_idx5\n" + "\n" + " This will only run inputs 3 and 5 instead of all\n" + " of them. Note that if you specify an index higher\n" + " than the number of inputs for your test, then it\n" + " will be ignored.\n" + "\n" + " Note: this is zero-based indexing. So to run the\n" + " 2nd test input sequence, use TestCase_idx1.\n" + "\n" + " File path to the csv results to compare this\n" + " executable's results against.\n" + "\n" "Options:\n" "\n" " -h, --help Show this help and exit\n" "\n" + " --info Show compilation information and exit\n" + "\n" " -L, --list-tests\n" " List all available tests and exit.\n" "\n" @@ -328,6 +376,14 @@ std::string usage(std::string progName) { " individual test. This means each test will be run\n" " multiple times by default.\n" "\n" + " Note: when MPI is turned on (by setting the\n" + " enable_mpi variable in flit-config.toml to true)\n" + " and running more than one process, automatic loop\n" + " tuning is disabled, otherwise a deadlock could\n" + " occur. If you try to use the auto-tuning (which\n" + " is the default behavior), then the loops will be\n" + " converted to one instead.\n" + "\n" " -r REPEATS, --timing-repeats REPEATS\n" " How many times to repeat the timing. The default\n" " is to repeat timing 3 times. The timing reported\n" @@ -353,6 +409,8 @@ std::string usage(std::string progName) { " arguments are interpreted as the results files to\n" " use in the comparison.\n" "\n" + " This option implies --no-timing\n" + "\n" " Note: for tests returning a string, the results\n" " file will contain a relative path to the file that\n" " actually contains the string return value. So you\n" @@ -360,6 +418,34 @@ std::string usage(std::string progName) { " same directory used when executing the test\n" " executable.\n" "\n" + " -g GT_RESULTS, --compare-gt GT_RESULTS\n" + " Only applicable with --compare-mode on.\n" + "\n" + " Specify the csv file to use for the ground-truth\n" + " results. If this is not specified, then the\n" + " associated tests will be executed in order to\n" + " compare. If there are tests not in this results\n" + " file, but needing comparison, then those tests\n" + " will be executed to be able to compare.\n" + "\n" + " If the --output option is specified as well, then\n" + " only the extra tests that were executed and not\n" + " found in this results file will be output.\n" + "\n" + " -s SUFFIX, --suffix SUFFIX\n" + " Only applicable with --compare-mode on.\n" + "\n" + " Typically in compare mode, each compare file is\n" + " read in, compared, and then rewritten over the top\n" + " of that compare file. If you want to keep the\n" + " compare file untouched and instead output to a\n" + " different file, you can use this option to add a\n" + " suffix to the compared filename.\n" + "\n" + " In other words, the default value for this option\n" + " is the empty string, causing the filenames to\n" + " match.\n" + "\n" " -p PRECISION, --precision PRECISION\n" " Which precision to run. The choices are 'float',\n" " 'double', 'long double', and 'all'. The default\n" @@ -386,9 +472,9 @@ std::vector parseResults(std::istream &in) { auto nanosec = std::stol(row["nanosec"]); Variant value; std::string resultfile; - if (row["score"] != "NULL") { - // Convert score into a long double - value = as_float(flit::stouint128(row["score"])); + if (row["score_hex"] != "NULL") { + // Convert score_hex into a long double + value = as_float(flit::stouint128(row["score_hex"])); } else { // Read string from the resultfile if (row["resultfile"] == "NULL") { @@ -426,7 +512,7 @@ std::unordered_map parseMetadata(std::istream &in) { return metadata; } -std::string removeIdxFromName(const std::string &name) { +std::string removeIdxFromName(const std::string &name, int *idx) { std::string pattern("_idx"); // followed by 1 or more digits auto it = std::find_end(name.begin(), name.end(), pattern.begin(), pattern.end()); @@ -439,7 +525,40 @@ std::string removeIdxFromName(const std::string &name) { if (!is_integer_idx) { throw std::invalid_argument("in removeIdxFromName, non-integer idx"); } + if (idx != nullptr) { + if (it != name.end()) { + *idx = std::stoi(std::string(it+4, name.end())); + } else { + *idx = -1; + } + } return std::string(name.begin(), it); } +std::vector calculateMissingComparisons(const FlitOptions &opt) { + // We don't want to run the tests that are specified in the gt test file + std::set gtTestNames; + if (!opt.compareGtFile.empty()) { + std::ifstream gtresultfile(opt.compareGtFile); + for (auto &result : parseResults(gtresultfile)) { + gtTestNames.emplace(result.name()); + } + } + + // TODO: double check that we have {testname, precision} pairings in there + // parse the incoming files to determine which tests need to be run + std::set testNames; + for (auto fname : opt.compareFiles) { + std::ifstream resultfile(fname); + for (auto &result : parseResults(resultfile)) { + if (gtTestNames.end() == gtTestNames.find(result.name())) { + testNames.emplace(result.name()); + } + } + } + + std::vector missingTests(testNames.begin(), testNames.end()); + return missingTests; +} + } // end of namespace flit diff --git a/src/flit.h b/src/flit.h index c8c2e2f3..bb668bd4 100644 --- a/src/flit.h +++ b/src/flit.h @@ -87,18 +87,10 @@ #ifndef FLIT_H #define FLIT_H 0 -#include "Matrix.h" -#include "MatrixCU.h" +#include "MpiEnvironment.h" #include "TestBase.h" -#include "Vector.h" -#include "VectorCU.h" #include "flitHelpers.h" -#ifdef __CUDA__ -//#include -#include "CUHelpers.h" -#endif - #include #include #include @@ -143,18 +135,21 @@ namespace flit { /** Command-line options */ struct FlitOptions { - bool help = false; // show usage and exit - bool listTests = false; // list available tests and exit - bool verbose = false; // show debug verbose messages + bool help = false; // show usage and exit + bool info = false; // show compilation info and exit + bool listTests = false; // list available tests and exit + bool verbose = false; // show debug verbose messages std::vector tests; // which tests to run std::string precision = "all"; // which precision to use std::string output = ""; // output file for results. default stdout - bool timing = true; // should we run timing? - int timingLoops = -1; // < 1 means to auto-determine the timing loops - int timingRepeats = 3; // return best of this many timings - - bool compareMode = false; // compare results after running the test + bool timing = true; // should we run timing? + int timingLoops = -1; // < 1 means to auto-determine the timing loops + int timingRepeats = 3; // return best of this many timings + + bool compareMode = false; // compare results after running the test + std::string compareGtFile; // ground truth results to use in compareMode std::vector compareFiles; // files for compareMode + std::string compareSuffix; // suffix to add when writing back compareFiles /** Give a string representation of this struct for printing purposes */ std::string toString() const; @@ -182,30 +177,56 @@ struct pair_hash { } }; -/** Parse arguments */ +/// Parse arguments FlitOptions parseArguments(int argCount, char const* const argList[]); -/** Returns the usage information as a string */ +/// Returns the usage information as a string std::string usage(std::string progName); -/** Read file contents entirely into a string */ +/// The compilation information as a string +static std::string info = + "Compilation information:\n" + " Host: \"" FLIT_HOST "\"\n" + " Compiler: \"" FLIT_COMPILER "\"\n" + " Optimization level: \"" FLIT_OPTL "\"\n" + " Compiler flags: \"" FLIT_SWITCHES "\"\n" + " Filename: \"" FLIT_FILENAME "\"\n"; + +/// Read file contents entirely into a string std::string readFile(const std::string &filename); -/** Parse the results file into a vector of results */ +/// Parse the results file into a vector of results std::vector parseResults(std::istream &in); -/** Parse the result file to get metadata from the first row */ +/// Parse the result file to get metadata from the first row std::unordered_map parseMetadata(std::istream &in); -/** Test names sometimes are postfixed with "_idx" + . Remove that postfix */ -std::string removeIdxFromName(const std::string &name); +/** Removes the "_idx" from the name + * + * The name passed in is not modified, but the shortened one is returned. + * Optionally, you can pass in an integer pointer to have it populated with the + * value of the from the end of the idx string. + * + * If the name does not end in "_idx", then the name is returned as-is, + * and idx (if not nullptr) is set to -1. + * + * @param name Name to remove "_idx" from the end + * @param idx Pointer to an integer to store (optional) + * + * @return shortened name with "_idx" removed from the end + */ +std::string removeIdxFromName(const std::string &name, int *idx = nullptr); + +/// Returns the tests that need to be run for comparisons +std::vector calculateMissingComparisons(const FlitOptions &opt); class TestResultMap { public: using key_type = std::pair; void loadfile(const std::string &filename) { - std::ifstream resultfile(filename); + std::ifstream resultfile; + flit::ifopen(resultfile, filename); auto parsed = parseResults(resultfile); this->extend(parsed, filename); } @@ -251,7 +272,9 @@ class TestResultMap { TestResult*, pair_hash > m_testmap; // (testname, precision) -> TestResult* - std::unordered_multimap m_filemap; // filename -> TestResult + + // filename -> TestResult + std::unordered_multimap m_filemap; }; inline void outputResults ( @@ -270,11 +293,11 @@ inline void outputResults ( "optl," "switches," "precision," + "score_hex," "score," - "score_d," "resultfile," + "comparison_hex," "comparison," - "comparison_d," "file," "nanosec" << std::endl; @@ -290,13 +313,13 @@ inline void outputResults ( if (result.result().type() == Variant::Type::LongDouble) { out - << as_int(result.result().longDouble()) << "," // score - << result.result().longDouble() << "," // score_d + << as_int(result.result().longDouble()) << "," // score_hex + << result.result().longDouble() << "," // score ; } else { out + << FLIT_NULL << "," // score_hex << FLIT_NULL << "," // score - << FLIT_NULL << "," // score_d ; } @@ -308,13 +331,13 @@ inline void outputResults ( if (result.is_comparison_null()) { out + << FLIT_NULL << "," // comparison_hex << FLIT_NULL << "," // comparison - << FLIT_NULL << "," // comparison_d ; } else { out - << as_int(result.comparison()) << "," // comparison - << result.comparison() << "," // comparison_d + << as_int(result.comparison()) << "," // comparison_hex + << result.comparison() << "," // comparison ; } @@ -332,11 +355,12 @@ void runTestWithDefaultInput(TestFactory* factory, const std::string &filebase = "", bool shouldTime = true, int timingLoops = -1, - int timingRepeats = 3) { + int timingRepeats = 3, + int idx = -1) { auto test = factory->get(); auto ip = test->getDefaultInput(); auto results = test->run(ip, filebase, shouldTime, timingLoops, - timingRepeats); + timingRepeats, idx); totResults.insert(totResults.end(), results.begin(), results.end()); info_stream.flushout(); } @@ -391,71 +415,117 @@ class ParseException : public std::exception { }; inline int runFlitTests(int argc, char* argv[]) { + // Now only used for MPI, but basically a boolean to say whether this process + // is the main one + MpiEnvironment mpi_env(argc, argv); + flit::mpi = &mpi_env; + // Argument parsing FlitOptions options; try { options = parseArguments(argc, argv); } catch (ParseException &ex) { - std::cerr << "Error: " << ex.what() << "\n" - << " Use the --help option for more information\n"; + if (mpi->is_root()) { + std::cerr << "Error: " << ex.what() << "\n" + << " Use the --help option for more information\n"; + } return 1; } if (options.help) { - std::cout << usage(argv[0]); + if (mpi->is_root()) { + std::cout << usage(argv[0]); + } + return 0; + } + + if (options.info) { + if (mpi->is_root()) { + std::cout << info; + } return 0; } if (options.listTests) { - for (auto& test : getKeys(getTests())) { - std::cout << test << std::endl; + if (mpi->is_root()) { + for (auto& test : getKeys(getTests())) { + std::cout << test << std::endl; + } } return 0; } - if (options.verbose) { + if (options.verbose && mpi->is_root()) { info_stream.show(); } + // When MPI is enabled, we cannot use the automatic timing loop algorithm, + // otherwise we could deadlock + if (mpi->size > 1 && options.timing && options.timingLoops < 1) { + if (mpi->is_root()) { + std::cerr << "Warning: cannot run auto-looping with MPI; " + "Looping set to 1\n"; + } + options.timingLoops = 1; + } + std::unique_ptr stream_deleter; std::ostream *outstream = &std::cout; std::string test_result_filebase(FLIT_FILENAME); - if (!options.output.empty()) { - stream_deleter.reset(new std::ofstream(options.output.c_str())); + if (!options.output.empty() && mpi->is_root()) { + stream_deleter.reset(new std::ofstream()); outstream = stream_deleter.get(); + try { + flit::ofopen(static_cast(*outstream), options.output); + } catch (std::ios::failure &ex) { + std::cerr << "Error: failed to open " << options.output << std::endl; + mpi->abort(1); + return 1; + } test_result_filebase = options.output; } + std::vector results; + + // if comparison mode, then find out which tests we need to run + if (options.compareMode) { + options.tests = calculateMissingComparisons(options); + if (!options.compareGtFile.empty()) { + std::ifstream fin; + try { + flit::ifopen(fin, options.compareGtFile); + } catch (std::ios::failure &ex) { + std::cerr << "Error: file does not exist: " << options.compareGtFile + << std::endl; + return 1; + } + results = parseResults(fin); + } + } + std::cout.precision(1000); //set cout to print many decimal places info_stream.precision(1000); -#ifdef __CUDA__ - initDeviceData(); -#endif - - std::vector results; auto testMap = getTests(); for (auto& testName : options.tests) { - auto factory = testMap[testName]; + int idx; + auto factory = testMap[removeIdxFromName(testName, &idx)]; if (options.precision == "all" || options.precision == "float") { runTestWithDefaultInput(factory, results, test_result_filebase, options.timing, options.timingLoops, - options.timingRepeats); + options.timingRepeats, idx); } if (options.precision == "all" || options.precision == "double") { runTestWithDefaultInput(factory, results, test_result_filebase, options.timing, options.timingLoops, - options.timingRepeats); + options.timingRepeats, idx); } if (options.precision == "all" || options.precision == "long double") { runTestWithDefaultInput( factory, results, test_result_filebase, options.timing, - options.timingLoops, options.timingRepeats); + options.timingLoops, options.timingRepeats, idx); } } -#if defined(__CUDA__) && !defined(__CPUKERNEL__) - cudaDeviceSynchronize(); -#endif // Sort the results first by name then by precision auto testComparator = [](const TestResult &a, const TestResult &b) { @@ -468,11 +538,17 @@ inline int runFlitTests(int argc, char* argv[]) { std::sort(results.begin(), results.end(), testComparator); // Let's now run the ground-truth comparisons - if (options.compareMode) { + if (options.compareMode && mpi->is_root()) { TestResultMap comparisonResults; - + for (auto fname : options.compareFiles) { - comparisonResults.loadfile(fname); + try { + comparisonResults.loadfile(fname); + } catch (std::ios::failure &ex) { + std::cerr << "Error: failed to open file " << fname << std::endl; + mpi->abort(1); + return 1; + } } // compare mode is only done in the ground truth compilation @@ -491,7 +567,14 @@ inline int runFlitTests(int argc, char* argv[]) { // read in the metadata to use in creating the file again std::unordered_map metadata; { - std::ifstream fin(fname); + std::ifstream fin; + try { + flit::ifopen(fin, fname); + } catch (std::ios_base::failure &ex) { + std::cerr << "Error: file does not exist: " << fname << std::endl; + mpi->abort(1); + return 1; + } metadata = parseMetadata(fin); } @@ -507,7 +590,14 @@ inline int runFlitTests(int argc, char* argv[]) { // output back to a file { - std::ofstream fout(fname); + std::ofstream fout; + try { + flit::ofopen(fout, fname + options.compareSuffix); + } catch (std::ios::failure &ex) { + std::cerr << "Error: could not write to " << fname << std::endl; + mpi->abort(1); + return 1; + } outputResults( fileresults, fout, @@ -522,7 +612,10 @@ inline int runFlitTests(int argc, char* argv[]) { } // Create the main results output - outputResults(results, *outstream); + if (mpi->is_root()) { + outputResults(results, *outstream); + } + return 0; } diff --git a/src/flitHelpers.cpp b/src/flitHelpers.cpp index a6345f62..16383be0 100644 --- a/src/flitHelpers.cpp +++ b/src/flitHelpers.cpp @@ -92,31 +92,6 @@ namespace flit { -const std::vector -getShuffleSeq(uint_fast32_t size){ - std::vector retVal(size); - iota(retVal.begin(), retVal.end(), 0); - shuffle(retVal.begin(), retVal.end(), std::mt19937(RAND_SEED)); - return retVal; -} - -template<> -const std::vector& -getRandSeq(){return float_rands;} - -template<> -const std::vector& -getRandSeq(){return double_rands;} - -template<> -const std::vector& -getRandSeq(){return long_rands;} - -const std::vector float_rands = setRandSeq(RAND_VECT_SIZE); -const std::vector double_rands = setRandSeq(RAND_VECT_SIZE); -const std::vector long_rands = setRandSeq(RAND_VECT_SIZE); - - thread_local InfoStream info_stream; std::ostream& operator<<(std::ostream& os, const unsigned __int128 i){ @@ -126,7 +101,7 @@ std::ostream& operator<<(std::ostream& os, const unsigned __int128 i){ auto bflags = os.flags(); os.flags(std::ios::hex & ~std::ios::showbase); ost.flags(std::ios::hex & ~std::ios::showbase); - ost << lo; + ost << lo; os << "0x" << hi; for(uint32_t x = 0; x < 16 - ost.str().length(); ++x){ os << "0"; @@ -152,7 +127,7 @@ unsigned __int128 stouint128(const std::string &str) { } if (copy.size() <= 16) { hi = 0; - lo = std::stoull(copy, nullptr, 16); + lo = std::stoull(copy, nullptr, 16); } else { auto mid = copy.end() - 16; hi = std::stoull(std::string(copy.begin(), mid), nullptr, 16); @@ -168,4 +143,4 @@ unsigned __int128 stouint128(const std::string &str) { } } // end of namespace flit - + diff --git a/src/flitHelpers.h b/src/flitHelpers.h index 7aa5ef01..5de6f615 100644 --- a/src/flitHelpers.h +++ b/src/flitHelpers.h @@ -89,9 +89,9 @@ #define FLIT_HELPERS_HPP #include "InfoStream.h" -#include "CUHelpers.h" #include +#include #include #include #include @@ -108,46 +108,12 @@ namespace flit { -const int RAND_SEED = 1; -const int RAND_VECT_SIZE = 256; - extern thread_local InfoStream info_stream; -// this section provides a pregenerated random -// sequence that can be used by tests, including -// CUDA - -template -const std::vector -setRandSeq(size_t size, int32_t seed = RAND_SEED){ - // there may be a bug with float uniform_real_dist - // it is giving very different results than double or long double - std::vector ret(size); - std::mt19937 gen; - gen.seed(seed); - std::uniform_real_distribution dist(-6.0, 6.0); - for(auto& i: ret) i = T(dist(gen)); - return ret; -} - -const std::vector -getShuffleSeq(uint_fast32_t); - -extern const std::vector float_rands; -extern const std::vector double_rands; -extern const std::vector long_rands; - -extern const std::vector shuffled_16; - -template -std::vector const & -getRandSeq(); - std::ostream& operator<<(std::ostream&, const unsigned __int128); unsigned __int128 stouint128(const std::string &str); template -HOST_DEVICE F as_float_impl(I val) { static_assert(sizeof(F) == sizeof(I), "cannot convert types of different sizes"); union { @@ -157,13 +123,11 @@ F as_float_impl(I val) { return u.f; } -HOST_DEVICE inline float as_float(uint32_t val) { return as_float_impl(val); } -HOST_DEVICE inline double as_float(uint64_t val) { return as_float_impl(val); @@ -175,7 +139,6 @@ as_float(unsigned __int128 val) { } template -HOST_DEVICE I as_int_impl(F val) { static_assert(sizeof(F) == sizeof(I), "cannot convert types of different sizes"); union { @@ -185,13 +148,11 @@ I as_int_impl(F val) { return u.i; } -HOST_DEVICE inline uint32_t as_int(float val) { return as_int_impl(val); } -HOST_DEVICE inline uint64_t as_int(double val) { return as_int_impl(val); @@ -204,7 +165,50 @@ as_int(long double val) { return temp & (~zero >> 48); } +/** Opens a file, but on failure, throws std::ios::failure + * + * T must be one of {fstream, ifstream, ofstream} + * + * The passed in filestream should be an empty-constructed stream + */ +template +void _openfile_check(T& filestream, const std::string &filename) { + // turn on exceptions on failure + filestream.exceptions(std::ios::failbit); + + // opening will throw if the file does not exist or is not readable + filestream.open(filename); + + // turn off all exceptions (back to the default behavior) + filestream.exceptions(std::ios::goodbit); +} + +/** Opens a file for reading, but on failure, throws std::ios::failure + * + * The passed in filestream should be an empty-constructed stream + * + * Note: This was changed to pass in the stream rather than return it because + * GCC 4.8 failed to compile - it failed to use the move assignment operator + * and move constructor, and instead tried to use the copy constructor. + */ +inline void ifopen(std::ifstream& in, const std::string &filename) { + _openfile_check(in, filename); +} + +/** Opens a file for writing, but on failure, throws std::ios::failure + * + * The passed in filestream should be an empty-constructed stream + * + * Note: this was changed to pass in the stream rather than return it because + * GCC 4.8 failed to compile - it failed to use the move assignment operator + * and move constructor, and instead tried to use the copy constructor. + */ +inline void ofopen(std::ofstream& out, const std::string &filename) { + _openfile_check(out, filename); + out.precision(1000); // lots of digits of precision +} + } // end of namespace flit #endif // FLIT_HELPERS_HPP - + diff --git a/src/timeFunction.cpp b/src/timeFunction.cpp index 0b49d6f1..a2b80dbf 100644 --- a/src/timeFunction.cpp +++ b/src/timeFunction.cpp @@ -102,7 +102,7 @@ int_fast64_t time_function_impl(const TimingFunction &func, size_t loops = 1, func(); } auto end = std::chrono::high_resolution_clock::now(); - int_fast64_t time = + int_fast64_t time = std::chrono::duration_cast< std::chrono::duration>(end - start).count(); min_time = std::min(min_time, time); diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 00000000..8d152b31 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,3 @@ +harness_tester +flit_src/tst_flit_cpp +flit_src/tst_flitHelpers_h diff --git a/tests/Makefile b/tests/Makefile index 7ce02588..000a3fed 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -14,8 +14,10 @@ BUILD_TARGETS := $(addprefix build__,$(SUB_DIRS)) .PHONY: build check help clean build: $(TESTER) $(BUILD_TARGETS) +include color_out.mk + check: run__$(TESTER) $(CHECK_TARGETS) - @echo "All tests pass" + @$(call color_out,GREEN,All tests pass) help: @echo "Makefile for running tests on FLiT framework" diff --git a/tests/color_out.mk b/tests/color_out.mk new file mode 100644 index 00000000..03c446b8 --- /dev/null +++ b/tests/color_out.mk @@ -0,0 +1,22 @@ +# A Makefile function +# @param 1: color (e.g. BLUE or GREEN) +# @param 2: message to be printed in the color +color_out = @if [ -t 1 ]; then \ + /bin/echo -e "$(BASH_$1)$2$(BASH_CLEAR)"; \ + else \ + /bin/echo "$2"; \ + fi + +BASH_CLEAR := \e[0m +BASH_BLACK := \e[0;30m +BASH_BROWN := \e[0;33m +BASH_GRAY := \e[0;37m +BASH_DARKGRAY := \e[1;30m +BASH_RED := \e[1;31m +BASH_GREEN := \e[1;32m +BASH_YELLOW := \e[1;33m +BASH_BLUE := \e[1;34m +BASH_PURPLE := \e[1;35m +BASH_CYAN := \e[1;36m +BASH_WHITE := \e[1;37m + diff --git a/tests/flit_cli/Makefile b/tests/flit_cli/Makefile index 27649460..242995ab 100644 --- a/tests/flit_cli/Makefile +++ b/tests/flit_cli/Makefile @@ -16,4 +16,4 @@ build: clean: run_% : %.py - @python $< + @$(RUNNER) $< diff --git a/scripts/hostCollectEnviro.source b/tests/flit_cli/tst_bisect.py similarity index 92% rename from scripts/hostCollectEnviro.source rename to tests/flit_cli/tst_bisect.py index fca400d9..1052aba5 100644 --- a/scripts/hostCollectEnviro.source +++ b/tests/flit_cli/tst_bisect.py @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # -- LICENSE BEGIN -- # # Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. @@ -82,10 +80,18 @@ # # -- LICENSE END -- -export CORES=24 -export DO_PIN=False -export DB_USER=sawaya -export DB_HOST=localhost -export FLIT_DIR=src -export SLURMED=None -export CUDA_ONLY=False +''' +Tests flit bisect functionality. +''' + +# Test setup before the docstring is run. +import sys +before_path = sys.path[:] +sys.path.append('..') +import test_harness as th +sys.path = before_path + +if __name__ == '__main__': + import doctest + doctest.testmod() + diff --git a/tests/flit_install/Makefile b/tests/flit_install/Makefile index 27649460..242995ab 100644 --- a/tests/flit_install/Makefile +++ b/tests/flit_install/Makefile @@ -16,4 +16,4 @@ build: clean: run_% : %.py - @python $< + @$(RUNNER) $< diff --git a/scripts/prepDBHost.py b/tests/flit_install/tst_uninstall_runthrough.py old mode 100755 new mode 100644 similarity index 61% rename from scripts/prepDBHost.py rename to tests/flit_install/tst_uninstall_runthrough.py index 6dc7f928..b442035a --- a/scripts/prepDBHost.py +++ b/tests/flit_install/tst_uninstall_runthrough.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - # -- LICENSE BEGIN -- # # Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. @@ -82,45 +80,61 @@ # # -- LICENSE END -- -#this script prepares the db host by making a place to -#push the output files to so that the import processes may -#be executed upon them - -from sys import argv +''' +Tests FLiT's capabilities to uninstall itself -COLL_DIR = 'flit_data' -DB_DIR = argv[1] +The tests are below using doctest -if __name__ == '__main__': +Let's now make a temporary directory, install there, and then uninstall. +>>> import glob +>>> import os +>>> import subprocess as subp +>>> with th.tempdir() as temp_dir: +... _ = subp.check_call(['make', '-C', os.path.join(th.config.lib_dir, '..'), +... 'install', 'PREFIX=' + temp_dir], +... stdout=subp.DEVNULL, stderr=subp.DEVNULL) +... dirs1 = os.listdir(temp_dir) +... dirs2 = [os.path.join(x, y) for x in dirs1 +... for y in os.listdir(os.path.join(temp_dir, x))] +... _ = subp.check_call(['make', '-C', os.path.join(th.config.lib_dir, '..'), +... 'uninstall', 'PREFIX=' + temp_dir], +... stdout=subp.DEVNULL, stderr=subp.DEVNULL) +... tempdir_exists = os.path.exists(temp_dir) +>>> sorted(dirs1) +['bin', 'include', 'lib', 'share'] +>>> sorted(dirs2) +['bin/flit', 'include/flit', 'lib/libflit.so', 'share/flit', 'share/licenses'] +>>> tempdir_exists +False - import tempfile, os, glob - from subprocess import check_output - import shutil +Now we test that directories are not deleted when other files exist in the +PREFIX path +>>> import glob +>>> with th.tempdir() as temp_dir: +... _ = subp.check_call(['make', '-C', os.path.join(th.config.lib_dir, '..'), +... 'install', 'PREFIX=' + temp_dir], +... stdout=subp.DEVNULL, stderr=subp.DEVNULL) +... with open(os.path.join(temp_dir, 'lib', 'otherlib.so'), 'w'): +... pass +... _ = subp.check_call(['make', '-C', os.path.join(th.config.lib_dir, '..'), +... 'uninstall', 'PREFIX=' + temp_dir], +... stdout=subp.DEVNULL, stderr=subp.DEVNULL) +... prevdir = os.path.realpath(os.curdir) +... os.chdir(temp_dir) +... all_files = glob.glob('**', recursive=True) +... os.chdir(prevdir) +>>> sorted(all_files) +['lib', 'lib/otherlib.so'] +''' - TAR = check_output('which tar', shell=True, universal_newlines=True)[:-1] +# Test setup before the docstring is run. +import sys +before_path = sys.path[:] +sys.path.append('..') +import test_harness as th +sys.path = before_path - try: - os.mkdir(COLL_DIR) - except FileExistsError: - if len(glob.glob(COLL_DIR + '/*')) > 0: - os.chdir(COLL_DIR) - f = tempfile.mkstemp('.tgz', dir='..', prefix=COLL_DIR + '_') - stdot = check_output(TAR + ' zcf ' + f[1] + ' *', shell=True, - universal_newlines=True) - os.chdir('..') - shutil.rmtree(COLL_DIR) - os.mkdir(COLL_DIR) - print('created ' + f[1]) - else: - print(COLL_DIR + ' was empty') - try: - os.mkdir(DB_DIR) - except FileExistsError: - pass - os.chdir(DB_DIR) - print(check_output(TAR + ' xf ' + os.environ['HOME'] + - '/dbPy.tgz', shell=True).decode("utf-8")) - os.remove(os.environ['HOME'] + '/dbPy.tgz') - print('set up ' + COLL_DIR) - exit(0) - +if __name__ == '__main__': + from doctest import testmod + failures, tests = testmod() + sys.exit(failures) diff --git a/tests/flit_makefile/Makefile b/tests/flit_makefile/Makefile index 27649460..242995ab 100644 --- a/tests/flit_makefile/Makefile +++ b/tests/flit_makefile/Makefile @@ -16,4 +16,4 @@ build: clean: run_% : %.py - @python $< + @$(RUNNER) $< diff --git a/tests/flit_makefile/tst_empty_project.py b/tests/flit_makefile/tst_empty_project.py index 64205760..10240ce2 100644 --- a/tests/flit_makefile/tst_empty_project.py +++ b/tests/flit_makefile/tst_empty_project.py @@ -143,14 +143,12 @@ ... stderr=subp.STDOUT) ... print(devrun_out.decode('utf-8'), end='') Creating ... -name,host,compiler,optl,switches,precision,score,score_d,resultfile,comparison,comparison_d,file,nanosec +name,host,compiler,optl,switches,precision,score_hex,score,resultfile,comparison_hex,comparison,file,nanosec TODO: let's test that the full set of tests would get created. -TODO: test the cuda generation, TODO: test that the custom.mk stuff gets used -TODO: test CUDA_ONLY TODO: test CLANG_ONLY -TODO: test targets dev, devcuda, gt, run, runbuild, clean, veryclean, distclean +TODO: test targets dev, gt, run, runbuild, clean, veryclean, distclean TODO: test solution on a mac (with UNAME_S being Darwin) ''' diff --git a/tests/flit_mpi/Makefile b/tests/flit_mpi/Makefile new file mode 100644 index 00000000..1d04452e --- /dev/null +++ b/tests/flit_mpi/Makefile @@ -0,0 +1,31 @@ +RUNNER := python3 +SRC := $(wildcard tst_*.py) +RUN_TARGETS := $(SRC:%.py=run_%) +MPIRUN := $(shell command -v mpirun 2>/dev/null) +MPICXX := $(shell command -v mpic++ 2>/dev/null) + +include ../color_out.mk + +.PHONY: check help clean build run_% +ifeq ($(MPIRUN),) +check: + $(call color_out,RED,Warning: mpirun is not found on your system; skipping the MPI tests) +else ifeq ($(MPICXX),) +check: + $(call color_out,RED,Warning: mpic++ is not found on your system; skipping the MPI tests) +else +check: $(TARGETS) $(RUN_TARGETS) +endif + +help: + @echo "Makefile for running tests on FLiT framework" + @echo " help print this help documentation and exit" + @echo " build just compile the targets" + @echo " check run tests and print results to the console" + @echo " clean remove all generated files" + +build: +clean: + +run_% : %.py + @$(RUNNER) $< diff --git a/tests/flit_mpi/data/MpiHello.cpp b/tests/flit_mpi/data/MpiHello.cpp new file mode 100644 index 00000000..60516113 --- /dev/null +++ b/tests/flit_mpi/data/MpiHello.cpp @@ -0,0 +1,113 @@ +/* -- LICENSE BEGIN -- + * + * Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. + * + * Produced at the Lawrence Livermore National Laboratory + * + * Written by + * Michael Bentley (mikebentley15@gmail.com), + * Geof Sawaya (fredricflinstone@gmail.com), + * and Ian Briggs (ian.briggs@utah.edu) + * under the direction of + * Ganesh Gopalakrishnan + * and Dong H. Ahn. + * + * LLNL-CODE-743137 + * + * All rights reserved. + * + * This file is part of FLiT. For details, see + * https://pruners.github.io/flit + * Please also read + * https://github.com/PRUNERS/FLiT/blob/master/LICENSE + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the disclaimer below. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * (as noted below) in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the LLNS/LLNL nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL + * SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. + * + * Additional BSD Notice + * + * 1. This notice is required to be provided under our contract + * with the U.S. Department of Energy (DOE). This work was + * produced at Lawrence Livermore National Laboratory under + * Contract No. DE-AC52-07NA27344 with the DOE. + * + * 2. Neither the United States Government nor Lawrence Livermore + * National Security, LLC nor any of their employees, makes any + * warranty, express or implied, or assumes any liability or + * responsibility for the accuracy, completeness, or usefulness of + * any information, apparatus, product, or process disclosed, or + * represents that its use would not infringe privately-owned + * rights. + * + * 3. Also, reference herein to any specific commercial products, + * process, or services by trade name, trademark, manufacturer or + * otherwise does not necessarily constitute or imply its + * endorsement, recommendation, or favoring by the United States + * Government or Lawrence Livermore National Security, LLC. The + * views and opinions of authors expressed herein do not + * necessarily state or reflect those of the United States + * Government or Lawrence Livermore National Security, LLC, and + * shall not be used for advertising or product endorsement + * purposes. + * + * -- LICENSE END -- + */ + +#include + +#include +#include + +template +class MpiHello : public flit::TestBase { +public: + MpiHello(std::string id) : flit::TestBase(std::move(id)) {} + + virtual size_t getInputsPerRun() override { return 1; } + virtual std::vector getDefaultInput() override { + return { T(flit::mpi->rank) }; + } + +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + std::ostringstream ss; + ss + << id << ": hello from rank " << flit::mpi->rank + << " of " << flit::mpi->size << std::endl; + std::cout << ss.str(); + return ss.str(); + } + +protected: + using flit::TestBase::id; +}; + +REGISTER_TYPE(MpiHello) diff --git a/tests/flit_mpi/data/flit-config.toml b/tests/flit_mpi/data/flit-config.toml new file mode 100644 index 00000000..63aeaf74 --- /dev/null +++ b/tests/flit_mpi/data/flit-config.toml @@ -0,0 +1,3 @@ +[run] +enable_mpi = true +mpirun_args = '-n 2' diff --git a/tests/flit_mpi/tst_run_mpi.py b/tests/flit_mpi/tst_run_mpi.py new file mode 100644 index 00000000..10d38069 --- /dev/null +++ b/tests/flit_mpi/tst_run_mpi.py @@ -0,0 +1,201 @@ +# -- LICENSE BEGIN -- +# +# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC. +# +# Produced at the Lawrence Livermore National Laboratory +# +# Written by +# Michael Bentley (mikebentley15@gmail.com), +# Geof Sawaya (fredricflinstone@gmail.com), +# and Ian Briggs (ian.briggs@utah.edu) +# under the direction of +# Ganesh Gopalakrishnan +# and Dong H. Ahn. +# +# LLNL-CODE-743137 +# +# All rights reserved. +# +# This file is part of FLiT. For details, see +# https://pruners.github.io/flit +# Please also read +# https://github.com/PRUNERS/FLiT/blob/master/LICENSE +# +# Redistribution and use in source and binary forms, with or +# without modification, are permitted provided that the following +# conditions are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the disclaimer below. +# +# - Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the disclaimer +# (as noted below) in the documentation and/or other materials +# provided with the distribution. +# +# - Neither the name of the LLNS/LLNL nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL +# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS 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. +# +# Additional BSD Notice +# +# 1. This notice is required to be provided under our contract +# with the U.S. Department of Energy (DOE). This work was +# produced at Lawrence Livermore National Laboratory under +# Contract No. DE-AC52-07NA27344 with the DOE. +# +# 2. Neither the United States Government nor Lawrence Livermore +# National Security, LLC nor any of their employees, makes any +# warranty, express or implied, or assumes any liability or +# responsibility for the accuracy, completeness, or usefulness of +# any information, apparatus, product, or process disclosed, or +# represents that its use would not infringe privately-owned +# rights. +# +# 3. Also, reference herein to any specific commercial products, +# process, or services by trade name, trademark, manufacturer or +# otherwise does not necessarily constitute or imply its +# endorsement, recommendation, or favoring by the United States +# Government or Lawrence Livermore National Security, LLC. The +# views and opinions of authors expressed herein do not +# necessarily state or reflect those of the United States +# Government or Lawrence Livermore National Security, LLC, and +# shall not be used for advertising or product endorsement +# purposes. +# +# -- LICENSE END -- + +''' +Tests FLiT's capabilities to compile and run MPI tests + +The tests are below using doctest + +Let's now make a temporary directory and test that we can successfully compile +and run the FLiT test with MPI + +>>> import glob +>>> import os +>>> import shutil +>>> import subprocess as subp + +>>> with th.tempdir() as temp_dir: +... th.flit.main(['init', '-C', temp_dir]) # doctest:+ELLIPSIS +... _ = shutil.copy(os.path.join('data', 'MpiHello.cpp'), +... os.path.join(temp_dir, 'tests')) +... _ = shutil.copy(os.path.join('data', 'flit-config.toml'), temp_dir) +... th.flit.main(['update', '-C', temp_dir]) +... compile_str = subp.check_output(['make', '-C', temp_dir, 'gt'], +... stderr=subp.STDOUT) +... run_str = subp.check_output(['make', '-C', temp_dir, 'ground-truth.csv'], +... stderr=subp.STDOUT) +... file_f = os.path.join(temp_dir, 'ground-truth.csv_MpiHello_f.dat') +... file_d = os.path.join(temp_dir, 'ground-truth.csv_MpiHello_d.dat') +... file_e = os.path.join(temp_dir, 'ground-truth.csv_MpiHello_e.dat') +... with open(file_f, 'r') as fin: contents_f = fin.read() +... with open(file_d, 'r') as fin: contents_d = fin.read() +... with open(file_e, 'r') as fin: contents_e = fin.read() +... run_str_2 = subp.check_output([ +... 'mpirun', '-n', '2', +... os.path.join(temp_dir, 'gtrun'), +... '--precision', 'double', +... '--output', os.path.join(temp_dir, 'ground-truth.csv'), +... '--timing-repeats', '1', +... '--timing-loops', '-1', +... ], stderr=subp.STDOUT) +... run_str_3 = subp.check_output([ +... 'mpirun', '-n', '1', +... os.path.join(temp_dir, 'gtrun'), +... '--precision', 'double', +... '--output', os.path.join(temp_dir, 'ground-truth.csv'), +... '--timing-repeats', '1', +... '--timing-loops', '-1', +... ], stderr=subp.STDOUT) +Creating /.../flit-config.toml +Creating /.../custom.mk +Creating /.../main.cpp +Creating /.../tests/Empty.cpp +Creating /.../Makefile +>>> compile_str = compile_str.decode('utf-8').strip().splitlines() +>>> run_str = run_str.decode('utf-8').strip().splitlines() +>>> run_str_2 = run_str_2.decode('utf-8').strip().splitlines() +>>> run_str_3 = run_str_3.decode('utf-8').strip().splitlines() + +Make sure the info statement about MPI being enabled is done at each make call + +>>> compile_str[1] +'MPI is enabled' +>>> run_str[1] +'MPI is enabled' + +Make sure the correct arguments are passed to mpirun + +>>> run_str[2] +'mpirun -n 2 ./gtrun --output ground-truth.csv --no-timing' + +Make sure the console messages are there, but they can be out of order + +>>> run_str.count('MpiHello: hello from rank 0 of 2') +3 +>>> run_str.count('MpiHello: hello from rank 1 of 2') +3 + +The string output files should only be written from rank 0, not rank 1 + +>>> contents_f +'MpiHello: hello from rank 0 of 2\\n' +>>> contents_d +'MpiHello: hello from rank 0 of 2\\n' +>>> contents_e +'MpiHello: hello from rank 0 of 2\\n' + +Run #2 was with 2 mpi processes only running the test with double precision. +First make sure that the warning about looping only once is issued. + +>>> run_str_2.count('Warning: cannot run auto-looping with MPI; Looping set to 1') +1 + +Now make sure the test was only run once + +>>> run_str_2.count('MpiHello: hello from rank 0 of 2') +1 +>>> run_str_2.count('MpiHello: hello from rank 1 of 2') +1 + +Run #3 was with 1 mpi process only running the test with double precision. +First make sure that the warning about looping was NOT issued. + +>>> run_str_3.count('Warning: cannot run auto-looping with MPI; Looping set to 1') +0 + +Make sure the test was run multiple times + +>>> run_str_3.count('MpiHello: hello from rank 0 of 1') > 1 +True +''' + +# Test setup before the docstring is run. +import sys +before_path = sys.path[:] +sys.path.append('..') +import test_harness as th +sys.path = before_path + +if __name__ == '__main__': + from doctest import testmod + failures, tests = testmod() + sys.exit(failures) diff --git a/tests/flit_src/tst_flitHelpers_h.cpp b/tests/flit_src/tst_flitHelpers_h.cpp index 2a9c3721..ea7bbf0d 100644 --- a/tests/flit_src/tst_flitHelpers_h.cpp +++ b/tests/flit_src/tst_flitHelpers_h.cpp @@ -106,30 +106,6 @@ unsigned __int128 combine_to_128(uint64_t left_half, uint64_t right_half) { } // end of unnamed namespace -template -void tst_setRandSeq() { - size_t n = 10; - int32_t seed = 5024; - auto expected = flit::setRandSeq(n, seed); - auto actual = flit::setRandSeq(n, seed); - for (decltype(n) i = 0; i < n; i++) { - TH_EQUAL(expected[i], actual[i]); - TH_VERIFY(expected[i] <= 6.0 && expected[i] >= -6.0); - } - - // Changing the seed should give you a different sequence - actual = flit::setRandSeq(n, seed + 2); - for (decltype(n) i = 0; i < n; i++) { - TH_NOT_EQUAL(expected[i], actual[i]); - } -} -void tst_setRandSeq_float() { tst_setRandSeq(); } -void tst_setRandSeq_double() { tst_setRandSeq(); } -void tst_setRandSeq_longdouble() { tst_setRandSeq(); } -TH_REGISTER(tst_setRandSeq_float); -TH_REGISTER(tst_setRandSeq_double); -TH_REGISTER(tst_setRandSeq_longdouble); - void tst_as_float_32bit() { uint32_t val = 1067316150; float expected = 1.234; diff --git a/tests/flit_src/tst_flit_cpp.cpp b/tests/flit_src/tst_flit_cpp.cpp index e085c2e0..8971e0e1 100644 --- a/tests/flit_src/tst_flit_cpp.cpp +++ b/tests/flit_src/tst_flit_cpp.cpp @@ -90,11 +90,49 @@ #include #include +#include #include #include #include +namespace { +struct TempFile { +public: + std::string name; + std::ofstream out; + TempFile() { + char fname_buf[L_tmpnam]; + char *s = std::tmpnam(fname_buf); // gives a warning, but I'm not worried + if (s != fname_buf) { + throw std::runtime_error("Could not create temporary file"); + } + + name = fname_buf; + name += "-tst_flit.in"; // this makes the danger much less likely + out.exceptions(std::ios::failbit); + out.open(name); + } + ~TempFile() { + out.close(); + std::remove(name.c_str()); + } +}; + +template +std::ostream& operator<<(std::ostream& out, const std::vector &v) { + out << "["; + if (v.size() > 0) { + out << v[0]; + } + for (int i = 1; i < v.size(); i++) { + out << ", " << v[i]; + } + out << "]"; + return out; +} +} // end of unnamed namespace + namespace tst_CsvRow { void tst_CsvRow_header() { CsvRow row {"1", "2", "3", "4"}; @@ -177,6 +215,7 @@ TH_REGISTER(tst_default_macro_values); void tst_FlitOptions_toString() { flit::FlitOptions opt; opt.help = true; + opt.info = false; opt.listTests = false; opt.verbose = false; opt.tests = {"one", "two", "three"}; @@ -186,11 +225,14 @@ void tst_FlitOptions_toString() { opt.timingLoops = 100; opt.timingRepeats = 2; opt.compareMode = true; + opt.compareGtFile = "MY-GTFILE"; + opt.compareSuffix = "-suffix.csv"; opt.compareFiles = {"A", "B", "C", "D"}; TH_EQUAL(opt.toString(), "Options:\n" " help: true\n" + " info: false\n" " verbose: false\n" " timing: false\n" " timingLoops: 100\n" @@ -199,6 +241,8 @@ void tst_FlitOptions_toString() { " precision: my precision\n" " output: my output\n" " compareMode: true\n" + " compareGtFile: MY-GTFILE\n" + " compareSuffix: -suffix.csv\n" " tests:\n" " one\n" " two\n" @@ -240,54 +284,60 @@ bool operator!=(const flit::FlitOptions& a, const flit::FlitOptions& b) { return ! (a == b); } void tst_parseArguments_empty() { - const char* argList[1] = {"progName"}; + std::vector argList = {"progName"}; flit::FlitOptions expected; - auto actual = flit::parseArguments(1, argList); + auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(expected, actual); } TH_REGISTER(tst_parseArguments_empty); void tst_parseArguments_one_flag() { - const char* argList[2] = {"progName", "-h"}; + std::vector argList = {"progName", "-h"}; flit::FlitOptions expected; expected.help = true; - auto actual = flit::parseArguments(2, argList); + auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(expected, actual); } TH_REGISTER(tst_parseArguments_one_flag); void tst_parseArguments_short_flags() { - const char* argList[17] = {"progName", + std::vector argList = {"progName", "-h", "-v", "-t", "-L", "-c", // bool flags "-l", "323", "-r", "21", "-p", "double", "-o", "out.txt", + "-s", "mysuffix.csv", + "-g", "gtrun.csv", "comp1", "comp2", "comp3", }; flit::FlitOptions expected; expected.help = true; expected.verbose = true; - expected.timing = true; + expected.timing = false; expected.listTests = true; expected.compareMode = true; expected.timingLoops = 323; expected.timingRepeats = 21; expected.precision = "double"; expected.output = "out.txt"; + expected.compareGtFile = "gtrun.csv"; + expected.compareSuffix = "mysuffix.csv"; expected.compareFiles = {"comp1", "comp2", "comp3"}; - auto actual = flit::parseArguments(17, argList); + auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(expected, actual); } TH_REGISTER(tst_parseArguments_short_flags); void tst_parseArguments_long_flags() { - const char* argList[17] = {"progName", - "--help", "--verbose", "--timing", "--list-tests", "--compare-mode", + std::vector argList = {"progName", + "--help", "--verbose", "--list-tests", "--compare-mode", "--timing", "--timing-loops", "323", "--timing-repeats", "21", "--precision", "double", "--output", "out.txt", + "--compare-gt", "my-gtrun-output-csv", + "--suffix", "my-suffix", "comp1", "comp2", "comp3", }; flit::FlitOptions expected; @@ -300,26 +350,50 @@ void tst_parseArguments_long_flags() { expected.timingRepeats = 21; expected.precision = "double"; expected.output = "out.txt"; + expected.compareGtFile = "my-gtrun-output-csv"; + expected.compareSuffix = "my-suffix"; expected.compareFiles = {"comp1", "comp2", "comp3"}; - auto actual = flit::parseArguments(17, argList); + auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(expected, actual); } TH_REGISTER(tst_parseArguments_long_flags); +void tst_parseArguments_compare_test_names() { + // tests that the parseArguments does not read the files - keep it simple + TempFile tmpf; + tmpf.out << "name,precision,score_hex,resultfile,nanosec\n" + << "test1,d,0x0,NULL,0\n" + << "test2,d,0x0,NULL,0\n" + << "test3,d,0x0,NULL,0"; + tmpf.out.flush(); + std::vector argList = {"progName", + "--compare-mode", tmpf.name.c_str() + }; + flit::FlitOptions expected; + expected.compareMode = true; + expected.timing = false; + expected.compareFiles = {tmpf.name}; + auto actual = flit::parseArguments(argList.size(), argList.data()); + TH_EQUAL(expected, actual); +} +TH_REGISTER(tst_parseArguments_compare_test_names); + void tst_parseArguments_unrecognized_flag() { - const char* argList[2] = {"progName", "-T"}; - TH_THROWS(flit::parseArguments(2, argList), flit::ParseException); + std::vector argList = {"progName", "-T"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); } TH_REGISTER(tst_parseArguments_unrecognized_flag); void tst_parseArguments_unknown_precision() { - const char* argList[3] = {"progName", "--precision", "half"}; - TH_THROWS(flit::parseArguments(2, argList), flit::ParseException); + std::vector argList = {"progName", "--precision", "half"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); } TH_REGISTER(tst_parseArguments_unknown_precision); void tst_parseArguments_valid_precisions() { - const char* argList[10] = {"progName", + std::vector argList = {"progName", "--precision", "all", "--precision", "float", "--precision", "double", @@ -329,43 +403,57 @@ void tst_parseArguments_valid_precisions() { flit::FlitOptions expected; expected.precision = "long double"; expected.timing = false; - auto actual = flit::parseArguments(10, argList); + auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(actual, expected); } TH_REGISTER(tst_parseArguments_valid_precisions); void tst_parseArguments_requires_argument() { - const char* argList1[2] = {"progName", "--precision"}; - TH_THROWS(flit::parseArguments(2, argList1), flit::ParseException); - const char* argList2[2] = {"progName", "--timing-loops"}; - TH_THROWS(flit::parseArguments(2, argList2), flit::ParseException); - const char* argList3[2] = {"progName", "--timing-repeats"}; - TH_THROWS(flit::parseArguments(2, argList3), flit::ParseException); - const char* argList4[2] = {"progName", "--output"}; - TH_THROWS(flit::parseArguments(2, argList4), flit::ParseException); + std::vector argList; + argList = {"progName", "--precision"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); + argList = {"progName", "--timing-loops"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); + argList = {"progName", "--timing-repeats"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); + argList = {"progName", "--output"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); + argList = {"progName", "--compare-gt"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); + argList = {"progName", "--suffix"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); // Giving a flag after a parameter option will result in the parameter option // assuming the flag is the argument to store. - const char* argList5[3] = {"progName", "--output", "--help"}; + argList = {"progName", "--output", "--help"}; flit::FlitOptions expected; expected.output = "--help"; - auto actual = flit::parseArguments(3, argList5); + auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(actual, expected); } TH_REGISTER(tst_parseArguments_requires_argument); void tst_parseArguments_expects_integers() { - const char* argList1[3] = {"progName", "--timing-loops", "123abc"}; + std::vector argList; + argList = {"progName", "--timing-loops", "123abc"}; flit::FlitOptions expected; expected.timingLoops = 123; - auto actual = flit::parseArguments(3, argList1); + auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(actual, expected); - - const char* argList2[3] = {"progName", "--timing-loops", "abc"}; - TH_THROWS(flit::parseArguments(3, argList2), flit::ParseException); - - const char* argList3[3] = {"progName", "--timing-repeats", "abc"}; - TH_THROWS(flit::parseArguments(3, argList3), flit::ParseException); + + argList = {"progName", "--timing-loops", "abc"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); + + argList = {"progName", "--timing-repeats", "abc"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); } TH_REGISTER(tst_parseArguments_expects_integers); @@ -378,16 +466,18 @@ void tst_parseArguments_specify_tests() { TestContainerDeleter deleter; (void)deleter; // suppresses the warning that deleter is not used - const char* argList[3] = {"progName", "test1", "test2"}; - TH_THROWS(flit::parseArguments(3, argList), flit::ParseException); + std::vector argList = {"progName", "test1", "test2"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); flit::getTests()["test1"] = nullptr; - TH_THROWS(flit::parseArguments(3, argList), flit::ParseException); + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); flit::getTests()["test2"] = nullptr; flit::FlitOptions expected; expected.tests = {"test1", "test2"}; - auto actual = flit::parseArguments(3, argList); + auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(actual, expected); } TH_REGISTER(tst_parseArguments_specify_tests); @@ -403,18 +493,19 @@ void tst_parseArguments_all_tests_expand() { flit::getTests()["test3"] = nullptr; // even if tests are provided, if "all" is there, just have each test once - const char* argList1[3] = {"progName", "test3", "all"}; - auto actual1 = flit::parseArguments(3, argList1); - TH_EQUAL(1, std::count(actual1.tests.begin(), actual1.tests.end(), "test1")); - TH_EQUAL(1, std::count(actual1.tests.begin(), actual1.tests.end(), "test2")); - TH_EQUAL(1, std::count(actual1.tests.begin(), actual1.tests.end(), "test3")); + std::vector argList; + argList = {"progName", "test3", "all"}; + auto actual = flit::parseArguments(argList.size(), argList.data()); + TH_EQUAL(1, std::count(actual.tests.begin(), actual.tests.end(), "test1")); + TH_EQUAL(1, std::count(actual.tests.begin(), actual.tests.end(), "test2")); + TH_EQUAL(1, std::count(actual.tests.begin(), actual.tests.end(), "test3")); // if no tests are provided, then use all tests - const char* argList2[1] = {"progName"}; - auto actual2 = flit::parseArguments(1, argList2); - TH_EQUAL(1, std::count(actual2.tests.begin(), actual2.tests.end(), "test1")); - TH_EQUAL(1, std::count(actual2.tests.begin(), actual2.tests.end(), "test2")); - TH_EQUAL(1, std::count(actual2.tests.begin(), actual2.tests.end(), "test3")); + argList = {"progName"}; + actual = flit::parseArguments(argList.size(), argList.data()); + TH_EQUAL(1, std::count(actual.tests.begin(), actual.tests.end(), "test1")); + TH_EQUAL(1, std::count(actual.tests.begin(), actual.tests.end(), "test2")); + TH_EQUAL(1, std::count(actual.tests.begin(), actual.tests.end(), "test3")); } TH_REGISTER(tst_parseArguments_all_tests_expand); @@ -428,8 +519,8 @@ void tst_parseArguments_specify_test_more_than_once() { flit::getTests()["test2"] = nullptr; flit::getTests()["test3"] = nullptr; - const char* argList[4] = {"progName", "test2", "test3", "test2"}; - auto actual = flit::parseArguments(4, argList); + std::vector argList = {"progName", "test2", "test3", "test2"}; + auto actual = flit::parseArguments(argList.size(), argList.data()); decltype(actual.tests) expected_tests {"test2", "test3", "test2"}; TH_EQUAL(actual.tests, expected_tests); } @@ -458,6 +549,8 @@ void tst_usage() { TH_VERIFY(usage_contains("-r REPEATS, --timing-repeats REPEATS")); TH_VERIFY(usage_contains("-o OUTFILE, --output OUTFILE")); TH_VERIFY(usage_contains("-c, --compare-mode")); + TH_VERIFY(usage_contains("-g GT_RESULTS, --compare-gt GT_RESULTS")); + TH_VERIFY(usage_contains("-s SUFFIX, --suffix SUFFIX")); TH_VERIFY(usage_contains("-p PRECISION, --precision PRECISION")); TH_VERIFY(usage_contains("'float'")); TH_VERIFY(usage_contains("'double'")); @@ -467,26 +560,7 @@ void tst_usage() { TH_REGISTER(tst_usage); void tst_readFile_exists() { - struct TmpFile { - std::ofstream out; - std::string fname; - - TmpFile() { - char fname_buf[L_tmpnam]; - auto ptr = std::tmpnam(fname_buf); // gives a warning, but I'm not worried - - fname = fname_buf; - fname += "-tst_flit.in"; // this makes the danger much less likely - out.exceptions(std::ios::failbit); - out.open(fname); - } - - ~TmpFile() { - out.close(); - std::remove(fname.c_str()); - } - }; - TmpFile tmp; + TempFile tmpf; std::string contents = "This is the sequence of characters and lines\n" "that I want to check that the readFile()\n" @@ -494,10 +568,10 @@ void tst_readFile_exists() { "\n" "\n" "You okay with that?"; - tmp.out << contents; - tmp.out.flush(); + tmpf.out << contents; + tmpf.out.flush(); - TH_EQUAL(contents, flit::readFile(tmp.fname)); + TH_EQUAL(contents, flit::readFile(tmpf.name)); } TH_REGISTER(tst_readFile_exists); @@ -524,7 +598,7 @@ namespace flit { } void tst_parseResults() { std::istringstream in( - "name,precision,score,resultfile,nanosec\n" + "name,precision,score_hex,resultfile,nanosec\n" "Mike,double,0x00000000000000000000,output.txt,149293\n" "Brady,long double,0x3fff8000000000000000,NULL,-1\n" "Julia,float,NULL,test-output.txt,498531\n" @@ -549,22 +623,22 @@ void tst_parseResults_invalid_format() { TH_THROWS(flit::parseResults(in), std::invalid_argument); // empty row - in.str("name,precision,score,resultfile,nanosec\n" + in.str("name,precision,score_hex,resultfile,nanosec\n" "\n"); TH_THROWS(flit::parseResults(in), std::out_of_range); // non-integer nanosec - in.str("name,precision,score,resultfile,nanosec\n" + in.str("name,precision,score_hex,resultfile,nanosec\n" "Mike,double,0x0,NULL,bob\n"); TH_THROWS(flit::parseResults(in), std::invalid_argument); // non-integer score - in.str("name,precision,score,resultfile,nanosec\n" + in.str("name,precision,score_hex,resultfile,nanosec\n" "Mike,double,giraffe,NULL,323\n"); TH_THROWS(flit::parseResults(in), std::invalid_argument); // doesn't end in a newline. Make sure it doesn't throw - in.str("name,precision,score,resultfile,nanosec\n" + in.str("name,precision,score_hex,resultfile,nanosec\n" "Mike,double,0x0,NULL,323"); auto actual = flit::parseResults(in); decltype(actual) expected; @@ -620,3 +694,56 @@ void tst_removeIdxFromName() { TH_THROWS(flit::removeIdxFromName("hello there_idxa"), std::invalid_argument); } TH_REGISTER(tst_removeIdxFromName); + +void tst_calculateMissingComparisons_empty() { + flit::FlitOptions options; + std::vector expected; + auto actual = calculateMissingComparisons(options); + TH_EQUAL(expected, actual); +} +TH_REGISTER(tst_calculateMissingComparisons_empty); + +void tst_calculateMissingComparisons_noGtFile() { + flit::FlitOptions options; + options.compareMode = true; + TempFile tmpf; + tmpf.out << "name,precision,score_hex,resultfile,nanosec\n" + << "test1,d,0x0,NULL,0\n" + << "test2,d,0x0,NULL,0\n" + << "test3,d,0x0,NULL,0"; + tmpf.out.flush(); + options.compareFiles = {tmpf.name}; + std::vector expected = {"test1", "test2", "test3"}; + auto actual = calculateMissingComparisons(options); + TH_EQUAL(expected, actual); +} +TH_REGISTER(tst_calculateMissingComparisons_noGtFile); + +void tst_calculateMissingComparisons_withGtFile() { + TempFile compf1; + compf1.out << "name,precision,score_hex,resultfile,nanosec\n" + << "test1,d,0x0,NULL,0\n" + << "test2,d,0x0,NULL,0\n" + << "test3,d,0x0,NULL,0\n"; + compf1.out.flush(); + TempFile compf2; + compf2.out << "name,precision,score_hex,resultfile,nanosec\n" + << "test2,d,0x0,NULL,0\n" + << "test4,d,0x0,NULL,0\n" + << "test6,d,0x0,NULL,0\n"; + compf2.out.flush(); + TempFile gtf; + gtf.out << "name,precision,score_hex,resultfile,nanosec\n" + << "test1,d,0x0,NULL,0\n" + << "test2,d,0x0,NULL,0\n" + << "test5,d,0x0,NULL,0\n"; + gtf.out.flush(); + flit::FlitOptions options; + options.compareMode = true; + options.compareFiles = {compf1.name, compf2.name}; + options.compareGtFile = gtf.name; + std::vector expected = {"test3", "test4", "test6"}; + auto actual = calculateMissingComparisons(options); + TH_EQUAL(expected, actual); +} +TH_REGISTER(tst_calculateMissingComparisons_withGtFile); diff --git a/tests/test_harness.py b/tests/test_harness.py index 587dd6f7..73a4b354 100644 --- a/tests/test_harness.py +++ b/tests/test_harness.py @@ -176,6 +176,8 @@ def tempdir(*args, **kwargs): of the with statement, the temporary directory will be deleted with everything in it. + Test that the temporary directory exists during the block and is removed + after >>> import os >>> temporary_directory = None >>> with tempdir() as new_dir: @@ -187,12 +189,20 @@ def tempdir(*args, **kwargs): False >>> print(os.path.exists(temporary_directory)) False + + Test that an exception is not thrown if it was already deleted + >>> import shutil + >>> with tempdir() as new_dir: + ... shutil.rmtree(new_dir) ''' import tempfile import shutil new_dir = tempfile.mkdtemp(*args, **kwargs) yield new_dir - shutil.rmtree(new_dir) + try: + shutil.rmtree(new_dir) + except FileNotFoundError: + pass def touch(filename): '''