From 0737cfc2062fbf7c1fb976ac2dfa2d42c408b619 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 22 Sep 2017 14:25:05 -0600 Subject: [PATCH 001/166] Kind of some flit bisect code --- scripts/flitcli/flit_bisect.py | 135 +++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 scripts/flitcli/flit_bisect.py diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py new file mode 100644 index 00000000..3d70730c --- /dev/null +++ b/scripts/flitcli/flit_bisect.py @@ -0,0 +1,135 @@ +''' +Implements the bisect subcommand, identifying the problematic subset of source +files that cause the variability. +''' + +import flitutil as util + +import toml + +import argparse +import csv +import datetime +import os +import sqlite3 +import sys + +brief_description = 'Bisect compilation to identify problematic source code' + +def _file_check(filename): + if not os.path.isfile(filename): + raise argparse.ArgumentTypeError('File does not exist: {0}'.format(filename)) + return filename + +def main(arguments, prog=sys.argv[0]): + 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. + ''', + ) + parser.add_argument('-c', '--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 compile, the second is the optimization + level, and the third (if present) is the switches. + ''') + args = parser.parse_args(arguments) + + try: + projconf = toml.load('flit-config.toml') + except FileNotFoundError: + print('Error: {0} not found. Run "flit init"'.format(tomlfile), + file=sys.stderr) + return 1 + + assert projconf['database']['type'] == 'sqlite', \ + 'Only sqlite database supported' + db = util.sqlite_open(projconf['database']['filepath']) + + # create a new run and set the args.append run id + if args.append is None: + # Create a new run to use in import + db.execute('insert into runs(rdate,label) values (?,?)', + (datetime.datetime.now(), args.label)) + db.commit() + args.append = db.execute('select id from runs order by id').fetchall()[-1]['id'] + + # Make sure the run id exists. + run_ids = [x['id'] for x in db.execute('select id from runs')] + assert args.append in run_ids, \ + 'Specified append run id {0} is not in the runs ' \ + 'table'.format(args.append) + + for importee in args.importfile: + print('Importing', importee) + if util.is_sqlite(importee): + import_db = util.sqlite_open(importee) + cur = import_db.cursor() + cur.execute('select id from runs') + importee_run_ids = sorted([x['id'] for x in cur]) + if len(importee_run_ids) == 0: + print(' no runs in database: nothing to import') + continue + 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 ' + 'from tests where run = ?', (import_run,)) + rows = [dict(x) for x in cur] + else: + with open(importee, 'r') as csvin: + reader = csv.DictReader(csvin) + rows = [row for row in reader] + if len(rows) == 0: + print(' zero rows: nothing to import') + continue + to_insert = [] + for row in rows: + # Convert 'NULL' to None + for key, val in row.items(): + row[key] = val if val != 'NULL' else None + # Insert + to_insert.append(( + args.append, + row['name'], + row['host'], + row['compiler'], + row['optl'], + row['switches'], + row['precision'], + row['comparison'], + row['comparison_d'], + row['file'], + row['nanosec'], + )) + db.executemany(''' + insert into tests( + run, + name, + host, + compiler, + optl, + switches, + precision, + comparison, + comparison_d, + file, + nanosec) + values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + ''', to_insert) + db.commit() + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) From bf438134398475ae0e6f08196a8418898eafde34 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 22 Dec 2017 14:02:55 -0700 Subject: [PATCH 002/166] Add some flit bisect functionality. Not even close to being completed --- scripts/flitcli/flit_bisect.py | 169 ++++++++++++++++++--------------- tests/flit_cli/tst_bisect.py | 15 +++ 2 files changed, 109 insertions(+), 75 deletions(-) create mode 100644 tests/flit_cli/tst_bisect.py diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 3d70730c..bfefa156 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -42,94 +42,113 @@ def main(arguments, prog=sys.argv[0]): -funsafe-math-optimizations" or "/opt/intel/bin/icpc -O1". The value will be split into three groups using space separators, the first - is the compile, the second is the optimization + is the compiler, the second is the optimization level, and the third (if present) is the switches. ''') args = parser.parse_args(arguments) + tomlfile = 'flit-config.toml' try: - projconf = toml.load('flit-config.toml') + projconf = toml.load(tomlfile) except FileNotFoundError: print('Error: {0} not found. Run "flit init"'.format(tomlfile), file=sys.stderr) return 1 - assert projconf['database']['type'] == 'sqlite', \ - 'Only sqlite database supported' - db = util.sqlite_open(projconf['database']['filepath']) + # Split the compilation into the separate components + compiler, optl, switches = args.compilation.strip().split(maxsplit=2) + print('compiler: ', repr(compiler)) + print('optl: ', repr(optl)) + print('switches: ', repr(switches)) - # create a new run and set the args.append run id - if args.append is None: - # Create a new run to use in import - db.execute('insert into runs(rdate,label) values (?,?)', - (datetime.datetime.now(), args.label)) - db.commit() - args.append = db.execute('select id from runs order by id').fetchall()[-1]['id'] + # TODO: see if the Makefile needs to be regenerated + # TODO: get the list of source files from the Makefile + # TODO: determine if the problem is on the linker's side + # TODO: I'm not yet sure the best way to do that + # TODO: Perform in parallel binary search from ground-truth and from + # problematic + # TODO: Use the custom comparison function in the test class when + # performing the binary search. + # TODO: autogenerate Makefiles in the /tmp directly, preferrably with the + # tempfile module. - # Make sure the run id exists. - run_ids = [x['id'] for x in db.execute('select id from runs')] - assert args.append in run_ids, \ - 'Specified append run id {0} is not in the runs ' \ - 'table'.format(args.append) + # Below was copied from flit_import + #assert projconf['database']['type'] == 'sqlite', \ + # 'Only sqlite database supported' + #db = util.sqlite_open(projconf['database']['filepath']) - for importee in args.importfile: - print('Importing', importee) - if util.is_sqlite(importee): - import_db = util.sqlite_open(importee) - cur = import_db.cursor() - cur.execute('select id from runs') - importee_run_ids = sorted([x['id'] for x in cur]) - if len(importee_run_ids) == 0: - print(' no runs in database: nothing to import') - continue - 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 ' - 'from tests where run = ?', (import_run,)) - rows = [dict(x) for x in cur] - else: - with open(importee, 'r') as csvin: - reader = csv.DictReader(csvin) - rows = [row for row in reader] - if len(rows) == 0: - print(' zero rows: nothing to import') - continue - to_insert = [] - for row in rows: - # Convert 'NULL' to None - for key, val in row.items(): - row[key] = val if val != 'NULL' else None - # Insert - to_insert.append(( - args.append, - row['name'], - row['host'], - row['compiler'], - row['optl'], - row['switches'], - row['precision'], - row['comparison'], - row['comparison_d'], - row['file'], - row['nanosec'], - )) - db.executemany(''' - insert into tests( - run, - name, - host, - compiler, - optl, - switches, - precision, - comparison, - comparison_d, - file, - nanosec) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - ''', to_insert) - db.commit() + ## create a new run and set the args.append run id + #if args.append is None: + # # Create a new run to use in import + # db.execute('insert into runs(rdate,label) values (?,?)', + # (datetime.datetime.now(), args.label)) + # db.commit() + # args.append = db.execute('select id from runs order by id').fetchall()[-1]['id'] + + ## Make sure the run id exists. + #run_ids = [x['id'] for x in db.execute('select id from runs')] + #assert args.append in run_ids, \ + # 'Specified append run id {0} is not in the runs ' \ + # 'table'.format(args.append) + + #for importee in args.importfile: + # print('Importing', importee) + # if util.is_sqlite(importee): + # import_db = util.sqlite_open(importee) + # cur = import_db.cursor() + # cur.execute('select id from runs') + # importee_run_ids = sorted([x['id'] for x in cur]) + # if len(importee_run_ids) == 0: + # print(' no runs in database: nothing to import') + # continue + # 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 ' + # 'from tests where run = ?', (import_run,)) + # rows = [dict(x) for x in cur] + # else: + # with open(importee, 'r') as csvin: + # reader = csv.DictReader(csvin) + # rows = [row for row in reader] + # if len(rows) == 0: + # print(' zero rows: nothing to import') + # continue + # to_insert = [] + # for row in rows: + # # Convert 'NULL' to None + # for key, val in row.items(): + # row[key] = val if val != 'NULL' else None + # # Insert + # to_insert.append(( + # args.append, + # row['name'], + # row['host'], + # row['compiler'], + # row['optl'], + # row['switches'], + # row['precision'], + # row['comparison'], + # row['comparison_d'], + # row['file'], + # row['nanosec'], + # )) + # db.executemany(''' + # insert into tests( + # run, + # name, + # host, + # compiler, + # optl, + # switches, + # precision, + # comparison, + # comparison_d, + # file, + # nanosec) + # values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + # ''', to_insert) + #db.commit() if __name__ == '__main__': sys.exit(main(sys.argv[1:])) diff --git a/tests/flit_cli/tst_bisect.py b/tests/flit_cli/tst_bisect.py new file mode 100644 index 00000000..6c2364c2 --- /dev/null +++ b/tests/flit_cli/tst_bisect.py @@ -0,0 +1,15 @@ +''' +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() + From 50223237aa7d0f2b7a59e8cb9642358f33ab10ea Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 22 Dec 2017 14:04:00 -0700 Subject: [PATCH 003/166] Add a plan document describing how to do flit bisect --- plans/bisect-plan.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 plans/bisect-plan.md diff --git a/plans/bisect-plan.md b/plans/bisect-plan.md new file mode 100644 index 00000000..b2a485da --- /dev/null +++ b/plans/bisect-plan.md @@ -0,0 +1,10 @@ +# FLiT Bisect Plan + +The user adds custom build specifications to `custom.mk`. I would want to +leverage this customization as well as the customization in the +`flit-config.toml` file. I think this can be done in an automatic way to use +this bisect functionality and identify all compilations that cause differences. + + + + From 137b82f2c9c9cd9340ac2849ebd8559c771f0c6d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 22 Dec 2017 17:21:01 -0700 Subject: [PATCH 004/166] bisect: Extract variables from Makefile --- plans/bisect-plan.md | 45 +++++++++++++-- scripts/flitcli/flit_bisect.py | 102 +++++---------------------------- scripts/flitcli/flitutil.py | 37 ++++++++++++ 3 files changed, 92 insertions(+), 92 deletions(-) diff --git a/plans/bisect-plan.md b/plans/bisect-plan.md index b2a485da..4294af45 100644 --- a/plans/bisect-plan.md +++ b/plans/bisect-plan.md @@ -1,10 +1,47 @@ # FLiT Bisect Plan -The user adds custom build specifications to `custom.mk`. I would want to -leverage this customization as well as the customization in the -`flit-config.toml` file. I think this can be done in an automatic way to use -this bisect functionality and identify all compilations that cause differences. +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 +``` diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index bfefa156..a9d09d6b 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -16,11 +16,6 @@ brief_description = 'Bisect compilation to identify problematic source code' -def _file_check(filename): - if not os.path.isfile(filename): - raise argparse.ArgumentTypeError('File does not exist: {0}'.format(filename)) - return filename - def main(arguments, prog=sys.argv[0]): parser = argparse.ArgumentParser( prog=prog, @@ -33,7 +28,7 @@ def main(arguments, prog=sys.argv[0]): reproducibility problem lies. ''', ) - parser.add_argument('-c', '--compilation', + parser.add_argument('compilation', help=''' The problematic compilation to use. This should specify the compiler, optimization level, and @@ -44,6 +39,8 @@ def main(arguments, prog=sys.argv[0]): 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. ''') args = parser.parse_args(arguments) @@ -57,98 +54,27 @@ def main(arguments, prog=sys.argv[0]): # Split the compilation into the separate components compiler, optl, switches = args.compilation.strip().split(maxsplit=2) - print('compiler: ', repr(compiler)) - print('optl: ', repr(optl)) - print('switches: ', repr(switches)) # TODO: see if the Makefile needs to be regenerated - # TODO: get the list of source files from the Makefile + + # get the list of source files from the Makefile + sources = util.extract_make_var('SOURCE', 'Makefile') + # TODO: determine if the problem is on the linker's side - # TODO: I'm not yet sure the best way to do that + # I'm not yet sure the best way to do that + # TODO: Perform in parallel binary search from ground-truth and from # problematic + # - create extra Makefile + # - run extra Makefile to determine if the problem is still there + # - + # TODO: Use the custom comparison function in the test class when # performing the binary search. + # TODO: autogenerate Makefiles in the /tmp directly, preferrably with the # tempfile module. - # Below was copied from flit_import - #assert projconf['database']['type'] == 'sqlite', \ - # 'Only sqlite database supported' - #db = util.sqlite_open(projconf['database']['filepath']) - - ## create a new run and set the args.append run id - #if args.append is None: - # # Create a new run to use in import - # db.execute('insert into runs(rdate,label) values (?,?)', - # (datetime.datetime.now(), args.label)) - # db.commit() - # args.append = db.execute('select id from runs order by id').fetchall()[-1]['id'] - - ## Make sure the run id exists. - #run_ids = [x['id'] for x in db.execute('select id from runs')] - #assert args.append in run_ids, \ - # 'Specified append run id {0} is not in the runs ' \ - # 'table'.format(args.append) - - #for importee in args.importfile: - # print('Importing', importee) - # if util.is_sqlite(importee): - # import_db = util.sqlite_open(importee) - # cur = import_db.cursor() - # cur.execute('select id from runs') - # importee_run_ids = sorted([x['id'] for x in cur]) - # if len(importee_run_ids) == 0: - # print(' no runs in database: nothing to import') - # continue - # 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 ' - # 'from tests where run = ?', (import_run,)) - # rows = [dict(x) for x in cur] - # else: - # with open(importee, 'r') as csvin: - # reader = csv.DictReader(csvin) - # rows = [row for row in reader] - # if len(rows) == 0: - # print(' zero rows: nothing to import') - # continue - # to_insert = [] - # for row in rows: - # # Convert 'NULL' to None - # for key, val in row.items(): - # row[key] = val if val != 'NULL' else None - # # Insert - # to_insert.append(( - # args.append, - # row['name'], - # row['host'], - # row['compiler'], - # row['optl'], - # row['switches'], - # row['precision'], - # row['comparison'], - # row['comparison_d'], - # row['file'], - # row['nanosec'], - # )) - # db.executemany(''' - # insert into tests( - # run, - # name, - # host, - # compiler, - # optl, - # switches, - # precision, - # comparison, - # comparison_d, - # file, - # nanosec) - # values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - # ''', to_insert) - #db.commit() if __name__ == '__main__': sys.exit(main(sys.argv[1:])) diff --git a/scripts/flitcli/flitutil.py b/scripts/flitcli/flitutil.py index 32ac972d..b631010b 100644 --- a/scripts/flitcli/flitutil.py +++ b/scripts/flitcli/flitutil.py @@ -6,7 +6,9 @@ import os import sqlite3 +import subprocess as subp import sys +import tempfile def process_in_file(infile, dest, vals, overwrite=False): ''' @@ -63,3 +65,38 @@ def is_sqlite(filename): header = fd.read(100) return header[:16] == b'SQLite format 3\000' + +def extract_make_var(var, makefile='Makefile'): + ''' + 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], stderr=subp.STDOUT) + output = output.strip().decode('utf-8') + var_values = output.split('=', maxsplit=1)[1].split() + return var_values + From 9973cb630496fcdf38157a2e3604295f2579f04f Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 2 Feb 2018 02:49:24 -0700 Subject: [PATCH 005/166] flitutil: extracting make var can now have a directory --- scripts/flitcli/flitutil.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/flitcli/flitutil.py b/scripts/flitcli/flitutil.py index b631010b..7a78abe0 100644 --- a/scripts/flitcli/flitutil.py +++ b/scripts/flitcli/flitutil.py @@ -66,7 +66,7 @@ def is_sqlite(filename): return header[:16] == b'SQLite format 3\000' -def extract_make_var(var, makefile='Makefile'): +def extract_make_var(var, makefile='Makefile', directory='.'): ''' Extracts the value of a particular variable within a particular Makefile. @@ -94,8 +94,10 @@ def extract_make_var(var, makefile='Makefile'): 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], stderr=subp.STDOUT) + 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 From cf47b96703f9f6ab3b51ccd2d3ec1754dcecac12 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 2 Feb 2018 02:51:35 -0700 Subject: [PATCH 006/166] flit-bisect: generate Makefile capable of compiling It can compile the gtrun target, the troublesome target, and also the mixed compilation target. It still does not automate: - The bisect itself - The compilations - The runs - Checking to see if the problem is still there - Seeing if the linker is to blame - Allow a custom linker --- data/Makefile.in | 12 ++-- data/Makefile_bisect_binary.in | 80 +++++++++++++++++++++++ scripts/flitcli/flit_bisect.py | 116 +++++++++++++++++++++++++++++++-- 3 files changed, 196 insertions(+), 12 deletions(-) create mode 100644 data/Makefile_bisect_binary.in diff --git a/data/Makefile.in b/data/Makefile.in index 62b79681..ca9a8ace 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -478,14 +478,14 @@ 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 +$(CUTARGETS): 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 +$(CUTARGETS): $(FLIT_LIB_DIR)/libflit.so endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac # include the build dependencies for gt and dev diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in new file mode 100644 index 00000000..a6783da9 --- /dev/null +++ b/data/Makefile_bisect_binary.in @@ -0,0 +1,80 @@ +# 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 + + +TROUBLE_CC := {trouble_cc} +TROUBLE_OPTL := {trouble_optl} +TROUBLE_SWITCHES := {trouble_switches} +BISECT_LINK := $(GT_CC) + +TROUBLE_ID := {trouble_id} + +MAKEFILE := {Makefile} +BISECT_TARGET := run-$(notdir $(MAKEFILE:%.mk=%)) +TROUBLE_TARGET := runbisect-trouble_$(TROUBLE_ID) + +TROUBLE_SRC := +BISECT_GT_SRC := +{TROUBLE_SRC} +{BISECT_GT_SRC} + +# TODO: fill in TROUBLE_SRC and BISECT_GT_SRC +TROUBLE_TARGET_OBJ := $(addprefix \ + $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_bisect_$(TROUBLE_ID).o))) +TROUBLE_OBJ := $(addprefix \ + $(OBJ_DIR)/,$(notdir $(TROUBLE_SRC:%.cpp=%_bisect_$(TROUBLE_ID).o))) +BISECT_GT_OBJ := $(addprefix \ + $(OBJ_DIR)/,$(notdir $(BISECT_GT_SRC:%.cpp=%_gt.o))) +BISECT_OBJ := $(BISECT_GT_OBJ) +BISECT_OBJ += $(TROUBLE_OBJ) +TROUBLE_TARGET_DEPS := $(TROUBLE_TARGET_OBJ:%.o=%.d) + +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 + +-include $(TROUBLE_TARGET_DEPS) + +$(BISECT_TARGET): $(BISECT_OBJ) Makefile custom.mk + $(GT_CC) $(CC_REQUIRED) -o $@ $(BISECT_OBJ) $(LD_REQUIRED) + +$(TROUBLE_TARGET): $(TROUBLE_TARGET_OBJ) Makefile custom.mk + $(TROUBLE_CC) $(CC_REQUIRED) -o $@ $(TROUBLE_TARGET_OBJ) $(LD_REQUIRED) + +# TODO: create TROUBLE_OUT +# TODO: create BISECT_OUT +# TODO: create job for comparing BISECT_OUT with GT_OUT via gtrun +# TODO: create job for compiling the BISECT_OUT or the comparison target + +# TODO: reminder: run everything with --no-timing + +.PHONY: bisect +bisect: $(BISECT_TARGET) $(TROUBLE_TARGET) $(GT_TARGET) +#bisect: $(GT_OUT) $(BISECT_OUT) $(TROUBLE_OUT) + +# ground-truth files are already specified in Makefile + +# 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-out"' + diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index a9d09d6b..1f786926 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -3,6 +3,7 @@ files that cause the variability. ''' +import flitconfig as conf import flitutil as util import toml @@ -10,9 +11,13 @@ import argparse import csv import datetime +import hashlib +import logging import os import sqlite3 +import subprocess as subp import sys +import tempfile brief_description = 'Bisect compilation to identify problematic source code' @@ -26,6 +31,9 @@ def main(arguments, prog=sys.argv[0]): 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. ''', ) parser.add_argument('compilation', @@ -42,9 +50,28 @@ def main(arguments, prog=sys.argv[0]): 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 ta default 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') args = parser.parse_args(arguments) - tomlfile = 'flit-config.toml' + tomlfile = os.path.join(args.directory, 'flit-config.toml') try: projconf = toml.load(tomlfile) except FileNotFoundError: @@ -53,17 +80,94 @@ def main(arguments, prog=sys.argv[0]): return 1 # Split the compilation into the separate components - compiler, optl, switches = args.compilation.strip().split(maxsplit=2) + split_compilation = args.compilation.strip().split(maxsplit=2) + compiler = split_compilation[0] + optl = '' + switches = '' + if len(split_compilation) > 1: + optl = split_compilation[1] + if len(split_compilation) > 2: + switches = split_compilation[2] + + # our hash is the first 10 digits of a sha1 sum + trouble_hash = hashlib.sha1( + (compiler + optl + switches).encode()).hexdigest()[:10] + + # 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) - # TODO: see if the Makefile needs to be regenerated + # TODO: add a variable in the Makefile of another include Makefile + # that include Makefile will be generated by this Makefile + # TODO: on second thought, the generated Makefile can be loaded at runtime + # with the Makefile here, simply by passing in multiple Makefiles to + # GNU Make. + # TODO: or we can simply hard-code in the include of the other Makefiles in + # this autogenerated one. I like this choice, it's easy to follow + # and implement. + + # keep a bisect.log of what was done + logging.basicConfig( + filename=os.path.join(args.directory, '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: "{0}"'.format(compiler)) + logging.debug(' trouble optimization level: "{0}"'.format(optl)) + logging.debug(' trouble switches: "{0}"'.format(switches)) + logging.debug(' trouble testcase: "{0}"'.format(args.testcase)) + logging.debug(' trouble hash: "{0}"'.format(trouble_hash)) # get the list of source files from the Makefile - sources = util.extract_make_var('SOURCE', 'Makefile') + sources = util.extract_make_var('SOURCE', 'Makefile', + directory=args.directory) + logging.debug('Sources') + for source in sources: + logging.debug(' ' + source) + + gt_src = sources[0:1] + trouble_src = sources[1:] + + with tempfile.NamedTemporaryFile(prefix='flit-bisect-', suffix='.mk', + delete=False) as makefile: + logging.info('Creating makefile: ' + makefile.name) + util.process_in_file( + os.path.join(conf.data_dir, 'Makefile_bisect_binary.in'), + makefile.name, + { + 'Makefile': makefile.name, + 'datetime': datetime.date.today().strftime("%B %d, %Y"), + 'flit_version': conf.version, + 'trouble_cc': compiler, + 'trouble_optl': optl, + 'trouble_switches': switches, + 'trouble_id': trouble_hash, + 'TROUBLE_SRC': '\n'.join(['TROUBLE_SRC := {0}'.format(x) + for x in trouble_src]), + 'BISECT_GT_SRC': '\n'.join(['BISECT_GT_SRC := {0}'.format(x) + for x in gt_src]), + }, + overwrite=True) + logging.debug( + 'BISECT_TARGET = ' + + ', '.join(util.extract_make_var('BISECT_TARGET', makefile.name, + directory=args.directory))) + logging.debug( + 'SOURCE = ' + + ', '.join(util.extract_make_var('SOURCE', makefile.name, + directory=args.directory))) + # TODO: should we delete these Makefiles? I think so... + #logging.info('Deleted makefile: ' + makefile.name) # TODO: determine if the problem is on the linker's side - # I'm not yet sure the best way to do that + # I'm not yet sure the best way to do that + # This is to be done later - first get for compilation problems - # TODO: Perform in parallel binary search from ground-truth and from + # TODO: Perform (in parallel?) binary search from ground-truth and from # problematic # - create extra Makefile # - run extra Makefile to determine if the problem is still there From f0537d38349dd5026bdd0d5a3ea77dd4430f4255 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 3 Feb 2018 23:24:55 -0700 Subject: [PATCH 007/166] bisect: implement bisect_search and split function for making makefile --- scripts/flitcli/flit_bisect.py | 156 +++++++++++++++++++++++++++------ 1 file changed, 128 insertions(+), 28 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 1f786926..9766b8a4 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -13,6 +13,7 @@ import datetime import hashlib import logging +import multiprocessing import os import sqlite3 import subprocess as subp @@ -21,6 +22,120 @@ brief_description = 'Bisect compilation to identify problematic source code' +def create_bisect_makefile(replacements, gt_src, trouble_src): + ''' + Returns a tempfile.NamedTemporaryFile instance populated with the + replacements, gt_src, and trouble_src. It is then ready to be executed by + 'make bisect' from the correct directory. + + @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. + + @return (tempfile.NamedTemporaryFile) a temporary makefile that is + populated to be able to compile the gt_src and the trouble_src into a + single executable. + ''' + 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]), + # TODO: remove delete=False after done testing + makefile = tempfile.NamedTemporaryFile(prefix='flit-bisect-', suffix='.mk', + delete=False) + logging.info('Creating makefile: ' + makefile.name) + util.process_in_file( + os.path.join(conf.data_dir, 'Makefile_bisect_binary.in'), + makefile.name, + repl_copy, + overwrite=True) + return makefile + +def build_bisect(makefilename, directory, jobs=None): + ''' + Creates the bisect executable by executing a parallel make. + + @param makefilename: the filepath to the makefile + @param directory: where to execute make + @param jobs: number of parallel jobs. Defaults to #cpus + + @return None + ''' + logging.info('Building the bisect executable') + if jobs is None: + jobs = multiprocessing.cpu_count() + subp.check_call( + [make, '-C', directory, '-f', makefilename, '-j', jobs, 'bisect'], + stdout=subp.DEVNULL, stderr=subp.DEVNULL) + +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. + + @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 + >>> sorted(bisect_search(lambda x,y: min(x) < 0, [1, 3, 4, 5, 10, -1, 0, -15])) + [-15, -1] + ''' + # copy the incoming list so that we don't modify it + quest_list = list(elements) + known_list = [] + + # TODO: since it is single tail recursion, convert to an iterative form + bad_list = [] + while is_bad(quest_list, known_list): + + # find one bad element + Q = quest_list + no_test = list(known_list) + bad_idx = 0 + while len(Q) > 1: + # split the questionable list into two lists + Q1 = Q[:len(Q) // 2] + Q2 = Q[len(Q) // 2:] + if is_bad(Q1, no_test + Q2): + Q = Q1 + no_test.extend(Q2) + # TODO: if the length of Q2 is big enough, test + # is_bad(Q2, no_test + Q1) + # and if that returns False, then mark Q2 as known so + # that we don't need to search it again. + else: + # update the local search + bad_idx += len(Q1) + Q = Q2 + no_test.extend(Q1) + # TODO: optimization: mark Q1 as known, so that we don't need + # to search it again + + bad_element = quest_list.pop(bad_idx) + bad_list.append(bad_element) + known_list.append(bad_element) + #print('known_list: ', known_list) + #print('bad_list: ', bad_list) + #print('quest_list: ', quest_list) + + # double check that we found a bad element + #assert is_bad([bad_element], known_list + quest_list) + + return bad_list + def main(arguments, prog=sys.argv[0]): parser = argparse.ArgumentParser( prog=prog, @@ -132,34 +247,19 @@ def main(arguments, prog=sys.argv[0]): gt_src = sources[0:1] trouble_src = sources[1:] - with tempfile.NamedTemporaryFile(prefix='flit-bisect-', suffix='.mk', - delete=False) as makefile: - logging.info('Creating makefile: ' + makefile.name) - util.process_in_file( - os.path.join(conf.data_dir, 'Makefile_bisect_binary.in'), - makefile.name, - { - 'Makefile': makefile.name, - 'datetime': datetime.date.today().strftime("%B %d, %Y"), - 'flit_version': conf.version, - 'trouble_cc': compiler, - 'trouble_optl': optl, - 'trouble_switches': switches, - 'trouble_id': trouble_hash, - 'TROUBLE_SRC': '\n'.join(['TROUBLE_SRC := {0}'.format(x) - for x in trouble_src]), - 'BISECT_GT_SRC': '\n'.join(['BISECT_GT_SRC := {0}'.format(x) - for x in gt_src]), - }, - overwrite=True) - logging.debug( - 'BISECT_TARGET = ' + - ', '.join(util.extract_make_var('BISECT_TARGET', makefile.name, - directory=args.directory))) - logging.debug( - 'SOURCE = ' + - ', '.join(util.extract_make_var('SOURCE', makefile.name, - directory=args.directory))) + replacements = { + 'Makefile': makefile.name, + 'datetime': datetime.date.today().strftime("%B %d, %Y"), + 'flit_version': conf.version, + 'trouble_cc': compiler, + 'trouble_optl': optl, + 'trouble_switches': switches, + 'trouble_id': trouble_hash, + }; + + makefile = create_bisect_makefile(replacements, gt_src, trouble_src) + build_bisect(makefile, args.directory) + # TODO: should we delete these Makefiles? I think so... #logging.info('Deleted makefile: ' + makefile.name) From 2f7c86ccbf61b4dd389aa9dac1cb9bfb53779fea Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 3 Feb 2018 23:43:12 -0700 Subject: [PATCH 008/166] bisect: add optimization for # calls to is_bad() --- scripts/flitcli/flit_bisect.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 9766b8a4..0e156658 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -90,8 +90,19 @@ def bisect_search(is_bad, elements): @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 - >>> sorted(bisect_search(lambda x,y: min(x) < 0, [1, 3, 4, 5, 10, -1, 0, -15])) + >>> 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, 10, -1, 0, -15]) + >>> 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 + 6 ''' # copy the incoming list so that we don't modify it quest_list = list(elements) @@ -99,12 +110,11 @@ def bisect_search(is_bad, elements): # TODO: since it is single tail recursion, convert to an iterative form bad_list = [] - while is_bad(quest_list, known_list): + while len(quest_list) > 0 and is_bad(quest_list, known_list): # find one bad element Q = quest_list no_test = list(known_list) - bad_idx = 0 while len(Q) > 1: # split the questionable list into two lists Q1 = Q[:len(Q) // 2] @@ -117,19 +127,17 @@ def bisect_search(is_bad, elements): # and if that returns False, then mark Q2 as known so # that we don't need to search it again. else: + # optimization: mark Q1 as known, so that we don't need to + # search it again + quest_list = quest_list[len(Q1):] + known_list.extend(Q1) # update the local search - bad_idx += len(Q1) Q = Q2 no_test.extend(Q1) - # TODO: optimization: mark Q1 as known, so that we don't need - # to search it again - bad_element = quest_list.pop(bad_idx) + bad_element = quest_list.pop(0) bad_list.append(bad_element) known_list.append(bad_element) - #print('known_list: ', known_list) - #print('bad_list: ', bad_list) - #print('quest_list: ', quest_list) # double check that we found a bad element #assert is_bad([bad_element], known_list + quest_list) From 8ff14bee3f05a18b1028f1e733f953ee419525d2 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 7 Feb 2018 13:12:12 -0700 Subject: [PATCH 009/166] bisect: update some comments in code --- scripts/flitcli/flit_bisect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 0e156658..2475e31c 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -89,7 +89,8 @@ def bisect_search(is_bad, elements): @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 + 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 @@ -108,7 +109,6 @@ def bisect_search(is_bad, elements): quest_list = list(elements) known_list = [] - # TODO: since it is single tail recursion, convert to an iterative form bad_list = [] while len(quest_list) > 0 and is_bad(quest_list, known_list): From 7edbce189a81ceab02639a3b027ff93e7b197b43 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 8 Feb 2018 11:55:22 -0700 Subject: [PATCH 010/166] Add licence headers for the added bisect files --- data/Makefile_bisect_binary.in | 82 ++++++++++++++++++++++++++++++++++ scripts/flitcli/flit_bisect.py | 82 ++++++++++++++++++++++++++++++++++ tests/flit_cli/tst_bisect.py | 82 ++++++++++++++++++++++++++++++++++ 3 files changed, 246 insertions(+) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index a6783da9..7759007e 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -1,3 +1,85 @@ +# -- 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} diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 2475e31c..7ab6d71f 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1,3 +1,85 @@ +# -- 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. diff --git a/tests/flit_cli/tst_bisect.py b/tests/flit_cli/tst_bisect.py index 6c2364c2..1052aba5 100644 --- a/tests/flit_cli/tst_bisect.py +++ b/tests/flit_cli/tst_bisect.py @@ -1,3 +1,85 @@ +# -- 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 bisect functionality. ''' From 7ed65c9970e73623d3dbea919aa5f4a8d4e888a8 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 8 Feb 2018 13:47:26 -0700 Subject: [PATCH 011/166] bisect: get it to compile correctly --- data/Makefile_bisect_binary.in | 4 ++-- scripts/flitcli/flit_bisect.py | 29 ++++++++++++----------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 7759007e..b705e141 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -104,7 +104,7 @@ TROUBLE_ID := {trouble_id} MAKEFILE := {Makefile} BISECT_TARGET := run-$(notdir $(MAKEFILE:%.mk=%)) -TROUBLE_TARGET := runbisect-trouble_$(TROUBLE_ID) +TROUBLE_TARGET := runbisect-trouble-$(TROUBLE_ID) TROUBLE_SRC := BISECT_GT_SRC := @@ -158,5 +158,5 @@ $(OBJ_DIR)/%_bisect_$(TROUBLE_ID).o: %.cpp Makefile custom.mk | $(OBJ_DIR) -DFLIT_COMPILER='"$(TROUBLE_CC)"' \ -DFLIT_OPTL='"$(TROUBLE_OPTL)"' \ -DFLIT_SWITCHES='"$(TROUBLE_SWITCHES)"' \ - -DFLIT_FILENAME='"bisect-out"' + -DFLIT_FILENAME='"bisect-default-out"' diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 7ab6d71f..a5297837 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -122,13 +122,14 @@ def create_bisect_makefile(replacements, gt_src, trouble_src): single executable. ''' 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['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]) # TODO: remove delete=False after done testing makefile = tempfile.NamedTemporaryFile(prefix='flit-bisect-', suffix='.mk', delete=False) + repl_copy['Makefile'] = makefile.name logging.info('Creating makefile: ' + makefile.name) util.process_in_file( os.path.join(conf.data_dir, 'Makefile_bisect_binary.in'), @@ -151,7 +152,7 @@ def build_bisect(makefilename, directory, jobs=None): if jobs is None: jobs = multiprocessing.cpu_count() subp.check_call( - [make, '-C', directory, '-f', makefilename, '-j', jobs, 'bisect'], + ['make', '-C', directory, '-f', makefilename, '-j', str(jobs), 'bisect'], stdout=subp.DEVNULL, stderr=subp.DEVNULL) def bisect_search(is_bad, elements): @@ -262,7 +263,7 @@ def main(arguments, prog=sys.argv[0]): by calling 'make dev' and then calling the created executable './devrun --list-tests'. ''') - # TODO: get ta default case to work + # TODO: get the default case to work #help=''' # The testcase to use. If there is only one test # case, then the default behavior is to use that test @@ -303,15 +304,6 @@ def main(arguments, prog=sys.argv[0]): subp.check_call(['make', '-C', args.directory, 'Makefile'], stdout=subp.DEVNULL, stderr=subp.DEVNULL) - # TODO: add a variable in the Makefile of another include Makefile - # that include Makefile will be generated by this Makefile - # TODO: on second thought, the generated Makefile can be loaded at runtime - # with the Makefile here, simply by passing in multiple Makefiles to - # GNU Make. - # TODO: or we can simply hard-code in the include of the other Makefiles in - # this autogenerated one. I like this choice, it's easy to follow - # and implement. - # keep a bisect.log of what was done logging.basicConfig( filename=os.path.join(args.directory, 'bisect.log'), @@ -338,7 +330,6 @@ def main(arguments, prog=sys.argv[0]): trouble_src = sources[1:] replacements = { - 'Makefile': makefile.name, 'datetime': datetime.date.today().strftime("%B %d, %Y"), 'flit_version': conf.version, 'trouble_cc': compiler, @@ -347,8 +338,12 @@ def main(arguments, prog=sys.argv[0]): 'trouble_id': trouble_hash, }; + # TODO: what kind of feedback should we give the user while it is building? + # It is quite annoying as a user to simply issue a command and wait + # with no feedback for a long time. + makefile = create_bisect_makefile(replacements, gt_src, trouble_src) - build_bisect(makefile, args.directory) + build_bisect(makefile.name, args.directory) # TODO: should we delete these Makefiles? I think so... #logging.info('Deleted makefile: ' + makefile.name) From c00a8d16fb3b6196c498a0f18562ca45d7d6fc8d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 8 Feb 2018 13:48:56 -0700 Subject: [PATCH 012/166] flit.h: add --compare-gt flag This flag specifies the gt results file to use instead of running the tests again. This is necessary for flit bisect to have a good runtime. --- src/flit.cpp | 21 +++++++++++++++++++++ src/flit.h | 21 ++++++++++++++------- tests/flit_src/tst_flit_cpp.cpp | 2 ++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/flit.cpp b/src/flit.cpp index 79aa6e83..c094405d 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -196,6 +196,7 @@ std::string FlitOptions::toString() const { << " precision: " << this->precision << "\n" << " output: " << this->output << "\n" << " compareMode: " << boolToString(this->compareMode) << "\n" + << " compareGtFile: " << this->compareGtFile << "\n" << " tests:\n"; for (auto& test : this->tests) { messanger << " " << test << "\n"; @@ -220,6 +221,7 @@ 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 allowedPrecisions = { "all", "float", "double", "long double" }; @@ -270,6 +272,11 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { options.output = argList[++i]; } else if (isIn(compareMode, current)) { options.compareMode = true; + } else if (isIn(compareGtFileOpts, current)) { + if (i+1 == argCount) { + throw ParseException(current + " requires an argument"); + } + options.compareGtFile = argList[++i]; } else { options.tests.push_back(current); if (!options.compareMode && !isIn(allowedTests, current)) { @@ -360,6 +367,20 @@ 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" " -p PRECISION, --precision PRECISION\n" " Which precision to run. The choices are 'float',\n" " 'double', 'long double', and 'all'. The default\n" diff --git a/src/flit.h b/src/flit.h index c8c2e2f3..f35b9200 100644 --- a/src/flit.h +++ b/src/flit.h @@ -143,17 +143,18 @@ 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 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 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 compareMode = false; // compare results after running the test + std::string compareGtFile; // ground truth results to use in compareMode std::vector compareFiles; // files for compareMode /** Give a string representation of this struct for printing purposes */ @@ -467,6 +468,12 @@ inline int runFlitTests(int argc, char* argv[]) { }; std::sort(results.begin(), results.end(), testComparator); + // TODO: if we are in comparison mode, then don't simply run all tests - BAD + // TODO: find the full list of tests that need comparison - only require + // those results + // TODO: load the results from options.comparisonGtFile before deciding to + // run the tests for comparison + // Let's now run the ground-truth comparisons if (options.compareMode) { TestResultMap comparisonResults; diff --git a/tests/flit_src/tst_flit_cpp.cpp b/tests/flit_src/tst_flit_cpp.cpp index e085c2e0..7c7fe1c7 100644 --- a/tests/flit_src/tst_flit_cpp.cpp +++ b/tests/flit_src/tst_flit_cpp.cpp @@ -186,6 +186,7 @@ void tst_FlitOptions_toString() { opt.timingLoops = 100; opt.timingRepeats = 2; opt.compareMode = true; + opt.compareGtFile = "MY-GTFILE"; opt.compareFiles = {"A", "B", "C", "D"}; TH_EQUAL(opt.toString(), @@ -199,6 +200,7 @@ void tst_FlitOptions_toString() { " precision: my precision\n" " output: my output\n" " compareMode: true\n" + " compareGtFile: MY-GTFILE\n" " tests:\n" " one\n" " two\n" From f0fd35f02e85a2d060171b60c9cb2ddaead9a160 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 8 Feb 2018 23:53:06 -0700 Subject: [PATCH 013/166] flit.h: add --compare-gt option for --compare-mode This allows to reuse precomputed ground truth results This is a necessary feature to make bisect feasible --- src/TestBase.h | 6 +- src/flit.cpp | 33 +++++++- src/flit.h | 33 +++++--- tests/flit_src/tst_flit_cpp.cpp | 133 ++++++++++++++++++++++++++------ 4 files changed, 165 insertions(+), 40 deletions(-) diff --git a/src/TestBase.h b/src/TestBase.h index d3057742..a9e56301 100644 --- a/src/TestBase.h +++ b/src/TestBase.h @@ -181,7 +181,8 @@ std::unique_ptr*> makeCudaArr(const T* vals, size_t length) { // Copy over the vals array from hist into the device if (vals != nullptr) { - checkCudaErrors(cudaMemcpy(ptr.get(), vals, arrSize, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaMemcpy(ptr.get(), vals, arrSize, + cudaMemcpyHostToDevice)); } return ptr; @@ -472,7 +473,8 @@ class TestBase { * 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. diff --git a/src/flit.cpp b/src/flit.cpp index c094405d..9d6f8d84 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -288,14 +289,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()); } @@ -463,4 +462,30 @@ std::string removeIdxFromName(const std::string &name) { 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 f35b9200..702164a2 100644 --- a/src/flit.h +++ b/src/flit.h @@ -189,18 +189,21 @@ FlitOptions parseArguments(int argCount, char const* const argList[]); /** Returns the usage information as a string */ std::string usage(std::string progName); -/** Read file contents entirely into a string */ +/// 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 */ +/// Test names sometimes are postfixed with "_idx" + . Remove that postfix std::string removeIdxFromName(const std::string &name); +/// Returns the tests that need to be run for comparisons +std::vector calculateMissingComparisons(const FlitOptions &opt); + class TestResultMap { public: using key_type = std::pair; @@ -252,7 +255,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 ( @@ -427,6 +432,17 @@ inline int runFlitTests(int argc, char* argv[]) { 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(options.compareGtFile); + results = parseResults(fin); + } + } + std::cout.precision(1000); //set cout to print many decimal places info_stream.precision(1000); @@ -434,7 +450,6 @@ inline int runFlitTests(int argc, char* argv[]) { initDeviceData(); #endif - std::vector results; auto testMap = getTests(); for (auto& testName : options.tests) { auto factory = testMap[testName]; @@ -468,11 +483,7 @@ inline int runFlitTests(int argc, char* argv[]) { }; std::sort(results.begin(), results.end(), testComparator); - // TODO: if we are in comparison mode, then don't simply run all tests - BAD - // TODO: find the full list of tests that need comparison - only require - // those results - // TODO: load the results from options.comparisonGtFile before deciding to - // run the tests for comparison + // TODO: comparison mode should imply --no-timing // Let's now run the ground-truth comparisons if (options.compareMode) { diff --git a/tests/flit_src/tst_flit_cpp.cpp b/tests/flit_src/tst_flit_cpp.cpp index 7c7fe1c7..49658fce 100644 --- a/tests/flit_src/tst_flit_cpp.cpp +++ b/tests/flit_src/tst_flit_cpp.cpp @@ -90,11 +90,46 @@ #include #include +#include #include #include #include +namespace { +struct TempFile { +public: + std::string name; + std::ofstream out; + TempFile() { + char fname_buf[L_tmpnam]; + std::tmpnam(fname_buf); // gives a warning, but I'm not worried + + 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"}; @@ -308,6 +343,23 @@ void tst_parseArguments_long_flags() { } 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,resultfile,nanosec\n" + << "test1,d,0x0,NULL,0\n" + << "test2,d,0x0,NULL,0\n" + << "test3,d,0x0,NULL,0"; + tmpf.out.flush(); + const char* argList[3] = {"progName", "--compare-mode", tmpf.name.c_str()}; + flit::FlitOptions expected; + expected.compareMode = true; + expected.compareFiles = {tmpf.name}; + auto actual = flit::parseArguments(3, argList); + 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); @@ -460,6 +512,7 @@ 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("-p PRECISION, --precision PRECISION")); TH_VERIFY(usage_contains("'float'")); TH_VERIFY(usage_contains("'double'")); @@ -469,26 +522,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" @@ -496,10 +530,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); @@ -622,3 +656,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,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,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,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,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); From 8d83993ecb9790389aca5ee982c448607993feb1 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 9 Feb 2018 00:25:30 -0700 Subject: [PATCH 014/166] --compare-mode implies --no-timing and file errors Technically two changes in this change set - the compare mode implies no timing - missing csv files specified on the command-line are human readable errors rather than simply ignored. --- src/flit.cpp | 3 ++ src/flit.h | 56 ++++++++++++++++++++++++++++----- tests/flit_src/tst_flit_cpp.cpp | 5 +-- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/flit.cpp b/src/flit.cpp index 9d6f8d84..32f1e53c 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -273,6 +273,7 @@ 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"); @@ -359,6 +360,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" diff --git a/src/flit.h b/src/flit.h index 702164a2..4ef1af0d 100644 --- a/src/flit.h +++ b/src/flit.h @@ -209,7 +209,10 @@ class TestResultMap { using key_type = std::pair; void loadfile(const std::string &filename) { - std::ifstream resultfile(filename); + std::ifstream resultfile; + resultfile.exceptions(std::ios::failbit); + resultfile.open(filename); + resultfile.exceptions(std::ios::goodbit); auto parsed = parseResults(resultfile); this->extend(parsed, filename); } @@ -427,7 +430,16 @@ inline int runFlitTests(int argc, char* argv[]) { 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())); + std::ofstream outputstream; + try { + outputstream.exceptions(std::ios::failbit); + outputstream.open(options.output); + } catch (std::ios::failure &ex) { + std::cerr << "Error: failed to open " << options.output << std::endl; + return 1; + } + outputstream.exceptions(std::ios::goodbit); + stream_deleter.reset(new std::ofstream(options.output)); outstream = stream_deleter.get(); test_result_filebase = options.output; } @@ -438,7 +450,16 @@ inline int runFlitTests(int argc, char* argv[]) { if (options.compareMode) { options.tests = calculateMissingComparisons(options); if (!options.compareGtFile.empty()) { - std::ifstream fin(options.compareGtFile); + std::ifstream fin; + try { + fin.exceptions(std::ios::failbit); + fin.open(options.compareGtFile); + } catch (std::ios::failure &ex) { + std::cerr << "Error: file does not exist: " << options.compareGtFile + << std::endl; + return 1; + } + fin.exceptions(std::ios::goodbit); results = parseResults(fin); } } @@ -483,14 +504,17 @@ inline int runFlitTests(int argc, char* argv[]) { }; std::sort(results.begin(), results.end(), testComparator); - // TODO: comparison mode should imply --no-timing - // Let's now run the ground-truth comparisons if (options.compareMode) { 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; + return 1; + } } // compare mode is only done in the ground truth compilation @@ -509,7 +533,15 @@ 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 { + fin.exceptions(std::ios::failbit); + fin.open(fname); + } catch (std::ios_base::failure &ex) { + std::cerr << "Error: file does not exist: " << fname << std::endl; + return 1; + } + fin.exceptions(std::ios::goodbit); metadata = parseMetadata(fin); } @@ -525,7 +557,15 @@ inline int runFlitTests(int argc, char* argv[]) { // output back to a file { - std::ofstream fout(fname); + std::ofstream fout; + try { + fout.exceptions(std::ios::failbit); + fout.open(fname); + } catch (std::ios::failure &ex) { + std::cerr << "Error: could not write to " << fname << std::endl; + return 1; + } + fout.exceptions(std::ios::goodbit); outputResults( fileresults, fout, diff --git a/tests/flit_src/tst_flit_cpp.cpp b/tests/flit_src/tst_flit_cpp.cpp index 49658fce..6c07e302 100644 --- a/tests/flit_src/tst_flit_cpp.cpp +++ b/tests/flit_src/tst_flit_cpp.cpp @@ -305,7 +305,7 @@ void tst_parseArguments_short_flags() { flit::FlitOptions expected; expected.help = true; expected.verbose = true; - expected.timing = true; + expected.timing = false; expected.listTests = true; expected.compareMode = true; expected.timingLoops = 323; @@ -320,7 +320,7 @@ TH_REGISTER(tst_parseArguments_short_flags); void tst_parseArguments_long_flags() { const char* argList[17] = {"progName", - "--help", "--verbose", "--timing", "--list-tests", "--compare-mode", + "--help", "--verbose", "--list-tests", "--compare-mode", "--timing", "--timing-loops", "323", "--timing-repeats", "21", "--precision", "double", @@ -354,6 +354,7 @@ void tst_parseArguments_compare_test_names() { const char* argList[3] = {"progName", "--compare-mode", tmpf.name.c_str()}; flit::FlitOptions expected; expected.compareMode = true; + expected.timing = false; expected.compareFiles = {tmpf.name}; auto actual = flit::parseArguments(3, argList); TH_EQUAL(expected, actual); From 905ef6d1af1d07953a2ff89f6a57b69b310caac8 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 9 Feb 2018 00:34:49 -0700 Subject: [PATCH 015/166] Makefile.in: add TODOs to use the new cli option --- data/Makefile.in | 3 +++ data/Makefile_bisect_binary.in | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/data/Makefile.in b/data/Makefile.in index b645de3a..c8e5b987 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -599,6 +599,9 @@ $(OBJ_DIR)/%_cu_dev.o: %.cpp Makefile custom.mk | $(OBJ_DIR) $(NVCC) -c $(NVCC_CFLAGS) $(DEV_NVCC_CC) $< -o $@ endif # ifdef HAS_CUDA +# TODO: use the new --compare-gt flag and split this up into multiple executions +# TODO: change the output from in-place to a new file for results +# TODO: maybe precomapre results will be *.csv.partial or something... # Ground truth compilation rules $(GT_OUT): $(GT_TARGET) $(TARGET_OUTS) $(CUTARGET_OUTS) ./$(GT_TARGET) --output $(GT_OUT) \ diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index b705e141..47ae345e 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -111,7 +111,6 @@ BISECT_GT_SRC := {TROUBLE_SRC} {BISECT_GT_SRC} -# TODO: fill in TROUBLE_SRC and BISECT_GT_SRC TROUBLE_TARGET_OBJ := $(addprefix \ $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_bisect_$(TROUBLE_ID).o))) TROUBLE_OBJ := $(addprefix \ From 048fe2f29b9e015c9dfb1037b4d6e9440f615697 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 9 Feb 2018 11:01:54 -0700 Subject: [PATCH 016/166] fix errors and fix issue #123 - precision for files not the same as stdout --- src/TestBase.h | 2 +- src/flit.h | 26 +++++++------------------- src/flitHelpers.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/TestBase.h b/src/TestBase.h index a9e56301..8316991c 100644 --- a/src/TestBase.h +++ b/src/TestBase.h @@ -359,7 +359,7 @@ 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 = ofopen(resultfile); resultout << testResult.string(); testResult = Variant(); // empty the result to release memory } diff --git a/src/flit.h b/src/flit.h index 4ef1af0d..33ad6017 100644 --- a/src/flit.h +++ b/src/flit.h @@ -209,10 +209,7 @@ class TestResultMap { using key_type = std::pair; void loadfile(const std::string &filename) { - std::ifstream resultfile; - resultfile.exceptions(std::ios::failbit); - resultfile.open(filename); - resultfile.exceptions(std::ios::goodbit); + std::ifstream resultfile = ifopen(filename); auto parsed = parseResults(resultfile); this->extend(parsed, filename); } @@ -430,17 +427,14 @@ inline int runFlitTests(int argc, char* argv[]) { std::ostream *outstream = &std::cout; std::string test_result_filebase(FLIT_FILENAME); if (!options.output.empty()) { - std::ofstream outputstream; + stream_deleter.reset(new std::ofstream()); + outstream = stream_deleter.get(); try { - outputstream.exceptions(std::ios::failbit); - outputstream.open(options.output); + static_cast(*outstream) = ofopen(options.output); } catch (std::ios::failure &ex) { std::cerr << "Error: failed to open " << options.output << std::endl; return 1; } - outputstream.exceptions(std::ios::goodbit); - stream_deleter.reset(new std::ofstream(options.output)); - outstream = stream_deleter.get(); test_result_filebase = options.output; } @@ -452,14 +446,12 @@ inline int runFlitTests(int argc, char* argv[]) { if (!options.compareGtFile.empty()) { std::ifstream fin; try { - fin.exceptions(std::ios::failbit); - fin.open(options.compareGtFile); + fin = ifopen(options.compareGtFile); } catch (std::ios::failure &ex) { std::cerr << "Error: file does not exist: " << options.compareGtFile << std::endl; return 1; } - fin.exceptions(std::ios::goodbit); results = parseResults(fin); } } @@ -535,13 +527,11 @@ inline int runFlitTests(int argc, char* argv[]) { { std::ifstream fin; try { - fin.exceptions(std::ios::failbit); - fin.open(fname); + fin = ifopen(fname); } catch (std::ios_base::failure &ex) { std::cerr << "Error: file does not exist: " << fname << std::endl; return 1; } - fin.exceptions(std::ios::goodbit); metadata = parseMetadata(fin); } @@ -559,13 +549,11 @@ inline int runFlitTests(int argc, char* argv[]) { { std::ofstream fout; try { - fout.exceptions(std::ios::failbit); - fout.open(fname); + fout = ofopen(fname); } catch (std::ios::failure &ex) { std::cerr << "Error: could not write to " << fname << std::endl; return 1; } - fout.exceptions(std::ios::goodbit); outputResults( fileresults, fout, diff --git a/src/flitHelpers.h b/src/flitHelpers.h index 7aa5ef01..511d4bf7 100644 --- a/src/flitHelpers.h +++ b/src/flitHelpers.h @@ -92,6 +92,7 @@ #include "CUHelpers.h" #include +#include #include #include #include @@ -204,6 +205,37 @@ 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} +template +T _openfile_check(const std::string &filename) { + T filestream; + + // 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); + + // This is okay because move constructor and move assignment are implemented + return filestream; +} + +/// Opens a file for reading, but on failure, throws std::ios::failure +inline std::ifstream ifopen(const std::string &filename) { + return _openfile_check(filename); +} + +/// Opens a file for writing, but on failure, throws std::ios::failure +inline std::ofstream ofopen(const std::string &filename) { + std::ofstream out = _openfile_check(filename); + out.precision(1000); // lots of digits of precision + return out; +} + } // end of namespace flit #endif // FLIT_HELPERS_HPP From c0df0fd81a8fff5585e61475d250712daf15ae98 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 9 Feb 2018 17:23:24 -0700 Subject: [PATCH 017/166] test-cli: add --suffix argument for compare mode The suffix argument allows for the user to not overwrite the files to be compared. Instead, the comparison result will be put into the same filename with the suffix added to the end. By default, it is the same behavior as before since the default suffix is the empty string. --- src/flit.cpp | 21 ++++++ src/flit.h | 3 +- tests/flit_src/tst_flit_cpp.cpp | 128 ++++++++++++++++++++------------ 3 files changed, 103 insertions(+), 49 deletions(-) diff --git a/src/flit.cpp b/src/flit.cpp index 32f1e53c..194c113d 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -198,6 +198,7 @@ std::string FlitOptions::toString() const { << " 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"; @@ -223,6 +224,7 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { 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" }; @@ -279,6 +281,11 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { 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)) { @@ -383,6 +390,20 @@ std::string usage(std::string progName) { " 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" diff --git a/src/flit.h b/src/flit.h index 33ad6017..bfca8614 100644 --- a/src/flit.h +++ b/src/flit.h @@ -156,6 +156,7 @@ struct FlitOptions { 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; @@ -549,7 +550,7 @@ inline int runFlitTests(int argc, char* argv[]) { { std::ofstream fout; try { - fout = ofopen(fname); + fout = ofopen(fname + options.compareSuffix); } catch (std::ios::failure &ex) { std::cerr << "Error: could not write to " << fname << std::endl; return 1; diff --git a/tests/flit_src/tst_flit_cpp.cpp b/tests/flit_src/tst_flit_cpp.cpp index 6c07e302..7acfc4ad 100644 --- a/tests/flit_src/tst_flit_cpp.cpp +++ b/tests/flit_src/tst_flit_cpp.cpp @@ -222,6 +222,7 @@ void tst_FlitOptions_toString() { opt.timingRepeats = 2; opt.compareMode = true; opt.compareGtFile = "MY-GTFILE"; + opt.compareSuffix = "-suffix.csv"; opt.compareFiles = {"A", "B", "C", "D"}; TH_EQUAL(opt.toString(), @@ -236,6 +237,7 @@ void tst_FlitOptions_toString() { " output: my output\n" " compareMode: true\n" " compareGtFile: MY-GTFILE\n" + " compareSuffix: -suffix.csv\n" " tests:\n" " one\n" " two\n" @@ -277,29 +279,31 @@ 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; @@ -312,19 +316,23 @@ void tst_parseArguments_short_flags() { 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", + 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; @@ -337,8 +345,10 @@ 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); @@ -351,30 +361,34 @@ void tst_parseArguments_compare_test_names() { << "test2,d,0x0,NULL,0\n" << "test3,d,0x0,NULL,0"; tmpf.out.flush(); - const char* argList[3] = {"progName", "--compare-mode", tmpf.name.c_str()}; + 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(3, argList); + 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", @@ -384,43 +398,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); + argList = {"progName", "--timing-loops", "abc"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); - const char* argList3[3] = {"progName", "--timing-repeats", "abc"}; - TH_THROWS(flit::parseArguments(3, argList3), flit::ParseException); + argList = {"progName", "--timing-repeats", "abc"}; + TH_THROWS(flit::parseArguments(argList.size(), argList.data()), + flit::ParseException); } TH_REGISTER(tst_parseArguments_expects_integers); @@ -433,16 +461,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); @@ -458,18 +488,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); @@ -483,8 +514,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); } @@ -514,6 +545,7 @@ void tst_usage() { 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'")); From f359a1c4b4875d07fc20c662a2a80f3ce4e1dde8 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 9 Feb 2018 20:27:07 -0700 Subject: [PATCH 018/166] Makefile.in: fixes #85 - separate command per comparison Take advantage of the new --suffix command to run the ground truth executable once for each comparison file to create. Also, this will be correctly compared even if it is interrupted midway through. --- data/Makefile.in | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/data/Makefile.in b/data/Makefile.in index c8e5b987..6fb47b08 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -486,10 +486,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.csv: % +%-out: % -./$< --output $@ + +# specify how to get comparison +%-out-comparison.csv: %-out $(GT_OUT) $(GT_TARGET) + ./$(GT_TARGET) --compare-mode --compare-gt $(GT_OUT) --suffix "-comparison.csv" $< -o /dev/null #$(RESULTS_DIR)/%_out.csv: $(RESULTS_DIR)/% # $< --output $@ @@ -502,7 +507,8 @@ DEP_CLEAN += $(OBJ_CLEAN:%.o=%.d) ifdef HAS_CUDA CUTARGET_OUTS := $(foreach s, $(CUSWITCHES), \ - $(RESULTS_DIR)/NVCC_$(HOSTNAME)_$(strip $(s))_out.csv) + $(RESULTS_DIR)/NVCC_$(HOSTNAME)_$(strip $(s))-out) +CUTARGET_RESULTS:= $(CUTARGET_OUTS:%=%-comparison.csv) CUTARGETS := $(CUTARGET_OUTS:%_out.csv=%) endif # ifdef HAS_CUDA @@ -512,7 +518,10 @@ devcuda: $(DEV_CUTARGET) gt: groundtruth groundtruth: $(GT_TARGET) -run: $(TARGET_OUTS) $(CUTARGET_OUTS) runbuild $(GT_OUT) +run: $(TARGET_RESULTS) $(TARGET_OUTS) +run: $(CUTARGET_RESULTS) $(CUTARGET_OUTS) +run: $(GT_OUT) +run: runbuild runbuild: $(TARGETS) $(CUTARGETS) groundtruth .PHONY: clean @@ -529,9 +538,11 @@ 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 $(CUTARGET_RESULTS) rm -f $(addsuffix *.dat,$(CUTARGET_OUTS)) rm -f $(CUTARGETS) rm -f $(GT_TARGET) @@ -603,9 +614,8 @@ endif # ifdef HAS_CUDA # TODO: change the output from in-place to a new file for results # TODO: maybe precomapre results will be *.csv.partial or something... # 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) + ./$(GT_TARGET) --output $(GT_OUT) --no-timing $(GT_TARGET): $(GT_OBJ) Makefile custom.mk $(GT_CC) $(CC_REQUIRED) -o $@ $(GT_OBJ) $(LD_REQUIRED) From 38f38ba9bc16474bea230ce26d9ba7e056d85ecd Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 9 Feb 2018 23:16:45 -0700 Subject: [PATCH 019/166] Makefile.in: remove resolved TODO statements --- data/Makefile.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/data/Makefile.in b/data/Makefile.in index 6fb47b08..65642017 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -610,9 +610,6 @@ $(OBJ_DIR)/%_cu_dev.o: %.cpp Makefile custom.mk | $(OBJ_DIR) $(NVCC) -c $(NVCC_CFLAGS) $(DEV_NVCC_CC) $< -o $@ endif # ifdef HAS_CUDA -# TODO: use the new --compare-gt flag and split this up into multiple executions -# TODO: change the output from in-place to a new file for results -# TODO: maybe precomapre results will be *.csv.partial or something... # Ground truth compilation rules $(GT_OUT): $(GT_TARGET) ./$(GT_TARGET) --output $(GT_OUT) --no-timing From d68e4ae55b14fdd6361ac02f8f377a942b5744c0 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 10 Feb 2018 08:48:43 -0700 Subject: [PATCH 020/166] bisect: generate output and comparison results --- data/Makefile_bisect_binary.in | 40 ++++++++++++++++++++++++++-------- scripts/flitcli/flit_bisect.py | 1 + 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 47ae345e..f4134047 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -94,6 +94,7 @@ # include it here. -include Makefile +TEST_CASE := {test_case} TROUBLE_CC := {trouble_cc} TROUBLE_OPTL := {trouble_optl} @@ -103,24 +104,32 @@ BISECT_LINK := $(GT_CC) TROUBLE_ID := {trouble_id} MAKEFILE := {Makefile} -BISECT_TARGET := run-$(notdir $(MAKEFILE:%.mk=%)) -TROUBLE_TARGET := runbisect-trouble-$(TROUBLE_ID) +BISECT_DIR := bisect-01 +BISECT_TARGET := $(BISECT_DIR)/run-$(notdir $(MAKEFILE:%.mk=%)) +TROUBLE_TARGET := $(BISECT_DIR)/runbisect-trouble-$(TROUBLE_ID) -TROUBLE_SRC := BISECT_GT_SRC := -{TROUBLE_SRC} {BISECT_GT_SRC} +TROUBLE_SRC := +{TROUBLE_SRC} + TROUBLE_TARGET_OBJ := $(addprefix \ $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_bisect_$(TROUBLE_ID).o))) -TROUBLE_OBJ := $(addprefix \ - $(OBJ_DIR)/,$(notdir $(TROUBLE_SRC:%.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) +TROUBLE_TARGET_OUT := $(TROUBBLE_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 @@ -131,10 +140,15 @@ endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac -include $(TROUBLE_TARGET_DEPS) -$(BISECT_TARGET): $(BISECT_OBJ) Makefile custom.mk +$(BISECT_OUT): $(BISECT_TARGET) | $(BISECT_DIR) + ./$< --output $@ $(TEST_CASE) +$(TROUBLE_TARGET_OUT): $(TROUBLE_TARGET) | $(BISECT_DIR) + ./$< --output $@ $(TEST_CASE) + +$(BISECT_TARGET): $(BISECT_OBJ) Makefile custom.mk | $(BISECT_DIR) $(GT_CC) $(CC_REQUIRED) -o $@ $(BISECT_OBJ) $(LD_REQUIRED) -$(TROUBLE_TARGET): $(TROUBLE_TARGET_OBJ) Makefile custom.mk +$(TROUBLE_TARGET): $(TROUBLE_TARGET_OBJ) Makefile custom.mk | $(BISECT_DIR) $(TROUBLE_CC) $(CC_REQUIRED) -o $@ $(TROUBLE_TARGET_OBJ) $(LD_REQUIRED) # TODO: create TROUBLE_OUT @@ -144,10 +158,18 @@ $(TROUBLE_TARGET): $(TROUBLE_TARGET_OBJ) Makefile custom.mk # TODO: reminder: run everything with --no-timing +.PHONY: trouble +trouble: $(TROUBLE_TARGET) $(GT_TARGET) +trouble: $(TROUBLE_RESULT) $(TROUBLE_OUT) + .PHONY: bisect -bisect: $(BISECT_TARGET) $(TROUBLE_TARGET) $(GT_TARGET) +bisect: $(BISECT_TARGET) $(GT_TARGET) +bisect: $(BISECT_RESULT) $(BISECT_OUT) #bisect: $(GT_OUT) $(BISECT_OUT) $(TROUBLE_OUT) +$(BISECT_DIR): + mkdir -p $(BISECT_DIR) + # ground-truth files are already specified in Makefile # specify how to build the troublesome ones diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index a5297837..ce35d61b 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -332,6 +332,7 @@ def main(arguments, prog=sys.argv[0]): replacements = { 'datetime': datetime.date.today().strftime("%B %d, %Y"), 'flit_version': conf.version, + 'test_case': args.testcase, 'trouble_cc': compiler, 'trouble_optl': optl, 'trouble_switches': switches, From e239ebd37a4d7b9cc7e1e3f09fbb76c271176a1d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 10 Feb 2018 09:54:27 -0700 Subject: [PATCH 021/166] bisect: create bisect folder for all artifacts --- data/Makefile_bisect_binary.in | 13 +++-- scripts/flitcli/flit_bisect.py | 101 +++++++++++++++++++++++++++------ 2 files changed, 90 insertions(+), 24 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index f4134047..b53752f3 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -103,10 +103,11 @@ BISECT_LINK := $(GT_CC) TROUBLE_ID := {trouble_id} -MAKEFILE := {Makefile} -BISECT_DIR := bisect-01 -BISECT_TARGET := $(BISECT_DIR)/run-$(notdir $(MAKEFILE:%.mk=%)) -TROUBLE_TARGET := $(BISECT_DIR)/runbisect-trouble-$(TROUBLE_ID) +MAKEFILE := {makefile} +NUMBER := {number} +BISECT_DIR := {bisect_dir} +BISECT_TARGET := $(BISECT_DIR)/runbisect-$(NUMBER) +TROUBLE_TARGET := $(BISECT_DIR)/runtrouble-$(TROUBLE_ID) BISECT_GT_SRC := {BISECT_GT_SRC} @@ -124,7 +125,7 @@ BISECT_OBJ := $(BISECT_GT_OBJ) BISECT_OBJ += $(TROUBLE_OBJ) TROUBLE_TARGET_DEPS := $(TROUBLE_TARGET_OBJ:%.o=%.d) -TROUBLE_TARGET_OUT := $(TROUBBLE_TARGET:%=%-out) +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) @@ -160,7 +161,7 @@ $(TROUBLE_TARGET): $(TROUBLE_TARGET_OBJ) Makefile custom.mk | $(BISECT_DIR) .PHONY: trouble trouble: $(TROUBLE_TARGET) $(GT_TARGET) -trouble: $(TROUBLE_RESULT) $(TROUBLE_OUT) +trouble: $(TROUBLE_TARGET_RESULT) $(TROUBLE_TARGET_OUT) .PHONY: bisect bisect: $(BISECT_TARGET) $(GT_TARGET) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index ce35d61b..a8a39623 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -104,12 +104,62 @@ brief_description = 'Bisect compilation to identify problematic source code' -def create_bisect_makefile(replacements, gt_src, trouble_src): +def create_bisect_dir(parent): ''' - Returns a tempfile.NamedTemporaryFile instance populated with the - replacements, gt_src, and trouble_src. It is then ready to be executed by - 'make bisect' from the correct directory. + 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): + ''' + 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 Makefil @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 @@ -117,23 +167,34 @@ def create_bisect_makefile(replacements, gt_src, trouble_src): @param trouble_src: (list) which source files would be compiled with the trouble compilation within the resulting binary. - @return (tempfile.NamedTemporaryFile) a temporary makefile that is - populated to be able to compile the gt_src and the trouble_src into a - single executable. + @return the bisect makefile name without directory prepended to it ''' 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]) - # TODO: remove delete=False after done testing - makefile = tempfile.NamedTemporaryFile(prefix='flit-bisect-', suffix='.mk', - delete=False) - repl_copy['Makefile'] = makefile.name - logging.info('Creating makefile: ' + makefile.name) + + # 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: ' + makepath) util.process_in_file( os.path.join(conf.data_dir, 'Makefile_bisect_binary.in'), - makefile.name, + makepath, repl_copy, overwrite=True) return makefile @@ -304,9 +365,13 @@ def main(arguments, prog=sys.argv[0]): 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_path = os.path.join(args.directory, bisect_dir) + # keep a bisect.log of what was done logging.basicConfig( - filename=os.path.join(args.directory, 'bisect.log'), + filename=os.path.join(bisect_path, 'bisect.log'), filemode='w', format='%(asctime)s bisect: %(message)s', #level=logging.INFO) @@ -330,6 +395,7 @@ def main(arguments, prog=sys.argv[0]): trouble_src = sources[1:] replacements = { + 'bisect_dir': bisect_dir, 'datetime': datetime.date.today().strftime("%B %d, %Y"), 'flit_version': conf.version, 'test_case': args.testcase, @@ -343,11 +409,10 @@ def main(arguments, prog=sys.argv[0]): # It is quite annoying as a user to simply issue a command and wait # with no feedback for a long time. - makefile = create_bisect_makefile(replacements, gt_src, trouble_src) - build_bisect(makefile.name, args.directory) + makefile = create_bisect_makefile(bisect_path, replacements, gt_src, trouble_src) + makepath = os.path.join(bisect_path, makefile) - # TODO: should we delete these Makefiles? I think so... - #logging.info('Deleted makefile: ' + makefile.name) + build_bisect(makepath, args.directory) # TODO: determine if the problem is on the linker's side # I'm not yet sure the best way to do that From 778926d86ce1ca137995065f097b790b5cbac13a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 10 Feb 2018 10:13:42 -0700 Subject: [PATCH 022/166] bisect: add required --precision argument --- data/Makefile_bisect_binary.in | 5 +++-- scripts/flitcli/flit_bisect.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index b53752f3..d35ebf82 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -94,6 +94,7 @@ # include it here. -include Makefile +PRECISION := {precision} TEST_CASE := {test_case} TROUBLE_CC := {trouble_cc} @@ -142,9 +143,9 @@ endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac -include $(TROUBLE_TARGET_DEPS) $(BISECT_OUT): $(BISECT_TARGET) | $(BISECT_DIR) - ./$< --output $@ $(TEST_CASE) + ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) $(TROUBLE_TARGET_OUT): $(TROUBLE_TARGET) | $(BISECT_DIR) - ./$< --output $@ $(TEST_CASE) + ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) $(BISECT_TARGET): $(BISECT_OBJ) Makefile custom.mk | $(BISECT_DIR) $(GT_CC) $(CC_REQUIRED) -o $@ $(BISECT_OBJ) $(LD_REQUIRED) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index a8a39623..15430fae 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -336,6 +336,16 @@ def main(arguments, prog=sys.argv[0]): # ''') 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'. + ''') + args = parser.parse_args(arguments) tomlfile = os.path.join(args.directory, 'flit-config.toml') @@ -398,6 +408,7 @@ def main(arguments, prog=sys.argv[0]): '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': compiler, 'trouble_optl': optl, From 714e81211012475fb7ad0c9c30aabf1599c414d9 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 10 Feb 2018 10:22:31 -0700 Subject: [PATCH 023/166] bisect: perform runs with --no-timing --- data/Makefile_bisect_binary.in | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index d35ebf82..22fe3a8c 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -143,9 +143,9 @@ endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac -include $(TROUBLE_TARGET_DEPS) $(BISECT_OUT): $(BISECT_TARGET) | $(BISECT_DIR) - ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) + ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing $(TROUBLE_TARGET_OUT): $(TROUBLE_TARGET) | $(BISECT_DIR) - ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) + ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing $(BISECT_TARGET): $(BISECT_OBJ) Makefile custom.mk | $(BISECT_DIR) $(GT_CC) $(CC_REQUIRED) -o $@ $(BISECT_OBJ) $(LD_REQUIRED) @@ -153,13 +153,6 @@ $(BISECT_TARGET): $(BISECT_OBJ) Makefile custom.mk | $(BISECT_DIR) $(TROUBLE_TARGET): $(TROUBLE_TARGET_OBJ) Makefile custom.mk | $(BISECT_DIR) $(TROUBLE_CC) $(CC_REQUIRED) -o $@ $(TROUBLE_TARGET_OBJ) $(LD_REQUIRED) -# TODO: create TROUBLE_OUT -# TODO: create BISECT_OUT -# TODO: create job for comparing BISECT_OUT with GT_OUT via gtrun -# TODO: create job for compiling the BISECT_OUT or the comparison target - -# TODO: reminder: run everything with --no-timing - .PHONY: trouble trouble: $(TROUBLE_TARGET) $(GT_TARGET) trouble: $(TROUBLE_TARGET_RESULT) $(TROUBLE_TARGET_OUT) @@ -167,7 +160,6 @@ trouble: $(TROUBLE_TARGET_RESULT) $(TROUBLE_TARGET_OUT) .PHONY: bisect bisect: $(BISECT_TARGET) $(GT_TARGET) bisect: $(BISECT_RESULT) $(BISECT_OUT) -#bisect: $(GT_OUT) $(BISECT_OUT) $(TROUBLE_OUT) $(BISECT_DIR): mkdir -p $(BISECT_DIR) From 99f07559b91c9ffa98cbb9ced72b917f02a811b7 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 10 Feb 2018 12:45:47 -0700 Subject: [PATCH 024/166] bisect: first pass implementation - it works! Still needs to be cleaned up with regard to the logging and feedback. This implementation simply lets the makefile output go to the console, which maybe isn't a bad thing. But the logging needs to be improved, and we need to generate a final report. --- scripts/flitcli/flit_bisect.py | 51 ++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 15430fae..2a1fc093 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -214,7 +214,22 @@ def build_bisect(makefilename, directory, jobs=None): jobs = multiprocessing.cpu_count() subp.check_call( ['make', '-C', directory, '-f', makefilename, '-j', str(jobs), 'bisect'], - stdout=subp.DEVNULL, stderr=subp.DEVNULL) + )#stdout=subp.DEVNULL)#, stderr=subp.DEVNULL) + +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_d']) != 0.0 def bisect_search(is_bad, elements): ''' @@ -401,9 +416,6 @@ def main(arguments, prog=sys.argv[0]): for source in sources: logging.debug(' ' + source) - gt_src = sources[0:1] - trouble_src = sources[1:] - replacements = { 'bisect_dir': bisect_dir, 'datetime': datetime.date.today().strftime("%B %d, %Y"), @@ -420,10 +432,33 @@ def main(arguments, prog=sys.argv[0]): # It is quite annoying as a user to simply issue a command and wait # with no feedback for a long time. - makefile = create_bisect_makefile(bisect_path, replacements, gt_src, trouble_src) - makepath = os.path.join(bisect_path, makefile) - - build_bisect(makepath, args.directory) + 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. + ''' + # TODO: log the trouble list + # TODO: log the result + # TODO: print feedback to the console + makefile = create_bisect_makefile(bisect_path, replacements, gt_src, + trouble_src) + makepath = os.path.join(bisect_path, makefile) + + build_bisect(makepath, args.directory) + 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) + return result_is_bad + + bad_sources = bisect_search(bisect_build_and_check, sources) + print("bad sources: ", bad_sources) # TODO: determine if the problem is on the linker's side # I'm not yet sure the best way to do that From bad2e56fcdace95edeeb654633ef79cafbca40e3 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 13 Feb 2018 12:33:16 -0700 Subject: [PATCH 025/166] litmus-ReciprocalMath: simplify --- litmus-tests/tests/ReciprocalMath.cpp | 36 +++++++++------------------ 1 file changed, 12 insertions(+), 24 deletions(-) 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) From 368b29eef3142f1254a15befb960060f9dec76f7 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 17 Feb 2018 16:40:45 -0700 Subject: [PATCH 026/166] bisect-plan: outline algorithm and future plans --- plans/bisect-plan.md | 167 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/plans/bisect-plan.md b/plans/bisect-plan.md index 4294af45..fb1dcfcd 100644 --- a/plans/bisect-plan.md +++ b/plans/bisect-plan.md @@ -45,3 +45,170 @@ 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 (1) both shared, (2) gt shared only, (3) trouble shared only, and (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 --local-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). + + From b5af41887b7f757cb811f3da8b0e8e9bea31ba40 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Feb 2018 12:10:02 -0700 Subject: [PATCH 027/166] bisect: Add support for finding symbols, unused Also add support for verbose output, but also unused. Still need to implement using the finding of symbols by - finding all symbols from the compiled bad source files - redoing the search over these symbols --- data/Makefile_bisect_binary.in | 65 ++++++++++++++++++++++++++++++++-- plans/bisect-plan.md | 2 +- scripts/flitcli/flit_bisect.py | 50 +++++++++++++++++++++----- 3 files changed, 106 insertions(+), 11 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 22fe3a8c..4616c9f0 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -107,6 +107,7 @@ 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) @@ -116,6 +117,9 @@ BISECT_GT_SRC := TROUBLE_SRC := {TROUBLE_SRC} +SPLIT_SRC := +{SPLIT_SRC} + TROUBLE_TARGET_OBJ := $(addprefix \ $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_bisect_$(TROUBLE_ID).o))) BISECT_GT_OBJ := $(addprefix \ @@ -125,6 +129,14 @@ TROUBLE_OBJ := $(addprefix \ BISECT_OBJ := $(BISECT_GT_OBJ) BISECT_OBJ += $(TROUBLE_OBJ) TROUBLE_TARGET_DEPS := $(TROUBLE_TARGET_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=%_bisect_$(TROUBLE_ID)_split_$(NUMBER).o))) +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) @@ -147,8 +159,8 @@ $(BISECT_OUT): $(BISECT_TARGET) | $(BISECT_DIR) $(TROUBLE_TARGET_OUT): $(TROUBLE_TARGET) | $(BISECT_DIR) ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing -$(BISECT_TARGET): $(BISECT_OBJ) Makefile custom.mk | $(BISECT_DIR) - $(GT_CC) $(CC_REQUIRED) -o $@ $(BISECT_OBJ) $(LD_REQUIRED) +$(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) @@ -164,7 +176,19 @@ bisect: $(BISECT_RESULT) $(BISECT_OUT) $(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 +$(OBJ_DIR)/%_gt_fPIC.o: %.cpp Makefile custom.mk | $(OBJ_DIR) + $(GT_CC) -fPIC $(GT_OPTL) $(GT_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -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) @@ -175,3 +199,40 @@ $(OBJ_DIR)/%_bisect_$(TROUBLE_ID).o: %.cpp Makefile custom.mk | $(OBJ_DIR) -DFLIT_SWITCHES='"$(TROUBLE_SWITCHES)"' \ -DFLIT_FILENAME='"bisect-default-out"' +# and the fPIC variant +$(OBJ_DIR)/%_bisect_$(TROUBLE_ID)_fPIC.o: %.cpp Makefile custom.mk | $(OBJ_DIR) + $(TROUBLE_CC) -fPIC $(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"' + +# 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: $$(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) + objcopy \ + --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_trouble_symbols_$$(NUMBER).txt \ + $$(OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o + +$$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: $$(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_trouble_symbols_$$(NUMBER).txt +$$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: | $$(BISECT_OBJ_DIR) + objcopy \ + --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_gt_symbols_$$(NUMBER).txt \ + $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o + +endef + +$(foreach s, $(notdir $(SPLIT_SRC:%.cpp=%)), \ + $(eval $(call SPLIT_RULE,$s))) diff --git a/plans/bisect-plan.md b/plans/bisect-plan.md index fb1dcfcd..e41891eb 100644 --- a/plans/bisect-plan.md +++ b/plans/bisect-plan.md @@ -177,7 +177,7 @@ I have actually found a way that works, but may have additional drawbacks. Let 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 --local-symbols=trouble-symbols.txt .o -copy.o` + `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: diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 2a1fc093..0aa8ce39 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -152,7 +152,8 @@ def create_bisect_dir(parent): else: return bisect_dir -def create_bisect_makefile(directory, replacements, gt_src, trouble_src): +def create_bisect_makefile(directory, replacements, gt_src, trouble_src, + split_symbol_map): ''' 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 @@ -163,9 +164,13 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src): @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. + 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 -> tuple (list good symbols, list bad symbols)) + Files to compile as a split between good and bad, specifying good and + bad symbols for each file. @return the bisect makefile name without directory prepended to it ''' @@ -174,6 +179,8 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src): 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]) # Find the next unique file name available in directory num = 0 @@ -197,9 +204,32 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src): 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, jobs=None): +def build_bisect(makefilename, directory, verbose=False, jobs=None): ''' Creates the bisect executable by executing a parallel make. @@ -212,9 +242,13 @@ def build_bisect(makefilename, directory, jobs=None): logging.info('Building the bisect executable') if jobs is None: jobs = multiprocessing.cpu_count() + kwargs = dict() + if verbose: + kwargs['stdout'] = subp.DEVNULL + kwargs['stderr'] = subp.DEVNULL subp.check_call( ['make', '-C', directory, '-f', makefilename, '-j', str(jobs), 'bisect'], - )#stdout=subp.DEVNULL)#, stderr=subp.DEVNULL) + **kwargs) def is_result_bad(resultfile): ''' @@ -432,7 +466,7 @@ def main(arguments, prog=sys.argv[0]): # It is quite annoying as a user to simply issue a command and wait # with no feedback for a long time. - def bisect_build_and_check(trouble_src, gt_src): + def bisect_build_and_check(trouble_src, gt_src, verbose=False): ''' Compiles the compilation with trouble_src compiled with the trouble compilation and with gt_src compiled with the ground truth compilation. @@ -447,10 +481,10 @@ def bisect_build_and_check(trouble_src, gt_src): # TODO: log the result # TODO: print feedback to the console makefile = create_bisect_makefile(bisect_path, replacements, gt_src, - trouble_src) + trouble_src, dict()) makepath = os.path.join(bisect_path, makefile) - build_bisect(makepath, args.directory) + build_bisect(makepath, args.directory, verbose) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) @@ -468,7 +502,7 @@ def bisect_build_and_check(trouble_src, gt_src): # problematic # - create extra Makefile # - run extra Makefile to determine if the problem is still there - # - + # - # TODO: Use the custom comparison function in the test class when # performing the binary search. From 58bdd653d016a8ebb4774aa2d95f96bd1c705c47 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Feb 2018 12:15:52 -0700 Subject: [PATCH 028/166] bisect: Implement --verbose --- scripts/flitcli/flit_bisect.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 0aa8ce39..ccbd322e 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -243,7 +243,7 @@ def build_bisect(makefilename, directory, verbose=False, jobs=None): if jobs is None: jobs = multiprocessing.cpu_count() kwargs = dict() - if verbose: + if not verbose: kwargs['stdout'] = subp.DEVNULL kwargs['stderr'] = subp.DEVNULL subp.check_call( @@ -394,6 +394,12 @@ def main(arguments, prog=sys.argv[0]): precision runs. The choices are 'float', 'double', and 'long double'. ''') + 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. + ''') args = parser.parse_args(arguments) @@ -466,7 +472,7 @@ def main(arguments, prog=sys.argv[0]): # It is quite annoying as a user to simply issue a command and wait # with no feedback for a long time. - def bisect_build_and_check(trouble_src, gt_src, verbose=False): + 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. @@ -484,7 +490,7 @@ def bisect_build_and_check(trouble_src, gt_src, verbose=False): trouble_src, dict()) makepath = os.path.join(bisect_path, makefile) - build_bisect(makepath, args.directory, verbose) + build_bisect(makepath, args.directory, verbose=args.verbose) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) From 2dc4e85f393f59c2365ecf3a1177f52822932034 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Feb 2018 12:17:40 -0700 Subject: [PATCH 029/166] bisect-plan: small updates --- plans/bisect-plan.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plans/bisect-plan.md b/plans/bisect-plan.md index e41891eb..9db1caba 100644 --- a/plans/bisect-plan.md +++ b/plans/bisect-plan.md @@ -166,10 +166,16 @@ This approach has a few downsides: 3. May not even be possible without writing my own tool. -TODO: make tests that check this functionality with (1) both shared, (2) gt shared only, (3) trouble shared only, and (4) inlining. +TODO: make tests that check this functionality with +(1) both shared, +(2) gt shared only, +(3) trouble shared only, and +(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`. +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: @@ -197,7 +203,7 @@ ensure that certain functions won't get overridden with something like 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 + > 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. From baac295a18be34a8bd6bea197098d26fad581aee Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Feb 2018 12:46:41 -0700 Subject: [PATCH 030/166] bisect: add some feedback to the user and log --- scripts/flitcli/flit_bisect.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index ccbd322e..b13cf64e 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -490,11 +490,23 @@ def bisect_build_and_check(trouble_src, gt_src): trouble_src, dict()) makepath = os.path.join(bisect_path, makefile) + sys.stdout.write('Created {0} - compiling and running'.format(makepath)) + sys.stdout.flush() + logging.info('Created {0}'.format(makepath)) + logging.info('Checking:') + for src in trouble_src: + logging.info(' ' + src) + build_bisect(makepath, args.directory, verbose=args.verbose) 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 {0}'.format(result_str)) + return result_is_bad bad_sources = bisect_search(bisect_build_and_check, sources) From bbc9063719095488177ae0f47c7cceea7c0471e0 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Feb 2018 13:10:56 -0700 Subject: [PATCH 031/166] bisect: update ground-truth.csv before running bisect --- scripts/flitcli/flit_bisect.py | 53 +++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index b13cf64e..7fe15b1e 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -235,6 +235,7 @@ def build_bisect(makefilename, directory, verbose=False, jobs=None): @param makefilename: the filepath to the makefile @param directory: where to execute make + @param verbose: False means block output from GNU make and running @param jobs: number of parallel jobs. Defaults to #cpus @return None @@ -250,6 +251,28 @@ def build_bisect(makefilename, directory, verbose=False, jobs=None): ['make', '-C', directory, '-f', makefilename, '-j', str(jobs), 'bisect'], **kwargs) +def update_gt_results(directory, verbose=False): + ''' + 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 + ''' + sys.stdout.flush() + 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 - {0}'.format(gt_resultfile)) + print('Updating ground-truth results -', gt_resultfile, end='') + subp.check_call( + ['make', '-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', @@ -483,9 +506,6 @@ def bisect_build_and_check(trouble_src, gt_src): @return True if the compilation has a non-zero comparison between this mixed compilation and the full ground truth compilation. ''' - # TODO: log the trouble list - # TODO: log the result - # TODO: print feedback to the console makefile = create_bisect_makefile(bisect_path, replacements, gt_src, trouble_src, dict()) makepath = os.path.join(bisect_path, makefile) @@ -509,24 +529,23 @@ def bisect_build_and_check(trouble_src, gt_src): return result_is_bad + update_gt_results(args.directory, verbose=args.verbose) + + 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) - print("bad sources: ", bad_sources) + print(' bad sources: ', bad_sources) + + for bad_src in bad_sources: + pass + #bad_obj = + #symbols = + #print('Searching for bad symbols in the bad sources:') + #logging.info('Searching for bad symbols in the bad sources') # TODO: determine if the problem is on the linker's side # I'm not yet sure the best way to do that - # This is to be done later - first get for compilation problems - - # TODO: Perform (in parallel?) binary search from ground-truth and from - # problematic - # - create extra Makefile - # - run extra Makefile to determine if the problem is still there - # - - - # TODO: Use the custom comparison function in the test class when - # performing the binary search. - - # TODO: autogenerate Makefiles in the /tmp directly, preferrably with the - # tempfile module. + # This is to be done later - first go for compilation problems if __name__ == '__main__': From d9820e51e22b1a85b65c5e81dd0d1a3f9a332536 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Feb 2018 14:45:50 -0700 Subject: [PATCH 032/166] bisect: implement symbol search --- data/Makefile_bisect_binary.in | 32 ++++++--- scripts/flitcli/flit_bisect.py | 116 +++++++++++++++++++++++++++++---- 2 files changed, 124 insertions(+), 24 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 4616c9f0..7f4d60a5 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -133,7 +133,7 @@ SPLIT_OBJ := $(addprefix \ $(BISECT_OBJ_DIR)/,$(notdir $(SPLIT_SRC:%.cpp=%_gt_split_$(NUMBER).o))) SPLIT_OBJ += $(addprefix \ $(BISECT_OBJ_DIR)/,$(notdir \ - $(SPLIT_SRC:%.cpp=%_bisect_$(TROUBLE_ID)_split_$(NUMBER).o))) + $(SPLIT_SRC:%.cpp=%_trouble_split_$(NUMBER).o))) TROUBLE_SYMBOLS := $(addprefix \ $(BISECT_OBJ_DIR)/,$(notdir \ $(SPLIT_SRC:%.cpp=%_trouble_symbols_$(NUMBER).txt))) @@ -218,19 +218,31 @@ $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o: $$(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) - objcopy \ - --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_trouble_symbols_$$(NUMBER).txt \ - $$(OBJ_DIR)/$1_gt_fPIC.o \ - $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o + if [ -s "$$(BISECT_OBJ_DIR)/$1_trouble_symbols_$$(NUMBER).txt" ]; then \ + objcopy \ + --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_trouble_symbols_$$(NUMBER).txt \ + $$(OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ + else \ + cp \ + $$(OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ + fi $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: $$(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_trouble_symbols_$$(NUMBER).txt +$$(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) - objcopy \ - --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_gt_symbols_$$(NUMBER).txt \ - $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ - $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o + if [ -s "$$(BISECT_OBJ_DIR)/$1_gt_symbols_$$(NUMBER).txt" ]; then \ + objcopy \ + --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_gt_symbols_$$(NUMBER).txt \ + $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ + else \ + cp \ + $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ + fi endef diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 7fe15b1e..3b06b360 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -168,7 +168,7 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src, @param trouble_src: (list) which source files would be compiled with the trouble compilation within the resulting binary. @param split_symbol_map: - (dict fname -> tuple (list good symbols, list bad symbols)) + (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. @@ -399,12 +399,12 @@ def main(arguments, prog=sys.argv[0]): # TODO: get the default 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'. + # 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') @@ -510,7 +510,8 @@ def bisect_build_and_check(trouble_src, gt_src): trouble_src, dict()) makepath = os.path.join(bisect_path, makefile) - sys.stdout.write('Created {0} - compiling and running'.format(makepath)) + sys.stdout.write(' Created {0} - compiling and running' \ + .format(makepath)) sys.stdout.flush() logging.info('Created {0}'.format(makepath)) logging.info('Checking:') @@ -532,16 +533,103 @@ def bisect_build_and_check(trouble_src, gt_src): update_gt_results(args.directory, verbose=args.verbose) print('Searching for bad source files:') - logging.info('Searching for bad source files under the trouble compilation') + logging.info('Searching for bad source files under the trouble' + ' compilation') bad_sources = bisect_search(bisect_build_and_check, sources) print(' bad sources: ', bad_sources) + symbol_tuples = [] for bad_src in bad_sources: - pass - #bad_obj = - #symbols = - #print('Searching for bad symbols in the bad sources:') - #logging.info('Searching for bad symbols in the bad sources') + bad_base = os.path.splitext(os.path.basename(bad_src))[0] + good_obj = os.path.join(args.directory, 'obj', bad_base + '_gt.o') + symbol_strings = subp.check_output([ + 'nm', + '--extern-only', + '--defined-only', + good_obj, + ]).splitlines() + demangled_symbol_strings = subp.check_output([ + 'nm', + '--extern-only', + '--defined-only', + '--demangle', + good_obj, + ]).splitlines() + for i in range(len(symbol_strings)): + symbol = symbol_strings[i].split(maxsplit=2)[2].decode('utf-8') + demangled = demangled_symbol_strings[i].split(maxsplit=2)[2] \ + .decode('utf-8') + symtype = symbol_strings[i].split()[1] + # We need to do all defined global symbols or we will get duplicate + # symbol linker error + #if symtype == b'T': + symbol_tuples.append((bad_src, symbol, demangled)) + + print('Searching for bad symbols in the bad sources:') + logging.info('Searching for bad symbols in the bad sources') + logging.info('Note: inlining disabled to isolate functions') + logging.info('Note: only searching over globally exported functions') + logging.debug('Symbols:') + for src, symbol, demangled in symbol_tuples: + logging.debug(' {0}: {1} -- {2}'.format(src, symbol, demangled)) + + 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: (tuple (src, symbol, demangled)) symbols to use + from the trouble compilation + @param gt_symbols: (tuple (src, symbol, demangled)) 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[0] for x in trouble_symbols + gt_symbols] + trouble_src = [] + gt_src = list(set(all_sources).difference(symbol_sources)) + symbol_map = { x: [ + [y[1] for y in gt_symbols if y[0] == x], + [z[1] for z in trouble_symbols if z[0] == 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) + + sys.stdout.write(' Created {0} - compiling and running' \ + .format(makepath)) + sys.stdout.flush() + logging.info('Created {0}'.format(makepath)) + logging.info('Checking:') + for src, symbol, demangled in trouble_symbols: + logging.info(' {0}: {1} -- {2}'.format(src, symbol, demangled)) + + build_bisect(makepath, args.directory, verbose=args.verbose) + 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 {0}'.format(result_str)) + + return result_is_bad + + bad_symbols = bisect_search(bisect_symbol_build_and_check, symbol_tuples) + print(' bad symbols:') + logging.info('BAD SYMBOLS:') + for src, symbol, demangled in bad_symbols: + print(' {0}: {1} -- {2}'.format(src, symbol, demangled)) + logging.info(' {0}: {1} -- {2}'.format(src, symbol, demangled)) + # TODO: determine if the problem is on the linker's side # I'm not yet sure the best way to do that From 334ab3d40e7011e15e40f8a7d54718e3bfc73f33 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 1 Mar 2018 15:02:58 -0700 Subject: [PATCH 033/166] bisect: split out parsing arguments into separate function --- scripts/flitcli/flit_bisect.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 3b06b360..dd0ce297 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -360,7 +360,13 @@ def bisect_search(is_bad, elements): return bad_list -def main(arguments, prog=sys.argv[0]): +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=''' @@ -425,6 +431,10 @@ def main(arguments, prog=sys.argv[0]): ''') args = parser.parse_args(arguments) + return args + +def main(arguments, prog=sys.argv[0]): + args = parse_args(arguments, prog) tomlfile = os.path.join(args.directory, 'flit-config.toml') try: From 445ba8a1f3b4c02f0e5e108b94179f15423b8a3b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 1 Mar 2018 15:04:09 -0700 Subject: [PATCH 034/166] bisect: remove tomlfile loading - not used --- scripts/flitcli/flit_bisect.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index dd0ce297..1863fd2c 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -436,14 +436,6 @@ def parse_args(arguments, prog=sys.argv[0]): def main(arguments, prog=sys.argv[0]): args = parse_args(arguments, prog) - tomlfile = os.path.join(args.directory, 'flit-config.toml') - try: - projconf = toml.load(tomlfile) - except FileNotFoundError: - print('Error: {0} not found. Run "flit init"'.format(tomlfile), - file=sys.stderr) - return 1 - # Split the compilation into the separate components split_compilation = args.compilation.strip().split(maxsplit=2) compiler = split_compilation[0] From d6e1ae6656db4a4de203a6f7e8f1c7b1f673b2a3 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 2 Mar 2018 16:55:03 -0700 Subject: [PATCH 035/166] bisect: Add line numbers to bisect found functions --- data/Makefile.in | 4 +- data/Makefile_bisect_binary.in | 44 ++++---- scripts/flitcli/flit_bisect.py | 201 +++++++++++++++++++++++---------- 3 files changed, 163 insertions(+), 86 deletions(-) diff --git a/data/Makefile.in b/data/Makefile.in index 65642017..1d8d2d45 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -430,7 +430,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)) \ @@ -618,7 +618,7 @@ $(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 index 7f4d60a5..36c245b5 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -121,22 +121,22 @@ SPLIT_SRC := {SPLIT_SRC} TROUBLE_TARGET_OBJ := $(addprefix \ - $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_bisect_$(TROUBLE_ID).o))) + $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_bisect_$(TROUBLE_ID).o))) BISECT_GT_OBJ := $(addprefix \ - $(OBJ_DIR)/,$(notdir $(BISECT_GT_SRC:%.cpp=%_gt.o))) + $(OBJ_DIR)/,$(notdir $(BISECT_GT_SRC:%.cpp=%_gt.o))) TROUBLE_OBJ := $(addprefix \ - $(OBJ_DIR)/,$(notdir $(TROUBLE_SRC:%.cpp=%_bisect_$(TROUBLE_ID).o))) + $(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) SPLIT_OBJ := $(addprefix \ - $(BISECT_OBJ_DIR)/,$(notdir $(SPLIT_SRC:%.cpp=%_gt_split_$(NUMBER).o))) + $(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))) + $(BISECT_OBJ_DIR)/,$(notdir \ + $(SPLIT_SRC:%.cpp=%_trouble_split_$(NUMBER).o))) TROUBLE_SYMBOLS := $(addprefix \ - $(BISECT_OBJ_DIR)/,$(notdir \ - $(SPLIT_SRC:%.cpp=%_trouble_symbols_$(NUMBER).txt))) + $(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) @@ -219,14 +219,14 @@ $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o: $$(BISECT_OBJ_DIR)/$1_trouble_symbo $$(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 \ - $$(OBJ_DIR)/$1_gt_fPIC.o \ - $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ + objcopy \ + --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_trouble_symbols_$$(NUMBER).txt \ + $$(OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ else \ - cp \ - $$(OBJ_DIR)/$1_gt_fPIC.o \ - $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ + cp \ + $$(OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ fi $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o @@ -234,14 +234,14 @@ $$(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 \ - $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ - $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ + objcopy \ + --weaken-symbols=$$(BISECT_OBJ_DIR)/$1_gt_symbols_$$(NUMBER).txt \ + $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ else \ - cp \ - $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ - $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ + cp \ + $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ fi endef diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 1863fd2c..16149c52 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -90,6 +90,7 @@ import toml +from collections import namedtuple import argparse import csv import datetime @@ -97,6 +98,7 @@ import logging import multiprocessing import os +import re import sqlite3 import subprocess as subp import sys @@ -268,6 +270,7 @@ def update_gt_results(directory, verbose=False): 'GT_OUT', os.path.join(directory, 'Makefile'))[0] logging.info('Updating ground-truth results - {0}'.format(gt_resultfile)) print('Updating ground-truth results -', gt_resultfile, end='') + sys.stdout.flush() subp.check_call( ['make', '-C', directory, gt_resultfile], **kwargs) print(' - done') @@ -288,6 +291,96 @@ def is_result_bad(resultfile): # identical to ground truth means comparison is zero return float(row['comparison_d']) != 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 i in range(len(symbol_strings)): + symtype, symbol = symbol_strings[i].split(maxsplit=2)[1:3] + demangled = demangled_symbol_strings[i].split(maxsplit=2)[2] + try: + deffile, defline = symbol_line_mapping[symbol] + except KeyError: + deffile, defline = None, None + # We need to do all defined global symbols or we will get duplicate + # symbol linker error + #if symtype == 'T': + 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 @@ -431,24 +524,25 @@ def parse_args(arguments, prog=sys.argv[0]): ''') args = parser.parse_args(arguments) - return args - -def main(arguments, prog=sys.argv[0]): - args = parse_args(arguments, prog) - # Split the compilation into the separate components + # Split the compilation into separate components split_compilation = args.compilation.strip().split(maxsplit=2) - compiler = split_compilation[0] - optl = '' - switches = '' + args.compiler = split_compilation[0] + args.optl = '' + args.switches = '' if len(split_compilation) > 1: - optl = split_compilation[1] + args.optl = split_compilation[1] if len(split_compilation) > 2: - switches = split_compilation[2] + args.switches = split_compilation[2] + + return args + +def main(arguments, prog=sys.argv[0]): + args = parse_args(arguments, prog) # our hash is the first 10 digits of a sha1 sum trouble_hash = hashlib.sha1( - (compiler + optl + switches).encode()).hexdigest()[:10] + (args.compiler + args.optl + args.switches).encode()).hexdigest()[:10] # see if the Makefile needs to be regenerated # we use the Makefile to check for itself, sweet @@ -468,9 +562,9 @@ def main(arguments, prog=sys.argv[0]): level=logging.DEBUG) logging.info('Starting the bisect procedure') - logging.debug(' trouble compiler: "{0}"'.format(compiler)) - logging.debug(' trouble optimization level: "{0}"'.format(optl)) - logging.debug(' trouble switches: "{0}"'.format(switches)) + logging.debug(' trouble compiler: "{0}"'.format(args.compiler)) + logging.debug(' trouble optimization level: "{0}"'.format(args.optl)) + logging.debug(' trouble switches: "{0}"'.format(args.switches)) logging.debug(' trouble testcase: "{0}"'.format(args.testcase)) logging.debug(' trouble hash: "{0}"'.format(trouble_hash)) @@ -487,9 +581,9 @@ def main(arguments, prog=sys.argv[0]): 'flit_version': conf.version, 'precision': args.precision, 'test_case': args.testcase, - 'trouble_cc': compiler, - 'trouble_optl': optl, - 'trouble_switches': switches, + 'trouble_cc': args.compiler, + 'trouble_optl': args.optl, + 'trouble_switches': args.switches, 'trouble_id': trouble_hash, }; @@ -538,42 +632,10 @@ def bisect_build_and_check(trouble_src, gt_src): logging.info('Searching for bad source files under the trouble' ' compilation') bad_sources = bisect_search(bisect_build_and_check, sources) - print(' bad sources: ', bad_sources) - - symbol_tuples = [] - for bad_src in bad_sources: - bad_base = os.path.splitext(os.path.basename(bad_src))[0] - good_obj = os.path.join(args.directory, 'obj', bad_base + '_gt.o') - symbol_strings = subp.check_output([ - 'nm', - '--extern-only', - '--defined-only', - good_obj, - ]).splitlines() - demangled_symbol_strings = subp.check_output([ - 'nm', - '--extern-only', - '--defined-only', - '--demangle', - good_obj, - ]).splitlines() - for i in range(len(symbol_strings)): - symbol = symbol_strings[i].split(maxsplit=2)[2].decode('utf-8') - demangled = demangled_symbol_strings[i].split(maxsplit=2)[2] \ - .decode('utf-8') - symtype = symbol_strings[i].split()[1] - # We need to do all defined global symbols or we will get duplicate - # symbol linker error - #if symtype == b'T': - symbol_tuples.append((bad_src, symbol, demangled)) + print(' bad sources:') + for src in bad_sources: + print(' ' + src) - print('Searching for bad symbols in the bad sources:') - logging.info('Searching for bad symbols in the bad sources') - logging.info('Note: inlining disabled to isolate functions') - logging.info('Note: only searching over globally exported functions') - logging.debug('Symbols:') - for src, symbol, demangled in symbol_tuples: - logging.debug(' {0}: {1} -- {2}'.format(src, symbol, demangled)) def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): ''' @@ -583,21 +645,21 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): 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: (tuple (src, symbol, demangled)) symbols to use + @param trouble_symbols: (list of SymbolTuple) symbols to use from the trouble compilation - @param gt_symbols: (tuple (src, symbol, demangled)) symbols to use from + @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[0] for x in trouble_symbols + gt_symbols] + 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[1] for y in gt_symbols if y[0] == x], - [z[1] for z in trouble_symbols if z[0] == 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 } @@ -610,8 +672,10 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): sys.stdout.flush() logging.info('Created {0}'.format(makepath)) logging.info('Checking:') - for src, symbol, demangled in trouble_symbols: - logging.info(' {0}: {1} -- {2}'.format(src, symbol, demangled)) + for sym in trouble_symbols: + logging.info( + ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' + .format(sym=sym)) build_bisect(makepath, args.directory, verbose=args.verbose) resultfile = util.extract_make_var('BISECT_RESULT', makepath, @@ -625,12 +689,25 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): return result_is_bad + print('Searching for bad symbols in the bad sources:') + logging.info('Searching for bad symbols in the bad sources') + 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_sources, 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(message) + bad_symbols = bisect_search(bisect_symbol_build_and_check, symbol_tuples) print(' bad symbols:') logging.info('BAD SYMBOLS:') - for src, symbol, demangled in bad_symbols: - print(' {0}: {1} -- {2}'.format(src, symbol, demangled)) - logging.info(' {0}: {1} -- {2}'.format(src, symbol, demangled)) + for sym in bad_symbols: + message = ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' \ + .format(sym=sym) + print(' ' + message) + logging.info(message) # TODO: determine if the problem is on the linker's side From 5bc134281a0d057cfb775d63becd9d04fb8fe827 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 20 Mar 2018 14:01:26 -0600 Subject: [PATCH 036/166] all: compile and link WITHOUT -pie This FORCES the compiler to NOT generate position-independent executables, which does two things: 1. It disables ALSR and makes it run faster 2. More importantly, it overrides whatever the default behavior of the compiler may be, resulting in the capability during bisect to create mixed executables from compiling with multiple compilers. --- data/Makefile.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/Makefile.in b/data/Makefile.in index 1d8d2d45..7327dfad 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -106,6 +106,8 @@ GT_SWITCHES := {ground_truth_switches} 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 +118,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 From cc18f07dab328474120fa7253365044adca99bf5 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 21 Mar 2018 08:19:38 -0600 Subject: [PATCH 037/166] Create empty output file if test run fails --- data/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/Makefile.in b/data/Makefile.in index 7327dfad..7a74f976 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -494,7 +494,7 @@ TARGET_OUTS := $(TARGETS:%=%-out) TARGET_RESULTS := $(TARGET_OUTS:%=%-comparison.csv) %-out: % - -./$< --output $@ + ./$< --output $@ || touch $@ # specify how to get comparison %-out-comparison.csv: %-out $(GT_OUT) $(GT_TARGET) From 93a852465acc4109e17978abf7ffe709c6c1141b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 21 Mar 2018 17:43:08 -0600 Subject: [PATCH 038/166] update: Fix bug with ground-truth compiler absolute path If the ground-truth compiler was given with a / in it, then it was using the name instead of the given path. This was a mistake and is now using the path. --- scripts/flitcli/flit_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_update.py b/scripts/flitcli/flit_update.py index ade7ddd4..9297d16f 100644 --- a/scripts/flitcli/flit_update.py +++ b/scripts/flitcli/flit_update.py @@ -149,7 +149,7 @@ 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) flitutil.process_in_file( os.path.join(conf.data_dir, 'Makefile.in'), From 8123abeb0c1629e2c7555fc5aa835d2eba5f0a53 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 21 Mar 2018 17:43:37 -0600 Subject: [PATCH 039/166] plans: add some more notes --- plans/clang-versions.md | 23 +++++++++++++++++++++++ plans/intel-linker.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 plans/clang-versions.md create mode 100644 plans/intel-linker.md 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..9cec13b2 --- /dev/null +++ b/plans/intel-linker.md @@ -0,0 +1,32 @@ +# 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`. + + +## 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. + + From 203061b74f943c56af4aea96891f4ac2c88bb9f7 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 21 Mar 2018 21:21:04 -0600 Subject: [PATCH 040/166] Add simple script to watch progress --- scripts/watch-progress.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scripts/watch-progress.sh 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' + + From 6e7b8172d32d0ed84f58df35dc8262a5df79750a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 22 Mar 2018 10:54:41 -0600 Subject: [PATCH 041/166] bisect: implement searching over intel libs This is hard-coded to search over a list of 7 static libs. Also, this does not work, since if we include some and not others, then there are symbols within the first static libs that are required and not satisfied, unless you also include the other static libs. It needs to be fixed to do all-or-nothing. Maybe I can come up with something later to isolate the problem better. --- data/Makefile_bisect_binary.in | 4 + scripts/flitcli/flit_bisect.py | 219 +++++++++++++++++++++++++-------- 2 files changed, 169 insertions(+), 54 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 36c245b5..4ca365b4 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -120,6 +120,10 @@ TROUBLE_SRC := SPLIT_SRC := {SPLIT_SRC} +# Add to the CC_REQUIRED and LD_REQUIRED if necessary +{EXTRA_CC_FLAGS} +{EXTRA_LD_FLAGS} + TROUBLE_TARGET_OBJ := $(addprefix \ $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_bisect_$(TROUBLE_ID).o))) BISECT_GT_OBJ := $(addprefix \ diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 16149c52..b2087574 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -99,6 +99,7 @@ import multiprocessing import os import re +import shutil import sqlite3 import subprocess as subp import sys @@ -155,7 +156,7 @@ def create_bisect_dir(parent): return bisect_dir def create_bisect_makefile(directory, replacements, gt_src, trouble_src, - split_symbol_map): + split_symbol_map, cpp_flags=[], link_flags=[]): ''' 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 @@ -173,6 +174,10 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src, (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. + @param cpp_flags: (list) (optional) List of c++ compiler flags to give to + each compiler when compiling object files from source files. + @param 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 ''' @@ -183,6 +188,11 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src, for x in gt_src]) repl_copy['SPLIT_SRC'] = '\n'.join(['SPLIT_SRC += {0}'.format(x) for x in split_symbol_map]) + repl_copy['EXTRA_CC_FLAGS'] = '\n'.join(['CC_REQUIRED += {0}'.format(x) + for x in cpp_flags]) + repl_copy['EXTRA_LD_FLAGS'] = '\n'.join(['LD_REQUIRED += {0}'.format(x) + for x in link_flags]) + # Find the next unique file name available in directory num = 0 @@ -537,60 +547,60 @@ def parse_args(arguments, prog=sys.argv[0]): return args -def main(arguments, prog=sys.argv[0]): - args = parse_args(arguments, prog) - - # our hash is the first 10 digits of a sha1 sum - trouble_hash = hashlib.sha1( - (args.compiler + args.optl + args.switches).encode()).hexdigest()[:10] - - # 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) +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. + ''' + def bisect_libs_build_and_check(trouble_libs, ignore_libs): + ''' + Compiles all source files under the ground truth compilation and + statically links in the trouble_libs. - # create a unique directory for this bisect run - bisect_dir = create_bisect_dir(args.directory) - bisect_path = os.path.join(args.directory, bisect_dir) + @param trouble_libs: static libraries to compile in + @param ignore_libs: static libraries to ignore and not include + + @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, sources, + [], dict(), link_flags=trouble_libs) + makepath = os.path.join(bisect_path, makefile) - # keep a bisect.log of what was done - logging.basicConfig( - filename=os.path.join(bisect_path, 'bisect.log'), - filemode='w', - format='%(asctime)s bisect: %(message)s', - #level=logging.INFO) - level=logging.DEBUG) + sys.stdout.write(' Create {0} - compiling and running' \ + .format(makepath)) + sys.stdout.flush() + logging.info('Created {0}'.format(makepath)) + logging.info('Checking:') + for lib in trouble_libs: + logging.info(' ' + lib) - logging.info('Starting the bisect procedure') - logging.debug(' trouble compiler: "{0}"'.format(args.compiler)) - logging.debug(' trouble optimization level: "{0}"'.format(args.optl)) - logging.debug(' trouble switches: "{0}"'.format(args.switches)) - logging.debug(' trouble testcase: "{0}"'.format(args.testcase)) - logging.debug(' trouble hash: "{0}"'.format(trouble_hash)) + build_bisect(makepath, args.directory, verbose=args.verbose) + 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) - # 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(' ' + source) + result_str = 'bad' if result_is_bad else 'good' + sys.stdout.write(' - {0}\n'.format(result_str)) + logging.info('Result was {0}'.format(result_str)) - 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, - }; + return result_is_bad - # TODO: what kind of feedback should we give the user while it is building? - # It is quite annoying as a user to simply issue a command and wait - # with no feedback for a long time. + 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 +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 @@ -626,17 +636,17 @@ def bisect_build_and_check(trouble_src, gt_src): return result_is_bad - update_gt_results(args.directory, verbose=args.verbose) - 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) - print(' bad sources:') - for src in bad_sources: - print(' ' + src) - + return bad_sources +def search_for_symbol_problems(args, bisect_path, replacements, sources, bad_sources): + ''' + Performs the search over the space of symbols within bad source files for + problems. + ''' def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): ''' Compiles the compilation with all files compiled under the ground truth @@ -701,6 +711,107 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): logging.info(message) bad_symbols = bisect_search(bisect_symbol_build_and_check, symbol_tuples) + return bad_symbols + +def main(arguments, prog=sys.argv[0]): + args = parse_args(arguments, prog) + + # our hash is the first 10 digits of a sha1 sum + trouble_hash = hashlib.sha1( + (args.compiler + args.optl + args.switches).encode()).hexdigest()[:10] + + # 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_path = os.path.join(args.directory, bisect_dir) + + # keep a bisect.log of what was done + 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: "{0}"'.format(args.compiler)) + logging.debug(' trouble optimization level: "{0}"'.format(args.optl)) + logging.debug(' trouble switches: "{0}"'.format(args.switches)) + logging.debug(' trouble testcase: "{0}"'.format(args.testcase)) + logging.debug(' trouble hash: "{0}"'.format(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(' ' + 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, + }; + + update_gt_results(args.directory, verbose=args.verbose) + + # Find out if the linker is to blame (e.g. intel linker linking mkl libs) + if os.path.basename(args.compiler) in ('icc', 'icpc'): + 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 + # This can be done by calling the linker command with -v to see + # what intel uses in its linker. The include path is in that + # 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'), + ] + bad_libs = search_for_linker_problems(args, bisect_path, replacements, + sources, libs) + print(' bad static libraries:') + for lib in bad_libs: + print(' ' + lib) + + # If the linker is to blame, remove it from the equation for future searching + # This is done simply by using the ground-truth compiler to link instead of + # using the trouble compiler to link. + # TODO: Handle the case where the ground-truth compiler is also an intel + # compiler. + # TODO: Extra care must be taken when there is more than one intel linker + # specified. + + bad_sources = search_for_source_problems(args, bisect_path, replacements, + sources) + print(' bad sources:') + for src in bad_sources: + print(' ' + src) + + + bad_symbols = search_for_symbol_problems(args, bisect_path, replacements, + sources, bad_sources) print(' bad symbols:') logging.info('BAD SYMBOLS:') for sym in bad_symbols: From 892b753917d291f9e329ffbe9bd12badd5ed641e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 22 Mar 2018 18:25:03 -0600 Subject: [PATCH 042/166] bisect: Add checks in bisect algorithm for violating the assumption The assumption is that all bad elements are independently bad. This means that the inclusion or exclusion of other elements has no impact on whether this element causes detectable variance in the program's result. It is clear this assumption could be violated, thus the checks --- plans/intel-linker.md | 13 ++++- scripts/flitcli/flit_bisect.py | 102 +++++++++++++++++++++++++++------ 2 files changed, 96 insertions(+), 19 deletions(-) diff --git a/plans/intel-linker.md b/plans/intel-linker.md index 9cec13b2..8ab45eeb 100644 --- a/plans/intel-linker.md +++ b/plans/intel-linker.md @@ -19,6 +19,11 @@ reproducibility problems. This static linking is performed by default, even if 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 @@ -29,4 +34,10 @@ 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/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index b2087574..97743b6b 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -156,7 +156,7 @@ def create_bisect_dir(parent): return bisect_dir def create_bisect_makefile(directory, replacements, gt_src, trouble_src, - split_symbol_map, cpp_flags=[], link_flags=[]): + split_symbol_map): ''' 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 @@ -174,10 +174,12 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src, (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. - @param cpp_flags: (list) (optional) List of c++ compiler flags to give to - each compiler when compiling object files from source files. - @param link_flags: (list) (optional) List of linker flags to give to the - ground-truth compiler when performing linking. + + 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 ''' @@ -188,10 +190,14 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src, for x in gt_src]) repl_copy['SPLIT_SRC'] = '\n'.join(['SPLIT_SRC += {0}'.format(x) for x in split_symbol_map]) - repl_copy['EXTRA_CC_FLAGS'] = '\n'.join(['CC_REQUIRED += {0}'.format(x) - for x in cpp_flags]) - repl_copy['EXTRA_LD_FLAGS'] = '\n'.join(['LD_REQUIRED += {0}'.format(x) - for x in link_flags]) + 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 @@ -401,6 +407,11 @@ def bisect_search(is_bad, elements): 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 @@ -422,7 +433,18 @@ def bisect_search(is_bad, elements): as a rough performance metric, we want to be sure our call count remains low for the is_bad() function. >>> call_count - 6 + 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) @@ -441,7 +463,8 @@ def bisect_search(is_bad, elements): if is_bad(Q1, no_test + Q2): Q = Q1 no_test.extend(Q2) - # TODO: if the length of Q2 is big enough, test + # TODO: possible optimization. + # if the length of Q2 is big enough, test # is_bad(Q2, no_test + Q1) # and if that returns False, then mark Q2 as known so # that we don't need to search it again. @@ -455,11 +478,20 @@ def bisect_search(is_bad, elements): no_test.extend(Q1) bad_element = quest_list.pop(0) - bad_list.append(bad_element) + + # double check that we found a bad element before declaring it bad + if 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) - # double check that we found a bad element - #assert is_bad([bad_element], known_list + quest_list) + # 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 @@ -556,6 +588,12 @@ def search_for_linker_problems(args, bisect_path, replacements, sources, libs): 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, ignore_libs): ''' @@ -568,8 +606,11 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): @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, sources, - [], dict(), link_flags=trouble_libs) + 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) sys.stdout.write(' Create {0} - compiling and running' \ @@ -594,8 +635,12 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): 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 + #bad_libs = bisect_search(bisect_libs_build_and_check, libs) + #return bad_libs + if bisect_libs_build_and_check(libs, []): + return libs + else: + return [] def search_for_source_problems(args, bisect_path, replacements, sources): ''' @@ -761,6 +806,8 @@ def main(arguments, prog=sys.argv[0]): 'trouble_optl': args.optl, 'trouble_switches': args.switches, 'trouble_id': trouble_hash, + 'link_flags': [], + 'cpp_flags': ['-nostdlib'], }; update_gt_results(args.directory, verbose=args.verbose) @@ -792,8 +839,19 @@ def main(arguments, prog=sys.argv[0]): bad_libs = search_for_linker_problems(args, bisect_path, replacements, sources, libs) print(' bad static libraries:') + logging.info('BAD STATIC LIBRARIES:') for lib in bad_libs: print(' ' + lib) + logging.info(' ' + lib) + if len(bad_libs) == 0: + print(' None') + logging.info(' None') + + replacements['link_flags'].extend([ + '-L' + intel_lib_dir, + '-lirc', + '-lsvml', + ]) # If the linker is to blame, remove it from the equation for future searching # This is done simply by using the ground-truth compiler to link instead of @@ -806,8 +864,13 @@ def main(arguments, prog=sys.argv[0]): bad_sources = search_for_source_problems(args, bisect_path, replacements, sources) print(' bad sources:') + logging.info('BAD SOURCES:') for src in bad_sources: print(' ' + src) + logging.info(' ' + src) + if len(bad_sources) == 0: + print(' None') + logging.info(' None') bad_symbols = search_for_symbol_problems(args, bisect_path, replacements, @@ -819,6 +882,9 @@ def main(arguments, prog=sys.argv[0]): .format(sym=sym) print(' ' + message) logging.info(message) + if len(bad_symbols) == 0: + print(' None') + logging.info(' None') # TODO: determine if the problem is on the linker's side From ac9a07535d65c66bea2b38540b57fa5a0605d205 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 22 Mar 2018 21:12:24 -0600 Subject: [PATCH 043/166] bisect: put in messages for when bisect fails Unfortunately, bisect fails when used with the intel compiler. This is not a simple problem. --- scripts/flitcli/flit_bisect.py | 72 +++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 97743b6b..92ae3551 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -426,7 +426,7 @@ def bisect_search(is_bad, elements): ... global call_count ... call_count += 1 ... return min(x) < 0 - >>> x = bisect_search(is_bad, [1, 3, 4, 5, 10, -1, 0, -15]) + >>> x = bisect_search(is_bad, [1, 3, 4, 5, -1, 10, 0, -15, 3]) >>> sorted(x) [-15, -1] @@ -479,6 +479,7 @@ def bisect_search(is_bad, elements): bad_element = quest_list.pop(0) + # TODO: only double check if the last check was False # double check that we found a bad element before declaring it bad if is_bad([bad_element], known_list + quest_list): bad_list.append(bad_element) @@ -489,9 +490,10 @@ def bisect_search(is_bad, elements): # 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' + if len(bad_list) > 0: + 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 @@ -758,6 +760,7 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): bad_symbols = bisect_search(bisect_symbol_build_and_check, symbol_tuples) return bad_symbols + def main(arguments, prog=sys.argv[0]): args = parse_args(arguments, prog) @@ -807,17 +810,22 @@ def main(arguments, prog=sys.argv[0]): 'trouble_switches': args.switches, 'trouble_id': trouble_hash, 'link_flags': [], - 'cpp_flags': ['-nostdlib'], + 'cpp_flags': [], }; update_gt_results(args.directory, verbose=args.verbose) # Find out if the linker is to blame (e.g. intel linker linking mkl libs) if os.path.basename(args.compiler) in ('icc', 'icpc'): + warning_message = 'Warning: The intel compiler may not work with bisect' + logging.info(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 # This can be done by calling the linker command with -v to see # what intel uses in its linker. The include path is in that @@ -847,22 +855,38 @@ def main(arguments, prog=sys.argv[0]): print(' None') logging.info(' None') - replacements['link_flags'].extend([ - '-L' + intel_lib_dir, - '-lirc', - '-lsvml', - ]) + #replacements['link_flags'].extend([ + # '-L' + intel_lib_dir, + # '-lirc', + # '-lsvml', + # ]) + + # TODO: If the linker is to blame, remove it from the equation for + # future searching This is done simply by using the ground-truth + # compiler to link instead of using the trouble compiler to link. + + # For now, if the linker was to blame, then exit saying there is + # nothing else we can do. + if len(bad_libs) > 0: + message = 'May not be able to search further, because of intel' + print(message) + logging.info(message) - # If the linker is to blame, remove it from the equation for future searching - # This is done simply by using the ground-truth compiler to link instead of - # using the trouble compiler to link. # TODO: Handle the case where the ground-truth compiler is also an intel # compiler. # TODO: Extra care must be taken when there is more than one intel linker # specified. - bad_sources = search_for_source_problems(args, bisect_path, replacements, - sources) + 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 1 + print(' bad sources:') logging.info('BAD SOURCES:') for src in bad_sources: @@ -873,8 +897,17 @@ def main(arguments, prog=sys.argv[0]): logging.info(' None') - bad_symbols = search_for_symbol_problems(args, bisect_path, replacements, - sources, bad_sources) + try: + bad_symbols = search_for_symbol_problems(args, bisect_path, + replacements, sources, + bad_sources) + except subp.CalledProcessError: + print() + print(' Executable failed to run.') + print('Failed to search for bad symbols -- cannot continue') + logging.exception('Failed to search for bad symbols.') + return 1 + print(' bad symbols:') logging.info('BAD SYMBOLS:') for sym in bad_symbols: @@ -887,10 +920,5 @@ def main(arguments, prog=sys.argv[0]): logging.info(' None') - # TODO: determine if the problem is on the linker's side - # I'm not yet sure the best way to do that - # This is to be done later - first go for compilation problems - - if __name__ == '__main__': sys.exit(main(sys.argv[1:])) From 5c753a0c29e484d9a77ac44d1705c1cbad2832ed Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 22 Mar 2018 23:40:34 -0600 Subject: [PATCH 044/166] bisect: Add a flag for auto bisect The auto bisect option allows for automation of running all bisect runs within a results sqlite file. --- scripts/flitcli/flit_bisect.py | 107 ++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 3 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 92ae3551..8fd82a0b 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -560,6 +560,17 @@ def parse_args(arguments, prog=sys.argv[0]): 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('-v', '--verbose', action='store_true', help=''' Give verbose output including the output from the @@ -760,8 +771,16 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): bad_symbols = bisect_search(bisect_symbol_build_and_check, symbol_tuples) return bad_symbols +def run_bisect(arguments, prog=sys.argv[0]): + ''' + The actual function for running the bisect command-line tool. -def main(arguments, prog=sys.argv[0]): + Returns four things, (libs, sources, symbols, returncode). + - 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 + ''' args = parse_args(arguments, prog) # our hash is the first 10 digits of a sha1 sum @@ -816,6 +835,7 @@ def main(arguments, prog=sys.argv[0]): update_gt_results(args.directory, verbose=args.verbose) # 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(warning_message) @@ -885,7 +905,8 @@ def main(arguments, prog=sys.argv[0]): print(' Executable failed to run.') print('Failed to search for bad sources -- cannot continue.') logging.exception('Failed to search for bad sources.') - return 1 + raise + return bad_libs, [], [], 1 print(' bad sources:') logging.info('BAD SOURCES:') @@ -906,7 +927,7 @@ def main(arguments, prog=sys.argv[0]): print(' Executable failed to run.') print('Failed to search for bad symbols -- cannot continue') logging.exception('Failed to search for bad symbols.') - return 1 + return bad_libs, bad_sources, [], 1 print(' bad symbols:') logging.info('BAD SYMBOLS:') @@ -919,6 +940,86 @@ def main(arguments, prog=sys.argv[0]): print(' None') logging.info(' None') + return bad_libs, bad_sources, bad_symbols, 0 + +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: + if '-a' in arguments: + idx = arguments.index('-a') + else: + idx = arguments.index('--auto-sqlite-run') + + arguments.pop(idx) + sqlitefile = arguments.pop(idx) + + try: + connection = util.sqlite_open(sqlitefile) + except: + print('Error:', sqlitefile, 'is not an sqlite3 file') + return 1 + + return_tot = 0 + with open('auto-bisect.csv', 'w') as resultsfile: + writer = csv.writer(resultsfile) + query = connection.execute( + 'select * from tests where comparison_d!=0.0') + precision_map = { + 'f': 'float', + 'd': 'double', + 'e': 'long double', + } + writer.writerow([ + 'testid', + 'compiler', + 'precision', + 'testcase', + 'type', + 'name', + 'return', + ]) + entries = [] + for row in query: + 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('flit bisect', + '--precision', precision, + '"' + compilation + '"', + testcase) + libs,srcs,syms,ret = run_bisect(row_args, prog) + return_tot += ret + + entries.extend([('lib',x) for x in libs]) + entries.extend([('src',x) for x in srcs]) + entries.extend([('sym',x) for x in syms]) + + for entry in entries: + writer.writerow([ + row['id'], + compiler, + precision, + testcase, + entry[0], + entry[1], + ret, + ]) + return return_tot + + else: + _,_,_,ret = run_bisect(arguments, prog) + return ret + if __name__ == '__main__': sys.exit(main(sys.argv[1:])) From 3634871b0616e2b844f628879a2b4a2a2d075da4 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 22 Mar 2018 23:54:19 -0600 Subject: [PATCH 045/166] bisect: flush to disk the results of auto That is after every one that is run. --- scripts/flitcli/flit_bisect.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 8fd82a0b..72730a4b 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -981,6 +981,7 @@ def main(arguments, prog=sys.argv[0]): 'name', 'return', ]) + resultsfile.flush() entries = [] for row in query: compilation = ' '.join( @@ -1014,6 +1015,7 @@ def main(arguments, prog=sys.argv[0]): entry[1], ret, ]) + resultsfile.flush() return return_tot else: From 005ff6fc3d2ef3c2316463418ac19440322d0f99 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 23 Mar 2018 00:07:32 -0600 Subject: [PATCH 046/166] bisect: Add intel linking in if it isn't a problem --- scripts/flitcli/flit_bisect.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 72730a4b..3fd40bbc 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -885,13 +885,30 @@ def run_bisect(arguments, prog=sys.argv[0]): # future searching This is done simply by using the ground-truth # compiler to link instead of using the trouble compiler to link. - # For now, if the linker was to blame, then exit saying there is - # nothing else we can do. + # 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' print(message) logging.info(message) + # TODO: Can we instead compare against the ground truth compilation + # with the intel linking? That is instead of giving up. + + # If the libraries weren't a problem, then include them for the + # following searches. + if len(bad_libs) == 0: + replacements['link_flags'].extend([ + '-L' + intel_lib_dir, + '-ldecimal', + '-limf', + '-lipgo', + '-lirc_s', + '-lirc', + '-lirng', + '-lsvml', + ]) + # TODO: Handle the case where the ground-truth compiler is also an intel # compiler. # TODO: Extra care must be taken when there is more than one intel linker From 26dbcc21464078f26d8ee026b58c905c58703ad7 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 23 Mar 2018 00:09:06 -0600 Subject: [PATCH 047/166] bisect: add bisect Makefile to install --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 9de86b59..19fc8dee 100644 --- a/Makefile +++ b/Makefile @@ -111,6 +111,7 @@ install: $(TARGET) 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/ From 8530d3ebfcb25d7af4230b937d45427ede35b41e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 23 Mar 2018 00:17:30 -0600 Subject: [PATCH 048/166] bisect: fix auto command with undefined var --- scripts/flitcli/flit_bisect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 3fd40bbc..bd100a16 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -992,6 +992,8 @@ def main(arguments, prog=sys.argv[0]): writer.writerow([ 'testid', 'compiler', + 'optl', + 'switches', 'precision', 'testcase', 'type', @@ -1025,7 +1027,9 @@ def main(arguments, prog=sys.argv[0]): for entry in entries: writer.writerow([ row['id'], - compiler, + row['compiler'], + row['optl'], + row['switches'], precision, testcase, entry[0], From 51edd354534516d1c26186e02438ac99928f7e4c Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 23 Mar 2018 00:29:41 -0600 Subject: [PATCH 049/166] bisect: auto - give feedback of progress --- scripts/flitcli/flit_bisect.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index bd100a16..bc8e9f81 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1002,7 +1002,11 @@ def main(arguments, prog=sys.argv[0]): ]) resultsfile.flush() entries = [] - for row in query: + i = 0 + rows = query.fetchall() + rowcount = len(rows) + for row in rows: + i += 1 compilation = ' '.join( [row['compiler'], row['optl'], row['switches']]) testcase = row['name'] @@ -1013,6 +1017,9 @@ def main(arguments, prog=sys.argv[0]): compilation, testcase, ]) + # give feedback about how much is left. Run x of y + print() + print('Run', i, 'of', rowcount) print('flit bisect', '--precision', precision, '"' + compilation + '"', From 591fc0466781e91c90efc95f11e6c906dfbb4fe4 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 23 Mar 2018 00:41:28 -0600 Subject: [PATCH 050/166] bisect: add -j argument for make jobs --- scripts/flitcli/flit_bisect.py | 18 +++++++++++++----- scripts/flitcli/flit_make.py | 16 ++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index bc8e9f81..2b4b6d1e 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -269,7 +269,8 @@ def build_bisect(makefilename, directory, verbose=False, jobs=None): ['make', '-C', directory, '-f', makefilename, '-j', str(jobs), 'bisect'], **kwargs) -def update_gt_results(directory, verbose=False): +def update_gt_results(directory, verbose=False, + jobs=multiprocessing.cpu_count()): ''' Update the ground-truth.csv results file for FLiT tests within the given directory. @@ -288,7 +289,7 @@ def update_gt_results(directory, verbose=False): print('Updating ground-truth results -', gt_resultfile, end='') sys.stdout.flush() subp.check_call( - ['make', '-C', directory, gt_resultfile], **kwargs) + ['make', '-j', str(jobs), '-C', directory, gt_resultfile], **kwargs) print(' - done') logging.info('Finished Updating ground-truth results') @@ -577,6 +578,13 @@ def parse_args(arguments, prog=sys.argv[0]): Makefiles. The default is to be quiet and to only output short updates. ''') + 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. + ''') args = parser.parse_args(arguments) @@ -634,7 +642,7 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): for lib in trouble_libs: logging.info(' ' + lib) - build_bisect(makepath, args.directory, verbose=args.verbose) + build_bisect(makepath, args.directory, verbose=args.verbose, args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) @@ -682,7 +690,7 @@ def bisect_build_and_check(trouble_src, gt_src): for src in trouble_src: logging.info(' ' + src) - build_bisect(makepath, args.directory, verbose=args.verbose) + build_bisect(makepath, args.directory, verbose=args.verbose, args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) @@ -745,7 +753,7 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' .format(sym=sym)) - build_bisect(makepath, args.directory, verbose=args.verbose) + build_bisect(makepath, args.directory, verbose=args.verbose, args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) 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 From f4b0b619880fa7e9e87b0d2f2c2f42156249987b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 23 Mar 2018 00:44:15 -0600 Subject: [PATCH 051/166] bisect: fix syntax error... --- scripts/flitcli/flit_bisect.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 2b4b6d1e..1afac126 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -642,7 +642,7 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): for lib in trouble_libs: logging.info(' ' + lib) - build_bisect(makepath, args.directory, verbose=args.verbose, args.jobs) + build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) @@ -690,7 +690,7 @@ def bisect_build_and_check(trouble_src, gt_src): for src in trouble_src: logging.info(' ' + src) - build_bisect(makepath, args.directory, verbose=args.verbose, args.jobs) + build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) @@ -753,7 +753,7 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' .format(sym=sym)) - build_bisect(makepath, args.directory, verbose=args.verbose, args.jobs) + build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) From 257487eab1f92c9b55b30aa18f623f00e49e5f1b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 23 Mar 2018 01:14:44 -0600 Subject: [PATCH 052/166] bisect: fix --jobs for gt update --- scripts/flitcli/flit_bisect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 1afac126..8340a97c 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -840,7 +840,7 @@ def run_bisect(arguments, prog=sys.argv[0]): 'cpp_flags': [], }; - update_gt_results(args.directory, verbose=args.verbose) + 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 = [] From 641209c444d3ce79130d1393659f8fa62a35258e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 24 Mar 2018 13:09:32 -0600 Subject: [PATCH 053/166] bisect: fix problem with failing in sources section Accidentally left in the raise in the except block that was put in during debugging. It is now removed so that we can continue even if there are only partial results. --- scripts/flitcli/flit_bisect.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 8340a97c..5a1d470e 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -930,7 +930,6 @@ def run_bisect(arguments, prog=sys.argv[0]): print(' Executable failed to run.') print('Failed to search for bad sources -- cannot continue.') logging.exception('Failed to search for bad sources.') - raise return bad_libs, [], [], 1 print(' bad sources:') From 66c45780446970810f71d19fd44107a13cb9adaa Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 24 Mar 2018 17:07:30 -0600 Subject: [PATCH 054/166] bisect: Add --parallel option for --auto-sqlite-run Run multiple instances of bisect in parallel automatically over the results sqlite file. --- scripts/flitcli/flit_bisect.py | 259 ++++++++++++++++++++++----------- 1 file changed, 174 insertions(+), 85 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 5a1d470e..0feaf38f 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -96,7 +96,7 @@ import datetime import hashlib import logging -import multiprocessing +import multiprocessing as mp import os import re import shutil @@ -260,7 +260,7 @@ def build_bisect(makefilename, directory, verbose=False, jobs=None): ''' logging.info('Building the bisect executable') if jobs is None: - jobs = multiprocessing.cpu_count() + jobs = mp.cpu_count() kwargs = dict() if not verbose: kwargs['stdout'] = subp.DEVNULL @@ -270,7 +270,7 @@ def build_bisect(makefilename, directory, verbose=False, jobs=None): **kwargs) def update_gt_results(directory, verbose=False, - jobs=multiprocessing.cpu_count()): + jobs=mp.cpu_count()): ''' Update the ground-truth.csv results file for FLiT tests within the given directory. @@ -519,6 +519,8 @@ def parse_args(arguments, prog=sys.argv[0]): 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 @@ -550,6 +552,7 @@ def parse_args(arguments, prog=sys.argv[0]): # 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, @@ -572,13 +575,21 @@ def parse_args(arguments, prog=sys.argv[0]): 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, but the bisect runs may + be parallelized if the user desires so. + ''') 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 = multiprocessing.cpu_count() + 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 @@ -804,7 +815,11 @@ def run_bisect(arguments, prog=sys.argv[0]): bisect_dir = create_bisect_dir(args.directory) bisect_path = os.path.join(args.directory, bisect_dir) - # keep a bisect.log of what was done + # 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', @@ -966,93 +981,167 @@ def run_bisect(arguments, prog=sys.argv[0]): return bad_libs, bad_sources, bad_symbols, 0 -def main(arguments, prog=sys.argv[0]): +def auto_bisect_worker(arg_queue, result_queue): ''' - A wrapper around the bisect program. This checks for the --auto-sqlite-run - stuff and runs the run_bisect multiple times if so. + 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 ''' - if '-a' in arguments or '--auto-sqlite-run' in arguments: - if '-a' in arguments: - idx = arguments.index('-a') - else: - idx = arguments.index('--auto-sqlite-run') + 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) - arguments.pop(idx) - sqlitefile = arguments.pop(idx) + libs,srcs,syms,ret = run_bisect(row_args) + result_queue.put((row,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 + ''' + # 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: + print('Error:', sqlitefile, 'is not an sqlite3 file') + return 1 + + return_tot = 0 + with open('auto-bisect.csv', 'w') as resultsfile: + writer = csv.writer(resultsfile) + query = connection.execute( + 'select * from tests where comparison_d!=0.0') + writer.writerow([ + 'testid', + 'compiler', + 'optl', + 'switches', + 'precision', + 'testcase', + 'type', + 'name', + 'return', + ]) + precision_map = { + 'f': 'float', + 'd': 'double', + 'e': 'long double', + } + resultsfile.flush() + rows = query.fetchall() + + # 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): + p = mp.Process(target=auto_bisect_worker, + args=(arg_queue, result_queue)) + p.start() + workers.append(p) + + # Process the results + for _ in range(rowcount): + row,libs,srcs,syms,ret = result_queue.get() + return_tot += ret - try: - connection = util.sqlite_open(sqlitefile) - except: - print('Error:', sqlitefile, 'is not an sqlite3 file') - return 1 - - return_tot = 0 - with open('auto-bisect.csv', 'w') as resultsfile: - writer = csv.writer(resultsfile) - query = connection.execute( - 'select * from tests where comparison_d!=0.0') - precision_map = { - 'f': 'float', - 'd': 'double', - 'e': 'long double', - } - writer.writerow([ - 'testid', - 'compiler', - 'optl', - 'switches', - 'precision', - 'testcase', - 'type', - 'name', - 'return', - ]) - resultsfile.flush() entries = [] - i = 0 - rows = query.fetchall() - rowcount = len(rows) - for row in rows: - i += 1 - 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, + entries.extend([('lib',x) for x in libs]) + entries.extend([('src',x) for x in srcs]) + entries.extend([('sym',x) for x in syms]) + + for entry in entries: + writer.writerow([ + row['id'], + row['compiler'], + row['optl'], + row['switches'], + precision_map[row['precision']], + row['name'], + entry[0], + entry[1], + ret, ]) - # give feedback about how much is left. Run x of y - print() - print('Run', i, 'of', rowcount) - print('flit bisect', - '--precision', precision, - '"' + compilation + '"', - testcase) - libs,srcs,syms,ret = run_bisect(row_args, prog) - return_tot += ret - - entries.extend([('lib',x) for x in libs]) - entries.extend([('src',x) for x in srcs]) - entries.extend([('sym',x) for x in syms]) - - for entry in entries: - writer.writerow([ - row['id'], - row['compiler'], - row['optl'], - row['switches'], - precision, - testcase, - entry[0], - entry[1], - ret, - ]) - resultsfile.flush() - return return_tot + resultsfile.flush() + + # Join the workers + for p in workers: + p.join() + 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) else: _,_,_,ret = run_bisect(arguments, prog) return ret From 21c91be3c164feb41f9767e034d6d7f65a8caa35 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 26 Mar 2018 13:10:25 -0600 Subject: [PATCH 055/166] Add plot script for making speedup histograms --- plotting/plot_speedup_histogram.py | 311 +++++++++++++++++++++++++++++ 1 file changed, 311 insertions(+) create mode 100755 plotting/plot_speedup_histogram.py diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py new file mode 100755 index 00000000..57642b5b --- /dev/null +++ b/plotting/plot_speedup_histogram.py @@ -0,0 +1,311 @@ +#!/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): + ''' + Calculates the safe speedup and the unsafe speedup for each test_name, + compiler combination. + + @return (safe_speedups, unsafe_speedups) + + - safe_speedups: (dict{compiler -> list[speedup for test_name i]}) + Safe speedups, defined by row['comparison_d'] == 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. This speedup is against the slowest run across + compilers. + ''' + 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} + slowest_time = max([int(x['nanosec']) for x in test_rows]) + 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_d']) == 0.0] + unsafe_times = [int(x['nanosec']) for x in compiler_rows + if float(x['comparison_d']) == 0.0] + + if len(safe_times) > 0: + safe_speedup = slowest_time / min(safe_times) + else: + safe_speedup = 0 + + if len(unsafe_times) > 0: + unsafe_speedup = slowest_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='.'): + ''' + 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) + 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') + + ax.set_ylabel('Speedup from Slowest') + 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() + plt.savefig(os.path.join(outdir, 'tmp.svg'), format='svg') + #plt.show() + + # ------- + +# for name in test_names: +# test_rows = [row for row in rows if row['name'] == name] +# hosts = set(row['host'] for row in test_rows) +# for host in hosts: +# host_rows = [row for row in test_rows if row['host'] == host] +# precisions = set(row['precision'] for row in host_rows) +# for p in precisions: +# p_rows = [row for row in host_rows if row['precision'] == p] +# data = {} +# data['name'] = name +# data['rows'] = p_rows +# data['times'] = np.asarray([int(row['nanosec']) +# for row in data['rows']]) +# 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. +# 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 +# for row in data['rows']] +# key = (name, host, p) +# test_data[key] = data +# +# for key, data in test_data.items(): +# name, host, p = key +# print(name, max(data['speedup'])) +# print(' slowest', data['slowest']) +# print(' fastest', data['fastest']) +# speedup = data['speedup'] +# xlab = data['xlab'] +# iseql = data['iseql'] +# joint_sort = sorted(zip(xlab, speedup, iseql), key=lambda x: x[1]) +# xlab = [x[0] for x in joint_sort] +# speedup = [x[1] for x in joint_sort] +# iseql = [x[2] for x in joint_sort] +# eql_idxs = [i for i in range(len(iseql)) if iseql[i] is True] +# not_eql_idxs = [i for i in range(len(iseql)) if iseql[i] is False] +# 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.plot(speedup) +# plt.plot(eql_idxs, eql_speeds, 'b.', +# label='same answer as ground truth') +# plt.plot(not_eql_idxs, not_eql_speeds, 'rx', +# label='different answer than ground truth') +# plt.xticks(np.arange(len(xlab)), xlab, rotation='vertical') +# plt.legend() +# plt.ylim(ymin=0) +# plt.ylabel('Speedup from slowest') +# plt.tight_layout() +# newname = '{0}-{1}-{2}.svg'.format(name, host, p) +# plt.savefig(os.path.join(outdir, newname), format='svg') +# plt.cla() + +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') + 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('sqlite') + parser.add_argument('test', nargs='*') + args = parser.parse_args(arguments) + 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) + +if __name__ == '__main__': + main(sys.argv[1:]) From b53e8e41706b661b0d9dfac14d30c3c85eaf224a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 26 Mar 2018 13:10:49 -0600 Subject: [PATCH 056/166] plot_timing: fix the creating of output directories --- plotting/plot_timing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotting/plot_timing.py b/plotting/plot_timing.py index 87647570..5639c410 100755 --- a/plotting/plot_timing.py +++ b/plotting/plot_timing.py @@ -145,7 +145,7 @@ def plot_timing(rows, test_names=[], outdir='.'): # Make sure outdir exists try: - os.mkdir(outdir) + os.makedirs(outdir) except FileExistsError: pass From f4ec47dff9e5067c7e33d7a0ec139f0380ddaa29 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 26 Mar 2018 13:11:46 -0600 Subject: [PATCH 057/166] plot_speedup_histogram: output to good name Name change from tmp.svg -> speedup_histogram.svg --- plotting/plot_speedup_histogram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py index 57642b5b..1d7b2d6e 100755 --- a/plotting/plot_speedup_histogram.py +++ b/plotting/plot_speedup_histogram.py @@ -228,7 +228,7 @@ def plot_histogram(rows, test_names=[], outdir='.'): label.set_transform(label.get_transform() + offset) plt.tight_layout() - plt.savefig(os.path.join(outdir, 'tmp.svg'), format='svg') + plt.savefig(os.path.join(outdir, 'speedup_histogram.svg'), format='svg') #plt.show() # ------- From ffe395188e701d985991e0076c651dd96383e750 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 26 Mar 2018 13:23:23 -0600 Subject: [PATCH 058/166] Clean up the plotting scripts a bit - Print after creating files - print_timing: dynamically allow the figure to widen by how many points are plotted --- plotting/plot_speedup_histogram.py | 64 ++---------------------------- plotting/plot_timing.py | 3 +- 2 files changed, 6 insertions(+), 61 deletions(-) diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py index 1d7b2d6e..e689f3f6 100755 --- a/plotting/plot_speedup_histogram.py +++ b/plotting/plot_speedup_histogram.py @@ -228,66 +228,10 @@ def plot_histogram(rows, test_names=[], outdir='.'): label.set_transform(label.get_transform() + offset) plt.tight_layout() - plt.savefig(os.path.join(outdir, 'speedup_histogram.svg'), format='svg') - #plt.show() - - # ------- - -# for name in test_names: -# test_rows = [row for row in rows if row['name'] == name] -# hosts = set(row['host'] for row in test_rows) -# for host in hosts: -# host_rows = [row for row in test_rows if row['host'] == host] -# precisions = set(row['precision'] for row in host_rows) -# for p in precisions: -# p_rows = [row for row in host_rows if row['precision'] == p] -# data = {} -# data['name'] = name -# data['rows'] = p_rows -# data['times'] = np.asarray([int(row['nanosec']) -# for row in data['rows']]) -# 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. -# 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 -# for row in data['rows']] -# key = (name, host, p) -# test_data[key] = data -# -# for key, data in test_data.items(): -# name, host, p = key -# print(name, max(data['speedup'])) -# print(' slowest', data['slowest']) -# print(' fastest', data['fastest']) -# speedup = data['speedup'] -# xlab = data['xlab'] -# iseql = data['iseql'] -# joint_sort = sorted(zip(xlab, speedup, iseql), key=lambda x: x[1]) -# xlab = [x[0] for x in joint_sort] -# speedup = [x[1] for x in joint_sort] -# iseql = [x[2] for x in joint_sort] -# eql_idxs = [i for i in range(len(iseql)) if iseql[i] is True] -# not_eql_idxs = [i for i in range(len(iseql)) if iseql[i] is False] -# 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.plot(speedup) -# plt.plot(eql_idxs, eql_speeds, 'b.', -# label='same answer as ground truth') -# plt.plot(not_eql_idxs, not_eql_speeds, 'rx', -# label='different answer than ground truth') -# plt.xticks(np.arange(len(xlab)), xlab, rotation='vertical') -# plt.legend() -# plt.ylim(ymin=0) -# plt.ylabel('Speedup from slowest') -# plt.tight_layout() -# newname = '{0}-{1}-{2}.svg'.format(name, host, p) -# plt.savefig(os.path.join(outdir, newname), format='svg') -# plt.cla() + 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()' diff --git a/plotting/plot_timing.py b/plotting/plot_timing.py index 5639c410..5cac486e 100755 --- a/plotting/plot_timing.py +++ b/plotting/plot_timing.py @@ -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): From 19739965e97254e9bc44f381493c25ae41c1e78d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 30 Mar 2018 13:22:16 -0600 Subject: [PATCH 059/166] bisect: fix the fPIC compilations --- data/Makefile_bisect_binary.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 4ca365b4..93906944 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -186,7 +186,7 @@ $(BISECT_OBJ_DIR): # ground-truth files are already specified in Makefile # but need to specify how to do the fPIC variant $(OBJ_DIR)/%_gt_fPIC.o: %.cpp Makefile custom.mk | $(OBJ_DIR) - $(GT_CC) -fPIC $(GT_OPTL) $(GT_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -c $< -o $@ \ + $(GT_CC) $(GT_OPTL) $(GT_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -fPIC -c $< -o $@ \ -DFLIT_HOST='"$(HOSTNAME)"' \ -DFLIT_COMPILER='"$(GT_CC)"' \ -DFLIT_OPTL='"$(GT_OPTL)"' \ @@ -205,7 +205,7 @@ $(OBJ_DIR)/%_bisect_$(TROUBLE_ID).o: %.cpp Makefile custom.mk | $(OBJ_DIR) # and the fPIC variant $(OBJ_DIR)/%_bisect_$(TROUBLE_ID)_fPIC.o: %.cpp Makefile custom.mk | $(OBJ_DIR) - $(TROUBLE_CC) -fPIC $(TROUBLE_OPTL) $(TROUBLE_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -c $< -o $@ \ + $(TROUBLE_CC) $(TROUBLE_OPTL) $(TROUBLE_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -fPIC -c $< -o $@ \ -DFLIT_HOST='"$(HOSTNAME)"' \ -DFLIT_COMPILER='"$(TROUBLE_CC)"' \ -DFLIT_OPTL='"$(TROUBLE_OPTL)"' \ From f8f3d34e0b6fcb899ac33fc8a645070a6548478a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Mar 2018 09:43:40 -0600 Subject: [PATCH 060/166] plot_speedup_histogram: fix unsafe bar It was being the fastest safe one instead of the fastest unsafe one --- plotting/plot_speedup_histogram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py index e689f3f6..d4c318d7 100755 --- a/plotting/plot_speedup_histogram.py +++ b/plotting/plot_speedup_histogram.py @@ -137,7 +137,7 @@ def calc_speedups(rows, test_names): safe_times = [int(x['nanosec']) for x in compiler_rows if float(x['comparison_d']) == 0.0] unsafe_times = [int(x['nanosec']) for x in compiler_rows - if float(x['comparison_d']) == 0.0] + if float(x['comparison_d']) != 0.0] if len(safe_times) > 0: safe_speedup = slowest_time / min(safe_times) From 50a0cc71bb53165ca6140b6f20fdd2887c2b0b74 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Mar 2018 09:45:03 -0600 Subject: [PATCH 061/166] plot_speedup_histogram: output change speedup_histogram.svg -> speedup-histogram.svg --- plotting/plot_speedup_histogram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py index d4c318d7..22b3d35d 100755 --- a/plotting/plot_speedup_histogram.py +++ b/plotting/plot_speedup_histogram.py @@ -228,7 +228,7 @@ def plot_histogram(rows, test_names=[], outdir='.'): label.set_transform(label.get_transform() + offset) plt.tight_layout() - figfile = os.path.join(outdir, 'speedup_histogram.svg') + figfile = os.path.join(outdir, 'speedup-histogram.svg') plt.savefig(figfile, format='svg') plt.cla() print('Created', figfile) From a50e6a3739dcb8ee6e8072283bf313f0a33ef6eb Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 28 Mar 2018 09:53:43 -0600 Subject: [PATCH 062/166] plot_speedup_histogram: disable precision argument This should be added back in, but for now, does not help anything. We should really create a histogram for each precision we have, since the timings between them makes no sense. Also add some documentation to the --help option. --- plotting/plot_speedup_histogram.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py index 22b3d35d..cda40d56 100755 --- a/plotting/plot_speedup_histogram.py +++ b/plotting/plot_speedup_histogram.py @@ -200,7 +200,8 @@ def plot_histogram(rows, test_names=[], outdir='.'): }) #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]) + 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) @@ -240,15 +241,20 @@ def main(arguments): 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') - 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('sqlite') - parser.add_argument('test', nargs='*') + # 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('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) rows = read_sqlite(args.sqlite, args.run) - if args.precision != 'all': - rows = [x for x in rows if x['precision'] == args.precision] + #if args.precision != 'all': + # rows = [x for x in rows if x['precision'] == args.precision] plot_histogram(rows, args.test, args.outdir) if __name__ == '__main__': From 1d66415b8a4ec3069797722778485a4a14052220 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 3 Apr 2018 12:01:19 -0600 Subject: [PATCH 063/166] plot_speedup_histogram: add option for baseline comparison The old behavior was to always choose the slowest compilation. Now, you can specify a compilation (that must be found within the results) to use as the baseline comparison, such as 'g++ -O2' or even the ground truth such as 'g++ -O0'. This may allow for more understandable results. --- plotting/plot_speedup_histogram.py | 56 ++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py index cda40d56..fcc48109 100755 --- a/plotting/plot_speedup_histogram.py +++ b/plotting/plot_speedup_histogram.py @@ -102,11 +102,20 @@ #matplotlib.use('Agg') import matplotlib.pyplot as plt -def calc_speedups(rows, test_names): +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]}) @@ -115,8 +124,7 @@ def calc_speedups(rows, test_names): 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. This speedup is against the slowest run across - compilers. + speedup returned is zero. ''' compilers = sorted(set(x['compiler'] for x in rows)) @@ -129,7 +137,14 @@ def calc_speedups(rows, test_names): compiler_row_map = {x: [row for row in test_rows if row['compiler'] == x] for x in compilers} - slowest_time = max([int(x['nanosec']) for x in test_rows]) + 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: @@ -140,12 +155,12 @@ def calc_speedups(rows, test_names): if float(x['comparison_d']) != 0.0] if len(safe_times) > 0: - safe_speedup = slowest_time / min(safe_times) + safe_speedup = baseline_time / min(safe_times) else: safe_speedup = 0 if len(unsafe_times) > 0: - unsafe_speedup = slowest_time / min(unsafe_times) + unsafe_speedup = baseline_time / min(unsafe_times) else: unsafe_speedup = 0 @@ -153,7 +168,7 @@ def calc_speedups(rows, test_names): unsafe_speedups[compiler].append(unsafe_speedup) return safe_speedups, unsafe_speedups -def plot_histogram(rows, test_names=[], outdir='.'): +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. @@ -174,7 +189,7 @@ def plot_histogram(rows, test_names=[], outdir='.'): except FileExistsError: pass - safe_speedups, unsafe_speedups = calc_speedups(rows, test_names) + safe_speedups, unsafe_speedups = calc_speedups(rows, test_names, baseline) compilers = safe_speedups.keys() width = 1 / (len(compilers) + 2) # The bar width @@ -209,7 +224,10 @@ def plot_histogram(rows, test_names=[], outdir='.'): width, color='r') - ax.set_ylabel('Speedup from Slowest') + 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) @@ -245,6 +263,14 @@ def main(arguments): #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=''' @@ -252,10 +278,18 @@ def main(arguments): 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) + plot_histogram(rows, args.test, args.outdir, split_baseline) if __name__ == '__main__': main(sys.argv[1:]) From e0d0d057e297d7442267cde800502a9c85c7bae4 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 3 Apr 2018 16:05:04 -0600 Subject: [PATCH 064/166] bisect: output completed steps into auto-bisect.csv The completed steps are a comma-separated list of steps completed from 'lib', 'src', and 'sym'. This helps in parsing afterwards what happened. --- scripts/flitcli/flit_bisect.py | 72 ++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 0feaf38f..66e78c7f 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -799,6 +799,11 @@ def run_bisect(arguments, prog=sys.argv[0]): - 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) @@ -887,8 +892,15 @@ def run_bisect(arguments, prog=sys.argv[0]): os.path.join(intel_lib_dir, 'libirng.a'), os.path.join(intel_lib_dir, 'libsvml.a'), ] - bad_libs = search_for_linker_problems(args, bisect_path, replacements, - sources, libs) + 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 None, None, None, 1 + print(' bad static libraries:') logging.info('BAD STATIC LIBRARIES:') for lib in bad_libs: @@ -945,7 +957,7 @@ def run_bisect(arguments, prog=sys.argv[0]): print(' Executable failed to run.') print('Failed to search for bad sources -- cannot continue.') logging.exception('Failed to search for bad sources.') - return bad_libs, [], [], 1 + return bad_libs, None, None, 1 print(' bad sources:') logging.info('BAD SOURCES:') @@ -966,7 +978,7 @@ def run_bisect(arguments, prog=sys.argv[0]): print(' Executable failed to run.') print('Failed to search for bad symbols -- cannot continue') logging.exception('Failed to search for bad symbols.') - return bad_libs, bad_sources, [], 1 + return bad_libs, bad_sources, None, 1 print(' bad symbols:') logging.info('BAD SYMBOLS:') @@ -1048,10 +1060,45 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): 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) + args = parse_args( + ['--precision', 'double', 'compilation', 'testcase'] + arguments, + prog) sqlitefile = args.auto_sqlite_run try: @@ -1110,9 +1157,18 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): return_tot += ret entries = [] - entries.extend([('lib',x) for x in libs]) - entries.extend([('src',x) for x in srcs]) - entries.extend([('sym',x) for x in syms]) + 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([ From 23d11c794cc20cd50a3ea23fc26d05de0f6c809e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 3 Apr 2018 16:05:59 -0600 Subject: [PATCH 065/166] make finding multi-line TODOs easier When a TODO statement is across multiple lines, then have following lines have TODO- instead of TODO: to indicate that it is a continuation. --- data/Makefile.in | 2 +- plans/bisect-plan.md | 8 ++++---- plotting/plot_timing.py | 2 +- plotting/stats_generator.py | 10 +++++----- scripts/flitcli/flit_bisect.py | 26 +++++++++++++------------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/data/Makefile.in b/data/Makefile.in index 7a74f976..f1cead7a 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -470,7 +470,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 diff --git a/plans/bisect-plan.md b/plans/bisect-plan.md index 9db1caba..d58662b6 100644 --- a/plans/bisect-plan.md +++ b/plans/bisect-plan.md @@ -167,10 +167,10 @@ This approach has a few downsides: TODO: make tests that check this functionality with -(1) both shared, -(2) gt shared only, -(3) trouble shared only, and -(4) inlining. +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 diff --git a/plotting/plot_timing.py b/plotting/plot_timing.py index 5cac486e..9ce06b03 100755 --- a/plotting/plot_timing.py +++ b/plotting/plot_timing.py @@ -172,7 +172,7 @@ 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 diff --git a/plotting/stats_generator.py b/plotting/stats_generator.py index d5393eb4..d178a187 100755 --- a/plotting/stats_generator.py +++ b/plotting/stats_generator.py @@ -125,11 +125,11 @@ 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 diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 66e78c7f..1b3a5561 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -465,10 +465,10 @@ def bisect_search(is_bad, elements): Q = Q1 no_test.extend(Q2) # TODO: possible optimization. - # if the length of Q2 is big enough, test - # is_bad(Q2, no_test + Q1) - # and if that returns False, then mark Q2 as known so - # that we don't need to search it again. + # TODO- if the length of Q2 is big enough, test + # TODO- is_bad(Q2, no_test + Q1) + # TODO- and if that returns False, then mark Q2 as known so + # TODO- that we don't need to search it again. else: # optimization: mark Q1 as known, so that we don't need to # search it again @@ -542,7 +542,7 @@ def parse_args(arguments, prog=sys.argv[0]): by calling 'make dev' and then calling the created executable './devrun --list-tests'. ''') - # TODO: get the default case to work + # 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 @@ -875,9 +875,9 @@ def run_bisect(arguments, prog=sys.argv[0]): compiler = os.path.realpath(shutil.which(args.compiler)) # TODO: find a more portable way of finding the static libraries - # This can be done by calling the linker command with -v to see - # what intel uses in its linker. The include path is in that - # output command. + # 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), '..', '..') @@ -917,8 +917,8 @@ def run_bisect(arguments, prog=sys.argv[0]): # ]) # TODO: If the linker is to blame, remove it from the equation for - # future searching This is done simply by using the ground-truth - # compiler to link instead of using the trouble compiler to link. + # TODO- future searching This is done simply by using the ground-truth + # TODO- compiler to link instead of using the trouble compiler to link. # For now, if the linker was to blame, then say there may be nothing # else we can do. @@ -928,7 +928,7 @@ def run_bisect(arguments, prog=sys.argv[0]): logging.info(message) # TODO: Can we instead compare against the ground truth compilation - # with the intel linking? That is instead of giving up. + # TODO- with the intel linking? That is instead of giving up. # If the libraries weren't a problem, then include them for the # following searches. @@ -945,9 +945,9 @@ def run_bisect(arguments, prog=sys.argv[0]): ]) # TODO: Handle the case where the ground-truth compiler is also an intel - # compiler. + # TODO- compiler. # TODO: Extra care must be taken when there is more than one intel linker - # specified. + # TODO- specified. try: bad_sources = search_for_source_problems(args, bisect_path, From bbfb554e46ab91bfbc9ac85778b544345d91d412 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Apr 2018 17:58:46 -0600 Subject: [PATCH 066/166] bisect: Add clean targets to the bisect-make-??.mk Targets are: - bisect-smallclean - bisect-clean - bisect-distclean --- data/Makefile_bisect_binary.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 93906944..57dcd43c 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -177,6 +177,30 @@ trouble: $(TROUBLE_TARGET_RESULT) $(TROUBLE_TARGET_OUT) 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 $(SPLIT_OBJ) + -rmdir $(BISECT_OBJ_DIR) + +bisect-clean: bisect-smallclean + rm -f $(TROUBLE_TARGET_OBJ) + +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) From b8a0cf0c9dda8ab20c888197c960cbf80605e47e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sun, 8 Apr 2018 21:25:13 -0600 Subject: [PATCH 067/166] bisect: clean up after bisect with --delete --- scripts/flitcli/flit_bisect.py | 65 ++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 1b3a5561..0b5fd0e2 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -247,12 +247,22 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src, return makefile -def build_bisect(makefilename, directory, verbose=False, jobs=None): +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 @@ -266,7 +276,7 @@ def build_bisect(makefilename, directory, verbose=False, jobs=None): kwargs['stdout'] = subp.DEVNULL kwargs['stderr'] = subp.DEVNULL subp.check_call( - ['make', '-C', directory, '-f', makefilename, '-j', str(jobs), 'bisect'], + ['make', '-C', directory, '-f', makefilename, '-j', str(jobs), target], **kwargs) def update_gt_results(directory, verbose=False, @@ -324,7 +334,7 @@ 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 @@ -380,7 +390,7 @@ def extract_symbols(file_or_filelist, objdir): 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 i in range(len(symbol_strings)): @@ -596,6 +606,24 @@ def parse_args(arguments, prog=sys.argv[0]): GNU make when performing the compilation. Note, this is not used when executing the tests. ''') + 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) @@ -615,7 +643,7 @@ 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 @@ -634,7 +662,7 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): @param trouble_libs: static libraries to compile in @param ignore_libs: static libraries to ignore and not include - + @return True if the compilation has a non-zero comparison between this mixed compilation and the full ground-truth compilation. ''' @@ -654,6 +682,9 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): logging.info(' ' + lib) build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) + if args.delete: + build_bisect(makepath, args.directory, target='bisect-smallclean', + verbose=args.verbose, jobs=args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) @@ -702,6 +733,9 @@ def bisect_build_and_check(trouble_src, gt_src): logging.info(' ' + src) build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) + if args.delete: + build_bisect(makepath, args.directory, target='bisect-smallclean', + verbose=args.verbose, jobs=args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) @@ -765,6 +799,9 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): .format(sym=sym)) build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) + if args.delete: + build_bisect(makepath, args.directory, target='bisect-smallclean', + verbose=args.verbose, jobs=args.jobs) resultfile = util.extract_make_var('BISECT_RESULT', makepath, args.directory)[0] resultpath = os.path.join(args.directory, resultfile) @@ -862,6 +899,16 @@ def run_bisect(arguments, prog=sys.argv[0]): update_gt_results(args.directory, verbose=args.verbose, jobs=args.jobs) + def cleanup_bisect(): + 'Cleanup after this run_bisect() function' + if args.delete: + build_bisect( + os.path.join(bisect_path, 'bisect-make-01.mk'), + args.directory, + target='bisect-clean', + 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'): @@ -899,6 +946,7 @@ def run_bisect(arguments, prog=sys.argv[0]): print() print(' Executable failed to run.') print('Failed to search for bad libraries -- cannot continue.') + cleanup_bisect() return None, None, None, 1 print(' bad static libraries:') @@ -957,6 +1005,7 @@ def run_bisect(arguments, prog=sys.argv[0]): print(' Executable failed to run.') print('Failed to search for bad sources -- cannot continue.') logging.exception('Failed to search for bad sources.') + cleanup_bisect() return bad_libs, None, None, 1 print(' bad sources:') @@ -978,6 +1027,7 @@ def run_bisect(arguments, prog=sys.argv[0]): print(' Executable failed to run.') print('Failed to search for bad symbols -- cannot continue') logging.exception('Failed to search for bad symbols.') + cleanup_bisect() return bad_libs, bad_sources, None, 1 print(' bad symbols:') @@ -991,6 +1041,7 @@ def run_bisect(arguments, prog=sys.argv[0]): print(' None') logging.info(' None') + cleanup_bisect() return bad_libs, bad_sources, bad_symbols, 0 def auto_bisect_worker(arg_queue, result_queue): @@ -1029,7 +1080,7 @@ def auto_bisect_worker(arg_queue, result_queue): try: while True: arguments, row, i, rowcount = arg_queue.get(False) - + compilation = ' '.join( [row['compiler'], row['optl'], row['switches']]) testcase = row['name'] From 5e647783a6697240a6bc3228561e67dbaf22ed5c Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sun, 8 Apr 2018 21:25:34 -0600 Subject: [PATCH 068/166] bisect: fix many pylint findings --- scripts/flitcli/flit_bisect.py | 105 ++++++++++++++++----------------- 1 file changed, 50 insertions(+), 55 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 0b5fd0e2..ddad0f58 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -85,11 +85,6 @@ files that cause the variability. ''' -import flitconfig as conf -import flitutil as util - -import toml - from collections import namedtuple import argparse import csv @@ -103,7 +98,9 @@ import sqlite3 import subprocess as subp import sys -import tempfile + +import flitconfig as conf +import flitutil as util brief_description = 'Bisect compilation to identify problematic source code' @@ -393,18 +390,16 @@ def extract_symbols(file_or_filelist, objdir): # generate the symbol tuples - for i in range(len(symbol_strings)): - symtype, symbol = symbol_strings[i].split(maxsplit=2)[1:3] - demangled = demangled_symbol_strings[i].split(maxsplit=2)[2] + 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 - # We need to do all defined global symbols or we will get duplicate - # symbol linker error - #if symtype == 'T': symbol_tuples.append( - SymbolTuple(fname, symbol, demangled, deffile, defline)) + SymbolTuple(fname, symbol, demangled, deffile, defline)) return symbol_tuples @@ -516,19 +511,19 @@ def parse_args(arguments, prog=sys.argv[0]): @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. - ''', - ) + 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', @@ -702,8 +697,7 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): #return bad_libs if bisect_libs_build_and_check(libs, []): return libs - else: - return [] + return [] def search_for_source_problems(args, bisect_path, replacements, sources): ''' @@ -778,11 +772,11 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): 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 } + 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) @@ -795,8 +789,8 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): logging.info('Checking:') for sym in trouble_symbols: logging.info( - ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' - .format(sym=sym)) + ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' + .format(sym=sym)) build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) if args.delete: @@ -895,7 +889,7 @@ def run_bisect(arguments, prog=sys.argv[0]): 'trouble_id': trouble_hash, 'link_flags': [], 'cpp_flags': [], - }; + } update_gt_results(args.directory, verbose=args.verbose, jobs=args.jobs) @@ -903,11 +897,11 @@ def cleanup_bisect(): 'Cleanup after this run_bisect() function' if args.delete: build_bisect( - os.path.join(bisect_path, 'bisect-make-01.mk'), - args.directory, - target='bisect-clean', - verbose=args.verbose, - jobs=args.jobs) + os.path.join(bisect_path, 'bisect-make-01.mk'), + args.directory, + target='bisect-clean', + verbose=args.verbose, + jobs=args.jobs) # Find out if the linker is to blame (e.g. intel linker linking mkl libs) bad_libs = [] @@ -1082,7 +1076,7 @@ def auto_bisect_worker(arg_queue, result_queue): arguments, row, i, rowcount = arg_queue.get(False) compilation = ' '.join( - [row['compiler'], row['optl'], row['switches']]) + [row['compiler'], row['optl'], row['switches']]) testcase = row['name'] precision = precision_map[row['precision']] row_args = list(arguments) @@ -1098,8 +1092,8 @@ def auto_bisect_worker(arg_queue, result_queue): '"' + compilation + '"', testcase) - libs,srcs,syms,ret = run_bisect(row_args) - result_queue.put((row,libs,srcs,syms,ret)) + libs, srcs, syms, ret = run_bisect(row_args) + result_queue.put((row, libs, srcs, syms, ret)) except queue.Empty: # exit the function @@ -1148,13 +1142,13 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): # 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) + ['--precision', 'double', 'compilation', 'testcase'] + arguments, + prog) sqlitefile = args.auto_sqlite_run try: connection = util.sqlite_open(sqlitefile) - except: + except sqlite3.DatabaseError: print('Error:', sqlitefile, 'is not an sqlite3 file') return 1 @@ -1162,7 +1156,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): with open('auto-bisect.csv', 'w') as resultsfile: writer = csv.writer(resultsfile) query = connection.execute( - 'select * from tests where comparison_d!=0.0') + 'select * from tests where comparison_d!=0.0') writer.writerow([ 'testid', 'compiler', @@ -1204,19 +1198,19 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): # Process the results for _ in range(rowcount): - row,libs,srcs,syms,ret = result_queue.get() + row, 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]) + entries.extend([('lib', x) for x in libs]) completed.append('lib') if srcs is not None: - entries.extend([('src',x) for x in srcs]) + entries.extend([('src', x) for x in srcs]) completed.append('src') if syms is not None: - entries.extend([('sym',x) for x in syms]) + entries.extend([('sym', x) for x in syms]) completed.append('sym') # prepend the completed items so it is first. entries = [('completed', ','.join(completed))] + entries @@ -1249,9 +1243,10 @@ def main(arguments, prog=sys.argv[0]): if '-a' in arguments or '--auto-sqlite-run' in arguments: return parallel_auto_bisect(arguments, prog) - else: - _,_,_,ret = run_bisect(arguments, prog) - return ret + + # else: + _, _, _, ret = run_bisect(arguments, prog) + return ret if __name__ == '__main__': From aa2a2f05f4d4f7ed8a1fd3e3cd6a7abc73cb74ee Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Apr 2018 15:26:15 -0600 Subject: [PATCH 069/166] flit: Add ability to specify tests with data index Just as the results are returned TestCase_idxN for tests with more than one input sequence, the test executable can now be called with the names with this _idxN ending added on, in which case only index N will be executed. --- src/TestBase.h | 30 +++++++++++++++++++++++++----- src/flit.cpp | 11 +++++++++-- src/flit.h | 31 +++++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/src/TestBase.h b/src/TestBase.h index 8316991c..691d1d2c 100644 --- a/src/TestBase.h +++ b/src/TestBase.h @@ -266,14 +266,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, one-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; @@ -326,7 +337,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; diff --git a/src/flit.cpp b/src/flit.cpp index 194c113d..3dfa8407 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -288,7 +288,7 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { 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); } } @@ -470,7 +470,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()); @@ -483,6 +483,13 @@ 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); } diff --git a/src/flit.h b/src/flit.h index bfca8614..2a975171 100644 --- a/src/flit.h +++ b/src/flit.h @@ -199,8 +199,21 @@ std::vector parseResults(std::istream &in); /// 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); @@ -339,11 +352,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(); } @@ -466,21 +480,22 @@ inline int runFlitTests(int argc, char* argv[]) { 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__) From 2a89207c673a3e164f7daed82f30a02aad3e073e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Apr 2018 15:26:15 -0600 Subject: [PATCH 070/166] flit: Add ability to specify tests with data index Just as the results are returned TestCase_idxN for tests with more than one input sequence, the test executable can now be called with the names with this _idxN ending added on, in which case only index N will be executed. --- src/TestBase.h | 30 +++++++++++++++++++++++++----- src/flit.cpp | 39 +++++++++++++++++++++++++++++++++++++-- src/flit.h | 31 +++++++++++++++++++++++-------- 3 files changed, 85 insertions(+), 15 deletions(-) diff --git a/src/TestBase.h b/src/TestBase.h index 8316991c..6ddde8bb 100644 --- a/src/TestBase.h +++ b/src/TestBase.h @@ -266,14 +266,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; @@ -326,7 +337,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; diff --git a/src/flit.cpp b/src/flit.cpp index 194c113d..88e297b7 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -288,7 +288,7 @@ FlitOptions parseArguments(int argCount, char const* const* argList) { 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); } } @@ -321,6 +321,34 @@ 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" @@ -470,7 +498,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()); @@ -483,6 +511,13 @@ 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); } diff --git a/src/flit.h b/src/flit.h index bfca8614..2a975171 100644 --- a/src/flit.h +++ b/src/flit.h @@ -199,8 +199,21 @@ std::vector parseResults(std::istream &in); /// 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); @@ -339,11 +352,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(); } @@ -466,21 +480,22 @@ inline int runFlitTests(int argc, char* argv[]) { 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__) From 4bb66a7dab84f78862172374c90a1b80cc725110 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 10 Apr 2018 10:42:34 -0600 Subject: [PATCH 071/166] Add bisect number to auto-bisect.csv results --- scripts/flitcli/flit_bisect.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index ddad0f58..9c838674 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -825,7 +825,9 @@ def run_bisect(arguments, prog=sys.argv[0]): ''' The actual function for running the bisect command-line tool. - Returns four things, (libs, sources, symbols, returncode). + 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 @@ -849,6 +851,7 @@ def run_bisect(arguments, prog=sys.argv[0]): # 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, @@ -941,7 +944,7 @@ def cleanup_bisect(): print(' Executable failed to run.') print('Failed to search for bad libraries -- cannot continue.') cleanup_bisect() - return None, None, None, 1 + return bisect_num, None, None, None, 1 print(' bad static libraries:') logging.info('BAD STATIC LIBRARIES:') @@ -1000,7 +1003,7 @@ def cleanup_bisect(): print('Failed to search for bad sources -- cannot continue.') logging.exception('Failed to search for bad sources.') cleanup_bisect() - return bad_libs, None, None, 1 + return bisect_num, bad_libs, None, None, 1 print(' bad sources:') logging.info('BAD SOURCES:') @@ -1022,7 +1025,7 @@ def cleanup_bisect(): print('Failed to search for bad symbols -- cannot continue') logging.exception('Failed to search for bad symbols.') cleanup_bisect() - return bad_libs, bad_sources, None, 1 + return bisect_num, bad_libs, bad_sources, None, 1 print(' bad symbols:') logging.info('BAD SYMBOLS:') @@ -1036,7 +1039,7 @@ def cleanup_bisect(): logging.info(' None') cleanup_bisect() - return bad_libs, bad_sources, bad_symbols, 0 + return bisect_num, bad_libs, bad_sources, bad_symbols, 0 def auto_bisect_worker(arg_queue, result_queue): ''' @@ -1092,8 +1095,8 @@ def auto_bisect_worker(arg_queue, result_queue): '"' + compilation + '"', testcase) - libs, srcs, syms, ret = run_bisect(row_args) - result_queue.put((row, libs, srcs, syms, ret)) + num, libs, srcs, syms, ret = run_bisect(row_args) + result_queue.put((row, num, libs, srcs, syms, ret)) except queue.Empty: # exit the function @@ -1159,6 +1162,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): 'select * from tests where comparison_d!=0.0') writer.writerow([ 'testid', + 'bisectnum', 'compiler', 'optl', 'switches', @@ -1198,7 +1202,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): # Process the results for _ in range(rowcount): - row, libs, srcs, syms, ret = result_queue.get() + row, num, libs, srcs, syms, ret = result_queue.get() return_tot += ret entries = [] @@ -1218,6 +1222,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): for entry in entries: writer.writerow([ row['id'], + num, row['compiler'], row['optl'], row['switches'], @@ -1245,7 +1250,7 @@ def main(arguments, prog=sys.argv[0]): return parallel_auto_bisect(arguments, prog) # else: - _, _, _, ret = run_bisect(arguments, prog) + _, _, _, _, ret = run_bisect(arguments, prog) return ret From d7142d2b718cee8a123c8103baa8125494e75016 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 13:38:21 -0600 Subject: [PATCH 072/166] bisect: remove cleaning since it removes shared object files --- scripts/flitcli/flit_bisect.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 9c838674..e05888d2 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -160,7 +160,7 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_src, 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 Makefil + @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 @@ -896,16 +896,6 @@ def run_bisect(arguments, prog=sys.argv[0]): update_gt_results(args.directory, verbose=args.verbose, jobs=args.jobs) - def cleanup_bisect(): - 'Cleanup after this run_bisect() function' - if args.delete: - build_bisect( - os.path.join(bisect_path, 'bisect-make-01.mk'), - args.directory, - target='bisect-clean', - 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'): @@ -943,7 +933,6 @@ def cleanup_bisect(): print() print(' Executable failed to run.') print('Failed to search for bad libraries -- cannot continue.') - cleanup_bisect() return bisect_num, None, None, None, 1 print(' bad static libraries:') @@ -1002,7 +991,6 @@ def cleanup_bisect(): print(' Executable failed to run.') print('Failed to search for bad sources -- cannot continue.') logging.exception('Failed to search for bad sources.') - cleanup_bisect() return bisect_num, bad_libs, None, None, 1 print(' bad sources:') @@ -1024,7 +1012,6 @@ def cleanup_bisect(): print(' Executable failed to run.') print('Failed to search for bad symbols -- cannot continue') logging.exception('Failed to search for bad symbols.') - cleanup_bisect() return bisect_num, bad_libs, bad_sources, None, 1 print(' bad symbols:') @@ -1038,7 +1025,6 @@ def cleanup_bisect(): print(' None') logging.info(' None') - cleanup_bisect() return bisect_num, bad_libs, bad_sources, bad_symbols, 0 def auto_bisect_worker(arg_queue, result_queue): From 8274afca5a5d57c14c1806724cd7c22a45bf724f Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 13:44:21 -0600 Subject: [PATCH 073/166] bisect: only have 80 character wide lines --- scripts/flitcli/flit_bisect.py | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index e05888d2..b64d51a5 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -188,12 +188,14 @@ def create_bisect_makefile(directory, replacements, gt_src, trouble_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']]) + 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']]) + repl_copy['EXTRA_LD_FLAGS'] = '\n'.join([ + 'LD_REQUIRED += {0}'.format(x) + for x in repl_copy['link_flags']]) del repl_copy['link_flags'] @@ -317,7 +319,8 @@ def is_result_bad(resultfile): SymbolTuple = namedtuple('SymbolTuple', 'src, symbol, demangled, fname, lineno') SymbolTuple.__doc__ = ''' -Tuple containing information about the symbols in a file. Has the following attributes: +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 @@ -374,19 +377,19 @@ def extract_symbols(file_or_filelist, objdir): symbol_line_mapping = dict() symbol = None for line in objdump_strings: - if len(line.strip()) == 0: # skip empty lines + if len(line.strip()) == 0: # skip empty lines continue - if line[0].isdigit(): # we are at a symbol + 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 + 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 + symbol = None # deactivate the symbol to not overwrite # generate the symbol tuples @@ -676,7 +679,8 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): for lib in trouble_libs: logging.info(' ' + lib) - build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs) if args.delete: build_bisect(makepath, args.directory, target='bisect-smallclean', verbose=args.verbose, jobs=args.jobs) @@ -726,7 +730,8 @@ def bisect_build_and_check(trouble_src, gt_src): for src in trouble_src: logging.info(' ' + src) - build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs) if args.delete: build_bisect(makepath, args.directory, target='bisect-smallclean', verbose=args.verbose, jobs=args.jobs) @@ -747,7 +752,8 @@ def bisect_build_and_check(trouble_src, gt_src): bad_sources = bisect_search(bisect_build_and_check, sources) return bad_sources -def search_for_symbol_problems(args, bisect_path, replacements, sources, bad_sources): +def search_for_symbol_problems(args, bisect_path, replacements, sources, + bad_sources): ''' Performs the search over the space of symbols within bad source files for problems. @@ -792,7 +798,8 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' .format(sym=sym)) - build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs) if args.delete: build_bisect(makepath, args.directory, target='bisect-smallclean', verbose=args.verbose, jobs=args.jobs) @@ -812,7 +819,8 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): 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_sources, os.path.join(args.directory, 'obj')) + symbol_tuples = extract_symbols(bad_sources, + os.path.join(args.directory, 'obj')) for sym in symbol_tuples: message = ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' \ .format(sym=sym) From 0a79b99047e97cf1c6a7cdff81008309a1b06005 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 14:28:29 -0600 Subject: [PATCH 074/166] bisect: compile object files first for parallel run --- scripts/flitcli/flit_bisect.py | 98 +++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 20 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index b64d51a5..177aab72 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -104,6 +104,10 @@ 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 @@ -152,8 +156,9 @@ def create_bisect_dir(parent): else: return bisect_dir -def create_bisect_makefile(directory, replacements, gt_src, trouble_src, - split_symbol_map): +def create_bisect_makefile(directory, replacements, gt_src, + trouble_src=[], + split_symbol_map=dict()): ''' 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 @@ -287,7 +292,6 @@ def update_gt_results(directory, verbose=False, @param directory: where to execute make @param verbose: False means block output from GNU make and running ''' - sys.stdout.flush() kwargs = dict() if not verbose: kwargs['stdout'] = subp.DEVNULL @@ -295,8 +299,7 @@ def update_gt_results(directory, verbose=False, gt_resultfile = util.extract_make_var( 'GT_OUT', os.path.join(directory, 'Makefile'))[0] logging.info('Updating ground-truth results - {0}'.format(gt_resultfile)) - print('Updating ground-truth results -', gt_resultfile, end='') - sys.stdout.flush() + print('Updating ground-truth results -', gt_resultfile, end='', flush=True) subp.check_call( ['make', '-j', str(jobs), '-C', directory, gt_resultfile], **kwargs) print(' - done') @@ -588,8 +591,11 @@ def parse_args(arguments, prog=sys.argv[0]): 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, but the bisect runs may - be parallelized if the user desires so. + 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=''' @@ -602,7 +608,8 @@ def parse_args(arguments, prog=sys.argv[0]): 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 not used when executing the tests, just in + compilation. ''') parser.add_argument('-d', '--delete', action='store_true', help=''' @@ -671,9 +678,8 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): [], dict()) makepath = os.path.join(bisect_path, makefile) - sys.stdout.write(' Create {0} - compiling and running' \ - .format(makepath)) - sys.stdout.flush() + print(' Create {0} - compiling and running'.format(makepath), + end='', flush=True) logging.info('Created {0}'.format(makepath)) logging.info('Checking:') for lib in trouble_libs: @@ -722,9 +728,8 @@ def bisect_build_and_check(trouble_src, gt_src): trouble_src, dict()) makepath = os.path.join(bisect_path, makefile) - sys.stdout.write(' Created {0} - compiling and running' \ - .format(makepath)) - sys.stdout.flush() + print(' Created {0} - compiling and running'.format(makepath), end='', + flush=True) logging.info('Created {0}'.format(makepath)) logging.info('Checking:') for src in trouble_src: @@ -788,9 +793,8 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): trouble_src, symbol_map) makepath = os.path.join(bisect_path, makefile) - sys.stdout.write(' Created {0} - compiling and running' \ - .format(makepath)) - sys.stdout.flush() + print(' Created {0} - compiling and running'.format(makepath), end='', + flush=True) logging.info('Created {0}'.format(makepath)) logging.info('Checking:') for sym in trouble_symbols: @@ -829,6 +833,50 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): 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 because + ''' + # 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': [], + } + 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. @@ -848,9 +896,7 @@ def run_bisect(arguments, prog=sys.argv[0]): ''' args = parse_args(arguments, prog) - # our hash is the first 10 digits of a sha1 sum - trouble_hash = hashlib.sha1( - (args.compiler + args.optl + args.switches).encode()).hexdigest()[:10] + 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 @@ -1174,6 +1220,18 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): resultsfile.flush() rows = query.fetchall() + compilation_set = {(row['compiler'], row['optl'], row['switches']) + for row in rows} + + print('Before parallel bisect run, compile all object files') + for compiler, optl, switches in compilation_set: + print(' ' + ' '.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) From 400c844781c5e53150975ebf768a6110ae941173 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 14:32:22 -0600 Subject: [PATCH 075/166] bisect: Store fPIC object files in bisect directory (no sharing) This is because this was also a race. We also will not know which files need to be compiled with fPIC, so it (1) has minimal sharing so not large impact, and (2) precompiling them will cause us to potentially create way more object files than necessary. --- data/Makefile_bisect_binary.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 57dcd43c..6e682b92 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -209,7 +209,7 @@ $(BISECT_OBJ_DIR): # ground-truth files are already specified in Makefile # but need to specify how to do the fPIC variant -$(OBJ_DIR)/%_gt_fPIC.o: %.cpp Makefile custom.mk | $(OBJ_DIR) +$(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)"' \ @@ -228,7 +228,7 @@ $(OBJ_DIR)/%_bisect_$(TROUBLE_ID).o: %.cpp Makefile custom.mk | $(OBJ_DIR) -DFLIT_FILENAME='"bisect-default-out"' # and the fPIC variant -$(OBJ_DIR)/%_bisect_$(TROUBLE_ID)_fPIC.o: %.cpp Makefile custom.mk | $(OBJ_DIR) +$(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)"' \ @@ -242,33 +242,33 @@ $(OBJ_DIR)/%_bisect_$(TROUBLE_ID)_fPIC.o: %.cpp Makefile custom.mk | $(OBJ_DIR) # @param 1: src basename (e.g. for 'tests/Example01.cpp' pass in 'Example01') define SPLIT_RULE -$$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o: $$(OBJ_DIR)/$1_gt_fPIC.o +$$(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 \ - $$(OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_fPIC.o \ $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ else \ cp \ - $$(OBJ_DIR)/$1_gt_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_gt_fPIC.o \ $$(BISECT_OBJ_DIR)/$1_gt_split_$$(NUMBER).o; \ fi -$$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o: $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o +$$(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 \ - $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ else \ cp \ - $$(OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ + $$(BISECT_OBJ_DIR)/$1_bisect_$$(TROUBLE_ID)_fPIC.o \ $$(BISECT_OBJ_DIR)/$1_trouble_split_$$(NUMBER).o; \ fi From 17de306e01d25e6fccd76ee9b6daa0880d0ed6ac Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 14:40:26 -0600 Subject: [PATCH 076/166] bisect: remove fPIC file with bisect-smallclean target --- data/Makefile_bisect_binary.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 6e682b92..d751f010 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -133,6 +133,10 @@ TROUBLE_OBJ := $(addprefix \ 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))) SPLIT_OBJ := $(addprefix \ $(BISECT_OBJ_DIR)/,$(notdir $(SPLIT_SRC:%.cpp=%_gt_split_$(NUMBER).o))) SPLIT_OBJ += $(addprefix \ @@ -189,6 +193,7 @@ bisect-smallclean: rm -f $(addsuffix *.dat,$(TROUBLE_TARGET_OUT)) rm -f $(TROUBLE_SYMBOLS) rm -f $(SPLIT_OBJ) + rm -f $(FPIC_OBJ) -rmdir $(BISECT_OBJ_DIR) bisect-clean: bisect-smallclean From 8e99587e4a5cb7919fbd5b13893b54f33c07d27d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 14:40:45 -0600 Subject: [PATCH 077/166] bisect: for parallel, update the Makefile first --- scripts/flitcli/flit_bisect.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 177aab72..695c5f29 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1223,6 +1223,11 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): 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 compiler, optl, switches in compilation_set: print(' ' + ' '.join((compiler, optl, switches)), end='', From ce9dfb350a5f8142f26982f0d816caf7856ca4cc Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 15:03:57 -0600 Subject: [PATCH 078/166] bisect: for --delete remove precompiled object files --- scripts/flitcli/flit_bisect.py | 111 +++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 48 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 695c5f29..ff17b28c 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1195,11 +1195,55 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): print('Error:', sqlitefile, 'is not an sqlite3 file') return 1 + query = connection.execute( + 'select * from tests where comparison_d!=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 compiler, optl, switches in compilation_set: + print(' ' + ' '.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): + p = mp.Process(target=auto_bisect_worker, + args=(arg_queue, result_queue)) + p.start() + workers.append(p) + return_tot = 0 with open('auto-bisect.csv', 'w') as resultsfile: writer = csv.writer(resultsfile) - query = connection.execute( - 'select * from tests where comparison_d!=0.0') writer.writerow([ 'testid', 'bisectnum', @@ -1212,50 +1256,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): 'name', 'return', ]) - precision_map = { - 'f': 'float', - 'd': 'double', - 'e': 'long double', - } resultsfile.flush() - rows = query.fetchall() - - 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 compiler, optl, switches in compilation_set: - print(' ' + ' '.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): - p = mp.Process(target=auto_bisect_worker, - args=(arg_queue, result_queue)) - p.start() - workers.append(p) # Process the results for _ in range(rowcount): @@ -1291,9 +1292,23 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): ]) resultsfile.flush() - # Join the workers - for p in workers: - p.join() + # Join the workers + for p in workers: + p.join() + + # Remove the files that were precompiled + if args.delete: + for row in rows: + hashval = hash_compilation(row['compiler'], row['optl'], + row['switches']) + basename = os.path.join(args.directory, 'obj', + '*_bisect_' + hashval) + filelist = itertools.chain( + glob.iglob(basename + '.d'), + glob.iglob(basename + '.o'), + ) + for fname in filelist: + os.remove(fname) return return_tot From 54ba77eb2d35ae174a4137560c49c6b85c2a14ef Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 15:16:08 -0600 Subject: [PATCH 079/166] bisect: for --parallel, fix precompile to only build target --- data/Makefile_bisect_binary.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index d751f010..6bda2b63 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -173,9 +173,9 @@ $(BISECT_TARGET): $(BISECT_OBJ) $(SPLIT_OBJ) Makefile custom.mk | $(BISECT_DIR) $(TROUBLE_TARGET): $(TROUBLE_TARGET_OBJ) Makefile custom.mk | $(BISECT_DIR) $(TROUBLE_CC) $(CC_REQUIRED) -o $@ $(TROUBLE_TARGET_OBJ) $(LD_REQUIRED) -.PHONY: trouble -trouble: $(TROUBLE_TARGET) $(GT_TARGET) -trouble: $(TROUBLE_TARGET_RESULT) $(TROUBLE_TARGET_OUT) +.PHONY: trouble trouble-out +trouble: $(TROUBLE_TARGET) +trouble-out: $(TROUBLE_TARGET_RESULT) $(TROUBLE_TARGET_OUT) .PHONY: bisect bisect: $(BISECT_TARGET) $(GT_TARGET) From a8826c6a3269b605a2a8c5749885834607c6053a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 15:18:59 -0600 Subject: [PATCH 080/166] bisect: sort compilation for precompiling --- scripts/flitcli/flit_bisect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index ff17b28c..321b155a 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1213,7 +1213,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): stdout=subp.DEVNULL, stderr=subp.DEVNULL) print('Before parallel bisect run, compile all object files') - for compiler, optl, switches in compilation_set: + for compiler, optl, switches in sorted(compilation_set): print(' ' + ' '.join((compiler, optl, switches)), end='', flush=True) compile_trouble(args.directory, compiler, optl, switches, From d8d0850e132b80f718d0e6aee7b0a87d792e4b87 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 15:35:00 -0600 Subject: [PATCH 081/166] bisect: precompile feedback of progress --- scripts/flitcli/flit_bisect.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 321b155a..aef391f8 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1213,8 +1213,11 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): stdout=subp.DEVNULL, stderr=subp.DEVNULL) print('Before parallel bisect run, compile all object files') - for compiler, optl, switches in sorted(compilation_set): - print(' ' + ' '.join((compiler, optl, switches)), end='', + for i, compilation in sorted(compilation_set): + compiler, optl, switches = compilation + print(' ({0} of {1})'.format(i, len(compilation_set)), + ' '.join((compiler, optl, switches)), + end='', flush=True) compile_trouble(args.directory, compiler, optl, switches, verbose=args.verbose, jobs=args.jobs, From 80bf3642a0843ddf69075a0810e4c782ba07dc17 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 15:37:13 -0600 Subject: [PATCH 082/166] bisect: fix syntax error --- scripts/flitcli/flit_bisect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index aef391f8..84545a32 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1213,7 +1213,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): stdout=subp.DEVNULL, stderr=subp.DEVNULL) print('Before parallel bisect run, compile all object files') - for i, compilation in sorted(compilation_set): + for i, compilation in enumerate(sorted(compilation_set)): compiler, optl, switches = compilation print(' ({0} of {1})'.format(i, len(compilation_set)), ' '.join((compiler, optl, switches)), From 5c608244a8782a0d938d11eddf933a09d413f25a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 12 Apr 2018 15:39:14 -0600 Subject: [PATCH 083/166] bisect: precompile, small change on console output --- scripts/flitcli/flit_bisect.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 84545a32..cb6dc40a 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1215,14 +1215,14 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): 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, len(compilation_set)), - ' '.join((compiler, optl, switches)), + 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) + print(' done', flush=True) # Update ground-truth results before launching workers update_gt_results(args.directory, verbose=args.verbose, jobs=args.jobs) From ab3555f5c0722912f7212feb117b8874d8c2f424 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 24 Apr 2018 10:41:36 -0600 Subject: [PATCH 084/166] bisect: revert intel libs to be static libs This means revert to absolute paths since it is possible to link against the shared library instead of the static one, which would cause a runtime error since there is no rpath. Another solution could have been to add an rpath, but there should be no need since it should be equivalent to link to the static library or the shared library. --- scripts/flitcli/flit_bisect.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index cb6dc40a..e3ec1893 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1021,16 +1021,7 @@ def run_bisect(arguments, prog=sys.argv[0]): # If the libraries weren't a problem, then include them for the # following searches. if len(bad_libs) == 0: - replacements['link_flags'].extend([ - '-L' + intel_lib_dir, - '-ldecimal', - '-limf', - '-lipgo', - '-lirc_s', - '-lirc', - '-lirng', - '-lsvml', - ]) + replacements['link_flags'].extend(libs) # TODO: Handle the case where the ground-truth compiler is also an intel # TODO- compiler. From ede3fba56c8f62f672af5da9780d7878431cebbd Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 11 May 2018 15:09:52 -0600 Subject: [PATCH 085/166] bisect: rebuild local gtrun for intel library problems This is so that the bisect file search is capable of getting further The libraries cause at least part of the variability. By resetting the ground-truth results and executable to have the variability introduced by the static libraries, we can isolate further, at least to the file bisect step. The symbol bisect with intel is still a little unstable because of the inline function problem. --- data/Makefile_bisect_binary.in | 33 +++++++++++++++++++++++++++++++++ scripts/flitcli/flit_bisect.py | 16 +++++++++++----- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 6bda2b63..4bb593f0 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -124,6 +124,8 @@ SPLIT_SRC := {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 \ @@ -160,6 +162,35 @@ $(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. +ifeq ($(BUILD_GT_LOCAL),true) + +GT_LIB_TARGET := $(BISECT_DIR)/gtrun-lib +GT_LIB_OUT := $(BISECT_DIR)/gtrun-lib-out + +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) + ./$(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) + ./$(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) $(BISECT_OUT): $(BISECT_TARGET) | $(BISECT_DIR) @@ -198,6 +229,8 @@ bisect-smallclean: bisect-clean: bisect-smallclean rm -f $(TROUBLE_TARGET_OBJ) + rm -f $(GT_LIB_TARGET) + rm -f $(GT_LIB_OUT) bisect-distclean: bisect-clean rm -f bisect.log diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index e3ec1893..e6cf3ef7 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -946,6 +946,7 @@ def run_bisect(arguments, prog=sys.argv[0]): 'trouble_id': trouble_hash, 'link_flags': [], 'cpp_flags': [], + 'build_gt_local': 'false', } update_gt_results(args.directory, verbose=args.verbose, jobs=args.jobs) @@ -1011,17 +1012,22 @@ def run_bisect(arguments, prog=sys.argv[0]): # 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' + message = 'May not be able to search further, because of intel optimizations' print(message) logging.info(message) # TODO: Can we instead compare against the ground truth compilation # TODO- with the intel linking? That is instead of giving up. - # If the libraries weren't a problem, then include them for the - # following searches. - if len(bad_libs) == 0: - replacements['link_flags'].extend(libs) + # 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' # TODO: Handle the case where the ground-truth compiler is also an intel # TODO- compiler. From 52415bdd1195ce5e74bc5bf6477105c716386a16 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 11 May 2018 16:10:14 -0600 Subject: [PATCH 086/166] bisect: fix auto run from last commit --- scripts/flitcli/flit_bisect.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index e6cf3ef7..0dc06fde 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -865,6 +865,7 @@ def compile_trouble(directory, compiler, optl, switches, verbose=False, '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) From bb3233516f357f524ebe6812d0d2f557afb10cbc Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 16 May 2018 21:26:03 -0600 Subject: [PATCH 087/166] bisect: fix missing imports and pylint warnings --- scripts/flitcli/flit_bisect.py | 105 ++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 0dc06fde..f633ef03 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -89,7 +89,9 @@ import argparse import csv import datetime +import glob import hashlib +import itertools import logging import multiprocessing as mp import os @@ -157,8 +159,8 @@ def create_bisect_dir(parent): return bisect_dir def create_bisect_makefile(directory, replacements, gt_src, - trouble_src=[], - split_symbol_map=dict()): + 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 @@ -185,6 +187,8 @@ def create_bisect_makefile(directory, replacements, gt_src, @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]) @@ -220,7 +224,7 @@ def create_bisect_makefile(directory, replacements, gt_src, repl_copy['makefile'] = makepath repl_copy['number'] = '{0:02d}'.format(num) - logging.info('Creating makefile: ' + makepath) + logging.info('Creating makefile: %s', makepath) util.process_in_file( os.path.join(conf.data_dir, 'Makefile_bisect_binary.in'), makepath, @@ -298,7 +302,7 @@ def update_gt_results(directory, verbose=False, kwargs['stderr'] = subp.DEVNULL gt_resultfile = util.extract_make_var( 'GT_OUT', os.path.join(directory, 'Makefile'))[0] - logging.info('Updating ground-truth results - {0}'.format(gt_resultfile)) + 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) @@ -466,28 +470,28 @@ def bisect_search(is_bad, elements): while len(quest_list) > 0 and is_bad(quest_list, known_list): # find one bad element - Q = quest_list + quest_copy = quest_list no_test = list(known_list) - while len(Q) > 1: + while len(quest_copy) > 1: # split the questionable list into two lists - Q1 = Q[:len(Q) // 2] - Q2 = Q[len(Q) // 2:] - if is_bad(Q1, no_test + Q2): - Q = Q1 - no_test.extend(Q2) + half_1 = quest_copy[:len(quest_copy) // 2] + half_2 = quest_copy[len(quest_copy) // 2:] + if is_bad(half_1, no_test + half_2): + quest_copy = half_1 + no_test.extend(half_2) # TODO: possible optimization. - # TODO- if the length of Q2 is big enough, test - # TODO- is_bad(Q2, no_test + Q1) - # TODO- and if that returns False, then mark Q2 as known so + # 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 Q1 as known, so that we don't need to + # optimization: mark half_1 as known, so that we don't need to # search it again - quest_list = quest_list[len(Q1):] - known_list.extend(Q1) + quest_list = quest_list[len(half_1):] + known_list.extend(half_1) # update the local search - Q = Q2 - no_test.extend(Q1) + quest_copy = half_2 + no_test.extend(half_1) bad_element = quest_list.pop(0) @@ -660,13 +664,14 @@ def search_for_linker_problems(args, bisect_path, replacements, sources, libs): the libraries included, and checks to see if there are reproducibility problems. ''' - def bisect_libs_build_and_check(trouble_libs, ignore_libs): + 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 ignore_libs: static libraries to ignore and not include + @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. @@ -680,10 +685,10 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): print(' Create {0} - compiling and running'.format(makepath), end='', flush=True) - logging.info('Created {0}'.format(makepath)) + logging.info('Created %s', makepath) logging.info('Checking:') for lib in trouble_libs: - logging.info(' ' + lib) + logging.info(' %s', lib) build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) @@ -697,7 +702,7 @@ def bisect_libs_build_and_check(trouble_libs, ignore_libs): result_str = 'bad' if result_is_bad else 'good' sys.stdout.write(' - {0}\n'.format(result_str)) - logging.info('Result was {0}'.format(result_str)) + logging.info('Result was %s', result_str) return result_is_bad @@ -730,10 +735,10 @@ def bisect_build_and_check(trouble_src, gt_src): print(' Created {0} - compiling and running'.format(makepath), end='', flush=True) - logging.info('Created {0}'.format(makepath)) + logging.info('Created %s', makepath) logging.info('Checking:') for src in trouble_src: - logging.info(' ' + src) + logging.info(' %s', src) build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs) @@ -747,7 +752,7 @@ def bisect_build_and_check(trouble_src, gt_src): result_str = 'bad' if result_is_bad else 'good' sys.stdout.write(' - {0}\n'.format(result_str)) - logging.info('Result was {0}'.format(result_str)) + logging.info('Result was %s', result_str) return result_is_bad @@ -795,10 +800,11 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): print(' Created {0} - compiling and running'.format(makepath), end='', flush=True) - logging.info('Created {0}'.format(makepath)) + 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)) @@ -814,7 +820,7 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): result_str = 'bad' if result_is_bad else 'good' sys.stdout.write(' - {0}\n'.format(result_str)) - logging.info('Result was {0}'.format(result_str)) + logging.info('Result was %s', result_str) return result_is_bad @@ -828,7 +834,7 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): for sym in symbol_tuples: message = ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' \ .format(sym=sym) - logging.info(message) + logging.info('%s', message) bad_symbols = bisect_search(bisect_symbol_build_and_check, symbol_tuples) return bad_symbols @@ -836,7 +842,10 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_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 because + 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) @@ -922,18 +931,18 @@ def run_bisect(arguments, prog=sys.argv[0]): level=logging.DEBUG) logging.info('Starting the bisect procedure') - logging.debug(' trouble compiler: "{0}"'.format(args.compiler)) - logging.debug(' trouble optimization level: "{0}"'.format(args.optl)) - logging.debug(' trouble switches: "{0}"'.format(args.switches)) - logging.debug(' trouble testcase: "{0}"'.format(args.testcase)) - logging.debug(' trouble hash: "{0}"'.format(trouble_hash)) + 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(' ' + source) + logging.debug(' %s', source) replacements = { 'bisect_dir': bisect_dir, @@ -956,7 +965,7 @@ def run_bisect(arguments, prog=sys.argv[0]): bad_libs = [] if os.path.basename(args.compiler) in ('icc', 'icpc'): warning_message = 'Warning: The intel compiler may not work with bisect' - logging.info(warning_message) + logging.info('%s', warning_message) print(warning_message) if '/' in args.compiler: @@ -995,7 +1004,7 @@ def run_bisect(arguments, prog=sys.argv[0]): logging.info('BAD STATIC LIBRARIES:') for lib in bad_libs: print(' ' + lib) - logging.info(' ' + lib) + logging.info(' %s', lib) if len(bad_libs) == 0: print(' None') logging.info(' None') @@ -1015,7 +1024,7 @@ def run_bisect(arguments, prog=sys.argv[0]): if len(bad_libs) > 0: message = 'May not be able to search further, because of intel optimizations' print(message) - logging.info(message) + logging.info('%s', message) # TODO: Can we instead compare against the ground truth compilation # TODO- with the intel linking? That is instead of giving up. @@ -1049,7 +1058,7 @@ def run_bisect(arguments, prog=sys.argv[0]): logging.info('BAD SOURCES:') for src in bad_sources: print(' ' + src) - logging.info(' ' + src) + logging.info(' %s', src) if len(bad_sources) == 0: print(' None') logging.info(' None') @@ -1072,7 +1081,7 @@ def run_bisect(arguments, prog=sys.argv[0]): message = ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' \ .format(sym=sym) print(' ' + message) - logging.info(message) + logging.info('%s', message) if len(bad_symbols) == 0: print(' None') logging.info(' None') @@ -1237,10 +1246,10 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): # Create the workers workers = [] for _ in range(args.parallel): - p = mp.Process(target=auto_bisect_worker, - args=(arg_queue, result_queue)) - p.start() - workers.append(p) + 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: @@ -1294,8 +1303,8 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): resultsfile.flush() # Join the workers - for p in workers: - p.join() + for process in workers: + process.join() # Remove the files that were precompiled if args.delete: From 26ea837041b66a62f8e0874e89650e425e9a3a39 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 16 May 2018 22:30:03 -0600 Subject: [PATCH 088/166] bisect: bisect search optimization on leaf nodes --- scripts/flitcli/flit_bisect.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index f633ef03..f466d6a2 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -472,11 +472,13 @@ def bisect_search(is_bad, elements): # 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:] - if is_bad(half_1, no_test + half_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. @@ -495,9 +497,8 @@ def bisect_search(is_bad, elements): bad_element = quest_list.pop(0) - # TODO: only double check if the last check was False # double check that we found a bad element before declaring it bad - if is_bad([bad_element], known_list + quest_list): + 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 From d9e53bff3ffd402c697b44c0f01bb5bbd6a7493d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 16 May 2018 22:37:15 -0600 Subject: [PATCH 089/166] bisect: cleanup some todo statements --- data/Makefile_bisect_binary.in | 3 ++- scripts/flitcli/flit_bisect.py | 23 +++-------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 4bb593f0..6a1821ef 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -168,11 +168,12 @@ endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac # executable, then simply set BUILD_GT_LOCAL=true. This generates # $(BISECT_DIR)/gtrun-lib that will be the ground truth for this bisect # execution. -ifeq ($(BUILD_GT_LOCAL),true) 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 diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index f466d6a2..e6db08f7 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1010,26 +1010,14 @@ def run_bisect(arguments, prog=sys.argv[0]): print(' None') logging.info(' None') - #replacements['link_flags'].extend([ - # '-L' + intel_lib_dir, - # '-lirc', - # '-lsvml', - # ]) - - # TODO: If the linker is to blame, remove it from the equation for - # TODO- future searching This is done simply by using the ground-truth - # TODO- compiler to link instead of using the trouble compiler to link. - # 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' + message = 'May not be able to search further, because of intel ' \ + 'optimizations' print(message) logging.info('%s', message) - # TODO: Can we instead compare against the ground truth compilation - # TODO- with the intel linking? That is instead of giving up. - # Compile all following executables with these static libraries # regardless of their effect replacements['link_flags'].extend(libs) @@ -1040,11 +1028,6 @@ def run_bisect(arguments, prog=sys.argv[0]): if len(bad_libs) > 0: replacements['build_gt_local'] = 'true' - # TODO: Handle the case where the ground-truth compiler is also an intel - # TODO- compiler. - # TODO: Extra care must be taken when there is more than one intel linker - # TODO- specified. - try: bad_sources = search_for_source_problems(args, bisect_path, replacements, sources) @@ -1204,7 +1187,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): return 1 query = connection.execute( - 'select * from tests where comparison_d!=0.0') + 'select * from tests where comparison_d != 0.0') rows = query.fetchall() precision_map = { 'f': 'float', From a1ea118e816dc3860001b5a9bb5618936280ae5f Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 16 May 2018 22:40:31 -0600 Subject: [PATCH 090/166] bisect: clean bisect runs afterward using makefile --- scripts/flitcli/flit_bisect.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index e6db08f7..60a6b68f 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1292,17 +1292,21 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): # Remove the files that were precompiled if args.delete: - for row in rows: - hashval = hash_compilation(row['compiler'], row['optl'], - row['switches']) - basename = os.path.join(args.directory, 'obj', - '*_bisect_' + hashval) - filelist = itertools.chain( - glob.iglob(basename + '.d'), - glob.iglob(basename + '.o'), - ) - for fname in filelist: - os.remove(fname) + for makepath in glob.iglob('bisect-*/bisect-make-01.mk'): + build_bisect(makepath, args.directory, verbose=args.verbose, + jobs=args.jobs, target='bisect-clean') + # TODO: test that these files are deleted with the above Makefile calls + #for row in rows: + # hashval = hash_compilation(row['compiler'], row['optl'], + # row['switches']) + # basename = os.path.join(args.directory, 'obj', + # '*_bisect_' + hashval) + # filelist = itertools.chain( + # glob.iglob(basename + '.d'), + # glob.iglob(basename + '.o'), + # ) + # for fname in filelist: + # os.remove(fname) return return_tot From d3086c8e087c120637fcec2ddaed26bd9a24fb03 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 17 May 2018 00:15:07 -0600 Subject: [PATCH 091/166] bisect: add fpic and split dependency files --- data/Makefile_bisect_binary.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 6a1821ef..ee95d35c 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -139,11 +139,13 @@ 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))) @@ -193,6 +195,8 @@ 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) ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing @@ -224,14 +228,18 @@ bisect-smallclean: rm -f $(TROUBLE_TARGET_OUT) rm -f $(addsuffix *.dat,$(TROUBLE_TARGET_OUT)) rm -f $(TROUBLE_SYMBOLS) - rm -f $(SPLIT_OBJ) 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) + -rmdir $(BISECT_OBJ_DIR) bisect-distclean: bisect-clean rm -f bisect.log From f5b62381a321ead74ef815d9ecd95b117641354b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 17 May 2018 00:15:43 -0600 Subject: [PATCH 092/166] bisect: call bisect-smallclean even when errors happen --- scripts/flitcli/flit_bisect.py | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 60a6b68f..6a436823 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -691,11 +691,13 @@ def bisect_libs_build_and_check(trouble_libs, dummy_libs): for lib in trouble_libs: logging.info(' %s', lib) - build_bisect(makepath, args.directory, verbose=args.verbose, - jobs=args.jobs) - if args.delete: - build_bisect(makepath, args.directory, target='bisect-smallclean', - verbose=args.verbose, jobs=args.jobs) + 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) @@ -741,11 +743,13 @@ def bisect_build_and_check(trouble_src, gt_src): for src in trouble_src: logging.info(' %s', src) - build_bisect(makepath, args.directory, verbose=args.verbose, - jobs=args.jobs) - if args.delete: - build_bisect(makepath, args.directory, target='bisect-smallclean', - verbose=args.verbose, jobs=args.jobs) + 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) @@ -809,11 +813,13 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' .format(sym=sym)) - build_bisect(makepath, args.directory, verbose=args.verbose, - jobs=args.jobs) - if args.delete: - build_bisect(makepath, args.directory, target='bisect-smallclean', - verbose=args.verbose, jobs=args.jobs) + 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) @@ -1319,7 +1325,6 @@ def main(arguments, prog=sys.argv[0]): if '-a' in arguments or '--auto-sqlite-run' in arguments: return parallel_auto_bisect(arguments, prog) - # else: _, _, _, _, ret = run_bisect(arguments, prog) return ret From e8ab72b873111ef04f35a98e55298696d9a3432a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 17 May 2018 00:31:29 -0600 Subject: [PATCH 093/166] bisect: remove GT_LIB_OUT generated dat files --- data/Makefile_bisect_binary.in | 1 + 1 file changed, 1 insertion(+) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index ee95d35c..977766ff 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -239,6 +239,7 @@ bisect-clean: bisect-smallclean 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 From 67cfdd2bc66b5d1fc2e02f0f4939a150f69e8bd0 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 17 May 2018 10:08:23 -0600 Subject: [PATCH 094/166] bisect: remove some commented out code --- scripts/flitcli/flit_bisect.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 6a436823..a1d923d6 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1301,18 +1301,6 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): for makepath in glob.iglob('bisect-*/bisect-make-01.mk'): build_bisect(makepath, args.directory, verbose=args.verbose, jobs=args.jobs, target='bisect-clean') - # TODO: test that these files are deleted with the above Makefile calls - #for row in rows: - # hashval = hash_compilation(row['compiler'], row['optl'], - # row['switches']) - # basename = os.path.join(args.directory, 'obj', - # '*_bisect_' + hashval) - # filelist = itertools.chain( - # glob.iglob(basename + '.d'), - # glob.iglob(basename + '.o'), - # ) - # for fname in filelist: - # os.remove(fname) return return_tot From 53e61bce0b6bdb5be5c11a527c150dae45f8ef2c Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 17 May 2018 12:29:02 -0600 Subject: [PATCH 095/166] Strip out all of the cuda code --- data/Makefile.in | 113 +------ data/custom.mk | 12 - data/tests/Empty.cpp | 29 -- documentation/flit-configuration-file.md | 1 - documentation/litmus-tests.md | 7 +- gensrc/testcase.py | 28 -- inputGen/CUHelpers.cpp | 1 - litmus-tests/disabled/simple_convex_hull.cpp | 4 - litmus-tests/disabled/simple_convex_hull.h | 4 - .../tests/DistributivityOfMultiplication.cpp | 26 -- litmus-tests/tests/DoHariGSBasic.cpp | 36 +-- litmus-tests/tests/DoHariGSImproved.cpp | 31 -- litmus-tests/tests/DoMatrixMultSanity.cpp | 19 -- litmus-tests/tests/DoOrthoPerturbTest.cpp | 48 --- litmus-tests/tests/DoSimpleRotate90.cpp | 22 -- .../tests/DoSkewSymCPRotationTest.cpp | 24 -- litmus-tests/tests/KahanSum.cpp | 2 - litmus-tests/tests/RotateAndUnrotate.cpp | 20 -- litmus-tests/tests/RotateFullCircle.cpp | 21 -- litmus-tests/tests/ShewchukSum.cpp | 2 - litmus-tests/tests/TrianglePHeron.cpp | 41 --- litmus-tests/tests/TrianglePSylv.cpp | 42 --- litmus-tests/tests/langois.cpp | 6 - litmus-tests/tests/tinys.cpp | 42 --- .../config/flit-default-future.toml.in | 2 +- scripts/hostCollect.sh | 5 - scripts/hostCollectEnviro.source | 1 - scripts/hostfile.py | 2 +- scripts/kingspeak_gpu_startup | 3 +- scripts/run_all.py | 1 - src/CUHelpers.cpp | 105 ------ src/CUHelpers.h | 230 ------------- src/MatrixCU.h | 235 -------------- src/TestBase.h | 150 --------- src/VectorCU.h | 302 ------------------ src/cuvector.h | 267 ---------------- src/flit.h | 14 - src/flitHelpers.h | 10 +- tests/flit_makefile/tst_empty_project.py | 4 +- 39 files changed, 10 insertions(+), 1902 deletions(-) delete mode 120000 inputGen/CUHelpers.cpp delete mode 100644 src/CUHelpers.cpp delete mode 100644 src/CUHelpers.h delete mode 100644 src/MatrixCU.h delete mode 100644 src/VectorCU.h delete mode 100644 src/cuvector.h diff --git a/data/Makefile.in b/data/Makefile.in index f1cead7a..aa2a5886 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 @@ -139,45 +138,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' @@ -191,7 +151,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' @@ -217,11 +176,6 @@ 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 endif @@ -363,45 +317,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 - ########################################################## # @@ -509,24 +424,15 @@ TARGET_RESULTS := $(TARGET_OUTS:%=%-comparison.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) -CUTARGET_RESULTS:= $(CUTARGET_OUTS:%=%-comparison.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_RESULTS) $(TARGET_OUTS) -run: $(CUTARGET_RESULTS) $(CUTARGET_OUTS) run: $(GT_OUT) run: runbuild -runbuild: $(TARGETS) $(CUTARGETS) groundtruth +runbuild: $(TARGETS) groundtruth .PHONY: clean clean: @@ -540,15 +446,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 $(CUTARGET_RESULTS) - rm -f $(addsuffix *.dat,$(CUTARGET_OUTS)) - rm -f $(CUTARGETS) rm -f $(GT_TARGET) rm -f $(GT_OUT) rm -f $(addsuffix *.dat,$(GT_OUT)) @@ -576,12 +477,10 @@ cleanlibflit: $(DEV_TARGET): lib/libflit.so $(GT_TARGET): lib/libflit.so $(TARGETS): lib/libflit.so -$(CUTARGETS): 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 endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac # include the build dependencies for gt and dev @@ -606,14 +505,6 @@ $(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) ./$(GT_TARGET) --output $(GT_OUT) --no-timing diff --git a/data/custom.mk b/data/custom.mk index dec800b5..3638e630 100644 --- a/data/custom.mk +++ b/data/custom.mk @@ -86,9 +86,6 @@ # 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,3 @@ LD_REQUIRED += 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/data/tests/Empty.cpp b/data/tests/Empty.cpp index 3b8da6bb..f84d2f13 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 @@ -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/flit-configuration-file.md b/documentation/flit-configuration-file.md index 1e8258b4..2346d163 100644 --- a/documentation/flit-configuration-file.md +++ b/documentation/flit-configuration-file.md @@ -117,7 +117,6 @@ 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. 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/gensrc/testcase.py b/gensrc/testcase.py index f13c7e6a..3dca106c 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 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/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/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..96856799 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 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..956a4705 100644 --- a/litmus-tests/tests/DoHariGSBasic.cpp +++ b/litmus-tests/tests/DoHariGSBasic.cpp @@ -84,37 +84,7 @@ #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,8 +94,6 @@ 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<<; @@ -175,9 +143,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/DoHariGSImproved.cpp b/litmus-tests/tests/DoHariGSImproved.cpp index 31caeedb..2788b092 100644 --- a/litmus-tests/tests/DoHariGSImproved.cpp +++ b/litmus-tests/tests/DoHariGSImproved.cpp @@ -84,34 +84,6 @@ #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,7 +93,6 @@ 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; @@ -160,9 +131,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..ee0299de 100644 --- a/litmus-tests/tests/DoMatrixMultSanity.cpp +++ b/litmus-tests/tests/DoMatrixMultSanity.cpp @@ -87,21 +87,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: @@ -114,10 +99,6 @@ class DoMatrixMultSanity: public flit::TestBase { } 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); diff --git a/litmus-tests/tests/DoOrthoPerturbTest.cpp b/litmus-tests/tests/DoOrthoPerturbTest.cpp index 1768c2b4..83988c8e 100644 --- a/litmus-tests/tests/DoOrthoPerturbTest.cpp +++ b/litmus-tests/tests/DoOrthoPerturbTest.cpp @@ -91,52 +91,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 +106,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<<; diff --git a/litmus-tests/tests/DoSimpleRotate90.cpp b/litmus-tests/tests/DoSimpleRotate90.cpp index 22a07ff7..2d2a7e0b 100644 --- a/litmus-tests/tests/DoSimpleRotate90.cpp +++ b/litmus-tests/tests/DoSimpleRotate90.cpp @@ -85,26 +85,6 @@ #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,8 +96,6 @@ 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]}; diff --git a/litmus-tests/tests/DoSkewSymCPRotationTest.cpp b/litmus-tests/tests/DoSkewSymCPRotationTest.cpp index 468dc2d0..3c0b0305 100644 --- a/litmus-tests/tests/DoSkewSymCPRotationTest.cpp +++ b/litmus-tests/tests/DoSkewSymCPRotationTest.cpp @@ -85,28 +85,6 @@ #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: @@ -120,8 +98,6 @@ class DoSkewSymCPRotationTest: public flit::TestBase { } 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; 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/litmus-tests/tests/RotateAndUnrotate.cpp b/litmus-tests/tests/RotateAndUnrotate.cpp index d93c5231..02cafb29 100644 --- a/litmus-tests/tests/RotateAndUnrotate.cpp +++ b/litmus-tests/tests/RotateAndUnrotate.cpp @@ -86,24 +86,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: @@ -115,8 +97,6 @@ class RotateAndUnrotate: public flit::TestBase { } 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); diff --git a/litmus-tests/tests/RotateFullCircle.cpp b/litmus-tests/tests/RotateFullCircle.cpp index d1a0fb98..a75b76a2 100644 --- a/litmus-tests/tests/RotateFullCircle.cpp +++ b/litmus-tests/tests/RotateFullCircle.cpp @@ -89,25 +89,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: @@ -120,8 +101,6 @@ class RotateFullCircle: public flit::TestBase { } protected: - virtual flit::KernelFunction* getKernel() override {return RFCKern; } - virtual flit::Variant run_impl(const std::vector& ti) override { flit::Vector A = flit::Vector(ti); auto orig = A; diff --git a/litmus-tests/tests/ShewchukSum.cpp b/litmus-tests/tests/ShewchukSum.cpp index ecac3a90..965cc8c3 100644 --- a/litmus-tests/tests/ShewchukSum.cpp +++ b/litmus-tests/tests/ShewchukSum.cpp @@ -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..f9d2c7d2 100644 --- a/litmus-tests/tests/TrianglePSylv.cpp +++ b/litmus-tests/tests/TrianglePSylv.cpp @@ -89,16 +89,6 @@ 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)) * @@ -108,36 +98,6 @@ T getArea(const T a, const T b, const T c) { (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/litmus-tests/tests/langois.cpp b/litmus-tests/tests/langois.cpp index 83c639cd..d1a518e8 100644 --- a/litmus-tests/tests/langois.cpp +++ b/litmus-tests/tests/langois.cpp @@ -131,8 +131,6 @@ 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; @@ -166,8 +164,6 @@ 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; @@ -204,8 +200,6 @@ 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; diff --git a/litmus-tests/tests/tinys.cpp b/litmus-tests/tests/tinys.cpp index 1570ff7d..03fd08df 100644 --- a/litmus-tests/tests/tinys.cpp +++ b/litmus-tests/tests/tinys.cpp @@ -98,8 +98,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 +125,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,8 +141,6 @@ 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; @@ -174,8 +168,6 @@ 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(); @@ -230,8 +222,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 +241,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; @@ -278,8 +266,6 @@ class divc: 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]; return res; @@ -299,8 +285,6 @@ class zeroMinusX: public flit::TestBase { } 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; @@ -320,8 +304,6 @@ class xMinusZero: 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] - T(0.0); return res; @@ -340,8 +322,6 @@ class zeroDivX: public flit::TestBase { return { flit::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; @@ -360,8 +340,6 @@ class xDivOne: public flit::TestBase { return { flit::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; @@ -380,8 +358,6 @@ class xDivNegOne: public flit::TestBase { return { flit::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; @@ -403,8 +379,6 @@ class negAdivB: 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]); return res; @@ -426,8 +400,6 @@ class negAminB: 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]); return res; @@ -447,8 +419,6 @@ class xMinusX: 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[0]; return res; @@ -470,8 +440,6 @@ class negAplusB: 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]); return res; @@ -494,8 +462,6 @@ class aXbDivC: 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; @@ -518,8 +484,6 @@ class aXbXc: 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; @@ -542,8 +506,6 @@ class aPbPc: 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; @@ -568,8 +530,6 @@ class xPc1EqC2: public flit::TestBase { }; } 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; @@ -594,8 +554,6 @@ class xPc1NeqC2: public flit::TestBase { }; } 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/scripts/flitcli/config/flit-default-future.toml.in b/scripts/flitcli/config/flit-default-future.toml.in index 80185f06..dee588d4 100644 --- a/scripts/flitcli/config/flit-default-future.toml.in +++ b/scripts/flitcli/config/flit-default-future.toml.in @@ -135,7 +135,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', diff --git a/scripts/hostCollect.sh b/scripts/hostCollect.sh index 03074443..107228bc 100755 --- a/scripts/hostCollect.sh +++ b/scripts/hostCollect.sh @@ -93,17 +93,12 @@ 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 .. diff --git a/scripts/hostCollectEnviro.source b/scripts/hostCollectEnviro.source index fca400d9..10bc5fe6 100644 --- a/scripts/hostCollectEnviro.source +++ b/scripts/hostCollectEnviro.source @@ -88,4 +88,3 @@ export DB_USER=sawaya export DB_HOST=localhost export FLIT_DIR=src export SLURMED=None -export CUDA_ONLY=False diff --git a/scripts/hostfile.py b/scripts/hostfile.py index d876a609..1e4449fc 100644 --- a/scripts/hostfile.py +++ b/scripts/hostfile.py @@ -83,7 +83,7 @@ #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) +#run_host: (user, fqdn, processes, SlurmScript, get opcode count) import os import multiprocessing diff --git a/scripts/kingspeak_gpu_startup b/scripts/kingspeak_gpu_startup index e78e5a86..4722f7e8 100755 --- a/scripts/kingspeak_gpu_startup +++ b/scripts/kingspeak_gpu_startup @@ -85,7 +85,7 @@ #required: #BRANCH REPO FLIT_DIR CORES DB_USER DB_HOST -#[maybe] CUDA_ONLY and DO_PIN +#[maybe] DO_PIN #SBATCH --time=1:00:00 #SBATCH --nodes=1 @@ -98,7 +98,6 @@ set -e -module load cuda module load gcc #setup working directory diff --git a/scripts/run_all.py b/scripts/run_all.py index bec0a0e6..2b0eeaac 100755 --- a/scripts/run_all.py +++ b/scripts/run_all.py @@ -158,7 +158,6 @@ def runOnAll(cmdStrs): 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]) diff --git a/src/CUHelpers.cpp b/src/CUHelpers.cpp deleted file mode 100644 index 5e7f6fee..00000000 --- a/src/CUHelpers.cpp +++ /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 -- - */ - -#include "CUHelpers.h" -#include "flitHelpers.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; -} - -} // end of namespace flit diff --git a/src/CUHelpers.h b/src/CUHelpers.h deleted file mode 100644 index 82215863..00000000 --- a/src/CUHelpers.h +++ /dev/null @@ -1,230 +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 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" - -#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; -} - -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__) -} - -} // end of namespace flit - -#endif // CU_HELPERS_HPP diff --git a/src/MatrixCU.h b/src/MatrixCU.h deleted file mode 100644 index 0e64b587..00000000 --- a/src/MatrixCU.h +++ /dev/null @@ -1,235 +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 MATRIX_CU_H -#define MATRIX_CU_H - -#include "CUHelpers.h" -#include "VectorCU.h" -#include "cuvector.h" - -namespace flit { - -template -class MatrixCU { - using rdtype = cuvector; - cuvector data; -public: - using vsize_t = typename cuvector::cvs_t; - - 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]; - } - - HOST_DEVICE - inline - rdtype - operator[](vsize_t indx) const { - return data[indx]; - } - - 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; - } - - 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; - } - - 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]; - } - } - } - 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; - } - } - 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]; - } - ++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; - } - y = 0; ++x; - } - return retVal; - } -}; - -} // end of namespace flit - -#endif // MATRIX_CU_H diff --git a/src/TestBase.h b/src/TestBase.h index 6ddde8bb..c57b0a8d 100644 --- a/src/TestBase.h +++ b/src/TestBase.h @@ -90,10 +90,6 @@ #include "flitHelpers.h" -#ifdef __CUDA__ -#include "CUHelpers.h" -#endif // __CUDA__ - #include "timeFunction.h" #include "Variant.h" @@ -154,103 +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: @@ -313,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 { @@ -454,9 +346,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 { @@ -473,20 +362,6 @@ 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 @@ -515,7 +390,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 {}; } }; @@ -562,28 +436,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: \ @@ -601,8 +453,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.h b/src/flit.h index 2a975171..1698303e 100644 --- a/src/flit.h +++ b/src/flit.h @@ -88,17 +88,10 @@ #define FLIT_H 0 #include "Matrix.h" -#include "MatrixCU.h" #include "TestBase.h" #include "Vector.h" -#include "VectorCU.h" #include "flitHelpers.h" -#ifdef __CUDA__ -//#include -#include "CUHelpers.h" -#endif - #include #include #include @@ -474,10 +467,6 @@ inline int runFlitTests(int argc, char* argv[]) { std::cout.precision(1000); //set cout to print many decimal places info_stream.precision(1000); -#ifdef __CUDA__ - initDeviceData(); -#endif - auto testMap = getTests(); for (auto& testName : options.tests) { int idx; @@ -498,9 +487,6 @@ inline int runFlitTests(int argc, char* argv[]) { 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) { diff --git a/src/flitHelpers.h b/src/flitHelpers.h index 511d4bf7..6e470035 100644 --- a/src/flitHelpers.h +++ b/src/flitHelpers.h @@ -89,7 +89,6 @@ #define FLIT_HELPERS_HPP #include "InfoStream.h" -#include "CUHelpers.h" #include #include @@ -115,8 +114,7 @@ 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 +// sequence that can be used by tests template const std::vector @@ -148,7 +146,6 @@ 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 { @@ -158,13 +155,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); @@ -176,7 +171,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 { @@ -186,13 +180,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); diff --git a/tests/flit_makefile/tst_empty_project.py b/tests/flit_makefile/tst_empty_project.py index 64205760..22f3d36a 100644 --- a/tests/flit_makefile/tst_empty_project.py +++ b/tests/flit_makefile/tst_empty_project.py @@ -146,11 +146,9 @@ name,host,compiler,optl,switches,precision,score,score_d,resultfile,comparison,comparison_d,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) ''' From 02d03f930ad56ef3b0e44baa47b375c09c8e3347 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 17 May 2018 12:41:53 -0600 Subject: [PATCH 096/166] Remove cuda from documentation --- documentation/installation.md | 8 ++++---- gensrc/testcase.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/documentation/installation.md b/documentation/installation.md index 6de0a724..800a5ca4 100644 --- a/documentation/installation.md +++ b/documentation/installation.md @@ -63,10 +63,10 @@ symbolic link called `python3` in your `PATH` pointing to that python executable ### Runner Prerequisites 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. +supported from each of the types: GCC, Clang, and Intel's `icpc`. 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. If this is not on the same machine as the Launcher, then the Database machine will need an SSH server running. diff --git a/gensrc/testcase.py b/gensrc/testcase.py index 3dca106c..bc1f74e5 100644 --- a/gensrc/testcase.py +++ b/gensrc/testcase.py @@ -91,7 +91,7 @@ # - default_input: populate ti.vals vector. # - vars_initialize: initialize scope variable for the test using ti.vals # 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" From b42347f68ba026e81e222a19c79a1c7604c5d42e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 17 May 2018 13:59:45 -0600 Subject: [PATCH 097/166] Remove old unused files These were used in the old framework, and either they are irrelevant, or the framework has changed enough that they would need to be almost completely redone anyway. --- R/analyzeOpcodes.R | 170 -- data/db/CreateFlitDBInstaller.sh | 116 -- data/db/InstallFlitDB.sh | 1631 ----------------- data/db/InstallFlitDB.sh.in | 102 -- data/db/README | 8 - data/db/dump_flit.sh | 85 - data/db/matplotlibrc | 510 ------ data/db/psql_commands/create_cleanupResults | 22 - .../db/psql_commands/create_importFLiTResults | 17 - .../psql_commands/create_import_switches.py | 17 - data/db/psql_commands/import_test | 1 - data/db/python/__init__.py | 0 data/db/python/plotting.py | 128 -- data/db/setup_db_host.sh | 205 --- data/db/tables-psql.sql | 974 ---------- pgm/BayesNetworkExamples.r | 176 -- pgm/BayesianNetworks.r | 369 ---- pgm/filter.py | 193 -- plotting/extractor.py | 165 -- plotting/plots/pyplot-intel-diff-by-flag.png | Bin 16614 -> 0 bytes plotting/stats.ipynb | 569 ------ plotting/stats_generator.py | 2 + plotting/tex/plot-intel-diff-by-flag.tex | 225 --- scripts/MakeCollectPin | 121 -- scripts/README | 1 - scripts/hostCollect.sh | 144 -- scripts/hostCollectEnviro.source | 90 - scripts/hostfile.py | 105 -- scripts/kingspeak_cpu_startup | 128 -- scripts/kingspeak_gpu_startup | 116 -- scripts/prepDBHost.py | 126 -- scripts/run_all.py | 403 ---- 32 files changed, 2 insertions(+), 6917 deletions(-) delete mode 100644 R/analyzeOpcodes.R delete mode 100755 data/db/CreateFlitDBInstaller.sh delete mode 100755 data/db/InstallFlitDB.sh delete mode 100644 data/db/InstallFlitDB.sh.in delete mode 100644 data/db/README delete mode 100755 data/db/dump_flit.sh delete mode 100644 data/db/matplotlibrc delete mode 100644 data/db/psql_commands/create_cleanupResults delete mode 100644 data/db/psql_commands/create_importFLiTResults delete mode 100644 data/db/psql_commands/create_import_switches.py delete mode 100644 data/db/psql_commands/import_test delete mode 100644 data/db/python/__init__.py delete mode 100644 data/db/python/plotting.py delete mode 100755 data/db/setup_db_host.sh delete mode 100644 data/db/tables-psql.sql delete mode 100644 pgm/BayesNetworkExamples.r delete mode 100644 pgm/BayesianNetworks.r delete mode 100755 pgm/filter.py delete mode 100755 plotting/extractor.py delete mode 100644 plotting/plots/pyplot-intel-diff-by-flag.png delete mode 100644 plotting/stats.ipynb delete mode 100644 plotting/tex/plot-intel-diff-by-flag.tex delete mode 100644 scripts/MakeCollectPin delete mode 100644 scripts/README delete mode 100755 scripts/hostCollect.sh delete mode 100644 scripts/hostCollectEnviro.source delete mode 100644 scripts/hostfile.py delete mode 100755 scripts/kingspeak_cpu_startup delete mode 100755 scripts/kingspeak_gpu_startup delete mode 100755 scripts/prepDBHost.py delete mode 100755 scripts/run_all.py 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/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/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/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/plots/pyplot-intel-diff-by-flag.png b/plotting/plots/pyplot-intel-diff-by-flag.png deleted file mode 100644 index 3a2bcd0bc4c777d4ef81831a810367d4a8432cf3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16614 zcmd74cT`hd*Do3fMWh)~dQAu@(tD^Xp@gcU(n67r^xjKEAxaM=bW{S0bOfZ6M|zi_ z^d?0JO;CD0@p<0&eD8Pfx#RqC$2j9KM##w8duOjT=WosVn`P(aJ$+63%j}l{002Eg z3;qBAAj6Vg2A8NvBPiNP1JWCX_g%!pOQgS$OSWjzXBrPJ6K?>3_UfM(8DS>u6ae4_ zAmDc%24rvM_^0zf+KZZV_c!s-Tn}$?i)& zdqvUnMC;X!w-Hy>CBawug)a%O9CXzWjLJ$iN`3q`Bhx&0qO|8@wECg^XS456+=>ub zypz>t%@$cs$!ZfzRCPhdN_2jWkBgD$OrNaul;~tNRFoAZo$|D+vxC(}cQbafPRrDk z5QBLtcMmfQCZ;v~RD@_L7!k_M!+z*tW=&gk2t)kJLc~lj7k30BBIqvRbmptQMl?=L z>lkq~Tj}qZxWb?n6dt`5ipE7lmA||>DHkKo>Q6W7H?ZYNX`9V@y~Z)Eg?0J>?-0x} z0*Ih07Xz&z^&GJFbK$AU1oSP4b%#RU{lL)(oI`JTpfRC5>UTJJfeR#2aw&Z_28noH zDt?B=eT2GB@Ap4~EWD~ZvA43Z+Cdu|5rpyn5piJaTy%ho{AA~4*PY!uTpzSl0eE0$ zK_Eg0d9b@ih`cpFjVqvNjdqKiI{zO2+;Uv8Aarvo$Y)|L><0$_4s{)3U75KBdlYt0 z5aWmSSr#uZoq3O#L=f_{r{w(EP7F_{Y+$Q$dLi#{}>u6_?Z z;EV;Ru!FpTeZb#jnm+SvZBJ(3+Q`g<=jjkXITj`hA{xO98C4gTtz_qa3}4~|78E~K z5&_Tw@`cP1rVNKb54nn`@P29+>JqYk^O#9dh|?)=G*G_aSJ@yJXl|<_1&Y!HFC-N-`#0rqDj(1>h~oSSlsLiW~5 z3sn<9$?$yWppeBcbuo|Z{M&x39Qmx}*1_HSl^$r5h42XrcHM|S?kfZ@g7-@eKI4>U zm;ZF?*LKyRmHgcNysb-UjOS7|6(_Y4*)&DTeON2S_WG}>3xMXM!A+Xe=H~-PcucCd zCV-Lbg3=A}n9W|Pl6&`q;himCu*bd+;pj1bu3I{Y&E#r%XIqQ< z&t$v-N*(pP_oD7ndbx<(0r{5T$g;!a=e_5Avu^_Xn$4V!=6maBP{pV=od6!`?(hKO z?8s#UE7&~2D=%8-uz!j9S(Zk?I~OIn7Pl@3x7{UU5cJT-Fk=p1n_1KExp*M$k?I?;jYVnJ|`A&^ls0> zXki~=HRXi+%LE0{X{gT&F%n4gUdKxBm`LWR0-9(8s69B22E$uKL{6(t^8_Q-Bfd?Z zA4EkKa9Eko`$Nyq$(u?=c$A*&#w4?X^WxA?IIwYr*gI+Polqx41YJBy5w{1(~AWU=0*H|NqB<7OJxe7~TI@xolH zR2xX2t=snTzm3Aif?)pCxe%#PG9Ice9wD1-i}6SCVrKE>_m1XDDYjJ#!)~TMrM-al zuxy8_U#$1U+7x)5uPpU_w3x`t(e*e1GDX-$gafi3UY(YLhERrZ9frc>azof!4Y#Cj zZ5MjEIahg9-W}e7&aZj78O|HvmF&VP=dZV+-@U{QbHC5N5ZV6Tdk(_;N7s!-;!g@e zJblR-6B^5{p|z*cG^qiHTovL@i9F=zx`n?@P&yIi)g7A%sLNyM+>5y0BOvQ!UG^RO z*pFC;GqOV~=zy{Tb5y5<){ma<*gg%s@RFhj%mWTB`AMbn__H;~d^nwTfA5~V&6>Y& z(33zTn#PWzYgeYWV8&tFAxGhhsDYl(9Zjiq7xWXCC0I$Tc=HSk-EpsLR$`Mao(2l`B$f1_+M43_ZB>$l3e<%zb@!}-~NjJ2^QJ1 zu{-e%zKtmuXNiE_YCTcd{>Zm=)H51dn3O&l*QcL)=1#7O{nr?IRzTz1w<^4#&42A}(Vh%&hI0Fr zWM4qHBYV$P@NBL-RUu|U%JzvYM+Nfy&Uc3%NU-DM@dc@et-10J%j)Pa+|x`x`qRnfbAuZ5R&I}#KYGG) zVBh>oD>^rW?H|vPUl*T}Ph&b^+l>L7qhEG84K0X>e{CXCt*S zQ5#2!eel~b0K}KC*0*jRcTAS?7>wRFQ+jx$LX%#)`%U6@<|fItNh|D9f$ZxsQBt`{bfTg49*pZz4WP>fqqi<%O~N2c0u zcVtMq9;|r5dlWKQmU()@4 z(WA87pk4PeDek%JkXd2s<1~R2jbc*^URvsr1&|dVVlgVf{l-vpV^z38R+{G9rEPV= zCMEO7Bj0rbpS+AdN#75T)Qz4(1UW2^Q&hcp*HN)hUZy`o9YM+e=wckBd*rQ|%zW_; zBq28O@WI$e9)77tW*s`;?>=>TbmKxgJHJ?5biwK zT)on;#iyhGZGGh>S|oahXNxk8^R3|#ch${zL31$30(%5nUI;u&LSSF=fWQb8Tn5(h z%St(OK#icxd;LzowEnOr+3xJ{2<>UCelIlLZ`wfYqj}Zl$u42I*|yZ?FYUSk4$z}~ z>1LnnZC@xSK8R;rM5@5(EDz`aT;; zY>F;1e>if$3EG+W+1d-14EvPPDZ`l9S=@nH9(N49DJJ~lvl0Db*g;}V`hLh#MXyZT zt5#FVLv$V1<*vd*LJ8(EMA6qk7~8KdTdIet23Pn`iEx9nK5E=uhbqvIs}Wvde()AA zx1G7BdZU)1n>U=E;SMm+1#gY_v{4t~6egIIYR2vBRZdT(v(?t-)Ct0NX2s7BbcQ~7 zh-~9Br0NI@6jSkxtn3hDUM$e5Ri{+(=Osdl&AST!v%IrSHHl~$J7p8 zb8XG)RDRcW4n-RAWm$(wl*Z`%@Zs~Q!_`CMlB=_OkJwc3c zZC(dmK<9q)XiYXW$$iwCL=xos?A|33?fDS2sp}55=RNG0+MD^mR1lqQG9yO=FY$^{ z*9X6zPxK~kJVn_U6J0dobiO^?)H0o+?!FJVERrtRq}_nWn;uHQp1nDq0-_fAl?8~( zy5YL#IxCQckojO+vw7F0J~9(+)_AwxP;Save#@wfYXfF!i)t$2=-@DxfCR74i%BD2 zcIt5Nx|5``$bP;==NYK|P8^Cwzw3T*#$bDM=g$1Ss>pr2Rxz>VG~2F=9NU$P1XLhZ zW6N<9I-RbGDL}@AP|q^nl6^uy;THMx z$B3!7Q>I>c$V_a7nBSbI(}qtYYTLxR_(RBf6=i)hk$YQY!Vaul~Kk&T+U7?eFL2o%G(&d~sTQ8o~rNgzD z>F`XKZQhGvqFlUm^K$X>*_=DIsuLk$jN2eDUh1VAC8|kBf6*_W@Qu_R?4EaJ*v>8G z+bXp*HZ_hM4;>^$dbJo2AF>t7-e~(!U#$?`5QRI6u!(r2l@wf?sr$6yLfbY<)|1^e ztI#0PM*?QLGETIZrqt&7lCyLpvqdW$a}GGQgmaELi`WNfDMV~Ut$r{{5^7G@IxwG~ zMjOA(R+9gKh(1YD<>- z>(J$;rTVT2gQS5PM!gfk!Y6c}URK-q)R^cJ)_dw%!UY9in``P9W`C6dkpesg{ZDay znYPs99FT>Cf{!OJ(TCd0nUxl6Ql06!S3t_{49>%wD%g|miPmu8lUDwz{&!$|55?C} z!T8-~7F~D6`3Ru>A@|wqH#ZeB|NJX?W1_J3<%@K~rrW6{zPXp}Br(kSd{mGA&&`HB zrdz)bbVVfd>+y3zw}yd#k7|v@>A+7@lLijCB-Z_Z{eW1V?T!7cd9L9YVZZA5jLI>J z!8!ddlaKTrwHcq#tINBIUoWXY)2Ov!x9PXi0^2VzgxbVPNRj=wh;_V<6xkMWaj=jM z)z~ar$4V6X{cpqE|8p1Vu6C$FXDF4(bg6O^&^5tt+DKux!|F>8F!$#0?>LE0 zpF|7Un4;(**-qAxJ3)3x@;YNe9{=Vy$lqdvmuGg&UIQ^|o3hqv5kx?qcI!*1RN65y zGqJ=V%lcPn3mx%J=|mKYjEagXNW@0#>w3Qqfedd5+R3S!LvK8^-TSb@&JJSlOfQ7I zM6ZUvtoyQOFM;sZ%4`hDV;ZNZtDI6G>aE@$7*%oYF$s<*#T{_=z*O|{)7 zlM*hum>MTXxFf4g=AiDJusvz~;(wJt_&+Du{~veC$z^3hEJDr2h#MA4bAR+fd^E7k zgr7sL{!1PA*;o*HDbnSbyfoA9!nV`R;s}307l3`>kG7<#b95adGYkqRq~Tj33qgo=M&B7!>d$rT0IN;^ zHIlYiSy@+WV)^d3cQ-2YpK%(~88aKlNk714?EY$`F=%3 zKrDk5y#A{OrEfrQp2RvSgbu&q0T}=pf$pNw7J#kyIw_j6^$GoS$w-hPIk_I>$h3bmvu99hDfs=0NDk)$k{ zO~fzL8M^L0^PMg44AXy!A#-#^k~Cv? zjrNs7f0u{PT>k5hg>2Yi*%(*J?n?iD^c9lXI&0G!^Pb>1yi}2m@jObR zkSIM+H$H*;eu{H= zw)OtejfsY$+C>!FxO8*e61=d7IcEozbJXxAFlYUHjmLJ?P|ZcQb;*xH$^|LPT0V!$T&%nZlQ|nze5z|I@x!iedqnZSHZ&X2`pGTz_5sXe zo{bRrX<$1!P7F8%Z~xR62EjPnJQYxKYeMufFocGnW;fqgfiPJrJP_naJ}qzO1D3LmUQeNms{cK#I7eLn$Ptr zq!M?~-8?`NFx3-{Xs|)y0)1eeTGBi3pBgDIGVdw4{I}~o1`3>{OMeiO-*l6%IL;at z^;Xg+lwn#P>|;}^{hA4X5cEi6YUNirJ_xUGcTwckPx8}jHAYLm;01b288sTM2_1Nl zFG^aMO*+Y-<|a$G)R5SBVco182`$M|ri)(JJg6$rxN@KoFnYAGmt>04?Qty~X>n-9 zzJt_=xZWZi@WKyMiohFQ`O>$gNW1|kt)|H&9T5$diz}p8=PvTB7X^j zcN61u{`-k>IwOA!qf_*G0K$^|apJC%WM~ZMtL1q?^WxmO$ zVSmj=;$38<&l)4Kf7^u|ZqO7xfuHIR;8_h>iTu4C-~}>-4x``ffc4qC|GWz6P1164 zeVvKRrOa(|xqpf2ABm0ENym{aQj%o~9Lz-PY$+X3WYS(2;(_(dn(%YVug#0Jl#>gTvV{xdy- z9!6!>^>0$t_dYfTcXn&ef#ds79<|DKP%&VgoF}!K;OIlbnUerSQWT>iMvNonmfKo6 zdX&KnmY^N%ud|!;_DW5@q(Ibuvy%^11HB%8aSDhEGcpqFJcZNxoE^Fvm{% z7Ey?dXadj@Fe)~sjTgYLyh53{*U4d|S+;fNnF^?WU!{KB@`>9v)`|OpjYi9Uwi{y~ zH!G`^mDTIwAx;{IZ+-ZU3fT(gZK-)Gt2s35{k)erlL+sK-{6JrTJJbk*xd7aivPa; ze?$=rQ`O5_ku;sN4yT-DEFt40pQch`2mR#ibf+XG#IJ(#*q55(bRz!~^#9f-U8iGQ z-xE-!LD4DyMQ*hA;AmU^ObI@W2C)(;F0%t`7Gm$Gg+jk)$+-)9VvzqfE0~g zWmjMPgV|Whw_QW-nNHp$XGf~D5j*ZJ8Ai;J_31Pi5x8eYtw`kg8=YK~)|I;#)f*~@{aQdi(Tnve9{ofnl{C`VVe=IHrH^4swCi)@r*4w416g)@n zi<6`#twyrbUAN0AuaUwPfb)CFzsE>1-?us~cE%8%aXMqR@%sdAUsZ?KTO9Eilm+c; zwm*0!o&NgI7Z|Ih{xh~#I3X~^2$p_h_IyVS*la8U$_sV6e)4wdQ%rFYypRjyZ(%b}3ChsDd z>(y1ikK=g}V}DAb@cCxEiTU5kYxAl3aTO${HA!6uU}Zd&2D@z)Qjttr&b#8!KgCpg z1|_vWVa4Wu$wo-)m!rDPQ>#L8QA}s*5Y4hT8zM$q!I*GaDw(8m$5-*MqIN{`uNE*p zAY{*cx%Z8r(>7Xh=;)N5AL6Hs4C3O^8bo>7zK~?syCHOMY$y@V{)-d7!v~#Ea4yw35D9idSaB052VUV> zP>kds`|18k0SK{|rAUXvPO0W?33D?SWIT?kxr*Hjcp50sjP6i+o5m{>&p%I%QCJHv zzq7M*$)gr0N3IAoBcn!4@;Atp)U52>ANG8Uli?o#ZqS6>A*7iH_=)W9-Lpk}koMlV z%|5c({W8l4NERD|Hk&H{DM#W;U#@Yvve#0Sk^KPr0Y<4UxIj8Orhot?utmx5qsY~X z_HJaOyCi%XN_4*Q05tRia5q zio^S_k7X(Mf#;W+sOo6OuN>;ZL*6kBl_j^7)j#|&@{v3N1AS8rS#SV(a%>~!l@NUg zjsK|a?URtBFa~kK?I%{tXp+9u^iZUtwEClC+cn(twmP&tm;4oDK;3Ih(!k~E%Stpp zIK=y#J7l~>8CzDRyHR!#6_5Vi3((dB+F_aZs|qa3KNEw*Cb%u-gj1DK=2FMMLIWd) z$osI*4DyN2i{xU^>3UQGdH74TJ1NYPs30@BtB52#&M66!`xg-4x}rnKc$Z^iTnN}H zbRKTyjwt?gY^(5^uRD_rU%Nd1O}(uheaIsY3PAN+DcogR$mb<^cio25U8C1b$~Zk* z&V2l?bxl?pf=*buvGc~q=FzQ=`Ju}jl>L;*>C24sxA11&=S7TP&o)e7qBE=^Sqi3e z3E<+>80?uVDh4%iQ}4xD35m62zKz^4lD{6HJ~2meDCi+yK|Ntx`(XJv-jPfN5Ks&ICXPy{tCz#qWjFGOc=99~Z8vuvQBBOgz}4X7>RoC3%f(q=df`I3@J$v!C# zdct`>0d7FQqU>P1VS=Q}+Veu|B{%X~F}AJ+JWoVka=}<+#A45Rv>D2O&nBdLi!mfY zx~Ni+xu~5JvK8wR zIwwp;6lc0kKrB5?7bHtawTU5DrF2WU>imy9aQWMBz20voM5sX);0Pw2-{Wuae0XHQJs_0iHeVN|ZB2BBeTQgRNeBbZl;lmoF^wj|ujt4STreEmmvxcpz)9Uta;>@$Ep zlfAw8R6K@D|J`pOtzl+#H)hAb8}zVL{7^jOOxL{tvO=3hrRzaH2}tPcw2Ds zjfe^}88bV7NsIA9A!NW>ZPkSFFlgfOjjl9`Fv^eyGli&vnlbW*V~2NT$E_J9YwpN> zF+iGYW7xzm6K9Q4ihuTdYXT=rJRnVG_F ze{PrN)EQQ&(+*ZOw=9L1i?CDVI#(-Tn!g^&mZrbPM=Sr4j5<+f!icOGyFFfp^oFJu z_FK3svwYc8Rf1>1wxLzOJ+`XCS-0sbv<0u~|DA(NKqvFnC8u-$i;Y_i#kcBhw*w_mAXuS1MUfE z{+q4damH0aEWq-{&d#jci!Ps(fpL1+` zwvDT#f<>y@PgSj2MW44_#m_~AMkJ8Q0Ts!;eUB&f&frY&^>uCxEV$pWcc2-GgFL4tK1Q-JF9mIxT1&KWjLtiq0|e zYW7xZP;cI0_$xbq!=L}VtUAe??3!vq)utjg`sX5DE}L8qxHSIBYqROwoDVOjg+aqx z7HyO3Vr_b*rcPcM$Q&gA<=1I|U^(80ks6HTcCPd8i z)#n$*K3zA-B-TU-xGvpD>B^9-4ez*mA4}GFf6_=X=k?#H3o5Xw=udKCKVeB_r=6%j z=CbM#Ega6Zwbw(i=$glvUNw$(DLZDGfcq#{m_)bD*WeqPW24{NP|im$w}wY#M^=Mj z1h*uM^>ybtYlu2Q15e7BhI^`4GMOwly%dI?MrGrDy<68EpG66*zCR3{q#IWO?>}sa zvW(oIO^Sm$_Y#qz%O!F!BiOr z&P}UkA=a)kLBrAj7Hl9vU$d#_ZmJbUDez##Q49G5iq_-F@?q){n*J5z+et2V*?-w* zsCN*>xGu5MA2#o6o814dC;osDaU24l9?c9Nc4sq7UQi=&XsJ4yB>~0UFw$bM)$jZ0 zfU-LKz_L90F!-q%L81UqEtJ8n3U+cJkU91JK6ne-xhGdMa4q>pw3^vMaFUON%Dq4* zeF|nu(_9k=kuK*w&#!-PC{jY+`xr9use; z)5Oyz&0glduK=D&a%oV~BZ^*JL#(I9`s<3;$#C{waA+QL2HPE--hfrPSa!%;7OXfgq=GXD-T-AZ!<7)YYxs|JR0V$x^_WXsC##F z{8Cq;tL{$5Cy0}W9G~VlU%T|G6J!*xb_qaLAZJ-bH?5a}Z^|bxsro9csK_S9S>|u; z-qBpQNOEqPR!^g%22VA!@LJ9rg3q4Z5xu={Ecp2?&90;hcp*HM-OicsqY)-*D;_;w z%-NW;ds2hNaex=r!rZ{ld`_BH)QE&+$~T_2s^3*ns}EI)4|gXUWCQabeCAtG%6>dy znY%mKU^3+{u$%uk6JaP!88?HrQT8M~piY7=9wcW>tK$`WWwH|U{ep7KPDE6M4$Nr} zo$SJ$s{%LtZAI4HOAl8M;z|aZX^mf&=($a}(wEiiM&77=7{F<)Pgw7c?~g>4lYi0) z66>gZ0!Pvre$qUM{5M%;;UBm=SbFFR4^bz)S$bxOP0ksh)-jFR$UBlD-feYvyc?1d zTtj7kTDdXAP=YA?QAh3}MpU`@h$#c)x{b^l!AF0%J&I4CN-3!XE%Z6WxN5# z3r7-p*3E#6i{?w&SqCX+FA$bUK{70P_?unzT{9$|V3@nO)jY>%`%rBe*Q$n!0c)lW5RTa< zR7Y5(p(KPH$KhBaeEH2af*u>EAv@!%mS&qm5M99q>VW72QWbR@s4$zrou}SxTl+fEeR#2jB;3qz( z7timU)5v4oGDfURHfvj0w}i4y}tlsDTNhg5qawEE!WMB0E}Zt(}lwohw?^* z7`!Z|45}H+CFYcmuKR?Pi_hjfanWgHgErT?omD5TYfbCkWJ?N*mxV;XK95C?JM{c3 z)}yZA+n(t?U+ruI*5QN0I)GE@-C*92Nehg$@ z^R0{PC|w~xwkzhJ_J80hMW)N2({Yya>V#2Yg*^XnDBe_*yC%kPZ36r zyiH_e-S9uFkl|A?RY(t-`0+@K8rPKwIi1xGG9ORNjyQ~4+nbI06j*JnM<;2zI)}Ge z;;&+fh=eR~Bc?C|W$>ND1 zxuDi03_NzUW&4(^EM8wZoRwWarP}b3+PlxVXa#$|6V`n}sV`jJKPsib)m14426Qy212g96`h0qo&RaE7 zar}#-KJlx7Ey77@`|kRSBEJwnlP-BHuY!DUYq-)Fl-`}%!YFp*ne7VE=1WFwjgbQQ z%rP_@Ikv1sklIFoDigf8QX=_7m0szDA=UxO;Dt{8f*1ku=0jd1gA!%o4?mIcX04eBNKUS9F;CCfumIZ}EtGUQeqZy)Kc$w$UL`XpdgIm}Sg}2$} zO{(s-JWN?m9he`l^U2t!(I1)D?)1BF#jkoN9-8@lmhjD!sH-IbMZ^_eb*g6t|G1{wmJsOBB zs+LbL+PSwRI`aWNEh3fIK;2Pgk@F*EKey3JTtQ zYq}HEMOl}a{nbx#o3g5B8!9yBuhZqK-UY#=ft}Oczg_!uD~0h_H%5 z2h2vS^8=`&)u07~fVYIZ zYN=VAoRm+X304$bOGBl;e1dMK5sF<0+Hu<$T**tv`swC6<+`z#2*t_b4MCCVDV->jSY z&1m!6v6A~L=##brg}gpt4B~L4(DY1bR(`BDa z_d|(eNw-);sZVc_T4fD&;7DO&;JgT^G8ISP%{D@6MG3?_rewhSnCN=uskEhB6uuI$~UIDGJaOnVeus*uFP9KOAedHI#tZAj)*Ez#U zT@PBO%;~My7)&QmKI2LCeoPoU%wypbbc=+Pdkl!#lx*}dsBrgDF6AEE)acI>sBU9i zoKAvcU%%+hoO;1qXE#LjWoff%l(gdy!fU+be@x;(@y|TgeCs}wzgm}lldGV#$J!|E z4AwKa#d1rdBCWq}6#p^FA$j{x<@B@29dWEJdLablUeYO@}U^wHx`r_A_x>snzSvTGJH80#3EMx&( z1^j(O(y+P4u;3r1WA5!9&o#2yq@mGUn&8uOace|5~$`f#Z z(QOSx9^}NP7Aj~_Mo55e{Cf2;>kYR6t@2zPIvU!X;luJ#4|X7eFx#^+j+JpivfnMn zv4i}RzMWo2arD*uOBFDZVj%aDlcVbpIT%zEuyy`n!agfIi}P>;HdSz^<) zMb^AY*+`#b8Y@4^5R{C8snnRkQ`cc{Vu`2AmWREihZ}3W_vil2s~auF}0*aPhinW>YLKT z=~zy=7@6mHBn#e=A`KVnkZXtc;n`rK^n5`fR^R7Gn(kf*qA_vvoH`NGEz2wTJLf8> zE5+IJI_ThAP7yP`LvjIOv~nnMJ&cnyl*az;4Q8KI$`)!ZR*bxe#?jciZjFIFjfx~h z3>YSIsRM)yb=x=Kf)_Id#9edzg?jsUj3_`<0IPG}h&xD1wsa>GU4N&NE+o$CW;nGMJ7MaX=;a}wwTS zXR2C5hU+HpJuyy>8bGxs>P5awEH*B)7|hXY5DfHRJ~jzTjZ&;n-42C%+^n#G)e3ur zyo{mj5%@ahBdO9v-&}7}^5kJAmRrAdv21TjC3w($?UWck7lXq#Cle<--C{vPk7$G|EEd_Ln!V`B3(dbt{8UkxW z%5F16hl+w#?ubSP^Ve4`Rcf>B;;jq(;3{@=)hF9TvhpU%C9p{!r0h1 z+^6wRNqS^V=~eF^yc5`Oe&OO~5{+D6Ft&>Ja`X4H_-t<%9+IPw{@~U`ig1o9Vi1<0 zwO>CCAAGHPb-bF^v+DB1g~TnQ$#<7txMG#q+Ji#fXGp5_#xjrh&pUqMJ4p$YCG_W` zKTNZ`p%EqKCuzR>)R{KMKV?@OB`w^A4M2 z3myUG6~VHp)i+>;7qattpq=Z8-|Fp)IgSqHbjq{oyL64x+o@=Ib3#`)$PJ6hI4erx ze(r2`(j+203MLW02f6-SME|wOCGpKqfVp@yBFDvfECm{n04RHjwtO$2_i&IVNMyq0 zBQ0_HFg`O^@zJT!N(d(_D9b3mlmf{xeYr`n%6`H>CZVPv=5a{%)2g{w3&`r{!+J}+ z=trpK2unY(dHT&dlae>^HybJjvNQuCPHo-w*QSyowxahH@JfaR?PYbt89gwXHq?*(avL1EfOzAhv(3HSRI&Q!K|_X;0oG*$o1B?b!Y@X>uRchV{V1_1lppnH*nWAXm&E_@kF@d1k#_9`2C2-=iN(} zkH1Rf3`6vjZt1Gr_d)9IaE;xepGwq=>Py~oQn7^j^P8})1|DyAY7DA1B=1TOE7XcQ z8LNCti|QJ77Hu%?*rA!D*;^xLXoglLmwgF$zvTKQl zB9ZERu(vV~XmqVPIB`(UomX+uIsdCw881B|#<#mAeFhwT*^)BkF@YYhHcS?NFO_d9 z7?qog@_;EERT63-2#1e!j}X z0WeAvmrn`NjHetm9Q@XBLn*m6zi!Ab_RDCCQaoqT9z;@2RRWwV++`rZ!qKQEQa*+l9+oJ&;K**3sz^4i|Is zC*K(#G>4w;L!OC;0W=j@oT^69ZE=~! z%sy7!1MdJQcp8o;DY;t~vZ7F;UN-P+5q(%ns9c~0d0LvYTM6+Pe@y;(U<5vi5ak`S zK4Prj>iiD!bbF`0jj82ZX$p}gfL4Q+vR^xE<+;v5bhaG~7G-@`$Jxix8}4g8+Aj(W zFAQ<+4b%;1rvmo^H3bqaN*!X*F};peBtgEjo9}^qn~QMxHTFU?Chm^u%T{aSc)qdl zKx&xIxw7raiC9FaPLw~m!X_s_ZPMbiI^qw>a=@JD&T8%tgaG7q2@1Zgb)`w3AWy1{ zH}P0$)otLshu7E9&v-Z65p&J=tMbXx9z%OV$*<66D1-izD9XYhO$%P3bHR9Z6dI$031@c!D-$2&{ygB*&Fyq`9%c>B(U*q~rm-#%6R&4I41$RZjJtb~4GU>NE76nau>YQ68gYROvr9hvG& zw5C}r>bUr#6jOzBKox@*Dy<#$`B_w_8U|M$<(lQJ^LpujsnYfrH`19*D(MKR;V3Y~ zMr5f6Y7Rb#=ghuG)ri!Ne{1%^B^Ve?>Rgw3vMAZ<)YqNMj}0+LxiBci`jiF8U+L{h zOD5$(w4GX+*uID2!!V+;XlH11GIHhg74ghN@~W;Q374{ZJ{|EpH-Iug;EO)zGq{t>(UEw`p79(rUVS zgdx-wrj>`tQ7GfhT8K}p7J&^doi^mjeEl60<=yS;kcO3ZE)MUFvio6^n7N5u()t|N z3&3*q2-r0~F9IbnuQPqnGw-#FkmJ=vlxoK#Clfb}TXT^o)?@Dj-!AhiJcelM`g-LY z5uM%-bY&2EQkZTsQmZh*V1akpS~fCu^v3IUL9Q8V?OGSwUCFbat(rkUmGgF)gN@-z zkI!7q#ZoQrjXa#3P15UznP`%zSWt1vg-4za&;5Zf`2o*K?W*V3>Sqtjmf(HSD8Uqc zsGw$ha%nA5A@&)4jFXUSKCM`aPrc@-FVz_Gm=p1nH(DTE!7J)GWXam77?W?43o-wi zSAcxJZkZG#&Sum9-gBTJ;by@{Z|J~X1y9m;s$V!>dj2`IyIwF_J5zVCqLo{|&f#sG zL@3HxG*s8@O?U&y zf-J(Dyc}Y_Xn6%>d26grZI)F^jkJDPB # 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 d178a187..bceaadc1 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 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/hostCollect.sh b/scripts/hostCollect.sh deleted file mode 100755 index 107228bc..00000000 --- a/scripts/hostCollect.sh +++ /dev/null @@ -1,144 +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} - -mkdir -p results - -#do the full test suite -cd src - -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/hostCollectEnviro.source b/scripts/hostCollectEnviro.source deleted file mode 100644 index 10bc5fe6..00000000 --- a/scripts/hostCollectEnviro.source +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env 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 -- - -export CORES=24 -export DO_PIN=False -export DB_USER=sawaya -export DB_HOST=localhost -export FLIT_DIR=src -export SLURMED=None diff --git a/scripts/hostfile.py b/scripts/hostfile.py deleted file mode 100644 index 1e4449fc..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, 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 4722f7e8..00000000 --- a/scripts/kingspeak_gpu_startup +++ /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 -- - - -#required: -#BRANCH REPO FLIT_DIR CORES DB_USER DB_HOST -#[maybe] 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 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/prepDBHost.py b/scripts/prepDBHost.py deleted file mode 100755 index 6dc7f928..00000000 --- a/scripts/prepDBHost.py +++ /dev/null @@ -1,126 +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 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 - -COLL_DIR = 'flit_data' -DB_DIR = argv[1] - -if __name__ == '__main__': - - import tempfile, os, glob - from subprocess import check_output - import shutil - - TAR = check_output('which tar', shell=True, universal_newlines=True)[:-1] - - 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) - diff --git a/scripts/run_all.py b/scripts/run_all.py deleted file mode 100755 index 2b0eeaac..00000000 --- a/scripts/run_all.py +++ /dev/null @@ -1,403 +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['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) From 3bb7427d35211065365783dc4d2d5f5dd9cce0ce Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 17 May 2018 14:31:44 -0600 Subject: [PATCH 098/166] Fix Makefile bug that was introduced today --- data/Makefile.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data/Makefile.in b/data/Makefile.in index aa2a5886..e11d5d10 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -177,7 +177,10 @@ INTEL := icpc GCC := g++ 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) @@ -338,8 +341,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 From 2ffbf1f3e5dfccd85444cdb187811001f006a2ea Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 25 May 2018 10:59:37 -0600 Subject: [PATCH 099/166] install: place includes into /include/flit --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 19fc8dee..78e0d63b 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ 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 @@ -104,7 +104,7 @@ install: $(TARGET) 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/ @@ -151,7 +151,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) From 112ae766161dc8c7d13798742bc4e2aab6a35c5d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 25 May 2018 10:59:50 -0600 Subject: [PATCH 100/166] Makefile: implement uninstall target --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 78e0d63b..d79f2d3c 100644 --- a/Makefile +++ b/Makefile @@ -166,3 +166,10 @@ 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)) From 29527421bee92fd61c3bda409580f54c3b406946 Mon Sep 17 00:00:00 2001 From: Ian Briggs Date: Fri, 25 May 2018 11:52:57 -0600 Subject: [PATCH 101/166] initial transform of polybench to FLiT tests --- benchmarks/adi.cpp | 14 +++ benchmarks/adi_base.hpp | 93 ++++++++++++++++++++ benchmarks/atax.cpp | 14 +++ benchmarks/atax_base.hpp | 54 ++++++++++++ benchmarks/bicg.cpp | 14 +++ benchmarks/bicg_base.hpp | 55 ++++++++++++ benchmarks/cholesky.cpp | 14 +++ benchmarks/cholesky_base.hpp | 54 ++++++++++++ benchmarks/correlation.cpp | 14 +++ benchmarks/correlation_base.hpp | 89 +++++++++++++++++++ benchmarks/covariance.cpp | 14 +++ benchmarks/covariance_base.hpp | 66 +++++++++++++++ benchmarks/deriche.cpp | 14 +++ benchmarks/deriche_base.hpp | 123 +++++++++++++++++++++++++++ benchmarks/doitgen.cpp | 14 +++ benchmarks/doitgen_base.hpp | 53 ++++++++++++ benchmarks/durbin.cpp | 14 +++ benchmarks/durbin_base.hpp | 66 +++++++++++++++ benchmarks/empty.hpp | 37 ++++++++ benchmarks/fdtd_2d.cpp | 14 +++ benchmarks/fdtd_2d_base.hpp | 58 +++++++++++++ benchmarks/floyd_warshall.cpp | 14 +++ benchmarks/floyd_warshall_base.hpp | 47 ++++++++++ benchmarks/gemm.cpp | 14 +++ benchmarks/gemm_base.hpp | 54 ++++++++++++ benchmarks/gemver.cpp | 14 +++ benchmarks/gemver_base.hpp | 71 ++++++++++++++++ benchmarks/gesummv.cpp | 14 +++ benchmarks/gesummv_base.hpp | 58 +++++++++++++ benchmarks/gramschmidt.cpp | 14 +++ benchmarks/gramschmidt_base.hpp | 61 +++++++++++++ benchmarks/heat_3d.cpp | 14 +++ benchmarks/heat_3d_base.hpp | 63 ++++++++++++++ benchmarks/jacobi_1d.cpp | 14 +++ benchmarks/jacobi_1d_base.hpp | 48 +++++++++++ benchmarks/jacobi_2d.cpp | 14 +++ benchmarks/jacobi_2d_base.hpp | 50 +++++++++++ benchmarks/lu.cpp | 14 +++ benchmarks/lu_base.hpp | 53 ++++++++++++ benchmarks/ludcmp.cpp | 14 +++ benchmarks/ludcmp_base.hpp | 75 ++++++++++++++++ benchmarks/mvt.cpp | 14 +++ benchmarks/mvt_base.hpp | 50 +++++++++++ benchmarks/nussinov.cpp | 14 +++ benchmarks/nussinov_base.hpp | 64 ++++++++++++++ benchmarks/polybench_utils.hpp | 132 +++++++++++++++++++++++++++++ benchmarks/seidel_2d.cpp | 14 +++ benchmarks/seidel_2d_base.hpp | 46 ++++++++++ benchmarks/symm.cpp | 14 +++ benchmarks/symm_base.hpp | 55 ++++++++++++ benchmarks/syr2k.cpp | 14 +++ benchmarks/syr2k_base.hpp | 54 ++++++++++++ benchmarks/syrk.cpp | 14 +++ benchmarks/syrk_base.hpp | 51 +++++++++++ benchmarks/test2mm.cpp | 14 +++ benchmarks/test2mm_base.hpp | 61 +++++++++++++ benchmarks/test3mm.cpp | 14 +++ benchmarks/test3mm_base.hpp | 70 +++++++++++++++ benchmarks/trisolv.cpp | 14 +++ benchmarks/trisolv_base.hpp | 49 +++++++++++ benchmarks/trmm.cpp | 14 +++ benchmarks/trmm_base.hpp | 49 +++++++++++ 62 files changed, 2429 insertions(+) create mode 100644 benchmarks/adi.cpp create mode 100644 benchmarks/adi_base.hpp create mode 100644 benchmarks/atax.cpp create mode 100644 benchmarks/atax_base.hpp create mode 100644 benchmarks/bicg.cpp create mode 100644 benchmarks/bicg_base.hpp create mode 100644 benchmarks/cholesky.cpp create mode 100644 benchmarks/cholesky_base.hpp create mode 100644 benchmarks/correlation.cpp create mode 100644 benchmarks/correlation_base.hpp create mode 100644 benchmarks/covariance.cpp create mode 100644 benchmarks/covariance_base.hpp create mode 100644 benchmarks/deriche.cpp create mode 100644 benchmarks/deriche_base.hpp create mode 100644 benchmarks/doitgen.cpp create mode 100644 benchmarks/doitgen_base.hpp create mode 100644 benchmarks/durbin.cpp create mode 100644 benchmarks/durbin_base.hpp create mode 100644 benchmarks/empty.hpp create mode 100644 benchmarks/fdtd_2d.cpp create mode 100644 benchmarks/fdtd_2d_base.hpp create mode 100644 benchmarks/floyd_warshall.cpp create mode 100644 benchmarks/floyd_warshall_base.hpp create mode 100644 benchmarks/gemm.cpp create mode 100644 benchmarks/gemm_base.hpp create mode 100644 benchmarks/gemver.cpp create mode 100644 benchmarks/gemver_base.hpp create mode 100644 benchmarks/gesummv.cpp create mode 100644 benchmarks/gesummv_base.hpp create mode 100644 benchmarks/gramschmidt.cpp create mode 100644 benchmarks/gramschmidt_base.hpp create mode 100644 benchmarks/heat_3d.cpp create mode 100644 benchmarks/heat_3d_base.hpp create mode 100644 benchmarks/jacobi_1d.cpp create mode 100644 benchmarks/jacobi_1d_base.hpp create mode 100644 benchmarks/jacobi_2d.cpp create mode 100644 benchmarks/jacobi_2d_base.hpp create mode 100644 benchmarks/lu.cpp create mode 100644 benchmarks/lu_base.hpp create mode 100644 benchmarks/ludcmp.cpp create mode 100644 benchmarks/ludcmp_base.hpp create mode 100644 benchmarks/mvt.cpp create mode 100644 benchmarks/mvt_base.hpp create mode 100644 benchmarks/nussinov.cpp create mode 100644 benchmarks/nussinov_base.hpp create mode 100644 benchmarks/polybench_utils.hpp create mode 100644 benchmarks/seidel_2d.cpp create mode 100644 benchmarks/seidel_2d_base.hpp create mode 100644 benchmarks/symm.cpp create mode 100644 benchmarks/symm_base.hpp create mode 100644 benchmarks/syr2k.cpp create mode 100644 benchmarks/syr2k_base.hpp create mode 100644 benchmarks/syrk.cpp create mode 100644 benchmarks/syrk_base.hpp create mode 100644 benchmarks/test2mm.cpp create mode 100644 benchmarks/test2mm_base.hpp create mode 100644 benchmarks/test3mm.cpp create mode 100644 benchmarks/test3mm_base.hpp create mode 100644 benchmarks/trisolv.cpp create mode 100644 benchmarks/trisolv_base.hpp create mode 100644 benchmarks/trmm.cpp create mode 100644 benchmarks/trmm_base.hpp diff --git a/benchmarks/adi.cpp b/benchmarks/adi.cpp new file mode 100644 index 00000000..2503528d --- /dev/null +++ b/benchmarks/adi.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "adi_base.hpp" + + +REGISTER_2(Adi, 4, 4) +REGISTER_2(Adi, 5, 5) +REGISTER_2(Adi, 6, 6) +REGISTER_2(Adi, 7, 7) +REGISTER_2(Adi, 8, 8) diff --git a/benchmarks/adi_base.hpp b/benchmarks/adi_base.hpp new file mode 100644 index 00000000..851b66d1 --- /dev/null +++ b/benchmarks/adi_base.hpp @@ -0,0 +1,93 @@ +#ifndef ADI_BASE_H +#define ADI_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N}; + std::vector u = split_vector(sizes, 0, ti); + std::vector v(N*N); + std::vector p(N*N); + std::vector 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 = static_cast(1.0)/(T)N; + DY = static_cast(1.0)/(T)N; + DT = static_cast(1.0)/(T)TSTEPS; + B1 = static_cast(2.0); + B2 = static_cast(1.0); + mul1 = B1 * DT / (DX * DX); + mul2 = B2 * DT / (DY * DY); + + a = -mul1 / static_cast(2.0); + b = static_cast(1.0)+mul1; + c = a; + d = -mul2 / static_cast(2.0); + e = static_cast(1.0)+mul2; + f = d; + + for (t=1; t<=TSTEPS; t++) { + //Column Sweep + for (i=1; i(1.0); + p[i*N + 0] = static_cast(0.0); + q[i*N + 0] = v[0*N + i]; + for (j=1; j(1.0)+static_cast(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] = static_cast(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(1.0); + p[i*N + 0] = static_cast(0.0); + q[i*N + 0] = u[i*N + 0]; + for (j=1; j(1.0)+static_cast(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] = static_cast(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; +}; + +#endif // ADI_BASE_H diff --git a/benchmarks/atax.cpp b/benchmarks/atax.cpp new file mode 100644 index 00000000..164b1f54 --- /dev/null +++ b/benchmarks/atax.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "atax_base.hpp" + + +REGISTER_2(Atax, 4, 4) +REGISTER_2(Atax, 5, 5) +REGISTER_2(Atax, 6, 6) +REGISTER_2(Atax, 7, 7) +REGISTER_2(Atax, 8, 8) diff --git a/benchmarks/atax_base.hpp b/benchmarks/atax_base.hpp new file mode 100644 index 00000000..6e250998 --- /dev/null +++ b/benchmarks/atax_base.hpp @@ -0,0 +1,54 @@ +#ifndef ATAX_BASE_H +#define ATAX_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {M*N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector x = split_vector(sizes, 1, ti); + std::vector y(N); + std::vector tmp(M); + + int i,j; + + for (i = 0; i < N; i++) + y[i] = 0; + for (i = 0; i < M; i++) + { + tmp[i] = static_cast(0.0); + for (j = 0; j < N; j++) + tmp[i] = tmp[i] + A[i*M + j] * x[j]; + for (j = 0; j < N; j++) + y[j] = y[j] + A[i*M + j] * tmp[i]; + } + + + return pickles({y, tmp}); +} + +protected: +using flit::TestBase::id; +}; + +#endif // ATAX_BASE_H diff --git a/benchmarks/bicg.cpp b/benchmarks/bicg.cpp new file mode 100644 index 00000000..d924a7be --- /dev/null +++ b/benchmarks/bicg.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "bicg_base.hpp" + + +REGISTER_2(Bicg, 4, 4) +REGISTER_2(Bicg, 5, 5) +REGISTER_2(Bicg, 6, 6) +REGISTER_2(Bicg, 7, 7) +REGISTER_2(Bicg, 8, 8) diff --git a/benchmarks/bicg_base.hpp b/benchmarks/bicg_base.hpp new file mode 100644 index 00000000..b48cfa31 --- /dev/null +++ b/benchmarks/bicg_base.hpp @@ -0,0 +1,55 @@ +#ifndef BICG_BASE_H +#define BICG_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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}; + std::vector A = split_vector(sizes, 0, ti); + std::vector r = split_vector(sizes, 1, ti); + std::vector p = split_vector(sizes, 2, ti); + std::vector s(M); + std::vector q(N); + + int i, j; + + for (i = 0; i < M; i++) + s[i] = 0; + for (i = 0; i < N; i++) + { + q[i] = static_cast(0.0); + for (j = 0; j < M; j++) + { + s[j] = s[j] + r[i] * A[i*N + j]; + q[i] = q[i] + A[i*N + j] * p[j]; + } + } + + return pickles({s, q}); + } + +protected: + using flit::TestBase::id; +}; + +#endif // BICG_BASE_H diff --git a/benchmarks/cholesky.cpp b/benchmarks/cholesky.cpp new file mode 100644 index 00000000..56942e4d --- /dev/null +++ b/benchmarks/cholesky.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "cholesky_base.hpp" + + +REGISTER_1(Cholesky, 4) +REGISTER_1(Cholesky, 5) +REGISTER_1(Cholesky, 6) +REGISTER_1(Cholesky, 7) +REGISTER_1(Cholesky, 8) diff --git a/benchmarks/cholesky_base.hpp b/benchmarks/cholesky_base.hpp new file mode 100644 index 00000000..70dddf76 --- /dev/null +++ b/benchmarks/cholesky_base.hpp @@ -0,0 +1,54 @@ +#ifndef CHOLESKY_BASE_H +#define CHOLESKY_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N}; + std::vector A = split_vector(sizes, 0, ti); + + int i, j, k; + + for (i = 0; i < N; i++) { + //j::id; +}; + +#endif // CHOLESKY_BASE_H diff --git a/benchmarks/correlation.cpp b/benchmarks/correlation.cpp new file mode 100644 index 00000000..8af7d4ed --- /dev/null +++ b/benchmarks/correlation.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "correlation_base.hpp" + + +REGISTER_2(Correlation, 4, 4) +REGISTER_2(Correlation, 5, 5) +REGISTER_2(Correlation, 6, 6) +REGISTER_2(Correlation, 7, 7) +REGISTER_2(Correlation, 8, 8) diff --git a/benchmarks/correlation_base.hpp b/benchmarks/correlation_base.hpp new file mode 100644 index 00000000..8966564c --- /dev/null +++ b/benchmarks/correlation_base.hpp @@ -0,0 +1,89 @@ +#ifndef CORRELATION_BASE_H +#define CORRELATION_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +template +class CorrelationBase : public flit::TestBase { +public: + CorrelationBase(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 { + std::vector data = ti; + std::vector corr (M*M); + std::vector mean (M); + std::vector stddev (M); + T float_n = N; + + int i, j, k; + + T eps = 0.1; + + + for (j=0; j::id; +}; + +#endif // CORRELATION_BASE_H diff --git a/benchmarks/covariance.cpp b/benchmarks/covariance.cpp new file mode 100644 index 00000000..80ea2d5e --- /dev/null +++ b/benchmarks/covariance.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "covariance_base.hpp" + + +REGISTER_2(Covariance, 4, 4) +REGISTER_2(Covariance, 5, 5) +REGISTER_2(Covariance, 6, 6) +REGISTER_2(Covariance, 7, 7) +REGISTER_2(Covariance, 8, 8) diff --git a/benchmarks/covariance_base.hpp b/benchmarks/covariance_base.hpp new file mode 100644 index 00000000..7bfdcad4 --- /dev/null +++ b/benchmarks/covariance_base.hpp @@ -0,0 +1,66 @@ +#ifndef COVARIANCE_BASE_H +#define COVARIANCE_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 = static_cast(N); + std::vector data = ti; + std::vector cov(M*M); + std::vector mean(M); + + int i, j, k; + + for (j = 0; j < M; j++) { + mean[j] = static_cast(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] = static_cast(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 - static_cast(1.0)); + cov[j*M + i] = cov[i*M + j]; + } + } + + return pickles({data, cov, mean}) ; + } + +protected: + using flit::TestBase::id; +}; + +#endif // COVARIANCE_BASE_H diff --git a/benchmarks/deriche.cpp b/benchmarks/deriche.cpp new file mode 100644 index 00000000..c3c430a2 --- /dev/null +++ b/benchmarks/deriche.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "deriche_base.hpp" + + +REGISTER_2(Deriche, 4, 4) +REGISTER_2(Deriche, 5, 5) +REGISTER_2(Deriche, 6, 6) +REGISTER_2(Deriche, 7, 7) +REGISTER_2(Deriche, 8, 8) diff --git a/benchmarks/deriche_base.hpp b/benchmarks/deriche_base.hpp new file mode 100644 index 00000000..e12110ee --- /dev/null +++ b/benchmarks/deriche_base.hpp @@ -0,0 +1,123 @@ +#ifndef DERICHE_BASE_H +#define DERICHE_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {W*H, W*H}; + std::vector imgIn = split_vector(sizes, 0, ti); + std::vector imgOut = split_vector(sizes, 1, ti); + std::vector y1(W*H); + std::vector y2(W*H); + + T alpha = static_cast(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 = (static_cast(1.0)-std::exp(-alpha))*(static_cast(1.0)-std::exp(-alpha))/(static_cast(1.0)+static_cast(2.0)*alpha*std::exp(-alpha)-std::exp(static_cast(2.0)*alpha)); + a1 = a5 = k; + a2 = a6 = k*std::exp(-alpha)*(alpha-static_cast(1.0)); + a3 = a7 = k*std::exp(-alpha)*(alpha+static_cast(1.0)); + a4 = a8 = -k*std::exp(static_cast(-2.0)*alpha); + b1 = std::pow(static_cast(2.0),-alpha); + b2 = -std::exp(static_cast(-2.0)*alpha); + c1 = c2 = 1; + + for (i=0; i(0.0); + ym2 = static_cast(0.0); + xm1 = static_cast(0.0); + for (j=0; j(0.0); + yp2 = static_cast(0.0); + xp1 = static_cast(0.0); + xp2 = static_cast(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(0.0); + ym1 = static_cast(0.0); + ym2 = static_cast(0.0); + for (i=0; i(0.0); + tp2 = static_cast(0.0); + yp1 = static_cast(0.0); + yp2 = static_cast(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::id; +}; + +#endif // DERICHE_BASE_H diff --git a/benchmarks/doitgen.cpp b/benchmarks/doitgen.cpp new file mode 100644 index 00000000..5788fa27 --- /dev/null +++ b/benchmarks/doitgen.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "doitgen_base.hpp" + + +REGISTER_3(Doitgen, 4, 4, 4) +REGISTER_3(Doitgen, 5, 5, 5) +REGISTER_3(Doitgen, 6, 6, 6) +REGISTER_3(Doitgen, 7, 7, 7) +REGISTER_3(Doitgen, 8, 8, 8) diff --git a/benchmarks/doitgen_base.hpp b/benchmarks/doitgen_base.hpp new file mode 100644 index 00000000..6988ee73 --- /dev/null +++ b/benchmarks/doitgen_base.hpp @@ -0,0 +1,53 @@ +#ifndef DOITGEN_BASE_H +#define DOITGEN_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {NR*NQ*NP, NP*NP}; + std::vector A = split_vector(sizes, 0, ti); + std::vector C4 = split_vector(sizes, 1, ti); + 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] = static_cast(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; +}; + +#endif // DOITGEN_BASE_H diff --git a/benchmarks/durbin.cpp b/benchmarks/durbin.cpp new file mode 100644 index 00000000..e9b3989d --- /dev/null +++ b/benchmarks/durbin.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "durbin_base.hpp" + + +REGISTER_1(Durbin, 4) +REGISTER_1(Durbin, 5) +REGISTER_1(Durbin, 6) +REGISTER_1(Durbin, 7) +REGISTER_1(Durbin, 8) diff --git a/benchmarks/durbin_base.hpp b/benchmarks/durbin_base.hpp new file mode 100644 index 00000000..e19cd53b --- /dev/null +++ b/benchmarks/durbin_base.hpp @@ -0,0 +1,66 @@ +#ifndef DURBIN_BASE_H +#define DURBIN_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N}; + std::vector r = split_vector(sizes, 0, ti); + std::vector y(N); + + std::vector z(N); + T alpha; + T beta; + T sum; + + int i,k; + + y[0] = -r[0]; + beta = static_cast(1.0); + alpha = -r[0]; + + for (k = 1; k < N; k++) { + beta = (1-alpha*alpha)*beta; + sum = static_cast(0.0); + for (i=0; i::id; +}; + +#endif // DURBIN_BASE_H diff --git a/benchmarks/empty.hpp b/benchmarks/empty.hpp new file mode 100644 index 00000000..a4e4b725 --- /dev/null +++ b/benchmarks/empty.hpp @@ -0,0 +1,37 @@ +#ifndef EMPTY_BASE_H +#define EMPTY_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +template +class EmptyBase : public flit::TestBase { +public: + EmptyBase(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 { + std::vector sizes = {}; + std::vector C = split_vector(sizes, 0, ti); + + return pickles({}); + } + +protected: + using flit::TestBase::id; +}; + +#endif // EMPTY_BASE_H diff --git a/benchmarks/fdtd_2d.cpp b/benchmarks/fdtd_2d.cpp new file mode 100644 index 00000000..39178940 --- /dev/null +++ b/benchmarks/fdtd_2d.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "fdtd_2d_base.hpp" + + +REGISTER_3(Fdtd_2d, 4, 4, 4) +REGISTER_3(Fdtd_2d, 5, 5, 5) +REGISTER_3(Fdtd_2d, 6, 6, 6) +REGISTER_3(Fdtd_2d, 7, 7, 7) +REGISTER_3(Fdtd_2d, 8, 8, 8) diff --git a/benchmarks/fdtd_2d_base.hpp b/benchmarks/fdtd_2d_base.hpp new file mode 100644 index 00000000..0ad4ec8e --- /dev/null +++ b/benchmarks/fdtd_2d_base.hpp @@ -0,0 +1,58 @@ +#ifndef FDTD_2D_BASE_H +#define FDTD_2D_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {NX*NY, NX*NY, NX*NY, TMAX}; + std::vector ex = split_vector(sizes, 0, ti); + std::vector ey = split_vector(sizes, 1, ti); + std::vector hz = split_vector(sizes, 2, ti); + std::vector _fict_ = split_vector(sizes, 3, ti); + + 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] = ey[i*NX + j] - static_cast(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] = ex[i*NX + j] - static_cast(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] = hz[i*NX + j] - static_cast(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; +}; + +#endif // FDTD_2D_BASE_H diff --git a/benchmarks/floyd_warshall.cpp b/benchmarks/floyd_warshall.cpp new file mode 100644 index 00000000..26dc684f --- /dev/null +++ b/benchmarks/floyd_warshall.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "floyd_warshall_base.hpp" + + +REGISTER_1(Floyd_Warshall, 4) +REGISTER_1(Floyd_Warshall, 5) +REGISTER_1(Floyd_Warshall, 6) +REGISTER_1(Floyd_Warshall, 7) +REGISTER_1(Floyd_Warshall, 8) diff --git a/benchmarks/floyd_warshall_base.hpp b/benchmarks/floyd_warshall_base.hpp new file mode 100644 index 00000000..16f5ea75 --- /dev/null +++ b/benchmarks/floyd_warshall_base.hpp @@ -0,0 +1,47 @@ +#ifndef FLOYD_WARSHALL_BASE_H +#define FLOYD_WARSHALL_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N}; + std::vector path = split_vector(sizes, 0, 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; +}; + +#endif // FLOYD_WARSHALL_BASE_H diff --git a/benchmarks/gemm.cpp b/benchmarks/gemm.cpp new file mode 100644 index 00000000..449701e5 --- /dev/null +++ b/benchmarks/gemm.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "gemm_base.hpp" + + +REGISTER_3(Gemm, 4, 4, 4) +REGISTER_3(Gemm, 5, 5, 5) +REGISTER_3(Gemm, 6, 6, 6) +REGISTER_3(Gemm, 7, 7, 7) +REGISTER_3(Gemm, 8, 8, 8) diff --git a/benchmarks/gemm_base.hpp b/benchmarks/gemm_base.hpp new file mode 100644 index 00000000..282467b9 --- /dev/null +++ b/benchmarks/gemm_base.hpp @@ -0,0 +1,54 @@ +#ifndef GEMM_BASE_H +#define GEMM_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 = static_cast(1.5); + T beta = static_cast(1.2); + std::vector sizes = {NI*NI, NI*NK, NK+NJ}; + std::vector C = split_vector(sizes, 0, ti); + std::vector A = split_vector(sizes, 1, ti); + std::vector B = split_vector(sizes, 2, ti); + + 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; +}; + +#endif // GEMM_BASE_H diff --git a/benchmarks/gemver.cpp b/benchmarks/gemver.cpp new file mode 100644 index 00000000..838510d6 --- /dev/null +++ b/benchmarks/gemver.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "gemver_base.hpp" + + +REGISTER_1(Gemver, 4) +REGISTER_1(Gemver, 5) +REGISTER_1(Gemver, 6) +REGISTER_1(Gemver, 7) +REGISTER_1(Gemver, 8) diff --git a/benchmarks/gemver_base.hpp b/benchmarks/gemver_base.hpp new file mode 100644 index 00000000..6833a7b0 --- /dev/null +++ b/benchmarks/gemver_base.hpp @@ -0,0 +1,71 @@ +#ifndef GEMVER_BASE_H +#define GEMVER_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 = static_cast(1.5); + T beta = static_cast(1.2); + std::vector sizes = {N*N, N, N, N, N, N, N, N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector u1 = split_vector(sizes, 1, ti); + std::vector v1 = split_vector(sizes, 2, ti); + std::vector u2 = split_vector(sizes, 3, ti); + std::vector v2 = split_vector(sizes, 4, ti); + std::vector w = split_vector(sizes, 5, ti); + std::vector x = split_vector(sizes, 6, ti); + std::vector y = split_vector(sizes, 7, ti); + std::vector z = split_vector(sizes, 8, ti); + + 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; +}; + +#endif // GEMVER_BASE_H diff --git a/benchmarks/gesummv.cpp b/benchmarks/gesummv.cpp new file mode 100644 index 00000000..00bc3490 --- /dev/null +++ b/benchmarks/gesummv.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "gesummv_base.hpp" + + +REGISTER_1(Gesummv, 4) +REGISTER_1(Gesummv, 5) +REGISTER_1(Gesummv, 6) +REGISTER_1(Gesummv, 7) +REGISTER_1(Gesummv, 8) diff --git a/benchmarks/gesummv_base.hpp b/benchmarks/gesummv_base.hpp new file mode 100644 index 00000000..137f253d --- /dev/null +++ b/benchmarks/gesummv_base.hpp @@ -0,0 +1,58 @@ +#ifndef GESUMMV_BASE_H +#define GESUMMV_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 = static_cast(1.5); + T beta = static_cast(1.2); + std::vector sizes = {N*N, N*N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + std::vector x = split_vector(sizes, 2, ti); + + std::vector tmp(N); + std::vector y(N); + + int i, j; + + for (i = 0; i < N; i++) + { + tmp[i] = static_cast(0.0); + y[i] = static_cast(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; +}; + +#endif // GESUMMV_BASE_H diff --git a/benchmarks/gramschmidt.cpp b/benchmarks/gramschmidt.cpp new file mode 100644 index 00000000..9ea505c8 --- /dev/null +++ b/benchmarks/gramschmidt.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "gramschmidt_base.hpp" + + +REGISTER_2(Gramschmidt, 4, 4) +REGISTER_2(Gramschmidt, 5, 5) +REGISTER_2(Gramschmidt, 6, 6) +REGISTER_2(Gramschmidt, 7, 7) +REGISTER_2(Gramschmidt, 8, 8) diff --git a/benchmarks/gramschmidt_base.hpp b/benchmarks/gramschmidt_base.hpp new file mode 100644 index 00000000..bb622f11 --- /dev/null +++ b/benchmarks/gramschmidt_base.hpp @@ -0,0 +1,61 @@ +#ifndef GRAMSCHMIDT_BASE_H +#define GRAMSCHMIDT_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {M*N, N*N, M*N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector R = split_vector(sizes, 1, ti); + std::vector Q = split_vector(sizes, 2, ti); + + int i, j, k; + + T nrm; + + for (k = 0; k < N; k++) + { + nrm = static_cast(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] = static_cast(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; +}; + +#endif // GRAMSCHMIDT_BASE_H diff --git a/benchmarks/heat_3d.cpp b/benchmarks/heat_3d.cpp new file mode 100644 index 00000000..bf75051e --- /dev/null +++ b/benchmarks/heat_3d.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "heat_3d_base.hpp" + + +REGISTER_2(Heat_3d, 4, 4) +REGISTER_2(Heat_3d, 5, 5) +REGISTER_2(Heat_3d, 6, 6) +REGISTER_2(Heat_3d, 7, 7) +REGISTER_2(Heat_3d, 8, 8) diff --git a/benchmarks/heat_3d_base.hpp b/benchmarks/heat_3d_base.hpp new file mode 100644 index 00000000..df44d5f5 --- /dev/null +++ b/benchmarks/heat_3d_base.hpp @@ -0,0 +1,63 @@ +#ifndef HEAT_3D_BASE_H +#define HEAT_3D_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N*N, N*N*N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + + 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] = static_cast(0.125) * (A[(i+1)*N*N + j*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[(i-1)*N*N + j*N +k]) + + static_cast(0.125) * (A[i*N*N + (j+1)*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[i*N*N + (j-1)*N*N + k]) + + static_cast(0.125) * (A[i*N*N + j*N +k+1] - static_cast(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] = static_cast(0.125) * (B[(i+1)*N*N + j*N +k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[(i-1)*N*N + j*N +k]) + + static_cast(0.125) * (B[i*N*N + (j+1)*N*N + k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + (j-1)*N*N + k]) + + static_cast(0.125) * (B[i*N*N + j*N +k+1] - static_cast(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; +}; + +#endif // HEAT_3D_BASE_H diff --git a/benchmarks/jacobi_1d.cpp b/benchmarks/jacobi_1d.cpp new file mode 100644 index 00000000..bbe0128e --- /dev/null +++ b/benchmarks/jacobi_1d.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "jacobi_1d_base.hpp" + + +REGISTER_2(Jacobi_1d, 4, 4) +REGISTER_2(Jacobi_1d, 5, 5) +REGISTER_2(Jacobi_1d, 6, 6) +REGISTER_2(Jacobi_1d, 7, 7) +REGISTER_2(Jacobi_1d, 8, 8) diff --git a/benchmarks/jacobi_1d_base.hpp b/benchmarks/jacobi_1d_base.hpp new file mode 100644 index 00000000..55b7b7b6 --- /dev/null +++ b/benchmarks/jacobi_1d_base.hpp @@ -0,0 +1,48 @@ +#ifndef JACOBI_1D_BASE_H +#define JACOBI_1D_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + + int t, i; + + for (t = 0; t < TSTEPS; t++) + { + for (i = 1; i < N - 1; i++) + B[i] = 0.33333 * (A[i-1] + A[i] + A[i + 1]); + for (i = 1; i < N - 1; i++) + A[i] = 0.33333 * (B[i-1] + B[i] + B[i + 1]); + } + + return pickles({A, B}); + } + +protected: + using flit::TestBase::id; +}; + +#endif // JACOBI_1D_BASE_H diff --git a/benchmarks/jacobi_2d.cpp b/benchmarks/jacobi_2d.cpp new file mode 100644 index 00000000..7b3fd9ae --- /dev/null +++ b/benchmarks/jacobi_2d.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "jacobi_2d_base.hpp" + + +REGISTER_2(Jacobi_2d, 4, 4) +REGISTER_2(Jacobi_2d, 5, 5) +REGISTER_2(Jacobi_2d, 6, 6) +REGISTER_2(Jacobi_2d, 7, 7) +REGISTER_2(Jacobi_2d, 8, 8) diff --git a/benchmarks/jacobi_2d_base.hpp b/benchmarks/jacobi_2d_base.hpp new file mode 100644 index 00000000..cfd8e418 --- /dev/null +++ b/benchmarks/jacobi_2d_base.hpp @@ -0,0 +1,50 @@ +#ifndef JACOBI_2D_BASE_H +#define JACOBI_2D_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N, N*N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + + 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] = static_cast(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] = static_cast(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; +}; + +#endif // JACOBI_2D_BASE_H diff --git a/benchmarks/lu.cpp b/benchmarks/lu.cpp new file mode 100644 index 00000000..9c7b178e --- /dev/null +++ b/benchmarks/lu.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "lu_base.hpp" + + +REGISTER_1(Lu, 4) +REGISTER_1(Lu, 5) +REGISTER_1(Lu, 6) +REGISTER_1(Lu, 7) +REGISTER_1(Lu, 8) diff --git a/benchmarks/lu_base.hpp b/benchmarks/lu_base.hpp new file mode 100644 index 00000000..4c810349 --- /dev/null +++ b/benchmarks/lu_base.hpp @@ -0,0 +1,53 @@ +#ifndef LU_BASE_H +#define LU_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N}; + std::vector A = split_vector(sizes, 0, ti); + + int i, j, k; + + for (i = 0; i < N; i++) { + for (j = 0; j ::id; +}; + +#endif // LU_BASE_H diff --git a/benchmarks/ludcmp.cpp b/benchmarks/ludcmp.cpp new file mode 100644 index 00000000..efa4aedf --- /dev/null +++ b/benchmarks/ludcmp.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "ludcmp_base.hpp" + + +REGISTER_1(Ludcmp, 4) +REGISTER_1(Ludcmp, 5) +REGISTER_1(Ludcmp, 6) +REGISTER_1(Ludcmp, 7) +REGISTER_1(Ludcmp, 8) diff --git a/benchmarks/ludcmp_base.hpp b/benchmarks/ludcmp_base.hpp new file mode 100644 index 00000000..c40209ce --- /dev/null +++ b/benchmarks/ludcmp_base.hpp @@ -0,0 +1,75 @@ +#ifndef LUDCMP_BASE_H +#define LUDCMP_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N, N, N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector b = split_vector(sizes, 1, ti); + std::vector x = split_vector(sizes, 2, ti); + std::vector y = split_vector(sizes, 3, ti); + + 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; +}; + +#endif // LUDCMP_BASE_H diff --git a/benchmarks/mvt.cpp b/benchmarks/mvt.cpp new file mode 100644 index 00000000..af4e06b7 --- /dev/null +++ b/benchmarks/mvt.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "mvt_base.hpp" + + +REGISTER_1(Mvt, 4) +REGISTER_1(Mvt, 5) +REGISTER_1(Mvt, 6) +REGISTER_1(Mvt, 7) +REGISTER_1(Mvt, 8) diff --git a/benchmarks/mvt_base.hpp b/benchmarks/mvt_base.hpp new file mode 100644 index 00000000..c252b18b --- /dev/null +++ b/benchmarks/mvt_base.hpp @@ -0,0 +1,50 @@ +#ifndef MVT_BASE_H +#define MVT_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N, N, N, N, N*N}; + std::vector x1 = split_vector(sizes, 0, ti); + std::vector x2 = split_vector(sizes, 1, ti); + std::vector y_1 = split_vector(sizes, 2, ti); + std::vector y_2 = split_vector(sizes, 3, ti); + std::vector A = split_vector(sizes, 4, ti); + + 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; +}; + +#endif // MVT_BASE_H diff --git a/benchmarks/nussinov.cpp b/benchmarks/nussinov.cpp new file mode 100644 index 00000000..bb0668fa --- /dev/null +++ b/benchmarks/nussinov.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "nussinov_base.hpp" + + +REGISTER_1(Nussinov, 4) +REGISTER_1(Nussinov, 5) +REGISTER_1(Nussinov, 6) +REGISTER_1(Nussinov, 7) +REGISTER_1(Nussinov, 8) diff --git a/benchmarks/nussinov_base.hpp b/benchmarks/nussinov_base.hpp new file mode 100644 index 00000000..1e578cb4 --- /dev/null +++ b/benchmarks/nussinov_base.hpp @@ -0,0 +1,64 @@ +#ifndef NUSSINOV_BASE_H +#define NUSSINOV_BASE_H + + +#include + +#include "polybench_utils.hpp" + +#define match(b1, b2) (((b1)+(b2)) == 3 ? 1 : 0) +#define max_score(s1, s2) ((s1 >= s2) ? s1 : s2) + +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 { + std::vector sizes = {N, N*N}; + std::vector seq = split_vector(sizes, 0, ti); + std::vector table = split_vector(sizes, 1, ti); + + int i, j, k; + + for (i = N-1; i >= 0; i--) { + for (j=i+1; j=0) + table[i*N + j] = max_score(table[i*N + j], table[i*N + j-1]); + if (i+1=0 && i+1::id; +}; + +#endif // NUSSINOV_BASE_H diff --git a/benchmarks/polybench_utils.hpp b/benchmarks/polybench_utils.hpp new file mode 100644 index 00000000..5242e03e --- /dev/null +++ b/benchmarks/polybench_utils.hpp @@ -0,0 +1,132 @@ +#ifndef POLYBENCH_UTILS_H +#define POLYBENCH_UTILS_H + + +#include +#include +#include + + +#define REGISTER_1(NAME, DIM0) \ + template class NAME##_##DIM0 : public NAME##Base { \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0) \ + +#define REGISTER_2(NAME, DIM0, DIM1) \ + template class NAME##_##DIM0##_##DIM1 : public NAME##Base { \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1) \ + +#define REGISTER_3(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 REGISTER_4(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 REGISTER_5(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) \ + + +template inline T max_f(); +template<> inline float max_f() { return FLT_MAX; } +template<> inline double max_f() { return DBL_MAX; } +template<> inline long double max_f() { return LDBL_MAX; } + + +template +std::vector seeded_random_vector(size_t n, unsigned int seed) { + std::vector v(n); + srand(seed); + + // IB: Not a good rng algo, improve later + uint32_t pad = 0; + for (int i = 0; i < n; i++) { + if ((i)%31 == 0) { + pad = static_cast(rand()); + } + int sign = -1 * (pad & 0x1); + pad >>= 1; + + v[i] = sign * static_cast(rand()) / RAND_MAX * max_f(); + } + return v; +} + + +template +std::vector random_vector(size_t n) { + return seeded_random_vector(n, 42); +} + + + +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 = max_f(); + } + + return absdiff; +} + + +template +std::string +pickles(std::initializer_list> cucumbers) { + std::stringstream ss; + ss << std::setprecision(22); // enough to round trip long doubles + + for (std::vector cuke : cucumbers) { + for (T c : cuke) { + ss << c << " "; + } + } + + return ss.str(); +} + +template +std::vector +split_vector(std::vector sizes, int index, std::vector ti) { + int start = 0; + int end = 0; + int i = 0; + for (; i(ti.begin() + start, ti.begin() + end); +} + +#endif // POLYBENCH_UTILS_H + diff --git a/benchmarks/seidel_2d.cpp b/benchmarks/seidel_2d.cpp new file mode 100644 index 00000000..6ec516a2 --- /dev/null +++ b/benchmarks/seidel_2d.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "seidel_2d_base.hpp" + + +REGISTER_2(Seidel_2d, 4, 4) +REGISTER_2(Seidel_2d, 5, 5) +REGISTER_2(Seidel_2d, 6, 6) +REGISTER_2(Seidel_2d, 7, 7) +REGISTER_2(Seidel_2d, 8, 8) diff --git a/benchmarks/seidel_2d_base.hpp b/benchmarks/seidel_2d_base.hpp new file mode 100644 index 00000000..2deffb10 --- /dev/null +++ b/benchmarks/seidel_2d_base.hpp @@ -0,0 +1,46 @@ +#ifndef SEIDEL_2D_BASE_H +#define SEIDEL_2D_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N}; + std::vector A = split_vector(sizes, 0, 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)])/static_cast(9.0); + + return pickles({A}); + } + +protected: + using flit::TestBase::id; +}; + +#endif // SEIDEL_2D_BASE_H diff --git a/benchmarks/symm.cpp b/benchmarks/symm.cpp new file mode 100644 index 00000000..46b7c0bc --- /dev/null +++ b/benchmarks/symm.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "symm_base.hpp" + + +REGISTER_2(Symm, 4, 4) +REGISTER_2(Symm, 5, 5) +REGISTER_2(Symm, 6, 6) +REGISTER_2(Symm, 7, 7) +REGISTER_2(Symm, 8, 8) diff --git a/benchmarks/symm_base.hpp b/benchmarks/symm_base.hpp new file mode 100644 index 00000000..5947dc2a --- /dev/null +++ b/benchmarks/symm_base.hpp @@ -0,0 +1,55 @@ +#ifndef SYMM_BASE_H +#define SYMM_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 = static_cast(1.5); + T beta = static_cast(1.2); + std::vector sizes = {M*N, M*M, M*N}; + std::vector C = split_vector(sizes, 0, ti); + std::vector A = split_vector(sizes, 1, ti); + std::vector B = split_vector(sizes, 2, ti); + + 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; +}; + +#endif // SYMM_BASE_H diff --git a/benchmarks/syr2k.cpp b/benchmarks/syr2k.cpp new file mode 100644 index 00000000..a1de372c --- /dev/null +++ b/benchmarks/syr2k.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "syr2k_base.hpp" + + +REGISTER_2(Syr2k, 4, 4) +REGISTER_2(Syr2k, 5, 5) +REGISTER_2(Syr2k, 6, 6) +REGISTER_2(Syr2k, 7, 7) +REGISTER_2(Syr2k, 8, 8) diff --git a/benchmarks/syr2k_base.hpp b/benchmarks/syr2k_base.hpp new file mode 100644 index 00000000..169a49dd --- /dev/null +++ b/benchmarks/syr2k_base.hpp @@ -0,0 +1,54 @@ +#ifndef SYR2K_BASE_H +#define SYR2K_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N, N*M, N*M}; + std::vector C = split_vector(sizes, 0, ti); + std::vector A = split_vector(sizes, 1, ti); + std::vector B = split_vector(sizes, 2, ti); + T alpha = static_cast(1.5); + T beta = static_cast(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; +}; + +#endif // SYR2K_BASE_H diff --git a/benchmarks/syrk.cpp b/benchmarks/syrk.cpp new file mode 100644 index 00000000..aef9588b --- /dev/null +++ b/benchmarks/syrk.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "syrk_base.hpp" + + +REGISTER_2(Syrk, 4, 4) +REGISTER_2(Syrk, 5, 5) +REGISTER_2(Syrk, 6, 6) +REGISTER_2(Syrk, 7, 7) +REGISTER_2(Syrk, 8, 8) diff --git a/benchmarks/syrk_base.hpp b/benchmarks/syrk_base.hpp new file mode 100644 index 00000000..5926227d --- /dev/null +++ b/benchmarks/syrk_base.hpp @@ -0,0 +1,51 @@ +#ifndef SYRK_BASE_H +#define SYRK_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N, N*M}; + std::vector C = split_vector(sizes, 0, ti); + std::vector A = split_vector(sizes, 1, ti); + T alpha = static_cast(1.5); + T beta = static_cast(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; +}; + +#endif // SYRK_BASE_H diff --git a/benchmarks/test2mm.cpp b/benchmarks/test2mm.cpp new file mode 100644 index 00000000..668ab054 --- /dev/null +++ b/benchmarks/test2mm.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "test2mm_base.hpp" + + +REGISTER_4(Test2mm, 4, 4, 4, 4) +REGISTER_4(Test2mm, 5, 5, 5, 5) +REGISTER_4(Test2mm, 6, 6, 6, 6) +REGISTER_4(Test2mm, 7, 7, 7, 7) +REGISTER_4(Test2mm, 8, 8, 8, 8) diff --git a/benchmarks/test2mm_base.hpp b/benchmarks/test2mm_base.hpp new file mode 100644 index 00000000..81217f1f --- /dev/null +++ b/benchmarks/test2mm_base.hpp @@ -0,0 +1,61 @@ +#ifndef TEST2MM_BASE_H +#define TEST2MM_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {NI*NK, NK*NJ, NJ*NL, NI*NL}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + std::vector C = split_vector(sizes, 2, ti); + std::vector D = split_vector(sizes, 3, ti); + std::vector tmp(NI*NJ); + T alpha = static_cast(1.5); + T beta = static_cast(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] = static_cast(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; +}; + +#endif // TEST2MM_BASE_H diff --git a/benchmarks/test3mm.cpp b/benchmarks/test3mm.cpp new file mode 100644 index 00000000..78e8b2f5 --- /dev/null +++ b/benchmarks/test3mm.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "test3mm_base.hpp" + + +REGISTER_5(Test3mm, 4, 4, 4, 4, 4) +REGISTER_5(Test3mm, 5, 5, 5, 5, 5) +REGISTER_5(Test3mm, 6, 6, 6, 6, 6) +REGISTER_5(Test3mm, 7, 7, 7, 7, 7) +REGISTER_5(Test3mm, 8, 8, 8, 8, 8) diff --git a/benchmarks/test3mm_base.hpp b/benchmarks/test3mm_base.hpp new file mode 100644 index 00000000..a02beda3 --- /dev/null +++ b/benchmarks/test3mm_base.hpp @@ -0,0 +1,70 @@ +#ifndef TEST3MM_BASE_H +#define TEST3MM_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {NI*NK, NK*NJ, NJ*NM, NM*NL}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + std::vector C = split_vector(sizes, 2, ti); + std::vector D = split_vector(sizes, 3, ti); + std::vector E(NI*NJ); + std::vector F(NJ*NL); + std::vector 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] = static_cast(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] = static_cast(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] = static_cast(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; +}; + +#endif // TEST3MM_BASE_H diff --git a/benchmarks/trisolv.cpp b/benchmarks/trisolv.cpp new file mode 100644 index 00000000..be8474e8 --- /dev/null +++ b/benchmarks/trisolv.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "trisolv_base.hpp" + + +REGISTER_1(Trisolv, 4) +REGISTER_1(Trisolv, 5) +REGISTER_1(Trisolv, 6) +REGISTER_1(Trisolv, 7) +REGISTER_1(Trisolv, 8) diff --git a/benchmarks/trisolv_base.hpp b/benchmarks/trisolv_base.hpp new file mode 100644 index 00000000..8e10d07e --- /dev/null +++ b/benchmarks/trisolv_base.hpp @@ -0,0 +1,49 @@ +#ifndef TRISOLV_BASE_H +#define TRISOLV_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {N*N, N, N}; + std::vector L = split_vector(sizes, 0, ti); + std::vector x = split_vector(sizes, 1, ti); + std::vector b = split_vector(sizes, 2, ti); + + int i, j; + + for (i = 0; i < N; i++) + { + x[i] = b[i]; + for (j = 0; j ::id; +}; + +#endif // TRISOLV_BASE_H diff --git a/benchmarks/trmm.cpp b/benchmarks/trmm.cpp new file mode 100644 index 00000000..139a6e79 --- /dev/null +++ b/benchmarks/trmm.cpp @@ -0,0 +1,14 @@ + + +#include + +#include + +#include "trmm_base.hpp" + + +REGISTER_2(Trmm, 4, 4) +REGISTER_2(Trmm, 5, 5) +REGISTER_2(Trmm, 6, 6) +REGISTER_2(Trmm, 7, 7) +REGISTER_2(Trmm, 8, 8) diff --git a/benchmarks/trmm_base.hpp b/benchmarks/trmm_base.hpp new file mode 100644 index 00000000..9a7bf424 --- /dev/null +++ b/benchmarks/trmm_base.hpp @@ -0,0 +1,49 @@ +#ifndef TRMM_BASE_H +#define TRMM_BASE_H + + +#include + +#include "polybench_utils.hpp" + + +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 { + std::vector sizes = {M*M, M*N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + T alpha = static_cast(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; +}; + +#endif // TRMM_BASE_H From 13d8a1714e9d4e0cf05b19779358e88a97f98cb7 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 6 Jun 2018 00:56:00 -0600 Subject: [PATCH 102/166] Add tests for distributions using Mersenne Twister --- benchmarks/random/README.md | 3 ++ benchmarks/random/custom.mk | 27 +++++++++++++++++ benchmarks/random/flit-config.toml | 47 ++++++++++++++++++++++++++++++ benchmarks/random/main.cpp | 5 ++++ benchmarks/random/tests/Random.cpp | 47 ++++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+) create mode 100644 benchmarks/random/README.md create mode 100644 benchmarks/random/custom.mk create mode 100644 benchmarks/random/flit-config.toml create mode 100644 benchmarks/random/main.cpp create mode 100644 benchmarks/random/tests/Random.cpp diff --git a/benchmarks/random/README.md b/benchmarks/random/README.md new file mode 100644 index 00000000..4b1218d8 --- /dev/null +++ b/benchmarks/random/README.md @@ -0,0 +1,3 @@ +# 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. 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..96962799 --- /dev/null +++ b/benchmarks/random/flit-config.toml @@ -0,0 +1,47 @@ +# 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' + +# 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/Random.cpp b/benchmarks/random/tests/Random.cpp new file mode 100644 index 00000000..de01a7ec --- /dev/null +++ b/benchmarks/random/tests/Random.cpp @@ -0,0 +1,47 @@ +#include + +#include +#include + +template +class Random : public flit::TestBase { +public: + Random(std::string id) : flit::TestBase(std::move(id)) {} + virtual size_t getInputsPerRun() override { return 1; } + virtual std::vector getDefaultInput() override { return { 42, 24, 12, 10, 103 }; } +protected: + virtual flit::Variant run_impl(const std::vector &ti) override { + size_t seed = ti[0]; + Gen g(seed); + return Dist()(g); + } +protected: + using flit::TestBase::id; +}; + +#define MY_REGISTRATION(name, gen, dist) \ + template \ + class name : public Random { \ + using Random::Random; \ + }; \ + REGISTER_TYPE(name) + +MY_REGISTRATION(Random_mt19937_uniform, std::mt19937, std::uniform_real_distribution) +MY_REGISTRATION(Random_mt19937_binomial, std::mt19937, std::binomial_distribution) +MY_REGISTRATION(Random_mt19937_bernoulli, std::mt19937, std::bernoulli_distribution) +MY_REGISTRATION(Random_mt19937_geometric, std::mt19937, std::geometric_distribution) +MY_REGISTRATION(Random_mt19937_negative_binomial, std::mt19937, std::negative_binomial_distribution) +MY_REGISTRATION(Random_mt19937_poisson, std::mt19937, std::poisson_distribution) +MY_REGISTRATION(Random_mt19937_exponential, std::mt19937, std::exponential_distribution) +MY_REGISTRATION(Random_mt19937_gamma, std::mt19937, std::gamma_distribution) +MY_REGISTRATION(Random_mt19937_weibull, std::mt19937, std::weibull_distribution) +MY_REGISTRATION(Random_mt19937_extreme_value, std::mt19937, std::extreme_value_distribution) +MY_REGISTRATION(Random_mt19937_normal, std::mt19937, std::normal_distribution) +MY_REGISTRATION(Random_mt19937_lognormal, std::mt19937, std::lognormal_distribution) +MY_REGISTRATION(Random_mt19937_chi_squared, std::mt19937, std::chi_squared_distribution) +MY_REGISTRATION(Random_mt19937_cauchy, std::mt19937, std::cauchy_distribution) +MY_REGISTRATION(Random_mt19937_fisher_f, std::mt19937, std::fisher_f_distribution) +MY_REGISTRATION(Random_mt19937_student_t, std::mt19937, std::student_t_distribution) +MY_REGISTRATION(Random_mt19937_discrete, std::mt19937, std::discrete_distribution) + + From a98ace685ea83c4c6eb6ec5e210b3d8ba2581cc3 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 6 Jun 2018 09:01:23 -0600 Subject: [PATCH 103/166] Add a lot of Random tests --- benchmarks/random/tests/Random.cpp | 69 +++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/benchmarks/random/tests/Random.cpp b/benchmarks/random/tests/Random.cpp index de01a7ec..f9d7dee1 100644 --- a/benchmarks/random/tests/Random.cpp +++ b/benchmarks/random/tests/Random.cpp @@ -3,14 +3,16 @@ #include #include +using namespace std; + template class Random : public flit::TestBase { public: - Random(std::string id) : flit::TestBase(std::move(id)) {} + Random(string id) : flit::TestBase(move(id)) {} virtual size_t getInputsPerRun() override { return 1; } - virtual std::vector getDefaultInput() override { return { 42, 24, 12, 10, 103 }; } + virtual vector getDefaultInput() override { return { 42, 24, 12, 10, 103 }; } protected: - virtual flit::Variant run_impl(const std::vector &ti) override { + virtual flit::Variant run_impl(const vector &ti) override { size_t seed = ti[0]; Gen g(seed); return Dist()(g); @@ -19,6 +21,21 @@ class Random : public flit::TestBase { using flit::TestBase::id; }; +template +struct Pass { + auto operator() (Gen &g) -> decltype(g()) { + return g(); + } +}; + +template +struct Canonical { + template + T operator() (G &g) { + return generate_canonical::digits>(g); + } +}; + #define MY_REGISTRATION(name, gen, dist) \ template \ class name : public Random { \ @@ -26,22 +43,34 @@ class Random : public flit::TestBase { }; \ REGISTER_TYPE(name) -MY_REGISTRATION(Random_mt19937_uniform, std::mt19937, std::uniform_real_distribution) -MY_REGISTRATION(Random_mt19937_binomial, std::mt19937, std::binomial_distribution) -MY_REGISTRATION(Random_mt19937_bernoulli, std::mt19937, std::bernoulli_distribution) -MY_REGISTRATION(Random_mt19937_geometric, std::mt19937, std::geometric_distribution) -MY_REGISTRATION(Random_mt19937_negative_binomial, std::mt19937, std::negative_binomial_distribution) -MY_REGISTRATION(Random_mt19937_poisson, std::mt19937, std::poisson_distribution) -MY_REGISTRATION(Random_mt19937_exponential, std::mt19937, std::exponential_distribution) -MY_REGISTRATION(Random_mt19937_gamma, std::mt19937, std::gamma_distribution) -MY_REGISTRATION(Random_mt19937_weibull, std::mt19937, std::weibull_distribution) -MY_REGISTRATION(Random_mt19937_extreme_value, std::mt19937, std::extreme_value_distribution) -MY_REGISTRATION(Random_mt19937_normal, std::mt19937, std::normal_distribution) -MY_REGISTRATION(Random_mt19937_lognormal, std::mt19937, std::lognormal_distribution) -MY_REGISTRATION(Random_mt19937_chi_squared, std::mt19937, std::chi_squared_distribution) -MY_REGISTRATION(Random_mt19937_cauchy, std::mt19937, std::cauchy_distribution) -MY_REGISTRATION(Random_mt19937_fisher_f, std::mt19937, std::fisher_f_distribution) -MY_REGISTRATION(Random_mt19937_student_t, std::mt19937, std::student_t_distribution) -MY_REGISTRATION(Random_mt19937_discrete, std::mt19937, std::discrete_distribution) +#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) + +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); From 1024a8c6f7d7515bac8fde0b2cae53f05ff3a7fb Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 6 Jun 2018 10:17:09 -0600 Subject: [PATCH 104/166] Random benchmark: minor formatting and comments --- benchmarks/random/tests/Random.cpp | 57 ++++++++++++++++-------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/benchmarks/random/tests/Random.cpp b/benchmarks/random/tests/Random.cpp index f9d7dee1..5aa32d41 100644 --- a/benchmarks/random/tests/Random.cpp +++ b/benchmarks/random/tests/Random.cpp @@ -21,6 +21,7 @@ class Random : public flit::TestBase { using flit::TestBase::id; }; +// A simple passthrough distribution that returns the generator's value template struct Pass { auto operator() (Gen &g) -> decltype(g()) { @@ -28,6 +29,7 @@ struct Pass { } }; +// A distribution between [0, 1) using std::generate_canonical() template struct Canonical { template @@ -36,6 +38,7 @@ struct Canonical { } }; +// Convenience macro to create new tests with a generator and distribution #define MY_REGISTRATION(name, gen, dist) \ template \ class name : public Random { \ @@ -43,34 +46,36 @@ struct Canonical { }; \ 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##_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) + 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 ) -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); +// 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 ) From e618cfcba11d6541894daba126bc654e39d7c5be Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 6 Jun 2018 10:20:17 -0600 Subject: [PATCH 105/166] Random benchmark: add license statement --- benchmarks/random/tests/Random.cpp | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/benchmarks/random/tests/Random.cpp b/benchmarks/random/tests/Random.cpp index 5aa32d41..beaf4ca1 100644 --- a/benchmarks/random/tests/Random.cpp +++ b/benchmarks/random/tests/Random.cpp @@ -1,3 +1,86 @@ +/* -- 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 From e4f1517168c375476cf3fe09ff5ed2b42dfc461a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 6 Jun 2018 16:24:06 -0600 Subject: [PATCH 106/166] Add uninstall documentation and fix other docs Some of the docs were woefully old, so update them. But I didn't go through exhaustively to update docs yet. --- README.md | 24 +++++--- documentation/flit-command-line.md | 56 ++++++++---------- documentation/installation.md | 94 ++++++++++-------------------- 3 files changed, 71 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index aaa15fe4..78db9846 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: diff --git a/documentation/flit-command-line.md b/documentation/flit-command-line.md index 0882a375..129573f5 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,30 @@ 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/installation.md b/documentation/installation.md index 800a5ca4..0a8b35e0 100644 --- a/documentation/installation.md +++ b/documentation/installation.md @@ -6,7 +6,6 @@ Instruction Contents: -* [Roles](#roles) * [Prerequisites](#prerequisites) * [Shared Prerequisites](#shared-prerequisites) * [Runner Prerequisites](#runner-prerequisites) @@ -15,39 +14,32 @@ Instruction Contents: * [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. - ## Prerequisites -### Shared Prerequisites +Stuff you should already have: + +* [bash](https://www.gnu.org/software/bash) +* [binutils](https://www.gnu.org/software/binutils) +* [coreutils](https://www.gnu.org/software/coreutils/coreutils.html) +* hostname -The following prerequisites are required for all three roles: +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 +50,20 @@ 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. - -### Runner Prerequisites +symbolic link called `python3` in your `PATH` pointing to that python +executable. -The test runner can run multiple compilers. For now, only one compiler is -supported from each of the types: GCC, Clang, and Intel's `icpc`. 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. +### Compilers -If this is not on the same machine as the Launcher, then the Database machine -will need an SSH server running. - -```bash -sudo apt install openssh-server -``` - -### Database Prerequisites - -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. +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. ## 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 +86,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 +100,19 @@ 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) | From 18fe1a732abd0169a8981f4d75f355a45a742ab8 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 6 Jun 2018 16:30:45 -0600 Subject: [PATCH 107/166] uninstall: try to remove created directories too --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index d79f2d3c..b73eb1e0 100644 --- a/Makefile +++ b/Makefile @@ -173,3 +173,9 @@ uninstall: 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) From b0a52d0537d3273bfe66b71fa83118a403794e1b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 10:17:42 -0600 Subject: [PATCH 108/166] Add tests for uninstall functionality --- .../flit_install/tst_uninstall_runthrough.py | 140 ++++++++++++++++++ tests/test_harness.py | 12 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 tests/flit_install/tst_uninstall_runthrough.py diff --git a/tests/flit_install/tst_uninstall_runthrough.py b/tests/flit_install/tst_uninstall_runthrough.py new file mode 100644 index 00000000..b442035a --- /dev/null +++ b/tests/flit_install/tst_uninstall_runthrough.py @@ -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 -- + +''' +Tests FLiT's capabilities to uninstall itself + +The tests are below using doctest + +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 + +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'] +''' + +# 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/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): ''' From 50de47aaa34561e53b38318ff966b72a77381d1d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 10:59:16 -0600 Subject: [PATCH 109/166] Add benchmarks to install --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 19fc8dee..027126d9 100644 --- a/Makefile +++ b/Makefile @@ -101,6 +101,7 @@ install: $(TARGET) 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)) @@ -120,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) From 0a9209062b535078beb693fa0cdad83531d3596e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 10:59:49 -0600 Subject: [PATCH 110/166] Add benchmark documentation --- README.md | 1 + benchmarks/README.md | 14 ++++++++++++ documentation/README.md | 1 + documentation/benchmarks.md | 33 +++++++++++++++++++++++++++++ documentation/database-structure.md | 2 +- documentation/test-executable.md | 2 +- 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 benchmarks/README.md create mode 100644 documentation/benchmarks.md diff --git a/README.md b/README.md index aaa15fe4..3183341a 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Contents: * [Available Compiler Flags](documentation/available-compiler-flags.md) * [Writing Test Cases](documentation/writing-test-cases.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** 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/documentation/README.md b/documentation/README.md index b35124e9..fd9f9d82 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -9,6 +9,7 @@ * [Available Compiler Flags](available-compiler-flags.md) * [Writing Test Cases](writing-test-cases.md) * [Test Executable](test-executable.md) +* [Benchmarks](benchmarks.md) * [Database Structure](database-structure.md) * [Analyze Results](analyze-results.md) * **Extra Tools** 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/database-structure.md b/documentation/database-structure.md index 666e075d..224bce1b 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) | diff --git a/documentation/test-executable.md b/documentation/test-executable.md index e245ad0e..b00e1e1f 100644 --- a/documentation/test-executable.md +++ b/documentation/test-executable.md @@ -4,7 +4,7 @@ | [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 From 8f3d91c30df49df6693a0f37f03cb55877e2dbaa Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 11:06:55 -0600 Subject: [PATCH 111/166] random benchmark: change one seed to zero Zero is possibly a special seed value, so let's test it. --- benchmarks/random/tests/Random.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/random/tests/Random.cpp b/benchmarks/random/tests/Random.cpp index beaf4ca1..d4f277db 100644 --- a/benchmarks/random/tests/Random.cpp +++ b/benchmarks/random/tests/Random.cpp @@ -93,7 +93,7 @@ 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 { 42, 24, 12, 10, 103 }; } + 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]; From 7efc25fe9d3086f5bde420c07aa1042e07590e51 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 11:15:20 -0600 Subject: [PATCH 112/166] Add a test for rand() with srand() --- benchmarks/random/README.md | 10 ++- benchmarks/random/tests/Rand.cpp | 114 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 benchmarks/random/tests/Rand.cpp diff --git a/benchmarks/random/README.md b/benchmarks/random/README.md index 4b1218d8..d5ab3410 100644 --- a/benchmarks/random/README.md +++ b/benchmarks/random/README.md @@ -1,3 +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. +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/tests/Rand.cpp b/benchmarks/random/tests/Rand.cpp new file mode 100644 index 00000000..0e64ac99 --- /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); From e3be635a49c072d54b1bdbedf08a4ba579103eb6 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 13:53:20 -0600 Subject: [PATCH 113/166] toml: enforce default values when loading toml files --- scripts/flitcli/flit_import.py | 1 + scripts/flitcli/flit_init.py | 13 +--- scripts/flitcli/flit_update.py | 1 + scripts/flitcli/flitutil.py | 113 +++++++++++++++++++++++++++++++-- 4 files changed, 110 insertions(+), 18 deletions(-) diff --git a/scripts/flitcli/flit_import.py b/scripts/flitcli/flit_import.py index f5c31f5a..be02578a 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' diff --git a/scripts/flitcli/flit_init.py b/scripts/flitcli/flit_init.py index 24b0c500..08def398 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): ''' diff --git a/scripts/flitcli/flit_update.py b/scripts/flitcli/flit_update.py index 9297d16f..c84a0a97 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): diff --git a/scripts/flitcli/flitutil.py b/scripts/flitcli/flitutil.py index 644d9903..3591c28a 100644 --- a/scripts/flitcli/flitutil.py +++ b/scripts/flitcli/flitutil.py @@ -86,11 +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): ''' @@ -118,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): ''' From 53affe6325b10cdccd53b738de74ad87b590afb3 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 13:53:51 -0600 Subject: [PATCH 114/166] flit-default: add timing options to toml file Not yet used --- .../flitcli/config/flit-default-future.toml.in | 17 ++++++++++++++++- scripts/flitcli/config/flit-default.toml.in | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/scripts/flitcli/config/flit-default-future.toml.in b/scripts/flitcli/config/flit-default-future.toml.in index dee588d4..05344db7 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. diff --git a/scripts/flitcli/config/flit-default.toml.in b/scripts/flitcli/config/flit-default.toml.in index 170def42..92337dcc 100644 --- a/scripts/flitcli/config/flit-default.toml.in +++ b/scripts/flitcli/config/flit-default.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]] name = '{hostname}' From baca9c7a861904b6982dcf39f77a296637e893c1 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 15:09:28 -0600 Subject: [PATCH 115/166] flit-update: add timing to generated Makefile from the flit-config.toml file --- data/Makefile.in | 2 ++ scripts/flitcli/flit_update.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/data/Makefile.in b/data/Makefile.in index e11d5d10..78da16bc 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -102,6 +102,8 @@ GT_CC := {ground_truth_compiler} GT_OPTL := {ground_truth_optl} GT_SWITCHES := {ground_truth_switches} +TEST_RUN_ARGS := {test_run_args} + OBJ_DIR = obj CC_REQUIRED += $(FFLAGS) diff --git a/scripts/flitcli/flit_update.py b/scripts/flitcli/flit_update.py index c84a0a97..9110b024 100644 --- a/scripts/flitcli/flit_update.py +++ b/scripts/flitcli/flit_update.py @@ -152,6 +152,14 @@ def main(arguments, prog=sys.argv[0]): if '/' in dev_compiler_bin: 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, @@ -167,6 +175,7 @@ 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, }, overwrite=True) From 07de0361a048dcf0a5603567d0b6c8fdd0ac146f Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 17:42:34 -0600 Subject: [PATCH 116/166] Makefile.in: add use of TEST_RUN_ARGS --- data/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/Makefile.in b/data/Makefile.in index 78da16bc..a0ec63df 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -412,7 +412,7 @@ TARGET_OUTS := $(TARGETS:%=%-out) TARGET_RESULTS := $(TARGET_OUTS:%=%-comparison.csv) %-out: % - ./$< --output $@ || touch $@ + ./$< $(TEST_RUN_ARGS) --output $@ || touch $@ # specify how to get comparison %-out-comparison.csv: %-out $(GT_OUT) $(GT_TARGET) From 70afe85f596291e4fa4188d24695d8819a780984 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 17:42:52 -0600 Subject: [PATCH 117/166] random-benchmark: set timing to false --- benchmarks/random/flit-config.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/benchmarks/random/flit-config.toml b/benchmarks/random/flit-config.toml index 96962799..6fc21156 100644 --- a/benchmarks/random/flit-config.toml +++ b/benchmarks/random/flit-config.toml @@ -11,6 +11,9 @@ type = 'sqlite' # configuration file. filepath = 'results.sqlite' +[run] +timing = false + # For now, only one host is supported, all others are ignored [[hosts]] From 9a9e1ecff3446825ee3b529527bc7fbf2d0edc29 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Thu, 7 Jun 2018 19:15:56 -0600 Subject: [PATCH 118/166] docs: update flit-configuration-file.md --- documentation/flit-configuration-file.md | 252 +++++------------------ 1 file changed, 57 insertions(+), 195 deletions(-) diff --git a/documentation/flit-configuration-file.md b/documentation/flit-configuration-file.md index 2346d163..c3786bb2 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,33 @@ 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 +``` + +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`. + +* `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). + ```toml [[hosts]] @@ -51,19 +80,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,121 +124,19 @@ 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` - -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', - ] -``` - -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', - ] -``` - -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`. - -```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]] - - binary = 'icpc' - name = 'intel-17.0' - type = 'intel' - optimization_levels = [ - '-O0', - ] - switches = [ - '', - ] -``` - -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`. +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`. ## Full Configuration File -Combining all of the above sections together, here is the full example configuration file: +Combining all of the above sections together, here is the full example (and +default) configuration file: ```toml [database] @@ -217,17 +144,27 @@ Combining all of the above sections together, here is the full example configura type = 'sqlite' filepath = 'results.sqlite' + +[run] + +timing = true +timing_loops = -1 +timing_repeats = 3 + + [[hosts]] 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] @@ -235,86 +172,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 = [ - '', - ] ``` From 7007b814ca11325e3d68e71467d08fc8dab50d39 Mon Sep 17 00:00:00 2001 From: Ian Briggs Date: Fri, 8 Jun 2018 10:44:43 -0600 Subject: [PATCH 119/166] Addressing changes requested by mikebentley15 --- benchmarks/README.md | 4 + benchmarks/adi.cpp | 14 -- benchmarks/adi_base.hpp | 93 -------- benchmarks/atax.cpp | 14 -- benchmarks/atax_base.hpp | 54 ----- benchmarks/bicg.cpp | 14 -- benchmarks/bicg_base.hpp | 55 ----- benchmarks/cholesky.cpp | 14 -- benchmarks/cholesky_base.hpp | 54 ----- benchmarks/correlation.cpp | 14 -- benchmarks/correlation_base.hpp | 89 -------- benchmarks/covariance.cpp | 14 -- benchmarks/covariance_base.hpp | 66 ------ benchmarks/deriche.cpp | 14 -- benchmarks/deriche_base.hpp | 123 ---------- benchmarks/doitgen.cpp | 14 -- benchmarks/doitgen_base.hpp | 53 ----- benchmarks/durbin.cpp | 14 -- benchmarks/durbin_base.hpp | 66 ------ benchmarks/empty.hpp | 37 --- benchmarks/fdtd_2d.cpp | 14 -- benchmarks/fdtd_2d_base.hpp | 58 ----- benchmarks/floyd_warshall.cpp | 14 -- benchmarks/floyd_warshall_base.hpp | 47 ---- benchmarks/gemm.cpp | 14 -- benchmarks/gemm_base.hpp | 54 ----- benchmarks/gemver.cpp | 14 -- benchmarks/gemver_base.hpp | 71 ------ benchmarks/gesummv.cpp | 14 -- benchmarks/gesummv_base.hpp | 58 ----- benchmarks/gramschmidt.cpp | 14 -- benchmarks/gramschmidt_base.hpp | 61 ----- benchmarks/heat_3d.cpp | 14 -- benchmarks/heat_3d_base.hpp | 63 ------ benchmarks/jacobi_1d.cpp | 14 -- benchmarks/jacobi_1d_base.hpp | 48 ---- benchmarks/jacobi_2d.cpp | 14 -- benchmarks/jacobi_2d_base.hpp | 50 ---- benchmarks/lu.cpp | 14 -- benchmarks/lu_base.hpp | 53 ----- benchmarks/ludcmp.cpp | 14 -- benchmarks/ludcmp_base.hpp | 75 ------ benchmarks/mvt.cpp | 14 -- benchmarks/mvt_base.hpp | 50 ---- benchmarks/nussinov.cpp | 14 -- benchmarks/nussinov_base.hpp | 64 ------ benchmarks/polybench/README.md | 27 +++ benchmarks/polybench/custom.mk | 39 ++++ benchmarks/polybench/flit-config.toml | 47 ++++ benchmarks/polybench/tests/adi.cpp | 184 +++++++++++++++ benchmarks/polybench/tests/atax.cpp | 145 ++++++++++++ benchmarks/polybench/tests/bicg.cpp | 146 ++++++++++++ benchmarks/polybench/tests/cholesky.cpp | 145 ++++++++++++ benchmarks/polybench/tests/correlation.cpp | 180 +++++++++++++++ benchmarks/polybench/tests/covariance.cpp | 157 +++++++++++++ benchmarks/polybench/tests/deriche.cpp | 214 ++++++++++++++++++ benchmarks/polybench/tests/doitgen.cpp | 144 ++++++++++++ benchmarks/polybench/tests/durbin.cpp | 157 +++++++++++++ benchmarks/polybench/tests/fdtd_2d.cpp | 149 ++++++++++++ benchmarks/polybench/tests/floyd_warshall.cpp | 138 +++++++++++ benchmarks/polybench/tests/gemm.cpp | 145 ++++++++++++ benchmarks/polybench/tests/gemver.cpp | 162 +++++++++++++ benchmarks/polybench/tests/gesummv.cpp | 149 ++++++++++++ benchmarks/polybench/tests/gramschmidt.cpp | 152 +++++++++++++ benchmarks/polybench/tests/heat_3d.cpp | 154 +++++++++++++ benchmarks/polybench/tests/jacobi_1d.cpp | 139 ++++++++++++ benchmarks/polybench/tests/jacobi_2d.cpp | 141 ++++++++++++ benchmarks/polybench/tests/lu.cpp | 144 ++++++++++++ benchmarks/polybench/tests/ludcmp.cpp | 166 ++++++++++++++ benchmarks/polybench/tests/mvt.cpp | 141 ++++++++++++ benchmarks/polybench/tests/nussinov.cpp | 156 +++++++++++++ .../tests/polybench_utils.h} | 82 +++++++ benchmarks/polybench/tests/seidel_2d.cpp | 137 +++++++++++ benchmarks/polybench/tests/symm.cpp | 146 ++++++++++++ benchmarks/polybench/tests/syr2k.cpp | 145 ++++++++++++ benchmarks/polybench/tests/syrk.cpp | 142 ++++++++++++ benchmarks/polybench/tests/test2mm.cpp | 152 +++++++++++++ benchmarks/polybench/tests/test3mm.cpp | 161 +++++++++++++ benchmarks/polybench/tests/trisolv.cpp | 140 ++++++++++++ benchmarks/polybench/tests/trmm.cpp | 140 ++++++++++++ benchmarks/seidel_2d.cpp | 14 -- benchmarks/seidel_2d_base.hpp | 46 ---- benchmarks/symm.cpp | 14 -- benchmarks/symm_base.hpp | 55 ----- benchmarks/syr2k.cpp | 14 -- benchmarks/syr2k_base.hpp | 54 ----- benchmarks/syrk.cpp | 14 -- benchmarks/syrk_base.hpp | 51 ----- benchmarks/test2mm.cpp | 14 -- benchmarks/test2mm_base.hpp | 61 ----- benchmarks/test3mm.cpp | 14 -- benchmarks/test3mm_base.hpp | 70 ------ benchmarks/trisolv.cpp | 14 -- benchmarks/trisolv_base.hpp | 49 ---- benchmarks/trmm.cpp | 14 -- benchmarks/trmm_base.hpp | 49 ---- 96 files changed, 4770 insertions(+), 2297 deletions(-) create mode 100644 benchmarks/README.md delete mode 100644 benchmarks/adi.cpp delete mode 100644 benchmarks/adi_base.hpp delete mode 100644 benchmarks/atax.cpp delete mode 100644 benchmarks/atax_base.hpp delete mode 100644 benchmarks/bicg.cpp delete mode 100644 benchmarks/bicg_base.hpp delete mode 100644 benchmarks/cholesky.cpp delete mode 100644 benchmarks/cholesky_base.hpp delete mode 100644 benchmarks/correlation.cpp delete mode 100644 benchmarks/correlation_base.hpp delete mode 100644 benchmarks/covariance.cpp delete mode 100644 benchmarks/covariance_base.hpp delete mode 100644 benchmarks/deriche.cpp delete mode 100644 benchmarks/deriche_base.hpp delete mode 100644 benchmarks/doitgen.cpp delete mode 100644 benchmarks/doitgen_base.hpp delete mode 100644 benchmarks/durbin.cpp delete mode 100644 benchmarks/durbin_base.hpp delete mode 100644 benchmarks/empty.hpp delete mode 100644 benchmarks/fdtd_2d.cpp delete mode 100644 benchmarks/fdtd_2d_base.hpp delete mode 100644 benchmarks/floyd_warshall.cpp delete mode 100644 benchmarks/floyd_warshall_base.hpp delete mode 100644 benchmarks/gemm.cpp delete mode 100644 benchmarks/gemm_base.hpp delete mode 100644 benchmarks/gemver.cpp delete mode 100644 benchmarks/gemver_base.hpp delete mode 100644 benchmarks/gesummv.cpp delete mode 100644 benchmarks/gesummv_base.hpp delete mode 100644 benchmarks/gramschmidt.cpp delete mode 100644 benchmarks/gramschmidt_base.hpp delete mode 100644 benchmarks/heat_3d.cpp delete mode 100644 benchmarks/heat_3d_base.hpp delete mode 100644 benchmarks/jacobi_1d.cpp delete mode 100644 benchmarks/jacobi_1d_base.hpp delete mode 100644 benchmarks/jacobi_2d.cpp delete mode 100644 benchmarks/jacobi_2d_base.hpp delete mode 100644 benchmarks/lu.cpp delete mode 100644 benchmarks/lu_base.hpp delete mode 100644 benchmarks/ludcmp.cpp delete mode 100644 benchmarks/ludcmp_base.hpp delete mode 100644 benchmarks/mvt.cpp delete mode 100644 benchmarks/mvt_base.hpp delete mode 100644 benchmarks/nussinov.cpp delete mode 100644 benchmarks/nussinov_base.hpp create mode 100644 benchmarks/polybench/README.md create mode 100644 benchmarks/polybench/custom.mk create mode 100644 benchmarks/polybench/flit-config.toml create mode 100644 benchmarks/polybench/tests/adi.cpp create mode 100644 benchmarks/polybench/tests/atax.cpp create mode 100644 benchmarks/polybench/tests/bicg.cpp create mode 100644 benchmarks/polybench/tests/cholesky.cpp create mode 100644 benchmarks/polybench/tests/correlation.cpp create mode 100644 benchmarks/polybench/tests/covariance.cpp create mode 100644 benchmarks/polybench/tests/deriche.cpp create mode 100644 benchmarks/polybench/tests/doitgen.cpp create mode 100644 benchmarks/polybench/tests/durbin.cpp create mode 100644 benchmarks/polybench/tests/fdtd_2d.cpp create mode 100644 benchmarks/polybench/tests/floyd_warshall.cpp create mode 100644 benchmarks/polybench/tests/gemm.cpp create mode 100644 benchmarks/polybench/tests/gemver.cpp create mode 100644 benchmarks/polybench/tests/gesummv.cpp create mode 100644 benchmarks/polybench/tests/gramschmidt.cpp create mode 100644 benchmarks/polybench/tests/heat_3d.cpp create mode 100644 benchmarks/polybench/tests/jacobi_1d.cpp create mode 100644 benchmarks/polybench/tests/jacobi_2d.cpp create mode 100644 benchmarks/polybench/tests/lu.cpp create mode 100644 benchmarks/polybench/tests/ludcmp.cpp create mode 100644 benchmarks/polybench/tests/mvt.cpp create mode 100644 benchmarks/polybench/tests/nussinov.cpp rename benchmarks/{polybench_utils.hpp => polybench/tests/polybench_utils.h} (50%) create mode 100644 benchmarks/polybench/tests/seidel_2d.cpp create mode 100644 benchmarks/polybench/tests/symm.cpp create mode 100644 benchmarks/polybench/tests/syr2k.cpp create mode 100644 benchmarks/polybench/tests/syrk.cpp create mode 100644 benchmarks/polybench/tests/test2mm.cpp create mode 100644 benchmarks/polybench/tests/test3mm.cpp create mode 100644 benchmarks/polybench/tests/trisolv.cpp create mode 100644 benchmarks/polybench/tests/trmm.cpp delete mode 100644 benchmarks/seidel_2d.cpp delete mode 100644 benchmarks/seidel_2d_base.hpp delete mode 100644 benchmarks/symm.cpp delete mode 100644 benchmarks/symm_base.hpp delete mode 100644 benchmarks/syr2k.cpp delete mode 100644 benchmarks/syr2k_base.hpp delete mode 100644 benchmarks/syrk.cpp delete mode 100644 benchmarks/syrk_base.hpp delete mode 100644 benchmarks/test2mm.cpp delete mode 100644 benchmarks/test2mm_base.hpp delete mode 100644 benchmarks/test3mm.cpp delete mode 100644 benchmarks/test3mm_base.hpp delete mode 100644 benchmarks/trisolv.cpp delete mode 100644 benchmarks/trisolv_base.hpp delete mode 100644 benchmarks/trmm.cpp delete mode 100644 benchmarks/trmm_base.hpp diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 00000000..728294d4 --- /dev/null +++ b/benchmarks/README.md @@ -0,0 +1,4 @@ +This directory contains test suits adapted to the FLiT test harness. + +Manifest: + polybench: The Polybench benchmark suite \ No newline at end of file diff --git a/benchmarks/adi.cpp b/benchmarks/adi.cpp deleted file mode 100644 index 2503528d..00000000 --- a/benchmarks/adi.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "adi_base.hpp" - - -REGISTER_2(Adi, 4, 4) -REGISTER_2(Adi, 5, 5) -REGISTER_2(Adi, 6, 6) -REGISTER_2(Adi, 7, 7) -REGISTER_2(Adi, 8, 8) diff --git a/benchmarks/adi_base.hpp b/benchmarks/adi_base.hpp deleted file mode 100644 index 851b66d1..00000000 --- a/benchmarks/adi_base.hpp +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef ADI_BASE_H -#define ADI_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N}; - std::vector u = split_vector(sizes, 0, ti); - std::vector v(N*N); - std::vector p(N*N); - std::vector 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 = static_cast(1.0)/(T)N; - DY = static_cast(1.0)/(T)N; - DT = static_cast(1.0)/(T)TSTEPS; - B1 = static_cast(2.0); - B2 = static_cast(1.0); - mul1 = B1 * DT / (DX * DX); - mul2 = B2 * DT / (DY * DY); - - a = -mul1 / static_cast(2.0); - b = static_cast(1.0)+mul1; - c = a; - d = -mul2 / static_cast(2.0); - e = static_cast(1.0)+mul2; - f = d; - - for (t=1; t<=TSTEPS; t++) { - //Column Sweep - for (i=1; i(1.0); - p[i*N + 0] = static_cast(0.0); - q[i*N + 0] = v[0*N + i]; - for (j=1; j(1.0)+static_cast(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] = static_cast(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(1.0); - p[i*N + 0] = static_cast(0.0); - q[i*N + 0] = u[i*N + 0]; - for (j=1; j(1.0)+static_cast(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] = static_cast(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; -}; - -#endif // ADI_BASE_H diff --git a/benchmarks/atax.cpp b/benchmarks/atax.cpp deleted file mode 100644 index 164b1f54..00000000 --- a/benchmarks/atax.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "atax_base.hpp" - - -REGISTER_2(Atax, 4, 4) -REGISTER_2(Atax, 5, 5) -REGISTER_2(Atax, 6, 6) -REGISTER_2(Atax, 7, 7) -REGISTER_2(Atax, 8, 8) diff --git a/benchmarks/atax_base.hpp b/benchmarks/atax_base.hpp deleted file mode 100644 index 6e250998..00000000 --- a/benchmarks/atax_base.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef ATAX_BASE_H -#define ATAX_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {M*N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector x = split_vector(sizes, 1, ti); - std::vector y(N); - std::vector tmp(M); - - int i,j; - - for (i = 0; i < N; i++) - y[i] = 0; - for (i = 0; i < M; i++) - { - tmp[i] = static_cast(0.0); - for (j = 0; j < N; j++) - tmp[i] = tmp[i] + A[i*M + j] * x[j]; - for (j = 0; j < N; j++) - y[j] = y[j] + A[i*M + j] * tmp[i]; - } - - - return pickles({y, tmp}); -} - -protected: -using flit::TestBase::id; -}; - -#endif // ATAX_BASE_H diff --git a/benchmarks/bicg.cpp b/benchmarks/bicg.cpp deleted file mode 100644 index d924a7be..00000000 --- a/benchmarks/bicg.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "bicg_base.hpp" - - -REGISTER_2(Bicg, 4, 4) -REGISTER_2(Bicg, 5, 5) -REGISTER_2(Bicg, 6, 6) -REGISTER_2(Bicg, 7, 7) -REGISTER_2(Bicg, 8, 8) diff --git a/benchmarks/bicg_base.hpp b/benchmarks/bicg_base.hpp deleted file mode 100644 index b48cfa31..00000000 --- a/benchmarks/bicg_base.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef BICG_BASE_H -#define BICG_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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}; - std::vector A = split_vector(sizes, 0, ti); - std::vector r = split_vector(sizes, 1, ti); - std::vector p = split_vector(sizes, 2, ti); - std::vector s(M); - std::vector q(N); - - int i, j; - - for (i = 0; i < M; i++) - s[i] = 0; - for (i = 0; i < N; i++) - { - q[i] = static_cast(0.0); - for (j = 0; j < M; j++) - { - s[j] = s[j] + r[i] * A[i*N + j]; - q[i] = q[i] + A[i*N + j] * p[j]; - } - } - - return pickles({s, q}); - } - -protected: - using flit::TestBase::id; -}; - -#endif // BICG_BASE_H diff --git a/benchmarks/cholesky.cpp b/benchmarks/cholesky.cpp deleted file mode 100644 index 56942e4d..00000000 --- a/benchmarks/cholesky.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "cholesky_base.hpp" - - -REGISTER_1(Cholesky, 4) -REGISTER_1(Cholesky, 5) -REGISTER_1(Cholesky, 6) -REGISTER_1(Cholesky, 7) -REGISTER_1(Cholesky, 8) diff --git a/benchmarks/cholesky_base.hpp b/benchmarks/cholesky_base.hpp deleted file mode 100644 index 70dddf76..00000000 --- a/benchmarks/cholesky_base.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef CHOLESKY_BASE_H -#define CHOLESKY_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N}; - std::vector A = split_vector(sizes, 0, ti); - - int i, j, k; - - for (i = 0; i < N; i++) { - //j::id; -}; - -#endif // CHOLESKY_BASE_H diff --git a/benchmarks/correlation.cpp b/benchmarks/correlation.cpp deleted file mode 100644 index 8af7d4ed..00000000 --- a/benchmarks/correlation.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "correlation_base.hpp" - - -REGISTER_2(Correlation, 4, 4) -REGISTER_2(Correlation, 5, 5) -REGISTER_2(Correlation, 6, 6) -REGISTER_2(Correlation, 7, 7) -REGISTER_2(Correlation, 8, 8) diff --git a/benchmarks/correlation_base.hpp b/benchmarks/correlation_base.hpp deleted file mode 100644 index 8966564c..00000000 --- a/benchmarks/correlation_base.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef CORRELATION_BASE_H -#define CORRELATION_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -template -class CorrelationBase : public flit::TestBase { -public: - CorrelationBase(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 { - std::vector data = ti; - std::vector corr (M*M); - std::vector mean (M); - std::vector stddev (M); - T float_n = N; - - int i, j, k; - - T eps = 0.1; - - - for (j=0; j::id; -}; - -#endif // CORRELATION_BASE_H diff --git a/benchmarks/covariance.cpp b/benchmarks/covariance.cpp deleted file mode 100644 index 80ea2d5e..00000000 --- a/benchmarks/covariance.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "covariance_base.hpp" - - -REGISTER_2(Covariance, 4, 4) -REGISTER_2(Covariance, 5, 5) -REGISTER_2(Covariance, 6, 6) -REGISTER_2(Covariance, 7, 7) -REGISTER_2(Covariance, 8, 8) diff --git a/benchmarks/covariance_base.hpp b/benchmarks/covariance_base.hpp deleted file mode 100644 index 7bfdcad4..00000000 --- a/benchmarks/covariance_base.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef COVARIANCE_BASE_H -#define COVARIANCE_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 = static_cast(N); - std::vector data = ti; - std::vector cov(M*M); - std::vector mean(M); - - int i, j, k; - - for (j = 0; j < M; j++) { - mean[j] = static_cast(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] = static_cast(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 - static_cast(1.0)); - cov[j*M + i] = cov[i*M + j]; - } - } - - return pickles({data, cov, mean}) ; - } - -protected: - using flit::TestBase::id; -}; - -#endif // COVARIANCE_BASE_H diff --git a/benchmarks/deriche.cpp b/benchmarks/deriche.cpp deleted file mode 100644 index c3c430a2..00000000 --- a/benchmarks/deriche.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "deriche_base.hpp" - - -REGISTER_2(Deriche, 4, 4) -REGISTER_2(Deriche, 5, 5) -REGISTER_2(Deriche, 6, 6) -REGISTER_2(Deriche, 7, 7) -REGISTER_2(Deriche, 8, 8) diff --git a/benchmarks/deriche_base.hpp b/benchmarks/deriche_base.hpp deleted file mode 100644 index e12110ee..00000000 --- a/benchmarks/deriche_base.hpp +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef DERICHE_BASE_H -#define DERICHE_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {W*H, W*H}; - std::vector imgIn = split_vector(sizes, 0, ti); - std::vector imgOut = split_vector(sizes, 1, ti); - std::vector y1(W*H); - std::vector y2(W*H); - - T alpha = static_cast(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 = (static_cast(1.0)-std::exp(-alpha))*(static_cast(1.0)-std::exp(-alpha))/(static_cast(1.0)+static_cast(2.0)*alpha*std::exp(-alpha)-std::exp(static_cast(2.0)*alpha)); - a1 = a5 = k; - a2 = a6 = k*std::exp(-alpha)*(alpha-static_cast(1.0)); - a3 = a7 = k*std::exp(-alpha)*(alpha+static_cast(1.0)); - a4 = a8 = -k*std::exp(static_cast(-2.0)*alpha); - b1 = std::pow(static_cast(2.0),-alpha); - b2 = -std::exp(static_cast(-2.0)*alpha); - c1 = c2 = 1; - - for (i=0; i(0.0); - ym2 = static_cast(0.0); - xm1 = static_cast(0.0); - for (j=0; j(0.0); - yp2 = static_cast(0.0); - xp1 = static_cast(0.0); - xp2 = static_cast(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(0.0); - ym1 = static_cast(0.0); - ym2 = static_cast(0.0); - for (i=0; i(0.0); - tp2 = static_cast(0.0); - yp1 = static_cast(0.0); - yp2 = static_cast(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::id; -}; - -#endif // DERICHE_BASE_H diff --git a/benchmarks/doitgen.cpp b/benchmarks/doitgen.cpp deleted file mode 100644 index 5788fa27..00000000 --- a/benchmarks/doitgen.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "doitgen_base.hpp" - - -REGISTER_3(Doitgen, 4, 4, 4) -REGISTER_3(Doitgen, 5, 5, 5) -REGISTER_3(Doitgen, 6, 6, 6) -REGISTER_3(Doitgen, 7, 7, 7) -REGISTER_3(Doitgen, 8, 8, 8) diff --git a/benchmarks/doitgen_base.hpp b/benchmarks/doitgen_base.hpp deleted file mode 100644 index 6988ee73..00000000 --- a/benchmarks/doitgen_base.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef DOITGEN_BASE_H -#define DOITGEN_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {NR*NQ*NP, NP*NP}; - std::vector A = split_vector(sizes, 0, ti); - std::vector C4 = split_vector(sizes, 1, ti); - 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] = static_cast(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; -}; - -#endif // DOITGEN_BASE_H diff --git a/benchmarks/durbin.cpp b/benchmarks/durbin.cpp deleted file mode 100644 index e9b3989d..00000000 --- a/benchmarks/durbin.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "durbin_base.hpp" - - -REGISTER_1(Durbin, 4) -REGISTER_1(Durbin, 5) -REGISTER_1(Durbin, 6) -REGISTER_1(Durbin, 7) -REGISTER_1(Durbin, 8) diff --git a/benchmarks/durbin_base.hpp b/benchmarks/durbin_base.hpp deleted file mode 100644 index e19cd53b..00000000 --- a/benchmarks/durbin_base.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef DURBIN_BASE_H -#define DURBIN_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N}; - std::vector r = split_vector(sizes, 0, ti); - std::vector y(N); - - std::vector z(N); - T alpha; - T beta; - T sum; - - int i,k; - - y[0] = -r[0]; - beta = static_cast(1.0); - alpha = -r[0]; - - for (k = 1; k < N; k++) { - beta = (1-alpha*alpha)*beta; - sum = static_cast(0.0); - for (i=0; i::id; -}; - -#endif // DURBIN_BASE_H diff --git a/benchmarks/empty.hpp b/benchmarks/empty.hpp deleted file mode 100644 index a4e4b725..00000000 --- a/benchmarks/empty.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef EMPTY_BASE_H -#define EMPTY_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -template -class EmptyBase : public flit::TestBase { -public: - EmptyBase(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 { - std::vector sizes = {}; - std::vector C = split_vector(sizes, 0, ti); - - return pickles({}); - } - -protected: - using flit::TestBase::id; -}; - -#endif // EMPTY_BASE_H diff --git a/benchmarks/fdtd_2d.cpp b/benchmarks/fdtd_2d.cpp deleted file mode 100644 index 39178940..00000000 --- a/benchmarks/fdtd_2d.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "fdtd_2d_base.hpp" - - -REGISTER_3(Fdtd_2d, 4, 4, 4) -REGISTER_3(Fdtd_2d, 5, 5, 5) -REGISTER_3(Fdtd_2d, 6, 6, 6) -REGISTER_3(Fdtd_2d, 7, 7, 7) -REGISTER_3(Fdtd_2d, 8, 8, 8) diff --git a/benchmarks/fdtd_2d_base.hpp b/benchmarks/fdtd_2d_base.hpp deleted file mode 100644 index 0ad4ec8e..00000000 --- a/benchmarks/fdtd_2d_base.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef FDTD_2D_BASE_H -#define FDTD_2D_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {NX*NY, NX*NY, NX*NY, TMAX}; - std::vector ex = split_vector(sizes, 0, ti); - std::vector ey = split_vector(sizes, 1, ti); - std::vector hz = split_vector(sizes, 2, ti); - std::vector _fict_ = split_vector(sizes, 3, ti); - - 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] = ey[i*NX + j] - static_cast(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] = ex[i*NX + j] - static_cast(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] = hz[i*NX + j] - static_cast(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; -}; - -#endif // FDTD_2D_BASE_H diff --git a/benchmarks/floyd_warshall.cpp b/benchmarks/floyd_warshall.cpp deleted file mode 100644 index 26dc684f..00000000 --- a/benchmarks/floyd_warshall.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "floyd_warshall_base.hpp" - - -REGISTER_1(Floyd_Warshall, 4) -REGISTER_1(Floyd_Warshall, 5) -REGISTER_1(Floyd_Warshall, 6) -REGISTER_1(Floyd_Warshall, 7) -REGISTER_1(Floyd_Warshall, 8) diff --git a/benchmarks/floyd_warshall_base.hpp b/benchmarks/floyd_warshall_base.hpp deleted file mode 100644 index 16f5ea75..00000000 --- a/benchmarks/floyd_warshall_base.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef FLOYD_WARSHALL_BASE_H -#define FLOYD_WARSHALL_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N}; - std::vector path = split_vector(sizes, 0, 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; -}; - -#endif // FLOYD_WARSHALL_BASE_H diff --git a/benchmarks/gemm.cpp b/benchmarks/gemm.cpp deleted file mode 100644 index 449701e5..00000000 --- a/benchmarks/gemm.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "gemm_base.hpp" - - -REGISTER_3(Gemm, 4, 4, 4) -REGISTER_3(Gemm, 5, 5, 5) -REGISTER_3(Gemm, 6, 6, 6) -REGISTER_3(Gemm, 7, 7, 7) -REGISTER_3(Gemm, 8, 8, 8) diff --git a/benchmarks/gemm_base.hpp b/benchmarks/gemm_base.hpp deleted file mode 100644 index 282467b9..00000000 --- a/benchmarks/gemm_base.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef GEMM_BASE_H -#define GEMM_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 = static_cast(1.5); - T beta = static_cast(1.2); - std::vector sizes = {NI*NI, NI*NK, NK+NJ}; - std::vector C = split_vector(sizes, 0, ti); - std::vector A = split_vector(sizes, 1, ti); - std::vector B = split_vector(sizes, 2, ti); - - 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; -}; - -#endif // GEMM_BASE_H diff --git a/benchmarks/gemver.cpp b/benchmarks/gemver.cpp deleted file mode 100644 index 838510d6..00000000 --- a/benchmarks/gemver.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "gemver_base.hpp" - - -REGISTER_1(Gemver, 4) -REGISTER_1(Gemver, 5) -REGISTER_1(Gemver, 6) -REGISTER_1(Gemver, 7) -REGISTER_1(Gemver, 8) diff --git a/benchmarks/gemver_base.hpp b/benchmarks/gemver_base.hpp deleted file mode 100644 index 6833a7b0..00000000 --- a/benchmarks/gemver_base.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef GEMVER_BASE_H -#define GEMVER_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 = static_cast(1.5); - T beta = static_cast(1.2); - std::vector sizes = {N*N, N, N, N, N, N, N, N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector u1 = split_vector(sizes, 1, ti); - std::vector v1 = split_vector(sizes, 2, ti); - std::vector u2 = split_vector(sizes, 3, ti); - std::vector v2 = split_vector(sizes, 4, ti); - std::vector w = split_vector(sizes, 5, ti); - std::vector x = split_vector(sizes, 6, ti); - std::vector y = split_vector(sizes, 7, ti); - std::vector z = split_vector(sizes, 8, ti); - - 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; -}; - -#endif // GEMVER_BASE_H diff --git a/benchmarks/gesummv.cpp b/benchmarks/gesummv.cpp deleted file mode 100644 index 00bc3490..00000000 --- a/benchmarks/gesummv.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "gesummv_base.hpp" - - -REGISTER_1(Gesummv, 4) -REGISTER_1(Gesummv, 5) -REGISTER_1(Gesummv, 6) -REGISTER_1(Gesummv, 7) -REGISTER_1(Gesummv, 8) diff --git a/benchmarks/gesummv_base.hpp b/benchmarks/gesummv_base.hpp deleted file mode 100644 index 137f253d..00000000 --- a/benchmarks/gesummv_base.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef GESUMMV_BASE_H -#define GESUMMV_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 = static_cast(1.5); - T beta = static_cast(1.2); - std::vector sizes = {N*N, N*N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - std::vector x = split_vector(sizes, 2, ti); - - std::vector tmp(N); - std::vector y(N); - - int i, j; - - for (i = 0; i < N; i++) - { - tmp[i] = static_cast(0.0); - y[i] = static_cast(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; -}; - -#endif // GESUMMV_BASE_H diff --git a/benchmarks/gramschmidt.cpp b/benchmarks/gramschmidt.cpp deleted file mode 100644 index 9ea505c8..00000000 --- a/benchmarks/gramschmidt.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "gramschmidt_base.hpp" - - -REGISTER_2(Gramschmidt, 4, 4) -REGISTER_2(Gramschmidt, 5, 5) -REGISTER_2(Gramschmidt, 6, 6) -REGISTER_2(Gramschmidt, 7, 7) -REGISTER_2(Gramschmidt, 8, 8) diff --git a/benchmarks/gramschmidt_base.hpp b/benchmarks/gramschmidt_base.hpp deleted file mode 100644 index bb622f11..00000000 --- a/benchmarks/gramschmidt_base.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef GRAMSCHMIDT_BASE_H -#define GRAMSCHMIDT_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {M*N, N*N, M*N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector R = split_vector(sizes, 1, ti); - std::vector Q = split_vector(sizes, 2, ti); - - int i, j, k; - - T nrm; - - for (k = 0; k < N; k++) - { - nrm = static_cast(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] = static_cast(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; -}; - -#endif // GRAMSCHMIDT_BASE_H diff --git a/benchmarks/heat_3d.cpp b/benchmarks/heat_3d.cpp deleted file mode 100644 index bf75051e..00000000 --- a/benchmarks/heat_3d.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "heat_3d_base.hpp" - - -REGISTER_2(Heat_3d, 4, 4) -REGISTER_2(Heat_3d, 5, 5) -REGISTER_2(Heat_3d, 6, 6) -REGISTER_2(Heat_3d, 7, 7) -REGISTER_2(Heat_3d, 8, 8) diff --git a/benchmarks/heat_3d_base.hpp b/benchmarks/heat_3d_base.hpp deleted file mode 100644 index df44d5f5..00000000 --- a/benchmarks/heat_3d_base.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef HEAT_3D_BASE_H -#define HEAT_3D_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N*N, N*N*N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - - 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] = static_cast(0.125) * (A[(i+1)*N*N + j*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[(i-1)*N*N + j*N +k]) - + static_cast(0.125) * (A[i*N*N + (j+1)*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[i*N*N + (j-1)*N*N + k]) - + static_cast(0.125) * (A[i*N*N + j*N +k+1] - static_cast(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] = static_cast(0.125) * (B[(i+1)*N*N + j*N +k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[(i-1)*N*N + j*N +k]) - + static_cast(0.125) * (B[i*N*N + (j+1)*N*N + k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + (j-1)*N*N + k]) - + static_cast(0.125) * (B[i*N*N + j*N +k+1] - static_cast(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; -}; - -#endif // HEAT_3D_BASE_H diff --git a/benchmarks/jacobi_1d.cpp b/benchmarks/jacobi_1d.cpp deleted file mode 100644 index bbe0128e..00000000 --- a/benchmarks/jacobi_1d.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "jacobi_1d_base.hpp" - - -REGISTER_2(Jacobi_1d, 4, 4) -REGISTER_2(Jacobi_1d, 5, 5) -REGISTER_2(Jacobi_1d, 6, 6) -REGISTER_2(Jacobi_1d, 7, 7) -REGISTER_2(Jacobi_1d, 8, 8) diff --git a/benchmarks/jacobi_1d_base.hpp b/benchmarks/jacobi_1d_base.hpp deleted file mode 100644 index 55b7b7b6..00000000 --- a/benchmarks/jacobi_1d_base.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef JACOBI_1D_BASE_H -#define JACOBI_1D_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - - int t, i; - - for (t = 0; t < TSTEPS; t++) - { - for (i = 1; i < N - 1; i++) - B[i] = 0.33333 * (A[i-1] + A[i] + A[i + 1]); - for (i = 1; i < N - 1; i++) - A[i] = 0.33333 * (B[i-1] + B[i] + B[i + 1]); - } - - return pickles({A, B}); - } - -protected: - using flit::TestBase::id; -}; - -#endif // JACOBI_1D_BASE_H diff --git a/benchmarks/jacobi_2d.cpp b/benchmarks/jacobi_2d.cpp deleted file mode 100644 index 7b3fd9ae..00000000 --- a/benchmarks/jacobi_2d.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "jacobi_2d_base.hpp" - - -REGISTER_2(Jacobi_2d, 4, 4) -REGISTER_2(Jacobi_2d, 5, 5) -REGISTER_2(Jacobi_2d, 6, 6) -REGISTER_2(Jacobi_2d, 7, 7) -REGISTER_2(Jacobi_2d, 8, 8) diff --git a/benchmarks/jacobi_2d_base.hpp b/benchmarks/jacobi_2d_base.hpp deleted file mode 100644 index cfd8e418..00000000 --- a/benchmarks/jacobi_2d_base.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef JACOBI_2D_BASE_H -#define JACOBI_2D_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N, N*N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - - 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] = static_cast(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] = static_cast(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; -}; - -#endif // JACOBI_2D_BASE_H diff --git a/benchmarks/lu.cpp b/benchmarks/lu.cpp deleted file mode 100644 index 9c7b178e..00000000 --- a/benchmarks/lu.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "lu_base.hpp" - - -REGISTER_1(Lu, 4) -REGISTER_1(Lu, 5) -REGISTER_1(Lu, 6) -REGISTER_1(Lu, 7) -REGISTER_1(Lu, 8) diff --git a/benchmarks/lu_base.hpp b/benchmarks/lu_base.hpp deleted file mode 100644 index 4c810349..00000000 --- a/benchmarks/lu_base.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef LU_BASE_H -#define LU_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N}; - std::vector A = split_vector(sizes, 0, ti); - - int i, j, k; - - for (i = 0; i < N; i++) { - for (j = 0; j ::id; -}; - -#endif // LU_BASE_H diff --git a/benchmarks/ludcmp.cpp b/benchmarks/ludcmp.cpp deleted file mode 100644 index efa4aedf..00000000 --- a/benchmarks/ludcmp.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "ludcmp_base.hpp" - - -REGISTER_1(Ludcmp, 4) -REGISTER_1(Ludcmp, 5) -REGISTER_1(Ludcmp, 6) -REGISTER_1(Ludcmp, 7) -REGISTER_1(Ludcmp, 8) diff --git a/benchmarks/ludcmp_base.hpp b/benchmarks/ludcmp_base.hpp deleted file mode 100644 index c40209ce..00000000 --- a/benchmarks/ludcmp_base.hpp +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef LUDCMP_BASE_H -#define LUDCMP_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N, N, N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector b = split_vector(sizes, 1, ti); - std::vector x = split_vector(sizes, 2, ti); - std::vector y = split_vector(sizes, 3, ti); - - 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; -}; - -#endif // LUDCMP_BASE_H diff --git a/benchmarks/mvt.cpp b/benchmarks/mvt.cpp deleted file mode 100644 index af4e06b7..00000000 --- a/benchmarks/mvt.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "mvt_base.hpp" - - -REGISTER_1(Mvt, 4) -REGISTER_1(Mvt, 5) -REGISTER_1(Mvt, 6) -REGISTER_1(Mvt, 7) -REGISTER_1(Mvt, 8) diff --git a/benchmarks/mvt_base.hpp b/benchmarks/mvt_base.hpp deleted file mode 100644 index c252b18b..00000000 --- a/benchmarks/mvt_base.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef MVT_BASE_H -#define MVT_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N, N, N, N, N*N}; - std::vector x1 = split_vector(sizes, 0, ti); - std::vector x2 = split_vector(sizes, 1, ti); - std::vector y_1 = split_vector(sizes, 2, ti); - std::vector y_2 = split_vector(sizes, 3, ti); - std::vector A = split_vector(sizes, 4, ti); - - 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; -}; - -#endif // MVT_BASE_H diff --git a/benchmarks/nussinov.cpp b/benchmarks/nussinov.cpp deleted file mode 100644 index bb0668fa..00000000 --- a/benchmarks/nussinov.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "nussinov_base.hpp" - - -REGISTER_1(Nussinov, 4) -REGISTER_1(Nussinov, 5) -REGISTER_1(Nussinov, 6) -REGISTER_1(Nussinov, 7) -REGISTER_1(Nussinov, 8) diff --git a/benchmarks/nussinov_base.hpp b/benchmarks/nussinov_base.hpp deleted file mode 100644 index 1e578cb4..00000000 --- a/benchmarks/nussinov_base.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef NUSSINOV_BASE_H -#define NUSSINOV_BASE_H - - -#include - -#include "polybench_utils.hpp" - -#define match(b1, b2) (((b1)+(b2)) == 3 ? 1 : 0) -#define max_score(s1, s2) ((s1 >= s2) ? s1 : s2) - -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 { - std::vector sizes = {N, N*N}; - std::vector seq = split_vector(sizes, 0, ti); - std::vector table = split_vector(sizes, 1, ti); - - int i, j, k; - - for (i = N-1; i >= 0; i--) { - for (j=i+1; j=0) - table[i*N + j] = max_score(table[i*N + j], table[i*N + j-1]); - if (i+1=0 && i+1::id; -}; - -#endif // NUSSINOV_BASE_H 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..968fedfa --- /dev/null +++ b/benchmarks/polybench/flit-config.toml @@ -0,0 +1,47 @@ +# 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' + +# For now, only one host is supported, all others are ignored +[[hosts]] + +name = 'fractus' +flit_path = '/home/ibriggs/FLIT/flit-install/share/flit/scripts/flit.py' +config_dir = '/home/ibriggs/FLIT/flit-install/share/flit/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/polybench/tests/adi.cpp b/benchmarks/polybench/tests/adi.cpp new file mode 100644 index 00000000..56b5edd6 --- /dev/null +++ b/benchmarks/polybench/tests/adi.cpp @@ -0,0 +1,184 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N}; + std::vector u = split_vector(sizes, 0, ti); + std::vector v(N*N); + std::vector p(N*N); + std::vector 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 = static_cast(1.0)/(T)N; + DY = static_cast(1.0)/(T)N; + DT = static_cast(1.0)/(T)TSTEPS; + B1 = static_cast(2.0); + B2 = static_cast(1.0); + mul1 = B1 * DT / (DX * DX); + mul2 = B2 * DT / (DY * DY); + + a = -mul1 / static_cast(2.0); + b = static_cast(1.0)+mul1; + c = a; + d = -mul2 / static_cast(2.0); + e = static_cast(1.0)+mul2; + f = d; + + for (t=1; t<=TSTEPS; t++) { + //Column Sweep + for (i=1; i(1.0); + p[i*N + 0] = static_cast(0.0); + q[i*N + 0] = v[0*N + i]; + for (j=1; j(1.0)+static_cast(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] = static_cast(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(1.0); + p[i*N + 0] = static_cast(0.0); + q[i*N + 0] = u[i*N + 0]; + for (j=1; j(1.0)+static_cast(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] = static_cast(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; +}; + + + + +REGISTER_2(Adi, 4, 4) +REGISTER_2(Adi, 5, 5) +REGISTER_2(Adi, 6, 6) +REGISTER_2(Adi, 7, 7) +REGISTER_2(Adi, 8, 8) diff --git a/benchmarks/polybench/tests/atax.cpp b/benchmarks/polybench/tests/atax.cpp new file mode 100644 index 00000000..c7491589 --- /dev/null +++ b/benchmarks/polybench/tests/atax.cpp @@ -0,0 +1,145 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {M*N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector x = split_vector(sizes, 1, ti); + std::vector y(N); + std::vector tmp(M); + + int i,j; + + for (i = 0; i < N; i++) + y[i] = 0; + for (i = 0; i < M; i++) + { + tmp[i] = static_cast(0.0); + for (j = 0; j < N; j++) + tmp[i] = tmp[i] + A[i*M + j] * x[j]; + for (j = 0; j < N; j++) + y[j] = y[j] + A[i*M + j] * tmp[i]; + } + + + return pickles({y, tmp}); +} + +protected: +using flit::TestBase::id; +}; + + + + +REGISTER_2(Atax, 4, 4) +REGISTER_2(Atax, 5, 5) +REGISTER_2(Atax, 6, 6) +REGISTER_2(Atax, 7, 7) +REGISTER_2(Atax, 8, 8) diff --git a/benchmarks/polybench/tests/bicg.cpp b/benchmarks/polybench/tests/bicg.cpp new file mode 100644 index 00000000..89f5b919 --- /dev/null +++ b/benchmarks/polybench/tests/bicg.cpp @@ -0,0 +1,146 @@ +/* -- 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 "polybench_utils.h" + + + + +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}; + std::vector A = split_vector(sizes, 0, ti); + std::vector r = split_vector(sizes, 1, ti); + std::vector p = split_vector(sizes, 2, ti); + std::vector s(M); + std::vector q(N); + + int i, j; + + for (i = 0; i < M; i++) + s[i] = 0; + for (i = 0; i < N; i++) + { + q[i] = static_cast(0.0); + for (j = 0; j < M; j++) + { + s[j] = s[j] + r[i] * A[i*N + j]; + q[i] = q[i] + A[i*N + j] * p[j]; + } + } + + return pickles({s, q}); + } + +protected: + using flit::TestBase::id; +}; + + + + +REGISTER_2(Bicg, 4, 4) +REGISTER_2(Bicg, 5, 5) +REGISTER_2(Bicg, 6, 6) +REGISTER_2(Bicg, 7, 7) +REGISTER_2(Bicg, 8, 8) diff --git a/benchmarks/polybench/tests/cholesky.cpp b/benchmarks/polybench/tests/cholesky.cpp new file mode 100644 index 00000000..e4b0ce22 --- /dev/null +++ b/benchmarks/polybench/tests/cholesky.cpp @@ -0,0 +1,145 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N}; + std::vector A = split_vector(sizes, 0, ti); + + int i, j, k; + + for (i = 0; i < N; i++) { + //j::id; +}; + + + + +REGISTER_1(Cholesky, 4) +REGISTER_1(Cholesky, 5) +REGISTER_1(Cholesky, 6) +REGISTER_1(Cholesky, 7) +REGISTER_1(Cholesky, 8) diff --git a/benchmarks/polybench/tests/correlation.cpp b/benchmarks/polybench/tests/correlation.cpp new file mode 100644 index 00000000..e7c00446 --- /dev/null +++ b/benchmarks/polybench/tests/correlation.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 + +#include + +#include "polybench_utils.h" + + + + +template +class CorrelationBase : public flit::TestBase { +public: + CorrelationBase(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 { + std::vector data = ti; + std::vector corr (M*M); + std::vector mean (M); + std::vector stddev (M); + T float_n = N; + + int i, j, k; + + T eps = 0.1; + + + for (j=0; j::id; +}; + + + + +REGISTER_2(Correlation, 4, 4) +REGISTER_2(Correlation, 5, 5) +REGISTER_2(Correlation, 6, 6) +REGISTER_2(Correlation, 7, 7) +REGISTER_2(Correlation, 8, 8) diff --git a/benchmarks/polybench/tests/covariance.cpp b/benchmarks/polybench/tests/covariance.cpp new file mode 100644 index 00000000..16483a2a --- /dev/null +++ b/benchmarks/polybench/tests/covariance.cpp @@ -0,0 +1,157 @@ +/* -- 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 "polybench_utils.h" + + + + +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 = static_cast(N); + std::vector data = ti; + std::vector cov(M*M); + std::vector mean(M); + + int i, j, k; + + for (j = 0; j < M; j++) { + mean[j] = static_cast(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] = static_cast(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 - static_cast(1.0)); + cov[j*M + i] = cov[i*M + j]; + } + } + + return pickles({data, cov, mean}) ; + } + +protected: + using flit::TestBase::id; +}; + + + + +REGISTER_2(Covariance, 4, 4) +REGISTER_2(Covariance, 5, 5) +REGISTER_2(Covariance, 6, 6) +REGISTER_2(Covariance, 7, 7) +REGISTER_2(Covariance, 8, 8) diff --git a/benchmarks/polybench/tests/deriche.cpp b/benchmarks/polybench/tests/deriche.cpp new file mode 100644 index 00000000..78f93e86 --- /dev/null +++ b/benchmarks/polybench/tests/deriche.cpp @@ -0,0 +1,214 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {W*H, W*H}; + std::vector imgIn = split_vector(sizes, 0, ti); + std::vector imgOut = split_vector(sizes, 1, ti); + std::vector y1(W*H); + std::vector y2(W*H); + + T alpha = static_cast(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 = (static_cast(1.0)-std::exp(-alpha))*(static_cast(1.0)-std::exp(-alpha))/(static_cast(1.0)+static_cast(2.0)*alpha*std::exp(-alpha)-std::exp(static_cast(2.0)*alpha)); + a1 = a5 = k; + a2 = a6 = k*std::exp(-alpha)*(alpha-static_cast(1.0)); + a3 = a7 = k*std::exp(-alpha)*(alpha+static_cast(1.0)); + a4 = a8 = -k*std::exp(static_cast(-2.0)*alpha); + b1 = std::pow(static_cast(2.0),-alpha); + b2 = -std::exp(static_cast(-2.0)*alpha); + c1 = c2 = 1; + + for (i=0; i(0.0); + ym2 = static_cast(0.0); + xm1 = static_cast(0.0); + for (j=0; j(0.0); + yp2 = static_cast(0.0); + xp1 = static_cast(0.0); + xp2 = static_cast(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(0.0); + ym1 = static_cast(0.0); + ym2 = static_cast(0.0); + for (i=0; i(0.0); + tp2 = static_cast(0.0); + yp1 = static_cast(0.0); + yp2 = static_cast(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::id; +}; + + + + +REGISTER_2(Deriche, 4, 4) +REGISTER_2(Deriche, 5, 5) +REGISTER_2(Deriche, 6, 6) +REGISTER_2(Deriche, 7, 7) +REGISTER_2(Deriche, 8, 8) diff --git a/benchmarks/polybench/tests/doitgen.cpp b/benchmarks/polybench/tests/doitgen.cpp new file mode 100644 index 00000000..8e6ab582 --- /dev/null +++ b/benchmarks/polybench/tests/doitgen.cpp @@ -0,0 +1,144 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {NR*NQ*NP, NP*NP}; + std::vector A = split_vector(sizes, 0, ti); + std::vector C4 = split_vector(sizes, 1, ti); + 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] = static_cast(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; +}; + + + + +REGISTER_3(Doitgen, 4, 4, 4) +REGISTER_3(Doitgen, 5, 5, 5) +REGISTER_3(Doitgen, 6, 6, 6) +REGISTER_3(Doitgen, 7, 7, 7) +REGISTER_3(Doitgen, 8, 8, 8) diff --git a/benchmarks/polybench/tests/durbin.cpp b/benchmarks/polybench/tests/durbin.cpp new file mode 100644 index 00000000..fa1031ed --- /dev/null +++ b/benchmarks/polybench/tests/durbin.cpp @@ -0,0 +1,157 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N}; + std::vector r = split_vector(sizes, 0, ti); + std::vector y(N); + + std::vector z(N); + T alpha; + T beta; + T sum; + + int i,k; + + y[0] = -r[0]; + beta = static_cast(1.0); + alpha = -r[0]; + + for (k = 1; k < N; k++) { + beta = (1-alpha*alpha)*beta; + sum = static_cast(0.0); + for (i=0; i::id; +}; + + + + +REGISTER_1(Durbin, 4) +REGISTER_1(Durbin, 5) +REGISTER_1(Durbin, 6) +REGISTER_1(Durbin, 7) +REGISTER_1(Durbin, 8) diff --git a/benchmarks/polybench/tests/fdtd_2d.cpp b/benchmarks/polybench/tests/fdtd_2d.cpp new file mode 100644 index 00000000..5f401677 --- /dev/null +++ b/benchmarks/polybench/tests/fdtd_2d.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 + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {NX*NY, NX*NY, NX*NY, TMAX}; + std::vector ex = split_vector(sizes, 0, ti); + std::vector ey = split_vector(sizes, 1, ti); + std::vector hz = split_vector(sizes, 2, ti); + std::vector _fict_ = split_vector(sizes, 3, ti); + + 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] = ey[i*NX + j] - static_cast(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] = ex[i*NX + j] - static_cast(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] = hz[i*NX + j] - static_cast(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; +}; + + + + +REGISTER_3(Fdtd_2d, 4, 4, 4) +REGISTER_3(Fdtd_2d, 5, 5, 5) +REGISTER_3(Fdtd_2d, 6, 6, 6) +REGISTER_3(Fdtd_2d, 7, 7, 7) +REGISTER_3(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..77e83292 --- /dev/null +++ b/benchmarks/polybench/tests/floyd_warshall.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 + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N}; + std::vector path = split_vector(sizes, 0, 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; +}; + + + + +REGISTER_1(Floyd_Warshall, 4) +REGISTER_1(Floyd_Warshall, 5) +REGISTER_1(Floyd_Warshall, 6) +REGISTER_1(Floyd_Warshall, 7) +REGISTER_1(Floyd_Warshall, 8) diff --git a/benchmarks/polybench/tests/gemm.cpp b/benchmarks/polybench/tests/gemm.cpp new file mode 100644 index 00000000..da22c934 --- /dev/null +++ b/benchmarks/polybench/tests/gemm.cpp @@ -0,0 +1,145 @@ +/* -- 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 "polybench_utils.h" + + + + +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 = static_cast(1.5); + T beta = static_cast(1.2); + std::vector sizes = {NI*NI, NI*NK, NK+NJ}; + std::vector C = split_vector(sizes, 0, ti); + std::vector A = split_vector(sizes, 1, ti); + std::vector B = split_vector(sizes, 2, ti); + + 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; +}; + + + + +REGISTER_3(Gemm, 4, 4, 4) +REGISTER_3(Gemm, 5, 5, 5) +REGISTER_3(Gemm, 6, 6, 6) +REGISTER_3(Gemm, 7, 7, 7) +REGISTER_3(Gemm, 8, 8, 8) diff --git a/benchmarks/polybench/tests/gemver.cpp b/benchmarks/polybench/tests/gemver.cpp new file mode 100644 index 00000000..790f92b5 --- /dev/null +++ b/benchmarks/polybench/tests/gemver.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 + +#include + +#include "polybench_utils.h" + + + + +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 = static_cast(1.5); + T beta = static_cast(1.2); + std::vector sizes = {N*N, N, N, N, N, N, N, N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector u1 = split_vector(sizes, 1, ti); + std::vector v1 = split_vector(sizes, 2, ti); + std::vector u2 = split_vector(sizes, 3, ti); + std::vector v2 = split_vector(sizes, 4, ti); + std::vector w = split_vector(sizes, 5, ti); + std::vector x = split_vector(sizes, 6, ti); + std::vector y = split_vector(sizes, 7, ti); + std::vector z = split_vector(sizes, 8, ti); + + 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; +}; + + + + +REGISTER_1(Gemver, 4) +REGISTER_1(Gemver, 5) +REGISTER_1(Gemver, 6) +REGISTER_1(Gemver, 7) +REGISTER_1(Gemver, 8) diff --git a/benchmarks/polybench/tests/gesummv.cpp b/benchmarks/polybench/tests/gesummv.cpp new file mode 100644 index 00000000..244ea851 --- /dev/null +++ b/benchmarks/polybench/tests/gesummv.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 + +#include + +#include "polybench_utils.h" + + + + +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 = static_cast(1.5); + T beta = static_cast(1.2); + std::vector sizes = {N*N, N*N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + std::vector x = split_vector(sizes, 2, ti); + + std::vector tmp(N); + std::vector y(N); + + int i, j; + + for (i = 0; i < N; i++) + { + tmp[i] = static_cast(0.0); + y[i] = static_cast(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; +}; + + + + +REGISTER_1(Gesummv, 4) +REGISTER_1(Gesummv, 5) +REGISTER_1(Gesummv, 6) +REGISTER_1(Gesummv, 7) +REGISTER_1(Gesummv, 8) diff --git a/benchmarks/polybench/tests/gramschmidt.cpp b/benchmarks/polybench/tests/gramschmidt.cpp new file mode 100644 index 00000000..56d461c8 --- /dev/null +++ b/benchmarks/polybench/tests/gramschmidt.cpp @@ -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 -- + */ + + +#include + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {M*N, N*N, M*N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector R = split_vector(sizes, 1, ti); + std::vector Q = split_vector(sizes, 2, ti); + + int i, j, k; + + T nrm; + + for (k = 0; k < N; k++) + { + nrm = static_cast(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] = static_cast(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; +}; + + + + +REGISTER_2(Gramschmidt, 4, 4) +REGISTER_2(Gramschmidt, 5, 5) +REGISTER_2(Gramschmidt, 6, 6) +REGISTER_2(Gramschmidt, 7, 7) +REGISTER_2(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..b311c432 --- /dev/null +++ b/benchmarks/polybench/tests/heat_3d.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 + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N*N, N*N*N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + + 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] = static_cast(0.125) * (A[(i+1)*N*N + j*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[(i-1)*N*N + j*N +k]) + + static_cast(0.125) * (A[i*N*N + (j+1)*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[i*N*N + (j-1)*N*N + k]) + + static_cast(0.125) * (A[i*N*N + j*N +k+1] - static_cast(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] = static_cast(0.125) * (B[(i+1)*N*N + j*N +k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[(i-1)*N*N + j*N +k]) + + static_cast(0.125) * (B[i*N*N + (j+1)*N*N + k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + (j-1)*N*N + k]) + + static_cast(0.125) * (B[i*N*N + j*N +k+1] - static_cast(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; +}; + + + + +REGISTER_2(Heat_3d, 4, 4) +REGISTER_2(Heat_3d, 5, 5) +REGISTER_2(Heat_3d, 6, 6) +REGISTER_2(Heat_3d, 7, 7) +REGISTER_2(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..91c42ffa --- /dev/null +++ b/benchmarks/polybench/tests/jacobi_1d.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 + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + + int t, i; + + for (t = 0; t < TSTEPS; t++) + { + for (i = 1; i < N - 1; i++) + B[i] = 0.33333 * (A[i-1] + A[i] + A[i + 1]); + for (i = 1; i < N - 1; i++) + A[i] = 0.33333 * (B[i-1] + B[i] + B[i + 1]); + } + + return pickles({A, B}); + } + +protected: + using flit::TestBase::id; +}; + + + + +REGISTER_2(Jacobi_1d, 4, 4) +REGISTER_2(Jacobi_1d, 5, 5) +REGISTER_2(Jacobi_1d, 6, 6) +REGISTER_2(Jacobi_1d, 7, 7) +REGISTER_2(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..f2cc516b --- /dev/null +++ b/benchmarks/polybench/tests/jacobi_2d.cpp @@ -0,0 +1,141 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N, N*N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + + 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] = static_cast(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] = static_cast(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; +}; + + + + +REGISTER_2(Jacobi_2d, 4, 4) +REGISTER_2(Jacobi_2d, 5, 5) +REGISTER_2(Jacobi_2d, 6, 6) +REGISTER_2(Jacobi_2d, 7, 7) +REGISTER_2(Jacobi_2d, 8, 8) diff --git a/benchmarks/polybench/tests/lu.cpp b/benchmarks/polybench/tests/lu.cpp new file mode 100644 index 00000000..b77ff5e9 --- /dev/null +++ b/benchmarks/polybench/tests/lu.cpp @@ -0,0 +1,144 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N}; + std::vector A = split_vector(sizes, 0, ti); + + int i, j, k; + + for (i = 0; i < N; i++) { + for (j = 0; j ::id; +}; + + + + +REGISTER_1(Lu, 4) +REGISTER_1(Lu, 5) +REGISTER_1(Lu, 6) +REGISTER_1(Lu, 7) +REGISTER_1(Lu, 8) diff --git a/benchmarks/polybench/tests/ludcmp.cpp b/benchmarks/polybench/tests/ludcmp.cpp new file mode 100644 index 00000000..9a1bd663 --- /dev/null +++ b/benchmarks/polybench/tests/ludcmp.cpp @@ -0,0 +1,166 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N, N, N, N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector b = split_vector(sizes, 1, ti); + std::vector x = split_vector(sizes, 2, ti); + std::vector y = split_vector(sizes, 3, ti); + + 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; +}; + + + + +REGISTER_1(Ludcmp, 4) +REGISTER_1(Ludcmp, 5) +REGISTER_1(Ludcmp, 6) +REGISTER_1(Ludcmp, 7) +REGISTER_1(Ludcmp, 8) diff --git a/benchmarks/polybench/tests/mvt.cpp b/benchmarks/polybench/tests/mvt.cpp new file mode 100644 index 00000000..51ee326f --- /dev/null +++ b/benchmarks/polybench/tests/mvt.cpp @@ -0,0 +1,141 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N, N, N, N, N*N}; + std::vector x1 = split_vector(sizes, 0, ti); + std::vector x2 = split_vector(sizes, 1, ti); + std::vector y_1 = split_vector(sizes, 2, ti); + std::vector y_2 = split_vector(sizes, 3, ti); + std::vector A = split_vector(sizes, 4, ti); + + 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; +}; + + + + +REGISTER_1(Mvt, 4) +REGISTER_1(Mvt, 5) +REGISTER_1(Mvt, 6) +REGISTER_1(Mvt, 7) +REGISTER_1(Mvt, 8) diff --git a/benchmarks/polybench/tests/nussinov.cpp b/benchmarks/polybench/tests/nussinov.cpp new file mode 100644 index 00000000..aa09f334 --- /dev/null +++ b/benchmarks/polybench/tests/nussinov.cpp @@ -0,0 +1,156 @@ +/* -- 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 "polybench_utils.h" + + + + +#define match(b1, b2) (((b1)+(b2)) == 3 ? 1 : 0) +#define max_score(s1, s2) ((s1 >= s2) ? s1 : s2) + +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 { + std::vector sizes = {N, N*N}; + std::vector seq = split_vector(sizes, 0, ti); + std::vector table = split_vector(sizes, 1, ti); + + int i, j, k; + + for (i = N-1; i >= 0; i--) { + for (j=i+1; j=0) + table[i*N + j] = max_score(table[i*N + j], table[i*N + j-1]); + if (i+1=0 && i+1::id; +}; + + + + +REGISTER_1(Nussinov, 4) +REGISTER_1(Nussinov, 5) +REGISTER_1(Nussinov, 6) +REGISTER_1(Nussinov, 7) +REGISTER_1(Nussinov, 8) diff --git a/benchmarks/polybench_utils.hpp b/benchmarks/polybench/tests/polybench_utils.h similarity index 50% rename from benchmarks/polybench_utils.hpp rename to benchmarks/polybench/tests/polybench_utils.h index 5242e03e..a72a9cad 100644 --- a/benchmarks/polybench_utils.hpp +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -1,3 +1,85 @@ +/* -- 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 diff --git a/benchmarks/polybench/tests/seidel_2d.cpp b/benchmarks/polybench/tests/seidel_2d.cpp new file mode 100644 index 00000000..7628b5e2 --- /dev/null +++ b/benchmarks/polybench/tests/seidel_2d.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 + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N}; + std::vector A = split_vector(sizes, 0, 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)])/static_cast(9.0); + + return pickles({A}); + } + +protected: + using flit::TestBase::id; +}; + + + + +REGISTER_2(Seidel_2d, 4, 4) +REGISTER_2(Seidel_2d, 5, 5) +REGISTER_2(Seidel_2d, 6, 6) +REGISTER_2(Seidel_2d, 7, 7) +REGISTER_2(Seidel_2d, 8, 8) diff --git a/benchmarks/polybench/tests/symm.cpp b/benchmarks/polybench/tests/symm.cpp new file mode 100644 index 00000000..14f3186b --- /dev/null +++ b/benchmarks/polybench/tests/symm.cpp @@ -0,0 +1,146 @@ +/* -- 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 "polybench_utils.h" + + + + +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 = static_cast(1.5); + T beta = static_cast(1.2); + std::vector sizes = {M*N, M*M, M*N}; + std::vector C = split_vector(sizes, 0, ti); + std::vector A = split_vector(sizes, 1, ti); + std::vector B = split_vector(sizes, 2, ti); + + 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; +}; + + + + +REGISTER_2(Symm, 4, 4) +REGISTER_2(Symm, 5, 5) +REGISTER_2(Symm, 6, 6) +REGISTER_2(Symm, 7, 7) +REGISTER_2(Symm, 8, 8) diff --git a/benchmarks/polybench/tests/syr2k.cpp b/benchmarks/polybench/tests/syr2k.cpp new file mode 100644 index 00000000..fbb41e25 --- /dev/null +++ b/benchmarks/polybench/tests/syr2k.cpp @@ -0,0 +1,145 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N, N*M, N*M}; + std::vector C = split_vector(sizes, 0, ti); + std::vector A = split_vector(sizes, 1, ti); + std::vector B = split_vector(sizes, 2, ti); + T alpha = static_cast(1.5); + T beta = static_cast(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; +}; + + + + +REGISTER_2(Syr2k, 4, 4) +REGISTER_2(Syr2k, 5, 5) +REGISTER_2(Syr2k, 6, 6) +REGISTER_2(Syr2k, 7, 7) +REGISTER_2(Syr2k, 8, 8) diff --git a/benchmarks/polybench/tests/syrk.cpp b/benchmarks/polybench/tests/syrk.cpp new file mode 100644 index 00000000..517b8cae --- /dev/null +++ b/benchmarks/polybench/tests/syrk.cpp @@ -0,0 +1,142 @@ +/* -- 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 "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N, N*M}; + std::vector C = split_vector(sizes, 0, ti); + std::vector A = split_vector(sizes, 1, ti); + T alpha = static_cast(1.5); + T beta = static_cast(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; +}; + + + + +REGISTER_2(Syrk, 4, 4) +REGISTER_2(Syrk, 5, 5) +REGISTER_2(Syrk, 6, 6) +REGISTER_2(Syrk, 7, 7) +REGISTER_2(Syrk, 8, 8) diff --git a/benchmarks/polybench/tests/test2mm.cpp b/benchmarks/polybench/tests/test2mm.cpp new file mode 100644 index 00000000..8adbfe89 --- /dev/null +++ b/benchmarks/polybench/tests/test2mm.cpp @@ -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 -- + */ + + +#include + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {NI*NK, NK*NJ, NJ*NL, NI*NL}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + std::vector C = split_vector(sizes, 2, ti); + std::vector D = split_vector(sizes, 3, ti); + std::vector tmp(NI*NJ); + T alpha = static_cast(1.5); + T beta = static_cast(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] = static_cast(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; +}; + + + + +REGISTER_4(Test2mm, 4, 4, 4, 4) +REGISTER_4(Test2mm, 5, 5, 5, 5) +REGISTER_4(Test2mm, 6, 6, 6, 6) +REGISTER_4(Test2mm, 7, 7, 7, 7) +REGISTER_4(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..a4756376 --- /dev/null +++ b/benchmarks/polybench/tests/test3mm.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 + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {NI*NK, NK*NJ, NJ*NM, NM*NL}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + std::vector C = split_vector(sizes, 2, ti); + std::vector D = split_vector(sizes, 3, ti); + std::vector E(NI*NJ); + std::vector F(NJ*NL); + std::vector 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] = static_cast(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] = static_cast(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] = static_cast(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; +}; + + + + +REGISTER_5(Test3mm, 4, 4, 4, 4, 4) +REGISTER_5(Test3mm, 5, 5, 5, 5, 5) +REGISTER_5(Test3mm, 6, 6, 6, 6, 6) +REGISTER_5(Test3mm, 7, 7, 7, 7, 7) +REGISTER_5(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..8f8f4de4 --- /dev/null +++ b/benchmarks/polybench/tests/trisolv.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 + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {N*N, N, N}; + std::vector L = split_vector(sizes, 0, ti); + std::vector x = split_vector(sizes, 1, ti); + std::vector b = split_vector(sizes, 2, ti); + + int i, j; + + for (i = 0; i < N; i++) + { + x[i] = b[i]; + for (j = 0; j ::id; +}; + + + + +REGISTER_1(Trisolv, 4) +REGISTER_1(Trisolv, 5) +REGISTER_1(Trisolv, 6) +REGISTER_1(Trisolv, 7) +REGISTER_1(Trisolv, 8) diff --git a/benchmarks/polybench/tests/trmm.cpp b/benchmarks/polybench/tests/trmm.cpp new file mode 100644 index 00000000..4165ae96 --- /dev/null +++ b/benchmarks/polybench/tests/trmm.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 + +#include + +#include "polybench_utils.h" + + + + +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 { + std::vector sizes = {M*M, M*N}; + std::vector A = split_vector(sizes, 0, ti); + std::vector B = split_vector(sizes, 1, ti); + T alpha = static_cast(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; +}; + + + + +REGISTER_2(Trmm, 4, 4) +REGISTER_2(Trmm, 5, 5) +REGISTER_2(Trmm, 6, 6) +REGISTER_2(Trmm, 7, 7) +REGISTER_2(Trmm, 8, 8) diff --git a/benchmarks/seidel_2d.cpp b/benchmarks/seidel_2d.cpp deleted file mode 100644 index 6ec516a2..00000000 --- a/benchmarks/seidel_2d.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "seidel_2d_base.hpp" - - -REGISTER_2(Seidel_2d, 4, 4) -REGISTER_2(Seidel_2d, 5, 5) -REGISTER_2(Seidel_2d, 6, 6) -REGISTER_2(Seidel_2d, 7, 7) -REGISTER_2(Seidel_2d, 8, 8) diff --git a/benchmarks/seidel_2d_base.hpp b/benchmarks/seidel_2d_base.hpp deleted file mode 100644 index 2deffb10..00000000 --- a/benchmarks/seidel_2d_base.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef SEIDEL_2D_BASE_H -#define SEIDEL_2D_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N}; - std::vector A = split_vector(sizes, 0, 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)])/static_cast(9.0); - - return pickles({A}); - } - -protected: - using flit::TestBase::id; -}; - -#endif // SEIDEL_2D_BASE_H diff --git a/benchmarks/symm.cpp b/benchmarks/symm.cpp deleted file mode 100644 index 46b7c0bc..00000000 --- a/benchmarks/symm.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "symm_base.hpp" - - -REGISTER_2(Symm, 4, 4) -REGISTER_2(Symm, 5, 5) -REGISTER_2(Symm, 6, 6) -REGISTER_2(Symm, 7, 7) -REGISTER_2(Symm, 8, 8) diff --git a/benchmarks/symm_base.hpp b/benchmarks/symm_base.hpp deleted file mode 100644 index 5947dc2a..00000000 --- a/benchmarks/symm_base.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SYMM_BASE_H -#define SYMM_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 = static_cast(1.5); - T beta = static_cast(1.2); - std::vector sizes = {M*N, M*M, M*N}; - std::vector C = split_vector(sizes, 0, ti); - std::vector A = split_vector(sizes, 1, ti); - std::vector B = split_vector(sizes, 2, ti); - - 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; -}; - -#endif // SYMM_BASE_H diff --git a/benchmarks/syr2k.cpp b/benchmarks/syr2k.cpp deleted file mode 100644 index a1de372c..00000000 --- a/benchmarks/syr2k.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "syr2k_base.hpp" - - -REGISTER_2(Syr2k, 4, 4) -REGISTER_2(Syr2k, 5, 5) -REGISTER_2(Syr2k, 6, 6) -REGISTER_2(Syr2k, 7, 7) -REGISTER_2(Syr2k, 8, 8) diff --git a/benchmarks/syr2k_base.hpp b/benchmarks/syr2k_base.hpp deleted file mode 100644 index 169a49dd..00000000 --- a/benchmarks/syr2k_base.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SYR2K_BASE_H -#define SYR2K_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N, N*M, N*M}; - std::vector C = split_vector(sizes, 0, ti); - std::vector A = split_vector(sizes, 1, ti); - std::vector B = split_vector(sizes, 2, ti); - T alpha = static_cast(1.5); - T beta = static_cast(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; -}; - -#endif // SYR2K_BASE_H diff --git a/benchmarks/syrk.cpp b/benchmarks/syrk.cpp deleted file mode 100644 index aef9588b..00000000 --- a/benchmarks/syrk.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "syrk_base.hpp" - - -REGISTER_2(Syrk, 4, 4) -REGISTER_2(Syrk, 5, 5) -REGISTER_2(Syrk, 6, 6) -REGISTER_2(Syrk, 7, 7) -REGISTER_2(Syrk, 8, 8) diff --git a/benchmarks/syrk_base.hpp b/benchmarks/syrk_base.hpp deleted file mode 100644 index 5926227d..00000000 --- a/benchmarks/syrk_base.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SYRK_BASE_H -#define SYRK_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N, N*M}; - std::vector C = split_vector(sizes, 0, ti); - std::vector A = split_vector(sizes, 1, ti); - T alpha = static_cast(1.5); - T beta = static_cast(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; -}; - -#endif // SYRK_BASE_H diff --git a/benchmarks/test2mm.cpp b/benchmarks/test2mm.cpp deleted file mode 100644 index 668ab054..00000000 --- a/benchmarks/test2mm.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "test2mm_base.hpp" - - -REGISTER_4(Test2mm, 4, 4, 4, 4) -REGISTER_4(Test2mm, 5, 5, 5, 5) -REGISTER_4(Test2mm, 6, 6, 6, 6) -REGISTER_4(Test2mm, 7, 7, 7, 7) -REGISTER_4(Test2mm, 8, 8, 8, 8) diff --git a/benchmarks/test2mm_base.hpp b/benchmarks/test2mm_base.hpp deleted file mode 100644 index 81217f1f..00000000 --- a/benchmarks/test2mm_base.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef TEST2MM_BASE_H -#define TEST2MM_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {NI*NK, NK*NJ, NJ*NL, NI*NL}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - std::vector C = split_vector(sizes, 2, ti); - std::vector D = split_vector(sizes, 3, ti); - std::vector tmp(NI*NJ); - T alpha = static_cast(1.5); - T beta = static_cast(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] = static_cast(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; -}; - -#endif // TEST2MM_BASE_H diff --git a/benchmarks/test3mm.cpp b/benchmarks/test3mm.cpp deleted file mode 100644 index 78e8b2f5..00000000 --- a/benchmarks/test3mm.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "test3mm_base.hpp" - - -REGISTER_5(Test3mm, 4, 4, 4, 4, 4) -REGISTER_5(Test3mm, 5, 5, 5, 5, 5) -REGISTER_5(Test3mm, 6, 6, 6, 6, 6) -REGISTER_5(Test3mm, 7, 7, 7, 7, 7) -REGISTER_5(Test3mm, 8, 8, 8, 8, 8) diff --git a/benchmarks/test3mm_base.hpp b/benchmarks/test3mm_base.hpp deleted file mode 100644 index a02beda3..00000000 --- a/benchmarks/test3mm_base.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef TEST3MM_BASE_H -#define TEST3MM_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {NI*NK, NK*NJ, NJ*NM, NM*NL}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - std::vector C = split_vector(sizes, 2, ti); - std::vector D = split_vector(sizes, 3, ti); - std::vector E(NI*NJ); - std::vector F(NJ*NL); - std::vector 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] = static_cast(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] = static_cast(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] = static_cast(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; -}; - -#endif // TEST3MM_BASE_H diff --git a/benchmarks/trisolv.cpp b/benchmarks/trisolv.cpp deleted file mode 100644 index be8474e8..00000000 --- a/benchmarks/trisolv.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "trisolv_base.hpp" - - -REGISTER_1(Trisolv, 4) -REGISTER_1(Trisolv, 5) -REGISTER_1(Trisolv, 6) -REGISTER_1(Trisolv, 7) -REGISTER_1(Trisolv, 8) diff --git a/benchmarks/trisolv_base.hpp b/benchmarks/trisolv_base.hpp deleted file mode 100644 index 8e10d07e..00000000 --- a/benchmarks/trisolv_base.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef TRISOLV_BASE_H -#define TRISOLV_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {N*N, N, N}; - std::vector L = split_vector(sizes, 0, ti); - std::vector x = split_vector(sizes, 1, ti); - std::vector b = split_vector(sizes, 2, ti); - - int i, j; - - for (i = 0; i < N; i++) - { - x[i] = b[i]; - for (j = 0; j ::id; -}; - -#endif // TRISOLV_BASE_H diff --git a/benchmarks/trmm.cpp b/benchmarks/trmm.cpp deleted file mode 100644 index 139a6e79..00000000 --- a/benchmarks/trmm.cpp +++ /dev/null @@ -1,14 +0,0 @@ - - -#include - -#include - -#include "trmm_base.hpp" - - -REGISTER_2(Trmm, 4, 4) -REGISTER_2(Trmm, 5, 5) -REGISTER_2(Trmm, 6, 6) -REGISTER_2(Trmm, 7, 7) -REGISTER_2(Trmm, 8, 8) diff --git a/benchmarks/trmm_base.hpp b/benchmarks/trmm_base.hpp deleted file mode 100644 index 9a7bf424..00000000 --- a/benchmarks/trmm_base.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef TRMM_BASE_H -#define TRMM_BASE_H - - -#include - -#include "polybench_utils.hpp" - - -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 { - std::vector sizes = {M*M, M*N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - T alpha = static_cast(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; -}; - -#endif // TRMM_BASE_H From 0adae7cd033814a69ff8d2baeb9c9f9aabe6aaff Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 9 Jun 2018 23:23:16 -0600 Subject: [PATCH 120/166] executable: add --info flag to print compiler information --- src/flit.cpp | 6 ++++++ src/flit.h | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/flit.cpp b/src/flit.cpp index 88e297b7..bed803ec 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -189,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" @@ -215,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" }; @@ -234,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)) { @@ -353,6 +357,8 @@ std::string usage(std::string progName) { "\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" diff --git a/src/flit.h b/src/flit.h index 1698303e..98057130 100644 --- a/src/flit.h +++ b/src/flit.h @@ -137,6 +137,7 @@ namespace flit { /** Command-line options */ struct FlitOptions { 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 @@ -177,12 +178,21 @@ 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); +/// 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); @@ -420,6 +430,11 @@ inline int runFlitTests(int argc, char* argv[]) { return 0; } + if (options.info) { + std::cout << info; + return 0; + } + if (options.listTests) { for (auto& test : getKeys(getTests())) { std::cout << test << std::endl; From 4af4775c6e71e5874867de48ff518762f21a6d8e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sun, 10 Jun 2018 00:58:30 -0600 Subject: [PATCH 121/166] Change column names comparison -> comparison_hex comparison_d -> comparison score -> score_hex score_d -> score --- data/db/tables-sqlite.sql | 4 ++-- documentation/database-structure.md | 4 ++-- documentation/test-executable.md | 6 +++--- plotting/plot_speedup_histogram.py | 6 +++--- plotting/plot_timing.py | 2 +- scripts/flitcli/flit_bisect.py | 4 ++-- scripts/flitcli/flit_import.py | 6 +++--- src/flit.cpp | 6 +++--- src/flit.h | 16 ++++++++-------- tests/flit_makefile/tst_empty_project.py | 2 +- tests/flit_src/tst_flit_cpp.cpp | 22 ++++++++++++---------- 11 files changed, 40 insertions(+), 38 deletions(-) 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/documentation/database-structure.md b/documentation/database-structure.md index 224bce1b..9032f548 100644 --- a/documentation/database-structure.md +++ b/documentation/database-structure.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/test-executable.md b/documentation/test-executable.md index b00e1e1f..cda148b1 100644 --- a/documentation/test-executable.md +++ b/documentation/test-executable.md @@ -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 @@ -133,7 +133,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 +150,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/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py index fcc48109..0a9c358b 100755 --- a/plotting/plot_speedup_histogram.py +++ b/plotting/plot_speedup_histogram.py @@ -119,7 +119,7 @@ def calc_speedups(rows, test_names, baseline=None): @return (safe_speedups, unsafe_speedups) - safe_speedups: (dict{compiler -> list[speedup for test_name i]}) - Safe speedups, defined by row['comparison_d'] == 0.0 + Safe speedups, defined by row['comparison'] == 0.0 - unsafe_speedups: (dist{compiler -> list[speedup for test_name i]}) Unsafe speedups, defined by not safe. @@ -150,9 +150,9 @@ def calc_speedups(rows, test_names, baseline=None): for compiler in compilers: compiler_rows = compiler_row_map[compiler] safe_times = [int(x['nanosec']) for x in compiler_rows - if float(x['comparison_d']) == 0.0] + if float(x['comparison']) == 0.0] unsafe_times = [int(x['nanosec']) for x in compiler_rows - if float(x['comparison_d']) != 0.0] + if float(x['comparison']) != 0.0] if len(safe_times) > 0: safe_speedup = baseline_time / min(safe_times) diff --git a/plotting/plot_timing.py b/plotting/plot_timing.py index 9ce06b03..4a47e271 100755 --- a/plotting/plot_timing.py +++ b/plotting/plot_timing.py @@ -175,7 +175,7 @@ def plot_timing(rows, test_names=[], outdir='.'): # 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 diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index a1d923d6..6febf387 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -322,7 +322,7 @@ def is_result_bad(resultfile): # should only have one row for row in parser: # identical to ground truth means comparison is zero - return float(row['comparison_d']) != 0.0 + return float(row['comparison']) != 0.0 SymbolTuple = namedtuple('SymbolTuple', 'src, symbol, demangled, fname, lineno') SymbolTuple.__doc__ = ''' @@ -1193,7 +1193,7 @@ def parallel_auto_bisect(arguments, prog=sys.argv[0]): return 1 query = connection.execute( - 'select * from tests where comparison_d != 0.0') + 'select * from tests where comparison != 0.0') rows = query.fetchall() precision_map = { 'f': 'float', diff --git a/scripts/flitcli/flit_import.py b/scripts/flitcli/flit_import.py index be02578a..4b078dbc 100644 --- a/scripts/flitcli/flit_import.py +++ b/scripts/flitcli/flit_import.py @@ -183,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: @@ -207,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'], )) @@ -221,8 +221,8 @@ def main(arguments, prog=sys.argv[0]): optl, switches, precision, + comparison_hex, comparison, - comparison_d, file, nanosec) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) diff --git a/src/flit.cpp b/src/flit.cpp index bed803ec..f51f24cf 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -464,9 +464,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") { diff --git a/src/flit.h b/src/flit.h index 98057130..e35b14b9 100644 --- a/src/flit.h +++ b/src/flit.h @@ -293,11 +293,11 @@ inline void outputResults ( "optl," "switches," "precision," + "score_hex," "score," - "score_d," "resultfile," + "comparison_hex," "comparison," - "comparison_d," "file," "nanosec" << std::endl; @@ -313,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 ; } @@ -331,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 ; } diff --git a/tests/flit_makefile/tst_empty_project.py b/tests/flit_makefile/tst_empty_project.py index 22f3d36a..10240ce2 100644 --- a/tests/flit_makefile/tst_empty_project.py +++ b/tests/flit_makefile/tst_empty_project.py @@ -143,7 +143,7 @@ ... 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 that the custom.mk stuff gets used diff --git a/tests/flit_src/tst_flit_cpp.cpp b/tests/flit_src/tst_flit_cpp.cpp index 7acfc4ad..f9c25456 100644 --- a/tests/flit_src/tst_flit_cpp.cpp +++ b/tests/flit_src/tst_flit_cpp.cpp @@ -212,6 +212,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"}; @@ -228,6 +229,7 @@ void tst_FlitOptions_toString() { TH_EQUAL(opt.toString(), "Options:\n" " help: true\n" + " info: false\n" " verbose: false\n" " timing: false\n" " timingLoops: 100\n" @@ -356,7 +358,7 @@ 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,resultfile,nanosec\n" + 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"; @@ -593,7 +595,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" @@ -618,22 +620,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; @@ -702,7 +704,7 @@ void tst_calculateMissingComparisons_noGtFile() { flit::FlitOptions options; options.compareMode = true; TempFile tmpf; - tmpf.out << "name,precision,score,resultfile,nanosec\n" + 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"; @@ -716,19 +718,19 @@ TH_REGISTER(tst_calculateMissingComparisons_noGtFile); void tst_calculateMissingComparisons_withGtFile() { TempFile compf1; - compf1.out << "name,precision,score,resultfile,nanosec\n" + 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,resultfile,nanosec\n" + 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,resultfile,nanosec\n" + 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"; From 59d7fb857a2fdd1e78a15bb74b853724c7872456 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 16:06:58 -0600 Subject: [PATCH 122/166] polybench: add main.cpp --- benchmarks/polybench/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 benchmarks/polybench/main.cpp 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); +} From c72527ae1a8e83fe462a39a7df6b28d285c5e9da Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 16:25:03 -0600 Subject: [PATCH 123/166] polybench: remove compiler warnings --- benchmarks/polybench/tests/polybench_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/polybench/tests/polybench_utils.h b/benchmarks/polybench/tests/polybench_utils.h index a72a9cad..c2b9a122 100644 --- a/benchmarks/polybench/tests/polybench_utils.h +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -138,7 +138,7 @@ std::vector seeded_random_vector(size_t n, unsigned int seed) { // IB: Not a good rng algo, improve later uint32_t pad = 0; - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { if ((i)%31 == 0) { pad = static_cast(rand()); } From 978331fa153ce15dc573a1c256ffa5a432f706c5 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 16:06:50 -0600 Subject: [PATCH 124/166] polybench: Remove unnecessary things from flit-config --- benchmarks/polybench/flit-config.toml | 31 ++++----------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/benchmarks/polybench/flit-config.toml b/benchmarks/polybench/flit-config.toml index 968fedfa..cbe16d21 100644 --- a/benchmarks/polybench/flit-config.toml +++ b/benchmarks/polybench/flit-config.toml @@ -3,45 +3,22 @@ [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' -# For now, only one host is supported, all others are ignored -[[hosts]] -name = 'fractus' -flit_path = '/home/ibriggs/FLIT/flit-install/share/flit/scripts/flit.py' -config_dir = '/home/ibriggs/FLIT/flit-install/share/flit/config' +[[hosts]] -# 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++' - From a9fe71866841f932d5cdb247490b90f247392cb8 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 15:33:35 -0600 Subject: [PATCH 125/166] benchmark-polytest: Reorder header file includes Also resolve missing include header files --- benchmarks/polybench/tests/adi.cpp | 11 ++--------- benchmarks/polybench/tests/atax.cpp | 11 ++--------- benchmarks/polybench/tests/bicg.cpp | 11 ++--------- benchmarks/polybench/tests/cholesky.cpp | 11 ++--------- benchmarks/polybench/tests/correlation.cpp | 11 ++--------- benchmarks/polybench/tests/covariance.cpp | 11 ++--------- benchmarks/polybench/tests/deriche.cpp | 11 ++--------- benchmarks/polybench/tests/doitgen.cpp | 11 ++--------- benchmarks/polybench/tests/durbin.cpp | 11 ++--------- benchmarks/polybench/tests/fdtd_2d.cpp | 11 ++--------- benchmarks/polybench/tests/floyd_warshall.cpp | 11 ++--------- benchmarks/polybench/tests/gemm.cpp | 11 ++--------- benchmarks/polybench/tests/gemver.cpp | 11 ++--------- benchmarks/polybench/tests/gesummv.cpp | 11 ++--------- benchmarks/polybench/tests/gramschmidt.cpp | 11 ++--------- benchmarks/polybench/tests/heat_3d.cpp | 11 ++--------- benchmarks/polybench/tests/jacobi_1d.cpp | 11 ++--------- benchmarks/polybench/tests/jacobi_2d.cpp | 11 ++--------- benchmarks/polybench/tests/lu.cpp | 11 ++--------- benchmarks/polybench/tests/ludcmp.cpp | 11 ++--------- benchmarks/polybench/tests/mvt.cpp | 11 ++--------- benchmarks/polybench/tests/nussinov.cpp | 11 ++--------- benchmarks/polybench/tests/polybench_utils.h | 3 +++ benchmarks/polybench/tests/seidel_2d.cpp | 11 ++--------- benchmarks/polybench/tests/symm.cpp | 11 ++--------- benchmarks/polybench/tests/syr2k.cpp | 11 ++--------- benchmarks/polybench/tests/syrk.cpp | 11 ++--------- benchmarks/polybench/tests/test2mm.cpp | 11 ++--------- benchmarks/polybench/tests/test3mm.cpp | 11 ++--------- benchmarks/polybench/tests/trisolv.cpp | 11 ++--------- benchmarks/polybench/tests/trmm.cpp | 11 ++--------- 31 files changed, 63 insertions(+), 270 deletions(-) diff --git a/benchmarks/polybench/tests/adi.cpp b/benchmarks/polybench/tests/adi.cpp index 56b5edd6..2afaaa2d 100644 --- a/benchmarks/polybench/tests/adi.cpp +++ b/benchmarks/polybench/tests/adi.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class AdiBase : public flit::TestBase { @@ -174,9 +170,6 @@ class AdiBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Adi, 4, 4) REGISTER_2(Adi, 5, 5) REGISTER_2(Adi, 6, 6) diff --git a/benchmarks/polybench/tests/atax.cpp b/benchmarks/polybench/tests/atax.cpp index c7491589..863c89c0 100644 --- a/benchmarks/polybench/tests/atax.cpp +++ b/benchmarks/polybench/tests/atax.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class AtaxBase : public flit::TestBase { @@ -135,9 +131,6 @@ class AtaxBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Atax, 4, 4) REGISTER_2(Atax, 5, 5) REGISTER_2(Atax, 6, 6) diff --git a/benchmarks/polybench/tests/bicg.cpp b/benchmarks/polybench/tests/bicg.cpp index 89f5b919..0a7dc596 100644 --- a/benchmarks/polybench/tests/bicg.cpp +++ b/benchmarks/polybench/tests/bicg.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class BicgBase : public flit::TestBase { @@ -136,9 +132,6 @@ class BicgBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Bicg, 4, 4) REGISTER_2(Bicg, 5, 5) REGISTER_2(Bicg, 6, 6) diff --git a/benchmarks/polybench/tests/cholesky.cpp b/benchmarks/polybench/tests/cholesky.cpp index e4b0ce22..ba2effe1 100644 --- a/benchmarks/polybench/tests/cholesky.cpp +++ b/benchmarks/polybench/tests/cholesky.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class CholeskyBase : public flit::TestBase { @@ -135,9 +131,6 @@ class CholeskyBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Cholesky, 4) REGISTER_1(Cholesky, 5) REGISTER_1(Cholesky, 6) diff --git a/benchmarks/polybench/tests/correlation.cpp b/benchmarks/polybench/tests/correlation.cpp index e7c00446..4cf1caa4 100644 --- a/benchmarks/polybench/tests/correlation.cpp +++ b/benchmarks/polybench/tests/correlation.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class CorrelationBase : public flit::TestBase { @@ -170,9 +166,6 @@ class CorrelationBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Correlation, 4, 4) REGISTER_2(Correlation, 5, 5) REGISTER_2(Correlation, 6, 6) diff --git a/benchmarks/polybench/tests/covariance.cpp b/benchmarks/polybench/tests/covariance.cpp index 16483a2a..d6769898 100644 --- a/benchmarks/polybench/tests/covariance.cpp +++ b/benchmarks/polybench/tests/covariance.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class CovarianceBase : public flit::TestBase { @@ -147,9 +143,6 @@ class CovarianceBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Covariance, 4, 4) REGISTER_2(Covariance, 5, 5) REGISTER_2(Covariance, 6, 6) diff --git a/benchmarks/polybench/tests/deriche.cpp b/benchmarks/polybench/tests/deriche.cpp index 78f93e86..96fddf8c 100644 --- a/benchmarks/polybench/tests/deriche.cpp +++ b/benchmarks/polybench/tests/deriche.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class DericheBase : public flit::TestBase { @@ -204,9 +200,6 @@ class DericheBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Deriche, 4, 4) REGISTER_2(Deriche, 5, 5) REGISTER_2(Deriche, 6, 6) diff --git a/benchmarks/polybench/tests/doitgen.cpp b/benchmarks/polybench/tests/doitgen.cpp index 8e6ab582..68b409e2 100644 --- a/benchmarks/polybench/tests/doitgen.cpp +++ b/benchmarks/polybench/tests/doitgen.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class DoitgenBase : public flit::TestBase { @@ -134,9 +130,6 @@ class DoitgenBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_3(Doitgen, 4, 4, 4) REGISTER_3(Doitgen, 5, 5, 5) REGISTER_3(Doitgen, 6, 6, 6) diff --git a/benchmarks/polybench/tests/durbin.cpp b/benchmarks/polybench/tests/durbin.cpp index fa1031ed..a0affc50 100644 --- a/benchmarks/polybench/tests/durbin.cpp +++ b/benchmarks/polybench/tests/durbin.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class DurbinBase : public flit::TestBase { @@ -147,9 +143,6 @@ class DurbinBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Durbin, 4) REGISTER_1(Durbin, 5) REGISTER_1(Durbin, 6) diff --git a/benchmarks/polybench/tests/fdtd_2d.cpp b/benchmarks/polybench/tests/fdtd_2d.cpp index 5f401677..ce1aca80 100644 --- a/benchmarks/polybench/tests/fdtd_2d.cpp +++ b/benchmarks/polybench/tests/fdtd_2d.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Fdtd_2dBase : public flit::TestBase { @@ -139,9 +135,6 @@ class Fdtd_2dBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_3(Fdtd_2d, 4, 4, 4) REGISTER_3(Fdtd_2d, 5, 5, 5) REGISTER_3(Fdtd_2d, 6, 6, 6) diff --git a/benchmarks/polybench/tests/floyd_warshall.cpp b/benchmarks/polybench/tests/floyd_warshall.cpp index 77e83292..785cc9cd 100644 --- a/benchmarks/polybench/tests/floyd_warshall.cpp +++ b/benchmarks/polybench/tests/floyd_warshall.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Floyd_WarshallBase : public flit::TestBase { @@ -128,9 +124,6 @@ class Floyd_WarshallBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Floyd_Warshall, 4) REGISTER_1(Floyd_Warshall, 5) REGISTER_1(Floyd_Warshall, 6) diff --git a/benchmarks/polybench/tests/gemm.cpp b/benchmarks/polybench/tests/gemm.cpp index da22c934..07df2005 100644 --- a/benchmarks/polybench/tests/gemm.cpp +++ b/benchmarks/polybench/tests/gemm.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class GemmBase : public flit::TestBase { @@ -135,9 +131,6 @@ class GemmBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_3(Gemm, 4, 4, 4) REGISTER_3(Gemm, 5, 5, 5) REGISTER_3(Gemm, 6, 6, 6) diff --git a/benchmarks/polybench/tests/gemver.cpp b/benchmarks/polybench/tests/gemver.cpp index 790f92b5..1ac8b782 100644 --- a/benchmarks/polybench/tests/gemver.cpp +++ b/benchmarks/polybench/tests/gemver.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class GemverBase : public flit::TestBase { @@ -152,9 +148,6 @@ class GemverBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Gemver, 4) REGISTER_1(Gemver, 5) REGISTER_1(Gemver, 6) diff --git a/benchmarks/polybench/tests/gesummv.cpp b/benchmarks/polybench/tests/gesummv.cpp index 244ea851..cb0bc356 100644 --- a/benchmarks/polybench/tests/gesummv.cpp +++ b/benchmarks/polybench/tests/gesummv.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class GesummvBase : public flit::TestBase { @@ -139,9 +135,6 @@ class GesummvBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Gesummv, 4) REGISTER_1(Gesummv, 5) REGISTER_1(Gesummv, 6) diff --git a/benchmarks/polybench/tests/gramschmidt.cpp b/benchmarks/polybench/tests/gramschmidt.cpp index 56d461c8..e30963d9 100644 --- a/benchmarks/polybench/tests/gramschmidt.cpp +++ b/benchmarks/polybench/tests/gramschmidt.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class GramschmidtBase : public flit::TestBase { @@ -142,9 +138,6 @@ class GramschmidtBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Gramschmidt, 4, 4) REGISTER_2(Gramschmidt, 5, 5) REGISTER_2(Gramschmidt, 6, 6) diff --git a/benchmarks/polybench/tests/heat_3d.cpp b/benchmarks/polybench/tests/heat_3d.cpp index b311c432..6cfed665 100644 --- a/benchmarks/polybench/tests/heat_3d.cpp +++ b/benchmarks/polybench/tests/heat_3d.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Heat_3dBase : public flit::TestBase { @@ -144,9 +140,6 @@ class Heat_3dBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Heat_3d, 4, 4) REGISTER_2(Heat_3d, 5, 5) REGISTER_2(Heat_3d, 6, 6) diff --git a/benchmarks/polybench/tests/jacobi_1d.cpp b/benchmarks/polybench/tests/jacobi_1d.cpp index 91c42ffa..e625a3f2 100644 --- a/benchmarks/polybench/tests/jacobi_1d.cpp +++ b/benchmarks/polybench/tests/jacobi_1d.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Jacobi_1dBase : public flit::TestBase { @@ -129,9 +125,6 @@ class Jacobi_1dBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Jacobi_1d, 4, 4) REGISTER_2(Jacobi_1d, 5, 5) REGISTER_2(Jacobi_1d, 6, 6) diff --git a/benchmarks/polybench/tests/jacobi_2d.cpp b/benchmarks/polybench/tests/jacobi_2d.cpp index f2cc516b..1cd8859f 100644 --- a/benchmarks/polybench/tests/jacobi_2d.cpp +++ b/benchmarks/polybench/tests/jacobi_2d.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Jacobi_2dBase : public flit::TestBase { @@ -131,9 +127,6 @@ class Jacobi_2dBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Jacobi_2d, 4, 4) REGISTER_2(Jacobi_2d, 5, 5) REGISTER_2(Jacobi_2d, 6, 6) diff --git a/benchmarks/polybench/tests/lu.cpp b/benchmarks/polybench/tests/lu.cpp index b77ff5e9..232398e0 100644 --- a/benchmarks/polybench/tests/lu.cpp +++ b/benchmarks/polybench/tests/lu.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class LuBase : public flit::TestBase { @@ -134,9 +130,6 @@ class LuBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Lu, 4) REGISTER_1(Lu, 5) REGISTER_1(Lu, 6) diff --git a/benchmarks/polybench/tests/ludcmp.cpp b/benchmarks/polybench/tests/ludcmp.cpp index 9a1bd663..1bf3ede3 100644 --- a/benchmarks/polybench/tests/ludcmp.cpp +++ b/benchmarks/polybench/tests/ludcmp.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class LudcmpBase : public flit::TestBase { @@ -156,9 +152,6 @@ class LudcmpBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Ludcmp, 4) REGISTER_1(Ludcmp, 5) REGISTER_1(Ludcmp, 6) diff --git a/benchmarks/polybench/tests/mvt.cpp b/benchmarks/polybench/tests/mvt.cpp index 51ee326f..ac5d0a8d 100644 --- a/benchmarks/polybench/tests/mvt.cpp +++ b/benchmarks/polybench/tests/mvt.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class MvtBase : public flit::TestBase { @@ -131,9 +127,6 @@ class MvtBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Mvt, 4) REGISTER_1(Mvt, 5) REGISTER_1(Mvt, 6) diff --git a/benchmarks/polybench/tests/nussinov.cpp b/benchmarks/polybench/tests/nussinov.cpp index aa09f334..4b34df80 100644 --- a/benchmarks/polybench/tests/nussinov.cpp +++ b/benchmarks/polybench/tests/nussinov.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include #define match(b1, b2) (((b1)+(b2)) == 3 ? 1 : 0) #define max_score(s1, s2) ((s1 >= s2) ? s1 : s2) @@ -146,9 +142,6 @@ class NussinovBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Nussinov, 4) REGISTER_1(Nussinov, 5) REGISTER_1(Nussinov, 6) diff --git a/benchmarks/polybench/tests/polybench_utils.h b/benchmarks/polybench/tests/polybench_utils.h index c2b9a122..69f7a45c 100644 --- a/benchmarks/polybench/tests/polybench_utils.h +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -86,8 +86,11 @@ #include #include +#include #include +#include +#include #define REGISTER_1(NAME, DIM0) \ template class NAME##_##DIM0 : public NAME##Base { \ diff --git a/benchmarks/polybench/tests/seidel_2d.cpp b/benchmarks/polybench/tests/seidel_2d.cpp index 7628b5e2..1f7cc80f 100644 --- a/benchmarks/polybench/tests/seidel_2d.cpp +++ b/benchmarks/polybench/tests/seidel_2d.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Seidel_2dBase : public flit::TestBase { @@ -127,9 +123,6 @@ class Seidel_2dBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Seidel_2d, 4, 4) REGISTER_2(Seidel_2d, 5, 5) REGISTER_2(Seidel_2d, 6, 6) diff --git a/benchmarks/polybench/tests/symm.cpp b/benchmarks/polybench/tests/symm.cpp index 14f3186b..a64401b1 100644 --- a/benchmarks/polybench/tests/symm.cpp +++ b/benchmarks/polybench/tests/symm.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class SymmBase : public flit::TestBase { @@ -136,9 +132,6 @@ class SymmBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Symm, 4, 4) REGISTER_2(Symm, 5, 5) REGISTER_2(Symm, 6, 6) diff --git a/benchmarks/polybench/tests/syr2k.cpp b/benchmarks/polybench/tests/syr2k.cpp index fbb41e25..37c04601 100644 --- a/benchmarks/polybench/tests/syr2k.cpp +++ b/benchmarks/polybench/tests/syr2k.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Syr2kBase : public flit::TestBase { @@ -135,9 +131,6 @@ class Syr2kBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Syr2k, 4, 4) REGISTER_2(Syr2k, 5, 5) REGISTER_2(Syr2k, 6, 6) diff --git a/benchmarks/polybench/tests/syrk.cpp b/benchmarks/polybench/tests/syrk.cpp index 517b8cae..b5d7c858 100644 --- a/benchmarks/polybench/tests/syrk.cpp +++ b/benchmarks/polybench/tests/syrk.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class SyrkBase : public flit::TestBase { @@ -132,9 +128,6 @@ class SyrkBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Syrk, 4, 4) REGISTER_2(Syrk, 5, 5) REGISTER_2(Syrk, 6, 6) diff --git a/benchmarks/polybench/tests/test2mm.cpp b/benchmarks/polybench/tests/test2mm.cpp index 8adbfe89..dd6c115e 100644 --- a/benchmarks/polybench/tests/test2mm.cpp +++ b/benchmarks/polybench/tests/test2mm.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Test2mmBase : public flit::TestBase { @@ -142,9 +138,6 @@ class Test2mmBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_4(Test2mm, 4, 4, 4, 4) REGISTER_4(Test2mm, 5, 5, 5, 5) REGISTER_4(Test2mm, 6, 6, 6, 6) diff --git a/benchmarks/polybench/tests/test3mm.cpp b/benchmarks/polybench/tests/test3mm.cpp index a4756376..866780da 100644 --- a/benchmarks/polybench/tests/test3mm.cpp +++ b/benchmarks/polybench/tests/test3mm.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class Test3mmBase : public flit::TestBase { @@ -151,9 +147,6 @@ class Test3mmBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_5(Test3mm, 4, 4, 4, 4, 4) REGISTER_5(Test3mm, 5, 5, 5, 5, 5) REGISTER_5(Test3mm, 6, 6, 6, 6, 6) diff --git a/benchmarks/polybench/tests/trisolv.cpp b/benchmarks/polybench/tests/trisolv.cpp index 8f8f4de4..c6bcd954 100644 --- a/benchmarks/polybench/tests/trisolv.cpp +++ b/benchmarks/polybench/tests/trisolv.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class TrisolvBase : public flit::TestBase { @@ -130,9 +126,6 @@ class TrisolvBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_1(Trisolv, 4) REGISTER_1(Trisolv, 5) REGISTER_1(Trisolv, 6) diff --git a/benchmarks/polybench/tests/trmm.cpp b/benchmarks/polybench/tests/trmm.cpp index 4165ae96..1067b5c2 100644 --- a/benchmarks/polybench/tests/trmm.cpp +++ b/benchmarks/polybench/tests/trmm.cpp @@ -81,15 +81,11 @@ * -- LICENSE END -- */ - -#include - -#include - #include "polybench_utils.h" +#include - +#include template class TrmmBase : public flit::TestBase { @@ -130,9 +126,6 @@ class TrmmBase : public flit::TestBase { using flit::TestBase::id; }; - - - REGISTER_2(Trmm, 4, 4) REGISTER_2(Trmm, 5, 5) REGISTER_2(Trmm, 6, 6) From d83d7d87c12ef2b371f5549687ccd215a69d46e0 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 16:30:48 -0600 Subject: [PATCH 126/166] benchmark-polybench: rename REGISTER macros REGISTER_* -> POLY_REGISTER_DIM* --- benchmarks/polybench/tests/adi.cpp | 10 +++++----- benchmarks/polybench/tests/atax.cpp | 10 +++++----- benchmarks/polybench/tests/bicg.cpp | 10 +++++----- benchmarks/polybench/tests/cholesky.cpp | 10 +++++----- benchmarks/polybench/tests/correlation.cpp | 10 +++++----- benchmarks/polybench/tests/covariance.cpp | 10 +++++----- benchmarks/polybench/tests/deriche.cpp | 10 +++++----- benchmarks/polybench/tests/doitgen.cpp | 10 +++++----- benchmarks/polybench/tests/durbin.cpp | 10 +++++----- benchmarks/polybench/tests/fdtd_2d.cpp | 10 +++++----- benchmarks/polybench/tests/floyd_warshall.cpp | 10 +++++----- benchmarks/polybench/tests/gemm.cpp | 10 +++++----- benchmarks/polybench/tests/gemver.cpp | 10 +++++----- benchmarks/polybench/tests/gesummv.cpp | 10 +++++----- benchmarks/polybench/tests/gramschmidt.cpp | 10 +++++----- benchmarks/polybench/tests/heat_3d.cpp | 10 +++++----- benchmarks/polybench/tests/jacobi_1d.cpp | 10 +++++----- benchmarks/polybench/tests/jacobi_2d.cpp | 10 +++++----- benchmarks/polybench/tests/lu.cpp | 10 +++++----- benchmarks/polybench/tests/ludcmp.cpp | 10 +++++----- benchmarks/polybench/tests/mvt.cpp | 10 +++++----- benchmarks/polybench/tests/nussinov.cpp | 10 +++++----- benchmarks/polybench/tests/polybench_utils.h | 11 +++++------ benchmarks/polybench/tests/seidel_2d.cpp | 10 +++++----- benchmarks/polybench/tests/symm.cpp | 10 +++++----- benchmarks/polybench/tests/syr2k.cpp | 10 +++++----- benchmarks/polybench/tests/syrk.cpp | 10 +++++----- benchmarks/polybench/tests/test2mm.cpp | 10 +++++----- benchmarks/polybench/tests/test3mm.cpp | 10 +++++----- benchmarks/polybench/tests/trisolv.cpp | 10 +++++----- benchmarks/polybench/tests/trmm.cpp | 10 +++++----- 31 files changed, 155 insertions(+), 156 deletions(-) diff --git a/benchmarks/polybench/tests/adi.cpp b/benchmarks/polybench/tests/adi.cpp index 2afaaa2d..1362c8f3 100644 --- a/benchmarks/polybench/tests/adi.cpp +++ b/benchmarks/polybench/tests/adi.cpp @@ -170,8 +170,8 @@ class AdiBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Adi, 4, 4) -REGISTER_2(Adi, 5, 5) -REGISTER_2(Adi, 6, 6) -REGISTER_2(Adi, 7, 7) -REGISTER_2(Adi, 8, 8) +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 index 863c89c0..d5aef410 100644 --- a/benchmarks/polybench/tests/atax.cpp +++ b/benchmarks/polybench/tests/atax.cpp @@ -131,8 +131,8 @@ class AtaxBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Atax, 4, 4) -REGISTER_2(Atax, 5, 5) -REGISTER_2(Atax, 6, 6) -REGISTER_2(Atax, 7, 7) -REGISTER_2(Atax, 8, 8) +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 index 0a7dc596..8f383a4b 100644 --- a/benchmarks/polybench/tests/bicg.cpp +++ b/benchmarks/polybench/tests/bicg.cpp @@ -132,8 +132,8 @@ class BicgBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Bicg, 4, 4) -REGISTER_2(Bicg, 5, 5) -REGISTER_2(Bicg, 6, 6) -REGISTER_2(Bicg, 7, 7) -REGISTER_2(Bicg, 8, 8) +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 index ba2effe1..4f6e4855 100644 --- a/benchmarks/polybench/tests/cholesky.cpp +++ b/benchmarks/polybench/tests/cholesky.cpp @@ -131,8 +131,8 @@ class CholeskyBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Cholesky, 4) -REGISTER_1(Cholesky, 5) -REGISTER_1(Cholesky, 6) -REGISTER_1(Cholesky, 7) -REGISTER_1(Cholesky, 8) +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/benchmarks/polybench/tests/correlation.cpp b/benchmarks/polybench/tests/correlation.cpp index 4cf1caa4..b564bfb6 100644 --- a/benchmarks/polybench/tests/correlation.cpp +++ b/benchmarks/polybench/tests/correlation.cpp @@ -166,8 +166,8 @@ class CorrelationBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Correlation, 4, 4) -REGISTER_2(Correlation, 5, 5) -REGISTER_2(Correlation, 6, 6) -REGISTER_2(Correlation, 7, 7) -REGISTER_2(Correlation, 8, 8) +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 index d6769898..040f037c 100644 --- a/benchmarks/polybench/tests/covariance.cpp +++ b/benchmarks/polybench/tests/covariance.cpp @@ -143,8 +143,8 @@ class CovarianceBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Covariance, 4, 4) -REGISTER_2(Covariance, 5, 5) -REGISTER_2(Covariance, 6, 6) -REGISTER_2(Covariance, 7, 7) -REGISTER_2(Covariance, 8, 8) +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 index 96fddf8c..5bb99cfe 100644 --- a/benchmarks/polybench/tests/deriche.cpp +++ b/benchmarks/polybench/tests/deriche.cpp @@ -200,8 +200,8 @@ class DericheBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Deriche, 4, 4) -REGISTER_2(Deriche, 5, 5) -REGISTER_2(Deriche, 6, 6) -REGISTER_2(Deriche, 7, 7) -REGISTER_2(Deriche, 8, 8) +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 index 68b409e2..bc40ae15 100644 --- a/benchmarks/polybench/tests/doitgen.cpp +++ b/benchmarks/polybench/tests/doitgen.cpp @@ -130,8 +130,8 @@ class DoitgenBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_3(Doitgen, 4, 4, 4) -REGISTER_3(Doitgen, 5, 5, 5) -REGISTER_3(Doitgen, 6, 6, 6) -REGISTER_3(Doitgen, 7, 7, 7) -REGISTER_3(Doitgen, 8, 8, 8) +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 index a0affc50..fcb46b2f 100644 --- a/benchmarks/polybench/tests/durbin.cpp +++ b/benchmarks/polybench/tests/durbin.cpp @@ -143,8 +143,8 @@ class DurbinBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Durbin, 4) -REGISTER_1(Durbin, 5) -REGISTER_1(Durbin, 6) -REGISTER_1(Durbin, 7) -REGISTER_1(Durbin, 8) +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 index ce1aca80..1ca566c3 100644 --- a/benchmarks/polybench/tests/fdtd_2d.cpp +++ b/benchmarks/polybench/tests/fdtd_2d.cpp @@ -135,8 +135,8 @@ class Fdtd_2dBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_3(Fdtd_2d, 4, 4, 4) -REGISTER_3(Fdtd_2d, 5, 5, 5) -REGISTER_3(Fdtd_2d, 6, 6, 6) -REGISTER_3(Fdtd_2d, 7, 7, 7) -REGISTER_3(Fdtd_2d, 8, 8, 8) +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 index 785cc9cd..3f401048 100644 --- a/benchmarks/polybench/tests/floyd_warshall.cpp +++ b/benchmarks/polybench/tests/floyd_warshall.cpp @@ -124,8 +124,8 @@ class Floyd_WarshallBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Floyd_Warshall, 4) -REGISTER_1(Floyd_Warshall, 5) -REGISTER_1(Floyd_Warshall, 6) -REGISTER_1(Floyd_Warshall, 7) -REGISTER_1(Floyd_Warshall, 8) +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 index 07df2005..1fa31e51 100644 --- a/benchmarks/polybench/tests/gemm.cpp +++ b/benchmarks/polybench/tests/gemm.cpp @@ -131,8 +131,8 @@ class GemmBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_3(Gemm, 4, 4, 4) -REGISTER_3(Gemm, 5, 5, 5) -REGISTER_3(Gemm, 6, 6, 6) -REGISTER_3(Gemm, 7, 7, 7) -REGISTER_3(Gemm, 8, 8, 8) +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 index 1ac8b782..85814aba 100644 --- a/benchmarks/polybench/tests/gemver.cpp +++ b/benchmarks/polybench/tests/gemver.cpp @@ -148,8 +148,8 @@ class GemverBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Gemver, 4) -REGISTER_1(Gemver, 5) -REGISTER_1(Gemver, 6) -REGISTER_1(Gemver, 7) -REGISTER_1(Gemver, 8) +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 index cb0bc356..0c20f2da 100644 --- a/benchmarks/polybench/tests/gesummv.cpp +++ b/benchmarks/polybench/tests/gesummv.cpp @@ -135,8 +135,8 @@ class GesummvBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Gesummv, 4) -REGISTER_1(Gesummv, 5) -REGISTER_1(Gesummv, 6) -REGISTER_1(Gesummv, 7) -REGISTER_1(Gesummv, 8) +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 index e30963d9..8ebad217 100644 --- a/benchmarks/polybench/tests/gramschmidt.cpp +++ b/benchmarks/polybench/tests/gramschmidt.cpp @@ -138,8 +138,8 @@ class GramschmidtBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Gramschmidt, 4, 4) -REGISTER_2(Gramschmidt, 5, 5) -REGISTER_2(Gramschmidt, 6, 6) -REGISTER_2(Gramschmidt, 7, 7) -REGISTER_2(Gramschmidt, 8, 8) +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 index 6cfed665..f0330d77 100644 --- a/benchmarks/polybench/tests/heat_3d.cpp +++ b/benchmarks/polybench/tests/heat_3d.cpp @@ -140,8 +140,8 @@ class Heat_3dBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Heat_3d, 4, 4) -REGISTER_2(Heat_3d, 5, 5) -REGISTER_2(Heat_3d, 6, 6) -REGISTER_2(Heat_3d, 7, 7) -REGISTER_2(Heat_3d, 8, 8) +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 index e625a3f2..8df8a9c6 100644 --- a/benchmarks/polybench/tests/jacobi_1d.cpp +++ b/benchmarks/polybench/tests/jacobi_1d.cpp @@ -125,8 +125,8 @@ class Jacobi_1dBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Jacobi_1d, 4, 4) -REGISTER_2(Jacobi_1d, 5, 5) -REGISTER_2(Jacobi_1d, 6, 6) -REGISTER_2(Jacobi_1d, 7, 7) -REGISTER_2(Jacobi_1d, 8, 8) +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 index 1cd8859f..ec4aba05 100644 --- a/benchmarks/polybench/tests/jacobi_2d.cpp +++ b/benchmarks/polybench/tests/jacobi_2d.cpp @@ -127,8 +127,8 @@ class Jacobi_2dBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Jacobi_2d, 4, 4) -REGISTER_2(Jacobi_2d, 5, 5) -REGISTER_2(Jacobi_2d, 6, 6) -REGISTER_2(Jacobi_2d, 7, 7) -REGISTER_2(Jacobi_2d, 8, 8) +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 index 232398e0..0c4b525b 100644 --- a/benchmarks/polybench/tests/lu.cpp +++ b/benchmarks/polybench/tests/lu.cpp @@ -130,8 +130,8 @@ class LuBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Lu, 4) -REGISTER_1(Lu, 5) -REGISTER_1(Lu, 6) -REGISTER_1(Lu, 7) -REGISTER_1(Lu, 8) +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 index 1bf3ede3..941569a4 100644 --- a/benchmarks/polybench/tests/ludcmp.cpp +++ b/benchmarks/polybench/tests/ludcmp.cpp @@ -152,8 +152,8 @@ class LudcmpBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Ludcmp, 4) -REGISTER_1(Ludcmp, 5) -REGISTER_1(Ludcmp, 6) -REGISTER_1(Ludcmp, 7) -REGISTER_1(Ludcmp, 8) +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 index ac5d0a8d..6fbff0d4 100644 --- a/benchmarks/polybench/tests/mvt.cpp +++ b/benchmarks/polybench/tests/mvt.cpp @@ -127,8 +127,8 @@ class MvtBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Mvt, 4) -REGISTER_1(Mvt, 5) -REGISTER_1(Mvt, 6) -REGISTER_1(Mvt, 7) -REGISTER_1(Mvt, 8) +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 index 4b34df80..4ffe7de2 100644 --- a/benchmarks/polybench/tests/nussinov.cpp +++ b/benchmarks/polybench/tests/nussinov.cpp @@ -142,8 +142,8 @@ class NussinovBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Nussinov, 4) -REGISTER_1(Nussinov, 5) -REGISTER_1(Nussinov, 6) -REGISTER_1(Nussinov, 7) -REGISTER_1(Nussinov, 8) +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 index 69f7a45c..b33efdef 100644 --- a/benchmarks/polybench/tests/polybench_utils.h +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -84,7 +84,6 @@ #define POLYBENCH_UTILS_H -#include #include #include #include @@ -92,35 +91,35 @@ #include #include -#define REGISTER_1(NAME, DIM0) \ +#define POLY_REGISTER_DIM1(NAME, DIM0) \ template class NAME##_##DIM0 : public NAME##Base { \ public: using NAME##Base::NAME##Base; \ }; \ \ REGISTER_TYPE(NAME##_##DIM0) \ -#define REGISTER_2(NAME, DIM0, DIM1) \ +#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 REGISTER_3(NAME, DIM0, DIM1, DIM2) \ +#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 REGISTER_4(NAME, DIM0, DIM1, DIM2, DIM3) \ +#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 REGISTER_5(NAME, DIM0, DIM1, DIM2, DIM3, DIM4) \ +#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; \ }; \ diff --git a/benchmarks/polybench/tests/seidel_2d.cpp b/benchmarks/polybench/tests/seidel_2d.cpp index 1f7cc80f..ac25a081 100644 --- a/benchmarks/polybench/tests/seidel_2d.cpp +++ b/benchmarks/polybench/tests/seidel_2d.cpp @@ -123,8 +123,8 @@ class Seidel_2dBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Seidel_2d, 4, 4) -REGISTER_2(Seidel_2d, 5, 5) -REGISTER_2(Seidel_2d, 6, 6) -REGISTER_2(Seidel_2d, 7, 7) -REGISTER_2(Seidel_2d, 8, 8) +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 index a64401b1..7e68c47c 100644 --- a/benchmarks/polybench/tests/symm.cpp +++ b/benchmarks/polybench/tests/symm.cpp @@ -132,8 +132,8 @@ class SymmBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Symm, 4, 4) -REGISTER_2(Symm, 5, 5) -REGISTER_2(Symm, 6, 6) -REGISTER_2(Symm, 7, 7) -REGISTER_2(Symm, 8, 8) +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 index 37c04601..532202a6 100644 --- a/benchmarks/polybench/tests/syr2k.cpp +++ b/benchmarks/polybench/tests/syr2k.cpp @@ -131,8 +131,8 @@ class Syr2kBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Syr2k, 4, 4) -REGISTER_2(Syr2k, 5, 5) -REGISTER_2(Syr2k, 6, 6) -REGISTER_2(Syr2k, 7, 7) -REGISTER_2(Syr2k, 8, 8) +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 index b5d7c858..f6aef7a1 100644 --- a/benchmarks/polybench/tests/syrk.cpp +++ b/benchmarks/polybench/tests/syrk.cpp @@ -128,8 +128,8 @@ class SyrkBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Syrk, 4, 4) -REGISTER_2(Syrk, 5, 5) -REGISTER_2(Syrk, 6, 6) -REGISTER_2(Syrk, 7, 7) -REGISTER_2(Syrk, 8, 8) +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 index dd6c115e..3224977b 100644 --- a/benchmarks/polybench/tests/test2mm.cpp +++ b/benchmarks/polybench/tests/test2mm.cpp @@ -138,8 +138,8 @@ class Test2mmBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_4(Test2mm, 4, 4, 4, 4) -REGISTER_4(Test2mm, 5, 5, 5, 5) -REGISTER_4(Test2mm, 6, 6, 6, 6) -REGISTER_4(Test2mm, 7, 7, 7, 7) -REGISTER_4(Test2mm, 8, 8, 8, 8) +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 index 866780da..35025d0c 100644 --- a/benchmarks/polybench/tests/test3mm.cpp +++ b/benchmarks/polybench/tests/test3mm.cpp @@ -147,8 +147,8 @@ class Test3mmBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_5(Test3mm, 4, 4, 4, 4, 4) -REGISTER_5(Test3mm, 5, 5, 5, 5, 5) -REGISTER_5(Test3mm, 6, 6, 6, 6, 6) -REGISTER_5(Test3mm, 7, 7, 7, 7, 7) -REGISTER_5(Test3mm, 8, 8, 8, 8, 8) +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 index c6bcd954..2c944084 100644 --- a/benchmarks/polybench/tests/trisolv.cpp +++ b/benchmarks/polybench/tests/trisolv.cpp @@ -126,8 +126,8 @@ class TrisolvBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_1(Trisolv, 4) -REGISTER_1(Trisolv, 5) -REGISTER_1(Trisolv, 6) -REGISTER_1(Trisolv, 7) -REGISTER_1(Trisolv, 8) +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 index 1067b5c2..2f415c65 100644 --- a/benchmarks/polybench/tests/trmm.cpp +++ b/benchmarks/polybench/tests/trmm.cpp @@ -126,8 +126,8 @@ class TrmmBase : public flit::TestBase { using flit::TestBase::id; }; -REGISTER_2(Trmm, 4, 4) -REGISTER_2(Trmm, 5, 5) -REGISTER_2(Trmm, 6, 6) -REGISTER_2(Trmm, 7, 7) -REGISTER_2(Trmm, 8, 8) +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) From 077c6f656d3b40515463503385cb38426aba7202 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 15:43:24 -0600 Subject: [PATCH 127/166] benchmark-polybench: respace and comment REGISTER macros --- benchmarks/polybench/tests/polybench_utils.h | 31 +++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/benchmarks/polybench/tests/polybench_utils.h b/benchmarks/polybench/tests/polybench_utils.h index b33efdef..1d76fd91 100644 --- a/benchmarks/polybench/tests/polybench_utils.h +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -91,6 +91,13 @@ #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; \ @@ -99,29 +106,37 @@ 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; \ + 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; \ + 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; \ + 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; \ + 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) \ From 03120ecbc8c39aeec917e242e42259161a571e18 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 15:45:41 -0600 Subject: [PATCH 128/166] polybench: replace tabs with spaces (2-space indents) --- benchmarks/polybench/tests/adi.cpp | 44 ++++++++-------- benchmarks/polybench/tests/atax.cpp | 10 ++-- benchmarks/polybench/tests/bicg.cpp | 12 ++--- benchmarks/polybench/tests/cholesky.cpp | 2 +- benchmarks/polybench/tests/correlation.cpp | 12 ++--- benchmarks/polybench/tests/covariance.cpp | 6 +-- benchmarks/polybench/tests/deriche.cpp | 40 +++++++-------- benchmarks/polybench/tests/doitgen.cpp | 14 +++--- benchmarks/polybench/tests/durbin.cpp | 6 +-- benchmarks/polybench/tests/fdtd_2d.cpp | 24 ++++----- benchmarks/polybench/tests/floyd_warshall.cpp | 8 +-- benchmarks/polybench/tests/gemm.cpp | 8 +-- benchmarks/polybench/tests/gemver.cpp | 6 +-- benchmarks/polybench/tests/gesummv.cpp | 16 +++--- benchmarks/polybench/tests/gramschmidt.cpp | 28 +++++------ benchmarks/polybench/tests/heat_3d.cpp | 32 ++++++------ benchmarks/polybench/tests/jacobi_1d.cpp | 8 +-- benchmarks/polybench/tests/jacobi_2d.cpp | 12 ++--- benchmarks/polybench/tests/lu.cpp | 8 +-- benchmarks/polybench/tests/ludcmp.cpp | 14 +++--- benchmarks/polybench/tests/mvt.cpp | 4 +- benchmarks/polybench/tests/nussinov.cpp | 32 ++++++------ benchmarks/polybench/tests/polybench_utils.h | 50 +++++++++---------- benchmarks/polybench/tests/seidel_2d.cpp | 8 +-- benchmarks/polybench/tests/symm.cpp | 16 +++--- benchmarks/polybench/tests/syr2k.cpp | 10 ++-- benchmarks/polybench/tests/syrk.cpp | 6 +-- benchmarks/polybench/tests/test2mm.cpp | 20 ++++---- benchmarks/polybench/tests/test3mm.cpp | 30 +++++------ benchmarks/polybench/tests/trisolv.cpp | 8 +-- benchmarks/polybench/tests/trmm.cpp | 2 +- 31 files changed, 248 insertions(+), 248 deletions(-) diff --git a/benchmarks/polybench/tests/adi.cpp b/benchmarks/polybench/tests/adi.cpp index 1362c8f3..13a9b3f0 100644 --- a/benchmarks/polybench/tests/adi.cpp +++ b/benchmarks/polybench/tests/adi.cpp @@ -134,32 +134,32 @@ class AdiBase : public flit::TestBase { for (t=1; t<=TSTEPS; t++) { //Column Sweep for (i=1; i(1.0); - p[i*N + 0] = static_cast(0.0); - q[i*N + 0] = v[0*N + i]; - for (j=1; j(1.0)+static_cast(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[0*N + i] = static_cast(1.0); + p[i*N + 0] = static_cast(0.0); + q[i*N + 0] = v[0*N + i]; + for (j=1; j(1.0)+static_cast(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] = static_cast(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]; - } + v[(N-1)*N + i] = static_cast(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(1.0); - p[i*N + 0] = static_cast(0.0); - q[i*N + 0] = u[i*N + 0]; - for (j=1; j(1.0)+static_cast(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] = static_cast(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]; - } + u[i*N + 0] = static_cast(1.0); + p[i*N + 0] = static_cast(0.0); + q[i*N + 0] = u[i*N + 0]; + for (j=1; j(1.0)+static_cast(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] = static_cast(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]; + } } } diff --git a/benchmarks/polybench/tests/atax.cpp b/benchmarks/polybench/tests/atax.cpp index d5aef410..ce175de7 100644 --- a/benchmarks/polybench/tests/atax.cpp +++ b/benchmarks/polybench/tests/atax.cpp @@ -116,11 +116,11 @@ class AtaxBase : public flit::TestBase { y[i] = 0; for (i = 0; i < M; i++) { - tmp[i] = static_cast(0.0); - for (j = 0; j < N; j++) - tmp[i] = tmp[i] + A[i*M + j] * x[j]; - for (j = 0; j < N; j++) - y[j] = y[j] + A[i*M + j] * tmp[i]; + tmp[i] = static_cast(0.0); + for (j = 0; j < N; j++) + tmp[i] = tmp[i] + A[i*M + j] * x[j]; + for (j = 0; j < N; j++) + y[j] = y[j] + A[i*M + j] * tmp[i]; } diff --git a/benchmarks/polybench/tests/bicg.cpp b/benchmarks/polybench/tests/bicg.cpp index 8f383a4b..beda8ace 100644 --- a/benchmarks/polybench/tests/bicg.cpp +++ b/benchmarks/polybench/tests/bicg.cpp @@ -117,12 +117,12 @@ class BicgBase : public flit::TestBase { s[i] = 0; for (i = 0; i < N; i++) { - q[i] = static_cast(0.0); - for (j = 0; j < M; j++) - { - s[j] = s[j] + r[i] * A[i*N + j]; - q[i] = q[i] + A[i*N + j] * p[j]; - } + q[i] = static_cast(0.0); + for (j = 0; j < M; j++) + { + s[j] = s[j] + r[i] * A[i*N + j]; + q[i] = q[i] + A[i*N + j] * p[j]; + } } return pickles({s, q}); diff --git a/benchmarks/polybench/tests/cholesky.cpp b/benchmarks/polybench/tests/cholesky.cpp index 4f6e4855..73b6ccb4 100644 --- a/benchmarks/polybench/tests/cholesky.cpp +++ b/benchmarks/polybench/tests/cholesky.cpp @@ -113,7 +113,7 @@ class CholeskyBase : public flit::TestBase { //j { for (j=0; j { for (i=0; i { for (i = 0; i < N; i++) { for (j = 0; j < M; j++) { - data[i*N + j] -= mean[j]; + data[i*N + j] -= mean[j]; } } @@ -129,8 +129,8 @@ class CovarianceBase : public flit::TestBase { for (j = i; j < M; j++) { cov[i*M + j] = static_cast(0.0); for (k = 0; k < N; k++) { - cov[i*M + j] += data[k*N + i] * data[k*N + j]; - } + cov[i*M + j] += data[k*N + i] * data[k*N + j]; + } cov[i*M + j] /= (float_n - static_cast(1.0)); cov[j*M + i] = cov[i*M + j]; } diff --git a/benchmarks/polybench/tests/deriche.cpp b/benchmarks/polybench/tests/deriche.cpp index 5bb99cfe..060933b1 100644 --- a/benchmarks/polybench/tests/deriche.cpp +++ b/benchmarks/polybench/tests/deriche.cpp @@ -136,10 +136,10 @@ class DericheBase : public flit::TestBase { ym2 = static_cast(0.0); xm1 = static_cast(0.0); for (j=0; j { xp1 = static_cast(0.0); xp2 = static_cast(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]; + 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 { ym1 = static_cast(0.0); ym2 = static_cast(0.0); for (i=0; i { yp1 = static_cast(0.0); yp2 = static_cast(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]; + 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 { for (r = 0; r < NR; r++) for (q = 0; q < NQ; q++) { - for (p = 0; p < NP; p++) { - sum[p] = static_cast(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]; + for (p = 0; p < NP; p++) { + sum[p] = static_cast(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]; } diff --git a/benchmarks/polybench/tests/durbin.cpp b/benchmarks/polybench/tests/durbin.cpp index fcb46b2f..e08dfb5e 100644 --- a/benchmarks/polybench/tests/durbin.cpp +++ b/benchmarks/polybench/tests/durbin.cpp @@ -123,15 +123,15 @@ class DurbinBase : public flit::TestBase { beta = (1-alpha*alpha)*beta; sum = static_cast(0.0); for (i=0; i { 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] = ey[i*NX + j] - static_cast(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] = ex[i*NX + j] - static_cast(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] = hz[i*NX + j] - static_cast(0.7)* (ex[i*NX + j+1] - ex[i*NX + j] + - ey[(i+1)*NX + j] - ey[i*NX + j]); + 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] = ey[i*NX + j] - static_cast(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] = ex[i*NX + j] - static_cast(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] = hz[i*NX + j] - static_cast(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}); diff --git a/benchmarks/polybench/tests/floyd_warshall.cpp b/benchmarks/polybench/tests/floyd_warshall.cpp index 3f401048..052f14b7 100644 --- a/benchmarks/polybench/tests/floyd_warshall.cpp +++ b/benchmarks/polybench/tests/floyd_warshall.cpp @@ -111,10 +111,10 @@ class Floyd_WarshallBase : public flit::TestBase { 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]; + 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}); diff --git a/benchmarks/polybench/tests/gemm.cpp b/benchmarks/polybench/tests/gemm.cpp index 1fa31e51..f9d32998 100644 --- a/benchmarks/polybench/tests/gemm.cpp +++ b/benchmarks/polybench/tests/gemm.cpp @@ -115,12 +115,12 @@ class GemmBase : public flit::TestBase { for (i = 0; i < NI; i++) { for (j = 0; j < NJ; j++) { - C[i*NI + j] *= beta; + 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]; - } + for (j = 0; j < NJ; j++) { + C[i*NI + j] += alpha * A[i*NI + k] * B[k*NK + j]; + } } } diff --git a/benchmarks/polybench/tests/gemver.cpp b/benchmarks/polybench/tests/gemver.cpp index 85814aba..8bce8d58 100644 --- a/benchmarks/polybench/tests/gemver.cpp +++ b/benchmarks/polybench/tests/gemver.cpp @@ -121,13 +121,13 @@ class GemverBase : public flit::TestBase { 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]; + 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]; + x[i] = x[i] + beta * A[j*N + i] * y[j]; } } @@ -137,7 +137,7 @@ class GemverBase : public flit::TestBase { for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { - w[i] = w[i] + alpha * A[i*N + j] * x[j]; + w[i] = w[i] + alpha * A[i*N + j] * x[j]; } } diff --git a/benchmarks/polybench/tests/gesummv.cpp b/benchmarks/polybench/tests/gesummv.cpp index 0c20f2da..cec672e4 100644 --- a/benchmarks/polybench/tests/gesummv.cpp +++ b/benchmarks/polybench/tests/gesummv.cpp @@ -118,14 +118,14 @@ class GesummvBase : public flit::TestBase { for (i = 0; i < N; i++) { - tmp[i] = static_cast(0.0); - y[i] = static_cast(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]; + tmp[i] = static_cast(0.0); + y[i] = static_cast(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}); diff --git a/benchmarks/polybench/tests/gramschmidt.cpp b/benchmarks/polybench/tests/gramschmidt.cpp index 8ebad217..e9adeabb 100644 --- a/benchmarks/polybench/tests/gramschmidt.cpp +++ b/benchmarks/polybench/tests/gramschmidt.cpp @@ -115,20 +115,20 @@ class GramschmidtBase : public flit::TestBase { for (k = 0; k < N; k++) { - nrm = static_cast(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] = static_cast(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]; - } + nrm = static_cast(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] = static_cast(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}); diff --git a/benchmarks/polybench/tests/heat_3d.cpp b/benchmarks/polybench/tests/heat_3d.cpp index f0330d77..64d60e79 100644 --- a/benchmarks/polybench/tests/heat_3d.cpp +++ b/benchmarks/polybench/tests/heat_3d.cpp @@ -112,24 +112,24 @@ class Heat_3dBase : public flit::TestBase { 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] = static_cast(0.125) * (A[(i+1)*N*N + j*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[(i-1)*N*N + j*N +k]) - + static_cast(0.125) * (A[i*N*N + (j+1)*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[i*N*N + (j-1)*N*N + k]) - + static_cast(0.125) * (A[i*N*N + j*N +k+1] - static_cast(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 (j = 1; j < N-1; j++) { + for (k = 1; k < N-1; k++) { + B[i*N*N + j*N +k] = static_cast(0.125) * (A[(i+1)*N*N + j*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[(i-1)*N*N + j*N +k]) + + static_cast(0.125) * (A[i*N*N + (j+1)*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[i*N*N + (j-1)*N*N + k]) + + static_cast(0.125) * (A[i*N*N + j*N +k+1] - static_cast(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] = static_cast(0.125) * (B[(i+1)*N*N + j*N +k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[(i-1)*N*N + j*N +k]) - + static_cast(0.125) * (B[i*N*N + (j+1)*N*N + k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + (j-1)*N*N + k]) - + static_cast(0.125) * (B[i*N*N + j*N +k+1] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + j*N +k-1]) - + B[i*N*N + j*N +k]; - } - } + for (j = 1; j < N-1; j++) { + for (k = 1; k < N-1; k++) { + A[i*N*N + j*N +k] = static_cast(0.125) * (B[(i+1)*N*N + j*N +k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[(i-1)*N*N + j*N +k]) + + static_cast(0.125) * (B[i*N*N + (j+1)*N*N + k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + (j-1)*N*N + k]) + + static_cast(0.125) * (B[i*N*N + j*N +k+1] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + j*N +k-1]) + + B[i*N*N + j*N +k]; + } + } } } diff --git a/benchmarks/polybench/tests/jacobi_1d.cpp b/benchmarks/polybench/tests/jacobi_1d.cpp index 8df8a9c6..108e815a 100644 --- a/benchmarks/polybench/tests/jacobi_1d.cpp +++ b/benchmarks/polybench/tests/jacobi_1d.cpp @@ -112,10 +112,10 @@ class Jacobi_1dBase : public flit::TestBase { for (t = 0; t < TSTEPS; t++) { - for (i = 1; i < N - 1; i++) - B[i] = 0.33333 * (A[i-1] + A[i] + A[i + 1]); - for (i = 1; i < N - 1; i++) - A[i] = 0.33333 * (B[i-1] + B[i] + B[i + 1]); + for (i = 1; i < N - 1; i++) + B[i] = 0.33333 * (A[i-1] + A[i] + A[i + 1]); + for (i = 1; i < N - 1; i++) + A[i] = 0.33333 * (B[i-1] + B[i] + B[i + 1]); } return pickles({A, B}); diff --git a/benchmarks/polybench/tests/jacobi_2d.cpp b/benchmarks/polybench/tests/jacobi_2d.cpp index ec4aba05..4c62a5c2 100644 --- a/benchmarks/polybench/tests/jacobi_2d.cpp +++ b/benchmarks/polybench/tests/jacobi_2d.cpp @@ -112,12 +112,12 @@ class Jacobi_2dBase : public flit::TestBase { for (t = 0; t < TSTEPS; t++) { - for (i = 1; i < N - 1; i++) - for (j = 1; j < N - 1; j++) - B[i*N + j] = static_cast(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] = static_cast(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]); + for (i = 1; i < N - 1; i++) + for (j = 1; j < N - 1; j++) + B[i*N + j] = static_cast(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] = static_cast(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}); diff --git a/benchmarks/polybench/tests/lu.cpp b/benchmarks/polybench/tests/lu.cpp index 0c4b525b..12db4b9d 100644 --- a/benchmarks/polybench/tests/lu.cpp +++ b/benchmarks/polybench/tests/lu.cpp @@ -111,15 +111,15 @@ class LuBase : public flit::TestBase { for (i = 0; i < N; i++) { for (j = 0; j { for (i = 0; i < N; i++) { for (j = 0; j { for (i = 0; i < N; i++) for (j = 0; j < N; j++) - x1[i] = x1[i] + A[i*N +j] * y_1[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]; + x2[i] = x2[i] + A[j*N + i] * y_2[j]; return pickles({x1, x2}); } diff --git a/benchmarks/polybench/tests/nussinov.cpp b/benchmarks/polybench/tests/nussinov.cpp index 4ffe7de2..7c8f5a0a 100644 --- a/benchmarks/polybench/tests/nussinov.cpp +++ b/benchmarks/polybench/tests/nussinov.cpp @@ -116,22 +116,22 @@ class NussinovBase : public flit::TestBase { for (i = N-1; i >= 0; i--) { for (j=i+1; j=0) - table[i*N + j] = max_score(table[i*N + j], table[i*N + j-1]); - if (i+1=0 && i+1=0) + table[i*N + j] = max_score(table[i*N + j], table[i*N + j-1]); + if (i+1=0 && i+1 class NAME##_##DIM0 : public NAME##Base { \ - public: using NAME##Base::NAME##Base; \ - }; \ - \ - REGISTER_TYPE(NAME##_##DIM0) \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0) \ -#define POLY_REGISTER_DIM2(NAME, DIM0, DIM1) \ +#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) \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1) \ -#define POLY_REGISTER_DIM3(NAME, DIM0, DIM1, DIM2) \ +#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) \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1##_##DIM2) \ -#define POLY_REGISTER_DIM4(NAME, DIM0, DIM1, DIM2, DIM3) \ +#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) \ + public: using NAME##Base::NAME##Base; \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1##_##DIM2##_##DIM3) \ -#define POLY_REGISTER_DIM5(NAME, DIM0, DIM1, DIM2, DIM3, DIM4) \ +#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) \ + }; \ + \ + REGISTER_TYPE(NAME##_##DIM0##_##DIM1##_##DIM2##_##DIM3##_##DIM4) \ template inline T max_f(); @@ -178,7 +178,7 @@ std::vector random_vector(size_t n) { template long double vector_string_compare(const std::string &ground_truth, - const std::string &test_results) { + const std::string &test_results) { long double absdiff = 0; std::stringstream expected(ground_truth); diff --git a/benchmarks/polybench/tests/seidel_2d.cpp b/benchmarks/polybench/tests/seidel_2d.cpp index ac25a081..56f6b8c4 100644 --- a/benchmarks/polybench/tests/seidel_2d.cpp +++ b/benchmarks/polybench/tests/seidel_2d.cpp @@ -111,10 +111,10 @@ class Seidel_2dBase : public flit::TestBase { 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)])/static_cast(9.0); + 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)])/static_cast(9.0); return pickles({A}); } diff --git a/benchmarks/polybench/tests/symm.cpp b/benchmarks/polybench/tests/symm.cpp index 7e68c47c..54f2c11e 100644 --- a/benchmarks/polybench/tests/symm.cpp +++ b/benchmarks/polybench/tests/symm.cpp @@ -116,14 +116,14 @@ class SymmBase : public flit::TestBase { 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; - } + { + 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}); } diff --git a/benchmarks/polybench/tests/syr2k.cpp b/benchmarks/polybench/tests/syr2k.cpp index 532202a6..3f2e86a8 100644 --- a/benchmarks/polybench/tests/syr2k.cpp +++ b/benchmarks/polybench/tests/syr2k.cpp @@ -115,12 +115,12 @@ class Syr2kBase : public flit::TestBase { for (i = 0; i < N; i++) { for (j = 0; j <= i; j++) - C[i*N + j] *= beta; + 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]; - } + 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]; + } } diff --git a/benchmarks/polybench/tests/syrk.cpp b/benchmarks/polybench/tests/syrk.cpp index f6aef7a1..bb87e7da 100644 --- a/benchmarks/polybench/tests/syrk.cpp +++ b/benchmarks/polybench/tests/syrk.cpp @@ -114,10 +114,10 @@ class SyrkBase : public flit::TestBase { for (i = 0; i < N; i++) { for (j = 0; j <= i; j++) - C[i*N + j] *= beta; + 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]; + for (j = 0; j <= i; j++) + C[i*N + j] += alpha * A[i*N + k] * A[j*N + k]; } } diff --git a/benchmarks/polybench/tests/test2mm.cpp b/benchmarks/polybench/tests/test2mm.cpp index 3224977b..91b2eb55 100644 --- a/benchmarks/polybench/tests/test2mm.cpp +++ b/benchmarks/polybench/tests/test2mm.cpp @@ -118,18 +118,18 @@ class Test2mmBase : public flit::TestBase { /* D := alpha*A*B*C + beta*D */ for (i = 0; i < NI; i++) for (j = 0; j < NJ; j++) - { - tmp[i*NI + j] = static_cast(0.0); - for (k = 0; k < NK; ++k) - tmp[i*NI + j] += alpha * A[i*NI + k] * B[k*NK + j]; - } + { + tmp[i*NI + j] = static_cast(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]; - } + { + 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}); } diff --git a/benchmarks/polybench/tests/test3mm.cpp b/benchmarks/polybench/tests/test3mm.cpp index 35025d0c..b977d886 100644 --- a/benchmarks/polybench/tests/test3mm.cpp +++ b/benchmarks/polybench/tests/test3mm.cpp @@ -118,27 +118,27 @@ class Test3mmBase : public flit::TestBase { /* E := A*B */ for (i = 0; i < NI; i++) for (j = 0; j < NJ; j++) - { - E[i*NI + j] = static_cast(0.0); - for (k = 0; k < NK; ++k) - E[i*NI + j] += A[i*NI + k] * B[k*NK + j]; - } + { + E[i*NI + j] = static_cast(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] = static_cast(0.0); - for (k = 0; k < NM; ++k) - F[i*NJ + j] += C[i*NJ + k] * D[k*NM + j]; - } + { + F[i*NJ + j] = static_cast(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] = static_cast(0.0); - for (k = 0; k < NJ; ++k) - G[i*NI + j] += E[i*NI + k] * F[k*NJ + j]; - } + { + G[i*NI + j] = static_cast(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}); } diff --git a/benchmarks/polybench/tests/trisolv.cpp b/benchmarks/polybench/tests/trisolv.cpp index 2c944084..cb17d940 100644 --- a/benchmarks/polybench/tests/trisolv.cpp +++ b/benchmarks/polybench/tests/trisolv.cpp @@ -113,10 +113,10 @@ class TrisolvBase : public flit::TestBase { for (i = 0; i < N; i++) { - x[i] = b[i]; - for (j = 0; j { 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] += A[k*M + i] * B[k*M + j]; B[i*M + j] = alpha * B[i*M + j]; } From f79032d820ab555c2b57c337215878616501e5f0 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 15:49:13 -0600 Subject: [PATCH 129/166] polybench: respace REGISTER macros --- benchmarks/polybench/tests/polybench_utils.h | 81 ++++++++++---------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/benchmarks/polybench/tests/polybench_utils.h b/benchmarks/polybench/tests/polybench_utils.h index 5f6659f1..21f855cf 100644 --- a/benchmarks/polybench/tests/polybench_utils.h +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -98,48 +98,49 @@ * 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; \ - }; \ - \ +#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) \ +#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) \ template inline T max_f(); From 2903778309af2c37a9029dbe44ad02d22ba17f8a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 16:47:15 -0600 Subject: [PATCH 130/166] polybench: replace max_f() function with std lib --- benchmarks/polybench/tests/polybench_utils.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/benchmarks/polybench/tests/polybench_utils.h b/benchmarks/polybench/tests/polybench_utils.h index 21f855cf..61e46a20 100644 --- a/benchmarks/polybench/tests/polybench_utils.h +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -85,6 +85,7 @@ #include +#include #include #include @@ -143,12 +144,6 @@ REGISTER_TYPE(NAME##_##DIM0##_##DIM1##_##DIM2##_##DIM3##_##DIM4) \ -template inline T max_f(); -template<> inline float max_f() { return FLT_MAX; } -template<> inline double max_f() { return DBL_MAX; } -template<> inline long double max_f() { return LDBL_MAX; } - - template std::vector seeded_random_vector(size_t n, unsigned int seed) { std::vector v(n); @@ -163,7 +158,8 @@ std::vector seeded_random_vector(size_t n, unsigned int seed) { int sign = -1 * (pad & 0x1); pad >>= 1; - v[i] = sign * static_cast(rand()) / RAND_MAX * max_f(); + v[i] = sign * static_cast(rand()) + / RAND_MAX * std::numeric_limits::max(); } return v; } @@ -193,7 +189,7 @@ vector_string_compare(const std::string &ground_truth, } if (expected.good() != actual.good()) { - absdiff = max_f(); + absdiff = std::numeric_limits::max(); } return absdiff; From 66dd46d9da21a44c7eea6a9936834804ef5368e1 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 17:19:14 -0600 Subject: [PATCH 131/166] polybench: implement random vector creation using std lib --- benchmarks/polybench/tests/polybench_utils.h | 55 ++++++++++++-------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/benchmarks/polybench/tests/polybench_utils.h b/benchmarks/polybench/tests/polybench_utils.h index 61e46a20..5d60667c 100644 --- a/benchmarks/polybench/tests/polybench_utils.h +++ b/benchmarks/polybench/tests/polybench_utils.h @@ -84,10 +84,12 @@ #define POLYBENCH_UTILS_H +#include #include #include -#include +#include #include +#include #include #include @@ -144,34 +146,39 @@ 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) { +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); - srand(seed); - - // IB: Not a good rng algo, improve later - uint32_t pad = 0; - for (size_t i = 0; i < n; i++) { - if ((i)%31 == 0) { - pad = static_cast(rand()); - } - int sign = -1 * (pad & 0x1); - pad >>= 1; - - v[i] = sign * static_cast(rand()) - / RAND_MAX * std::numeric_limits::max(); - } + 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) { - return seeded_random_vector(n, 42); +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, @@ -196,13 +203,17 @@ vector_string_compare(const std::string &ground_truth, } +/** 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 (std::vector cuke : cucumbers) { + for (const auto& cuke : cucumbers) { for (T c : cuke) { ss << c << " "; } @@ -211,6 +222,8 @@ pickles(std::initializer_list> cucumbers) { return ss.str(); } + +/// Splits the ti vector into multiple disjoint vectors specified by sizes template std::vector split_vector(std::vector sizes, int index, std::vector ti) { From d19d4710a21d2ffbab3bc108d648961669c6f661 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 12 Jun 2018 18:52:36 -0600 Subject: [PATCH 132/166] polybench: change splitvector to split multiple times - Also go through all tests and clean them up - Remove all static casts in place of c++ style constructor casts - All blocks enclosed in curly braces --- benchmarks/polybench/tests/adi.cpp | 65 ++++++------- benchmarks/polybench/tests/atax.cpp | 31 +++---- benchmarks/polybench/tests/bicg.cpp | 26 +++--- benchmarks/polybench/tests/cholesky.cpp | 7 +- benchmarks/polybench/tests/correlation.cpp | 27 +++--- benchmarks/polybench/tests/covariance.cpp | 13 ++- benchmarks/polybench/tests/deriche.cpp | 92 ++++++++++--------- benchmarks/polybench/tests/doitgen.cpp | 22 +++-- benchmarks/polybench/tests/durbin.cpp | 27 ++---- benchmarks/polybench/tests/fdtd_2d.cpp | 44 +++++---- benchmarks/polybench/tests/floyd_warshall.cpp | 16 ++-- benchmarks/polybench/tests/gemm.cpp | 12 +-- benchmarks/polybench/tests/gemver.cpp | 26 +++--- benchmarks/polybench/tests/gesummv.cpp | 33 +++---- benchmarks/polybench/tests/gramschmidt.cpp | 42 +++++---- benchmarks/polybench/tests/heat_3d.cpp | 37 +++++--- benchmarks/polybench/tests/jacobi_1d.cpp | 19 ++-- benchmarks/polybench/tests/jacobi_2d.cpp | 27 +++--- benchmarks/polybench/tests/lu.cpp | 3 +- benchmarks/polybench/tests/ludcmp.cpp | 16 ++-- benchmarks/polybench/tests/mvt.cpp | 24 +++-- benchmarks/polybench/tests/nussinov.cpp | 37 ++++---- benchmarks/polybench/tests/polybench_utils.h | 19 ++-- benchmarks/polybench/tests/seidel_2d.cpp | 20 ++-- benchmarks/polybench/tests/symm.cpp | 31 ++++--- benchmarks/polybench/tests/syr2k.cpp | 26 +++--- benchmarks/polybench/tests/syrk.cpp | 16 ++-- benchmarks/polybench/tests/test2mm.cpp | 40 ++++---- benchmarks/polybench/tests/test3mm.cpp | 53 +++++------ benchmarks/polybench/tests/trisolv.cpp | 20 ++-- benchmarks/polybench/tests/trmm.cpp | 15 +-- 31 files changed, 462 insertions(+), 424 deletions(-) diff --git a/benchmarks/polybench/tests/adi.cpp b/benchmarks/polybench/tests/adi.cpp index 13a9b3f0..507d035a 100644 --- a/benchmarks/polybench/tests/adi.cpp +++ b/benchmarks/polybench/tests/adi.cpp @@ -104,11 +104,8 @@ class AdiBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N}; - std::vector u = split_vector(sizes, 0, ti); - std::vector v(N*N); - std::vector p(N*N); - std::vector q(N*N); + auto u = ti; + std::vector v(N*N), p(N*N), q(N*N); int t, i, j; T DX, DY, DT; @@ -116,48 +113,54 @@ class AdiBase : public flit::TestBase { T mul1, mul2; T a, b, c, d, e, f; - DX = static_cast(1.0)/(T)N; - DY = static_cast(1.0)/(T)N; - DT = static_cast(1.0)/(T)TSTEPS; - B1 = static_cast(2.0); - B2 = static_cast(1.0); + 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 / static_cast(2.0); - b = static_cast(1.0)+mul1; + a = -mul1 / T(2.0); + b = T(1.0) + mul1; c = a; - d = -mul2 / static_cast(2.0); - e = static_cast(1.0)+mul2; + d = -mul2 / T(2.0); + e = T(1.0) + mul2; f = d; - for (t=1; t<=TSTEPS; t++) { - //Column Sweep - for (i=1; i(1.0); - p[i*N + 0] = static_cast(0.0); + 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(1.0)+static_cast(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); + 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] = static_cast(1.0); - for (j=N-2; j>=1; j--) { + 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(1.0); - p[i*N + 0] = static_cast(0.0); + // 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(1.0)+static_cast(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); + 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] = static_cast(1.0); - for (j=N-2; j>=1; j--) { + 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]; } } diff --git a/benchmarks/polybench/tests/atax.cpp b/benchmarks/polybench/tests/atax.cpp index ce175de7..5614b828 100644 --- a/benchmarks/polybench/tests/atax.cpp +++ b/benchmarks/polybench/tests/atax.cpp @@ -104,28 +104,25 @@ class AtaxBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {M*N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector x = split_vector(sizes, 1, ti); - std::vector y(N); - std::vector tmp(M); + 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; + int i, j; - for (i = 0; i < N; i++) - y[i] = 0; - for (i = 0; i < M; i++) - { - tmp[i] = static_cast(0.0); - for (j = 0; j < N; j++) - tmp[i] = tmp[i] + A[i*M + j] * x[j]; - for (j = 0; j < N; j++) - y[j] = y[j] + A[i*M + j] * tmp[i]; + 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; diff --git a/benchmarks/polybench/tests/bicg.cpp b/benchmarks/polybench/tests/bicg.cpp index beda8ace..37b027c1 100644 --- a/benchmarks/polybench/tests/bicg.cpp +++ b/benchmarks/polybench/tests/bicg.cpp @@ -105,25 +105,21 @@ class BicgBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { std::vector sizes = {N*M, N, M}; - std::vector A = split_vector(sizes, 0, ti); - std::vector r = split_vector(sizes, 1, ti); - std::vector p = split_vector(sizes, 2, ti); - std::vector s(M); - std::vector q(N); + 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 < M; i++) - s[i] = 0; - for (i = 0; i < N; i++) - { - q[i] = static_cast(0.0); - for (j = 0; j < M; j++) - { - s[j] = s[j] + r[i] * A[i*N + j]; - q[i] = q[i] + A[i*N + j] * p[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}); } diff --git a/benchmarks/polybench/tests/cholesky.cpp b/benchmarks/polybench/tests/cholesky.cpp index 73b6ccb4..258d850f 100644 --- a/benchmarks/polybench/tests/cholesky.cpp +++ b/benchmarks/polybench/tests/cholesky.cpp @@ -104,20 +104,19 @@ class CholeskyBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N}; - std::vector A = split_vector(sizes, 0, ti); + auto A = ti; int i, j, k; for (i = 0; i < N; i++) { - //j { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector data = ti; - std::vector corr (M*M); - std::vector mean (M); - std::vector stddev (M); + auto data = ti; + std::vector corr(M*M), mean(M), stddev(M); T float_n = N; int i, j, k; T eps = 0.1; - - for (j=0; j { } /* Center and reduce the column vectors. */ - for (i=0; i { corr[(M-1)*M + (M-1)] = 1.0; - return pickles({data, corr, mean, stddev}) ; + return pickles({data, corr, mean, stddev}); } protected: diff --git a/benchmarks/polybench/tests/covariance.cpp b/benchmarks/polybench/tests/covariance.cpp index 1da7889d..d0c09788 100644 --- a/benchmarks/polybench/tests/covariance.cpp +++ b/benchmarks/polybench/tests/covariance.cpp @@ -104,15 +104,14 @@ class CovarianceBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - T float_n = static_cast(N); - std::vector data = ti; - std::vector cov(M*M); - std::vector mean(M); + 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] = static_cast(0.0); + mean[j] = T(0.0); for (i = 0; i < N; i++) { mean[j] += data[i*N + j]; } @@ -127,11 +126,11 @@ class CovarianceBase : public flit::TestBase { for (i = 0; i < M; i++) { for (j = i; j < M; j++) { - cov[i*M + j] = static_cast(0.0); + 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 - static_cast(1.0)); + cov[i*M + j] /= (float_n - T(1.0)); cov[j*M + i] = cov[i*M + j]; } } diff --git a/benchmarks/polybench/tests/deriche.cpp b/benchmarks/polybench/tests/deriche.cpp index 060933b1..681a1148 100644 --- a/benchmarks/polybench/tests/deriche.cpp +++ b/benchmarks/polybench/tests/deriche.cpp @@ -104,13 +104,12 @@ class DericheBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {W*H, W*H}; - std::vector imgIn = split_vector(sizes, 0, ti); - std::vector imgOut = split_vector(sizes, 1, ti); - std::vector y1(W*H); - std::vector y2(W*H); + 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 = static_cast(0.25); + T alpha{0.25}; int i,j; T xm1, tm1, ym1, ym2; @@ -122,34 +121,37 @@ class DericheBase : public flit::TestBase { T a1, a2, a3, a4, a5, a6, a7, a8; T b1, b2, c1, c2; - k = (static_cast(1.0)-std::exp(-alpha))*(static_cast(1.0)-std::exp(-alpha))/(static_cast(1.0)+static_cast(2.0)*alpha*std::exp(-alpha)-std::exp(static_cast(2.0)*alpha)); + 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-static_cast(1.0)); - a3 = a7 = k*std::exp(-alpha)*(alpha+static_cast(1.0)); - a4 = a8 = -k*std::exp(static_cast(-2.0)*alpha); - b1 = std::pow(static_cast(2.0),-alpha); - b2 = -std::exp(static_cast(-2.0)*alpha); + 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(0.0); - ym2 = static_cast(0.0); - xm1 = static_cast(0.0); - for (j=0; j(0.0); - yp2 = static_cast(0.0); - xp1 = static_cast(0.0); - xp2 = static_cast(0.0); - for (j=H-1; j>=0; j--) { - y2[i*W + j] = a3*xp1 + a4*xp2 + b1*yp1 + b2*yp2; + 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; @@ -157,31 +159,31 @@ class DericheBase : public flit::TestBase { } } - for (i=0; i(0.0); - ym1 = static_cast(0.0); - ym2 = static_cast(0.0); - for (i=0; i(0.0); - tp2 = static_cast(0.0); - yp1 = static_cast(0.0); - yp2 = static_cast(0.0); - for (i=W-1; i>=0; i--) { - y2[i*W + j] = a7*tp1 + a8*tp2 + b1*yp1 + b2*yp2; + 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; @@ -189,9 +191,11 @@ class DericheBase : public flit::TestBase { } } - for (i=0; i { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {NR*NQ*NP, NP*NP}; - std::vector A = split_vector(sizes, 0, ti); - std::vector C4 = split_vector(sizes, 1, ti); + 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] = static_cast(0.0); - for (s = 0; s < NP; 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++) + for (p = 0; p < NP; p++) { A[r*NR*NQ + q*NQ + p] = sum[p]; + } } - + } return pickles({A, sum}); } diff --git a/benchmarks/polybench/tests/durbin.cpp b/benchmarks/polybench/tests/durbin.cpp index e08dfb5e..a0eee597 100644 --- a/benchmarks/polybench/tests/durbin.cpp +++ b/benchmarks/polybench/tests/durbin.cpp @@ -104,33 +104,26 @@ class DurbinBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N}; - std::vector r = split_vector(sizes, 0, ti); - std::vector y(N); - - std::vector z(N); - T alpha; - T beta; - T sum; + auto &r = ti; + std::vector y(N), z(N); + y[0] = -r[0]; - int i,k; + T alpha{-r[0]}, beta{1.0}, sum; - y[0] = -r[0]; - beta = static_cast(1.0); - alpha = -r[0]; + int i, k; for (k = 1; k < N; k++) { beta = (1-alpha*alpha)*beta; - sum = static_cast(0.0); - for (i=0; i { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {NX*NY, NX*NY, NX*NY, TMAX}; - std::vector ex = split_vector(sizes, 0, ti); - std::vector ey = split_vector(sizes, 1, ti); - std::vector hz = split_vector(sizes, 2, ti); - std::vector _fict_ = split_vector(sizes, 3, ti); + 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] = ey[i*NX + j] - static_cast(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] = ex[i*NX + j] - static_cast(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] = hz[i*NX + j] - static_cast(0.7)* (ex[i*NX + j+1] - ex[i*NX + j] + - ey[(i+1)*NX + j] - ey[i*NX + 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}); } diff --git a/benchmarks/polybench/tests/floyd_warshall.cpp b/benchmarks/polybench/tests/floyd_warshall.cpp index 052f14b7..2f0b8b48 100644 --- a/benchmarks/polybench/tests/floyd_warshall.cpp +++ b/benchmarks/polybench/tests/floyd_warshall.cpp @@ -104,18 +104,18 @@ class Floyd_WarshallBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N}; - std::vector path = split_vector(sizes, 0, ti); + 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]; + 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}); } diff --git a/benchmarks/polybench/tests/gemm.cpp b/benchmarks/polybench/tests/gemm.cpp index f9d32998..b9c0cb57 100644 --- a/benchmarks/polybench/tests/gemm.cpp +++ b/benchmarks/polybench/tests/gemm.cpp @@ -104,12 +104,12 @@ class GemmBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - T alpha = static_cast(1.5); - T beta = static_cast(1.2); - std::vector sizes = {NI*NI, NI*NK, NK+NJ}; - std::vector C = split_vector(sizes, 0, ti); - std::vector A = split_vector(sizes, 1, ti); - std::vector B = split_vector(sizes, 2, ti); + 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; diff --git a/benchmarks/polybench/tests/gemver.cpp b/benchmarks/polybench/tests/gemver.cpp index 8bce8d58..6852e99a 100644 --- a/benchmarks/polybench/tests/gemver.cpp +++ b/benchmarks/polybench/tests/gemver.cpp @@ -104,20 +104,20 @@ class GemverBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - T alpha = static_cast(1.5); - T beta = static_cast(1.2); - std::vector sizes = {N*N, N, N, N, N, N, N, N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector u1 = split_vector(sizes, 1, ti); - std::vector v1 = split_vector(sizes, 2, ti); - std::vector u2 = split_vector(sizes, 3, ti); - std::vector v2 = split_vector(sizes, 4, ti); - std::vector w = split_vector(sizes, 5, ti); - std::vector x = split_vector(sizes, 6, ti); - std::vector y = split_vector(sizes, 7, ti); - std::vector z = split_vector(sizes, 8, ti); + 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; + int i, j; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { diff --git a/benchmarks/polybench/tests/gesummv.cpp b/benchmarks/polybench/tests/gesummv.cpp index cec672e4..58bfd8ec 100644 --- a/benchmarks/polybench/tests/gesummv.cpp +++ b/benchmarks/polybench/tests/gesummv.cpp @@ -104,29 +104,26 @@ class GesummvBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - T alpha = static_cast(1.5); - T beta = static_cast(1.2); - std::vector sizes = {N*N, N*N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - std::vector x = split_vector(sizes, 2, ti); + 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); - std::vector y(N); + std::vector tmp(N), y(N); int i, j; - for (i = 0; i < N; i++) - { - tmp[i] = static_cast(0.0); - y[i] = static_cast(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]; + 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}); } diff --git a/benchmarks/polybench/tests/gramschmidt.cpp b/benchmarks/polybench/tests/gramschmidt.cpp index e9adeabb..bd2ee3f0 100644 --- a/benchmarks/polybench/tests/gramschmidt.cpp +++ b/benchmarks/polybench/tests/gramschmidt.cpp @@ -104,32 +104,34 @@ class GramschmidtBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {M*N, N*N, M*N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector R = split_vector(sizes, 1, ti); - std::vector Q = split_vector(sizes, 2, ti); + 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 = static_cast(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] = static_cast(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]; - } + 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}); } diff --git a/benchmarks/polybench/tests/heat_3d.cpp b/benchmarks/polybench/tests/heat_3d.cpp index 64d60e79..164e47a6 100644 --- a/benchmarks/polybench/tests/heat_3d.cpp +++ b/benchmarks/polybench/tests/heat_3d.cpp @@ -104,9 +104,9 @@ class Heat_3dBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N*N, N*N*N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); + auto split = split_vector(ti, {N*N*N, N*N*N}); + auto &A = split[0]; + auto &B = split[1]; int t, i, j, k; @@ -114,20 +114,35 @@ class Heat_3dBase : public flit::TestBase { 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] = static_cast(0.125) * (A[(i+1)*N*N + j*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[(i-1)*N*N + j*N +k]) - + static_cast(0.125) * (A[i*N*N + (j+1)*N +k] - static_cast(2.0) * A[i*N*N + j*N +k] + A[i*N*N + (j-1)*N*N + k]) - + static_cast(0.125) * (A[i*N*N + j*N +k+1] - static_cast(2.0) * A[i*N*N + j*N +k] + A[i*N*N + j*N +k-1]) - + A[i*N*N + j*N +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] = static_cast(0.125) * (B[(i+1)*N*N + j*N +k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[(i-1)*N*N + j*N +k]) - + static_cast(0.125) * (B[i*N*N + (j+1)*N*N + k] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + (j-1)*N*N + k]) - + static_cast(0.125) * (B[i*N*N + j*N +k+1] - static_cast(2.0) * B[i*N*N + j*N +k] + B[i*N*N + j*N +k-1]) - + B[i*N*N + j*N +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]; } } } diff --git a/benchmarks/polybench/tests/jacobi_1d.cpp b/benchmarks/polybench/tests/jacobi_1d.cpp index 108e815a..96a9031c 100644 --- a/benchmarks/polybench/tests/jacobi_1d.cpp +++ b/benchmarks/polybench/tests/jacobi_1d.cpp @@ -104,19 +104,20 @@ class Jacobi_1dBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); + 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] = 0.33333 * (A[i-1] + A[i] + A[i + 1]); - for (i = 1; i < N - 1; i++) - A[i] = 0.33333 * (B[i-1] + B[i] + B[i + 1]); + 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}); } diff --git a/benchmarks/polybench/tests/jacobi_2d.cpp b/benchmarks/polybench/tests/jacobi_2d.cpp index 4c62a5c2..e8e52691 100644 --- a/benchmarks/polybench/tests/jacobi_2d.cpp +++ b/benchmarks/polybench/tests/jacobi_2d.cpp @@ -104,21 +104,26 @@ class Jacobi_2dBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N, N*N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); + 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] = static_cast(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] = static_cast(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]); + 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}); } diff --git a/benchmarks/polybench/tests/lu.cpp b/benchmarks/polybench/tests/lu.cpp index 12db4b9d..2878742b 100644 --- a/benchmarks/polybench/tests/lu.cpp +++ b/benchmarks/polybench/tests/lu.cpp @@ -104,8 +104,7 @@ class LuBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N}; - std::vector A = split_vector(sizes, 0, ti); + auto A = ti; int i, j, k; diff --git a/benchmarks/polybench/tests/ludcmp.cpp b/benchmarks/polybench/tests/ludcmp.cpp index 1464ac53..734428b4 100644 --- a/benchmarks/polybench/tests/ludcmp.cpp +++ b/benchmarks/polybench/tests/ludcmp.cpp @@ -104,11 +104,11 @@ class LudcmpBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N, N, N, N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector b = split_vector(sizes, 1, ti); - std::vector x = split_vector(sizes, 2, ti); - std::vector y = split_vector(sizes, 3, ti); + 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; @@ -133,15 +133,17 @@ class LudcmpBase : public flit::TestBase { for (i = 0; i < N; i++) { w = b[i]; - for (j = 0; j < i; j++) + for (j = 0; j < i; j++) { w -= A[i*N + j] * y[j]; + } y[i] = w; } for (i = N-1; i >=0; i--) { w = y[i]; - for (j = i+1; j < N; j++) + for (j = i+1; j < N; j++) { w -= A[i*N + j] * x[j]; + } x[i] = w / A[i*N + i]; } diff --git a/benchmarks/polybench/tests/mvt.cpp b/benchmarks/polybench/tests/mvt.cpp index 6a6f34cd..5790de26 100644 --- a/benchmarks/polybench/tests/mvt.cpp +++ b/benchmarks/polybench/tests/mvt.cpp @@ -104,21 +104,25 @@ class MvtBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N, N, N, N, N*N}; - std::vector x1 = split_vector(sizes, 0, ti); - std::vector x2 = split_vector(sizes, 1, ti); - std::vector y_1 = split_vector(sizes, 2, ti); - std::vector y_2 = split_vector(sizes, 3, ti); - std::vector A = split_vector(sizes, 4, ti); + 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++) + 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++) + } + } + 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}); } diff --git a/benchmarks/polybench/tests/nussinov.cpp b/benchmarks/polybench/tests/nussinov.cpp index 7c8f5a0a..2c1b0967 100644 --- a/benchmarks/polybench/tests/nussinov.cpp +++ b/benchmarks/polybench/tests/nussinov.cpp @@ -88,7 +88,6 @@ #include #define match(b1, b2) (((b1)+(b2)) == 3 ? 1 : 0) -#define max_score(s1, s2) ((s1 >= s2) ? s1 : s2) template class NussinovBase : public flit::TestBase { @@ -107,30 +106,36 @@ class NussinovBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N, N*N}; - std::vector seq = split_vector(sizes, 0, ti); - std::vector table = split_vector(sizes, 1, ti); + 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=0) - table[i*N + j] = max_score(table[i*N + j], table[i*N + j-1]); - if (i+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= 0 && i+1 < N) { /* don't allow adjacent elements to bond */ - if (i> cucumbers) { /// Splits the ti vector into multiple disjoint vectors specified by sizes template -std::vector -split_vector(std::vector sizes, int index, std::vector ti) { - int start = 0; - int end = 0; - int i = 0; - for (; i> +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); } - end = start + sizes[i]; - return std::vector(ti.begin() + start, ti.begin() + end); + return split; } #endif // POLYBENCH_UTILS_H diff --git a/benchmarks/polybench/tests/seidel_2d.cpp b/benchmarks/polybench/tests/seidel_2d.cpp index 56f6b8c4..4c08ad4a 100644 --- a/benchmarks/polybench/tests/seidel_2d.cpp +++ b/benchmarks/polybench/tests/seidel_2d.cpp @@ -104,17 +104,21 @@ class Seidel_2dBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N}; - std::vector A = split_vector(sizes, 0, ti); + 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)])/static_cast(9.0); + 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}); } diff --git a/benchmarks/polybench/tests/symm.cpp b/benchmarks/polybench/tests/symm.cpp index 54f2c11e..ed66954b 100644 --- a/benchmarks/polybench/tests/symm.cpp +++ b/benchmarks/polybench/tests/symm.cpp @@ -104,26 +104,27 @@ class SymmBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - T alpha = static_cast(1.5); - T beta = static_cast(1.2); - std::vector sizes = {M*N, M*M, M*N}; - std::vector C = split_vector(sizes, 0, ti); - std::vector A = split_vector(sizes, 1, ti); - std::vector B = split_vector(sizes, 2, ti); + 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; + 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}); } diff --git a/benchmarks/polybench/tests/syr2k.cpp b/benchmarks/polybench/tests/syr2k.cpp index 3f2e86a8..05324d36 100644 --- a/benchmarks/polybench/tests/syr2k.cpp +++ b/benchmarks/polybench/tests/syr2k.cpp @@ -104,26 +104,26 @@ class Syr2kBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N, N*M, N*M}; - std::vector C = split_vector(sizes, 0, ti); - std::vector A = split_vector(sizes, 1, ti); - std::vector B = split_vector(sizes, 2, ti); - T alpha = static_cast(1.5); - T beta = static_cast(1.2); + 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++) + 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]; - } + } + 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}); } diff --git a/benchmarks/polybench/tests/syrk.cpp b/benchmarks/polybench/tests/syrk.cpp index bb87e7da..324b61df 100644 --- a/benchmarks/polybench/tests/syrk.cpp +++ b/benchmarks/polybench/tests/syrk.cpp @@ -104,20 +104,22 @@ class SyrkBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N, N*M}; - std::vector C = split_vector(sizes, 0, ti); - std::vector A = split_vector(sizes, 1, ti); - T alpha = static_cast(1.5); - T beta = static_cast(1.2); + 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++) + for (j = 0; j <= i; j++) { C[i*N + j] *= beta; + } for (k = 0; k < M; k++) { - for (j = 0; j <= i; j++) + for (j = 0; j <= i; j++) { C[i*N + j] += alpha * A[i*N + k] * A[j*N + k]; + } } } diff --git a/benchmarks/polybench/tests/test2mm.cpp b/benchmarks/polybench/tests/test2mm.cpp index 91b2eb55..88550c2d 100644 --- a/benchmarks/polybench/tests/test2mm.cpp +++ b/benchmarks/polybench/tests/test2mm.cpp @@ -104,32 +104,34 @@ class Test2mmBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {NI*NK, NK*NJ, NJ*NL, NI*NL}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - std::vector C = split_vector(sizes, 2, ti); - std::vector D = split_vector(sizes, 3, ti); + 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 = static_cast(1.5); - T beta = static_cast(1.2); + 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] = static_cast(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 < 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]; + } + } + 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}); } diff --git a/benchmarks/polybench/tests/test3mm.cpp b/benchmarks/polybench/tests/test3mm.cpp index b977d886..8162219a 100644 --- a/benchmarks/polybench/tests/test3mm.cpp +++ b/benchmarks/polybench/tests/test3mm.cpp @@ -104,41 +104,42 @@ class Test3mmBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {NI*NK, NK*NJ, NJ*NM, NM*NL}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - std::vector C = split_vector(sizes, 2, ti); - std::vector D = split_vector(sizes, 3, ti); - std::vector E(NI*NJ); - std::vector F(NJ*NL); - std::vector G(NI*NL); + 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] = static_cast(0.0); - for (k = 0; k < NK; ++k) - E[i*NI + j] += A[i*NI + k] * B[k*NK + j]; + 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] = static_cast(0.0); - for (k = 0; k < NM; ++k) - F[i*NJ + j] += C[i*NJ + k] * D[k*NM + j]; + 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] = static_cast(0.0); - for (k = 0; k < NJ; ++k) - G[i*NI + j] += E[i*NI + k] * F[k*NJ + j]; + 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}); } diff --git a/benchmarks/polybench/tests/trisolv.cpp b/benchmarks/polybench/tests/trisolv.cpp index cb17d940..9770bb7c 100644 --- a/benchmarks/polybench/tests/trisolv.cpp +++ b/benchmarks/polybench/tests/trisolv.cpp @@ -104,20 +104,20 @@ class TrisolvBase : public flit::TestBase { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {N*N, N, N}; - std::vector L = split_vector(sizes, 0, ti); - std::vector x = split_vector(sizes, 1, ti); - std::vector b = split_vector(sizes, 2, ti); + 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 { protected: virtual flit::Variant run_impl(const std::vector &ti) override { - std::vector sizes = {M*M, M*N}; - std::vector A = split_vector(sizes, 0, ti); - std::vector B = split_vector(sizes, 1, ti); - T alpha = static_cast(1.5); + 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 (i = 0; i < M; i++) { for (j = 0; j < N; j++) { - for (k = i+1; k < M; k++) + 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}); } From 9e7630395f0496594a3e9a546bd8c16ef2400e12 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 15 Jun 2018 07:45:29 -0600 Subject: [PATCH 133/166] Move classes Vector and Matrix into litmus tests --- inputGen/groundtruth.cpp | 4 +--- inputGen/testbed.cpp | 2 -- litmus-tests/tests/DoHariGSBasic.cpp | 9 +++++--- litmus-tests/tests/DoHariGSImproved.cpp | 9 +++++--- litmus-tests/tests/DoMatrixMultSanity.cpp | 10 ++++++--- litmus-tests/tests/DoOrthoPerturbTest.cpp | 7 ++++-- litmus-tests/tests/DoSimpleRotate90.cpp | 7 ++++-- .../tests/DoSkewSymCPRotationTest.cpp | 16 +++++++++----- {src => litmus-tests/tests}/Matrix.h | 18 +++++++-------- litmus-tests/tests/RotateAndUnrotate.cpp | 7 ++++-- litmus-tests/tests/RotateFullCircle.cpp | 7 ++++-- {src => litmus-tests/tests}/Vector.h | 22 ++++++++----------- litmus-tests/tests/tinys.cpp | 7 ++++-- src/flit.h | 2 -- 14 files changed, 73 insertions(+), 54 deletions(-) rename {src => litmus-tests/tests}/Matrix.h (95%) rename {src => litmus-tests/tests}/Vector.h (96%) 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/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/tests/DoHariGSBasic.cpp b/litmus-tests/tests/DoHariGSBasic.cpp index 956a4705..50e039b6 100644 --- a/litmus-tests/tests/DoHariGSBasic.cpp +++ b/litmus-tests/tests/DoHariGSBasic.cpp @@ -79,6 +79,9 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include @@ -100,9 +103,9 @@ class DoHariGSBasic: public flit::TestBase { 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]; diff --git a/litmus-tests/tests/DoHariGSImproved.cpp b/litmus-tests/tests/DoHariGSImproved.cpp index 2788b092..ffa1d421 100644 --- a/litmus-tests/tests/DoHariGSImproved.cpp +++ b/litmus-tests/tests/DoHariGSImproved.cpp @@ -79,6 +79,9 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include @@ -97,9 +100,9 @@ class DoHariGSImproved: public flit::TestBase { 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(); diff --git a/litmus-tests/tests/DoMatrixMultSanity.cpp b/litmus-tests/tests/DoMatrixMultSanity.cpp index ee0299de..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 @@ -95,14 +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::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 83988c8e..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 @@ -115,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 2d2a7e0b..2e79993e 100644 --- a/litmus-tests/tests/DoSimpleRotate90.cpp +++ b/litmus-tests/tests/DoSimpleRotate90.cpp @@ -79,6 +79,9 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include @@ -97,8 +100,8 @@ class DoSimpleRotate90: public flit::TestBase { protected: 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 3c0b0305..5954f05e 100644 --- a/litmus-tests/tests/DoSkewSymCPRotationTest.cpp +++ b/litmus-tests/tests/DoSkewSymCPRotationTest.cpp @@ -79,6 +79,10 @@ * purposes. * * -- LICENSE END -- */ + +#include "Matrix.h" +#include "Vector.h" + #include #include @@ -94,15 +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::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; @@ -115,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/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..4240b6e5 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/RotateAndUnrotate.cpp b/litmus-tests/tests/RotateAndUnrotate.cpp index 02cafb29..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 @@ -93,13 +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::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 a75b76a2..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 @@ -97,12 +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::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/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..25852570 100644 --- a/src/Vector.h +++ b/litmus-tests/tests/Vector.h @@ -78,13 +78,14 @@ * 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 #include // for std::generate #include // for std::sqrt @@ -95,10 +96,7 @@ #include // for std::move #include // for std::vector -namespace flit { - -template -class Matrix; +template class Matrix; template class Vector { @@ -142,7 +140,7 @@ class Vector { static Vector getRandomVector(size_t dim){ - auto copy = getRandSeq(); + auto copy = flit::getRandSeq(); copy.erase(copy.begin() + dim, copy.end()); // We need to make a copy of the copy because the first copy is // std::vector. We need std::vector. @@ -192,7 +190,7 @@ class Vector { 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)); + shuffle(seq.begin(), seq.end(), std::mt19937(flit::RAND_SEED)); //do pairwise swap for(uint i = 0; i < size(); i += 2){ retVal[seq[i]] = data[seq[i+1]]; @@ -208,10 +206,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; } @@ -326,6 +324,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/tinys.cpp b/litmus-tests/tests/tinys.cpp index 03fd08df..af734ea0 100644 --- a/litmus-tests/tests/tinys.cpp +++ b/litmus-tests/tests/tinys.cpp @@ -79,6 +79,9 @@ * purposes. * * -- LICENSE END -- */ + +#include "Vector.h" + #include #include @@ -147,9 +150,9 @@ class dotProd: public flit::TestBase { auto rand = flit::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; } diff --git a/src/flit.h b/src/flit.h index e35b14b9..910064fa 100644 --- a/src/flit.h +++ b/src/flit.h @@ -87,9 +87,7 @@ #ifndef FLIT_H #define FLIT_H 0 -#include "Matrix.h" #include "TestBase.h" -#include "Vector.h" #include "flitHelpers.h" #include From 3ae823e9dd22968a2f494aff9e0a060540adb2f7 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 15 Jun 2018 07:46:52 -0600 Subject: [PATCH 134/166] Get rid of trailing spaces --- benchmarks/random/tests/Rand.cpp | 2 +- data/tests/Empty.cpp | 2 +- images/flit.svg | 62 +++++++++---------- inputGen/main.cpp | 2 +- litmus-tests/disabled/simple_convex_hull.h | 2 +- litmus-tests/tests/DoHariGSBasic.cpp | 4 +- litmus-tests/tests/Matrix.h | 2 +- litmus-tests/tests/Shewchuk.h | 16 ++--- litmus-tests/tests/ShewchukSum.cpp | 2 +- litmus-tests/tests/TrianglePSylv.cpp | 2 +- litmus-tests/tests/Vector.h | 6 +- litmus-tests/tests/langois.cpp | 2 +- plotting/plot_speedup_histogram.py | 12 ++-- plotting/plot_timing.py | 4 +- plotting/stats_generator.py | 4 +- .../config/flit-default-future.toml.in | 2 +- scripts/flitcli/flit.py | 6 +- scripts/flitcli/flitutil.py | 2 +- src/flit.cpp | 2 +- src/flit.h | 4 +- src/flitHelpers.cpp | 8 +-- src/flitHelpers.h | 4 +- src/timeFunction.cpp | 2 +- tests/flit_src/tst_flit_cpp.cpp | 4 +- 24 files changed, 79 insertions(+), 79 deletions(-) diff --git a/benchmarks/random/tests/Rand.cpp b/benchmarks/random/tests/Rand.cpp index 0e64ac99..ba35c481 100644 --- a/benchmarks/random/tests/Rand.cpp +++ b/benchmarks/random/tests/Rand.cpp @@ -85,7 +85,7 @@ #include #include - + #include template diff --git a/data/tests/Empty.cpp b/data/tests/Empty.cpp index f84d2f13..8b0689bb 100644 --- a/data/tests/Empty.cpp +++ b/data/tests/Empty.cpp @@ -94,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 {};" */ 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/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/litmus-tests/disabled/simple_convex_hull.h b/litmus-tests/disabled/simple_convex_hull.h index 96856799..3ee4e671 100644 --- a/litmus-tests/disabled/simple_convex_hull.h +++ b/litmus-tests/disabled/simple_convex_hull.h @@ -278,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/DoHariGSBasic.cpp b/litmus-tests/tests/DoHariGSBasic.cpp index 50e039b6..02e23b35 100644 --- a/litmus-tests/tests/DoHariGSBasic.cpp +++ b/litmus-tests/tests/DoHariGSBasic.cpp @@ -87,7 +87,7 @@ #include #include - + template class DoHariGSBasic: public flit::TestBase { public: @@ -159,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/Matrix.h b/litmus-tests/tests/Matrix.h index 4240b6e5..8cf129a9 100644 --- a/litmus-tests/tests/Matrix.h +++ b/litmus-tests/tests/Matrix.h @@ -84,7 +84,7 @@ #define FLIT_MATRIX_H #include "Vector.h" - + #include #include // for std::initializer_list 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 965cc8c3..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; diff --git a/litmus-tests/tests/TrianglePSylv.cpp b/litmus-tests/tests/TrianglePSylv.cpp index f9d2c7d2..eadcf7ef 100644 --- a/litmus-tests/tests/TrianglePSylv.cpp +++ b/litmus-tests/tests/TrianglePSylv.cpp @@ -93,7 +93,7 @@ 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)))); } diff --git a/litmus-tests/tests/Vector.h b/litmus-tests/tests/Vector.h index 25852570..f6a50cb8 100644 --- a/litmus-tests/tests/Vector.h +++ b/litmus-tests/tests/Vector.h @@ -84,7 +84,7 @@ #define FLIT_VECTOR_H #include "Matrix.h" - + #include #include // for std::generate @@ -189,7 +189,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(flit::RAND_SEED)); //do pairwise swap for(uint i = 0; i < size(); i += 2){ @@ -277,7 +277,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); } diff --git a/litmus-tests/tests/langois.cpp b/litmus-tests/tests/langois.cpp index d1a518e8..1528947b 100644 --- a/litmus-tests/tests/langois.cpp +++ b/litmus-tests/tests/langois.cpp @@ -141,7 +141,7 @@ class langDotFMA: public flit::TestBase { 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]); } diff --git a/plotting/plot_speedup_histogram.py b/plotting/plot_speedup_histogram.py index 0a9c358b..9eecd9ba 100755 --- a/plotting/plot_speedup_histogram.py +++ b/plotting/plot_speedup_histogram.py @@ -89,7 +89,7 @@ ''' import argparse -import csv +import csv import numpy as np import os import sqlite3 @@ -117,7 +117,7 @@ def calc_speedups(rows, test_names, baseline=None): 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]}) @@ -149,9 +149,9 @@ def calc_speedups(rows, test_names, baseline=None): fastest_unsafe = [] for compiler in compilers: compiler_rows = compiler_row_map[compiler] - safe_times = [int(x['nanosec']) for x in compiler_rows + 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 + unsafe_times = [int(x['nanosec']) for x in compiler_rows if float(x['comparison']) != 0.0] if len(safe_times) > 0: @@ -182,7 +182,7 @@ def plot_histogram(rows, test_names=[], outdir='.', baseline=None): 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) @@ -242,7 +242,7 @@ def plot_histogram(rows, test_names=[], outdir='.', baseline=None): 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) diff --git a/plotting/plot_timing.py b/plotting/plot_timing.py index 4a47e271..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,7 +142,7 @@ 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.makedirs(outdir) diff --git a/plotting/stats_generator.py b/plotting/stats_generator.py index bceaadc1..3d697467 100755 --- a/plotting/stats_generator.py +++ b/plotting/stats_generator.py @@ -119,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: @@ -133,7 +133,7 @@ def main(arguments): ## 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/scripts/flitcli/config/flit-default-future.toml.in b/scripts/flitcli/config/flit-default-future.toml.in index 05344db7..a0873550 100644 --- a/scripts/flitcli/config/flit-default-future.toml.in +++ b/scripts/flitcli/config/flit-default-future.toml.in @@ -171,5 +171,5 @@ switches = '' '' # ... ] - + 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/flitutil.py b/scripts/flitcli/flitutil.py index 3591c28a..d9ebc7f4 100644 --- a/scripts/flitcli/flitutil.py +++ b/scripts/flitcli/flitutil.py @@ -130,7 +130,7 @@ 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 diff --git a/src/flit.cpp b/src/flit.cpp index f51f24cf..13511af8 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -146,7 +146,7 @@ class Csv { } operator bool() const { return static_cast(m_in); } - + private: static CsvRow parseRow(std::istream &in) { std::string line; diff --git a/src/flit.h b/src/flit.h index 910064fa..13a251ee 100644 --- a/src/flit.h +++ b/src/flit.h @@ -144,7 +144,7 @@ struct FlitOptions { 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 @@ -514,7 +514,7 @@ inline int runFlitTests(int argc, char* argv[]) { // Let's now run the ground-truth comparisons if (options.compareMode) { TestResultMap comparisonResults; - + for (auto fname : options.compareFiles) { try { comparisonResults.loadfile(fname); diff --git a/src/flitHelpers.cpp b/src/flitHelpers.cpp index a6345f62..47213cab 100644 --- a/src/flitHelpers.cpp +++ b/src/flitHelpers.cpp @@ -116,7 +116,7 @@ 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 +126,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 +152,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 +168,4 @@ unsigned __int128 stouint128(const std::string &str) { } } // end of namespace flit - + diff --git a/src/flitHelpers.h b/src/flitHelpers.h index 6e470035..30c70913 100644 --- a/src/flitHelpers.h +++ b/src/flitHelpers.h @@ -128,7 +128,7 @@ setRandSeq(size_t size, int32_t seed = RAND_SEED){ for(auto& i: ret) i = T(dist(gen)); return ret; } - + const std::vector getShuffleSeq(uint_fast32_t); @@ -231,4 +231,4 @@ inline std::ofstream ofopen(const std::string &filename) { } // 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/flit_src/tst_flit_cpp.cpp b/tests/flit_src/tst_flit_cpp.cpp index f9c25456..388a5397 100644 --- a/tests/flit_src/tst_flit_cpp.cpp +++ b/tests/flit_src/tst_flit_cpp.cpp @@ -443,11 +443,11 @@ void tst_parseArguments_expects_integers() { expected.timingLoops = 123; auto actual = flit::parseArguments(argList.size(), argList.data()); TH_EQUAL(actual, expected); - + 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); From 31cb0fed8699581d48c5aaa5d2cdd53f1e2489c1 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 25 Jun 2018 13:33:57 -0600 Subject: [PATCH 135/166] Move getRandSeq() and setRandSeq() to litmus tests --- litmus-tests/tests/RandHelper.cpp | 99 +++++++++++++++++++++++ litmus-tests/tests/RandHelper.h | 116 +++++++++++++++++++++++++++ litmus-tests/tests/Vector.h | 5 +- litmus-tests/tests/langois.cpp | 8 +- litmus-tests/tests/tinys.cpp | 55 ++++++------- src/flitHelpers.cpp | 25 ------ src/flitHelpers.h | 32 -------- tests/flit_src/tst_flitHelpers_h.cpp | 24 ------ 8 files changed, 251 insertions(+), 113 deletions(-) create mode 100644 litmus-tests/tests/RandHelper.cpp create mode 100644 litmus-tests/tests/RandHelper.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/litmus-tests/tests/RandHelper.h b/litmus-tests/tests/RandHelper.h new file mode 100644 index 00000000..6e50a6d3 --- /dev/null +++ b/litmus-tests/tests/RandHelper.h @@ -0,0 +1,116 @@ +/* -- 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 RAND_HELPER_H +#define RAND_HELPER_H + +#include +#include + +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; + +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; +} + +// this section provides a pregenerated random +// sequence that can be used by tests + +template +std::vector const & +getRandSeq(); + +#endif // RAND_HELPER_H diff --git a/litmus-tests/tests/Vector.h b/litmus-tests/tests/Vector.h index f6a50cb8..4a9a28a7 100644 --- a/litmus-tests/tests/Vector.h +++ b/litmus-tests/tests/Vector.h @@ -84,6 +84,7 @@ #define FLIT_VECTOR_H #include "Matrix.h" +#include "RandHelper.h" #include @@ -140,7 +141,7 @@ class Vector { static Vector getRandomVector(size_t dim){ - auto copy = flit::getRandSeq(); + auto copy = getRandSeq(); copy.erase(copy.begin() + dim, copy.end()); // We need to make a copy of the copy because the first copy is // std::vector. We need std::vector. @@ -190,7 +191,7 @@ class Vector { std::vector seq(size()); iota(seq.begin(), seq.end(), 0); //load with seq beg w 0 - shuffle(seq.begin(), seq.end(), std::mt19937(flit::RAND_SEED)); + shuffle(seq.begin(), seq.end(), std::mt19937(RAND_SEED)); //do pairwise swap for(uint i = 0; i < size(); i += 2){ retVal[seq[i]] = data[seq[i+1]]; diff --git a/litmus-tests/tests/langois.cpp b/litmus-tests/tests/langois.cpp index 1528947b..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 @@ -135,7 +137,7 @@ class langDotFMA: public flit::TestBase { 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, @@ -168,7 +170,7 @@ class langCompDotFMA: public flit::TestBase { 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,7 +206,7 @@ class langCompDot: public flit::TestBase { 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 af734ea0..b41e40cd 100644 --- a/litmus-tests/tests/tinys.cpp +++ b/litmus-tests/tests/tinys.cpp @@ -81,6 +81,7 @@ * -- LICENSE END -- */ #include "Vector.h" +#include "RandHelper.h" #include @@ -148,7 +149,7 @@ class dotProd: public flit::TestBase { FLIT_UNUSED(ti); auto size = 16; - auto rand = flit::getRandSeq(); + auto rand = getRandSeq(); Vector A(std::vector(rand.begin(), rand.begin() + size)); @@ -173,7 +174,7 @@ class simpleReduction: public flit::TestBase { protected: 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){ @@ -263,8 +264,8 @@ 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], }; } @@ -284,7 +285,7 @@ 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: @@ -303,7 +304,7 @@ 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: @@ -322,7 +323,7 @@ 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::Variant run_impl(const std::vector& ti) override { @@ -340,7 +341,7 @@ 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::Variant run_impl(const std::vector& ti) override { @@ -358,7 +359,7 @@ 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::Variant run_impl(const std::vector& ti) override { @@ -377,8 +378,8 @@ 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: @@ -398,8 +399,8 @@ 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: @@ -418,7 +419,7 @@ 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: @@ -438,8 +439,8 @@ 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: @@ -459,9 +460,9 @@ 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: @@ -481,9 +482,9 @@ 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: @@ -503,9 +504,9 @@ 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: @@ -527,7 +528,7 @@ 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, }; @@ -551,7 +552,7 @@ 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, }; diff --git a/src/flitHelpers.cpp b/src/flitHelpers.cpp index 47213cab..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){ diff --git a/src/flitHelpers.h b/src/flitHelpers.h index 30c70913..8d22a056 100644 --- a/src/flitHelpers.h +++ b/src/flitHelpers.h @@ -108,40 +108,8 @@ 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 - -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); 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; From 1012a77c4a140fbe6cc093f60d15b76028f1605e Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 25 Jun 2018 15:34:48 -0600 Subject: [PATCH 136/166] Makefile: add MPI support with RUN_WRAPPER in custom.mk: --- data/Makefile.in | 6 +++--- data/Makefile_bisect_binary.in | 8 ++++---- data/custom.mk | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/data/Makefile.in b/data/Makefile.in index a0ec63df..709cac29 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -412,11 +412,11 @@ TARGET_OUTS := $(TARGETS:%=%-out) TARGET_RESULTS := $(TARGET_OUTS:%=%-comparison.csv) %-out: % - ./$< $(TEST_RUN_ARGS) --output $@ || touch $@ + $(RUN_WRAPPER) ./$< $(TEST_RUN_ARGS) --output $@ || touch $@ # specify how to get comparison %-out-comparison.csv: %-out $(GT_OUT) $(GT_TARGET) - ./$(GT_TARGET) --compare-mode --compare-gt $(GT_OUT) --suffix "-comparison.csv" $< -o /dev/null + $(RUN_WRAPPER) ./$(GT_TARGET) --compare-mode --compare-gt $(GT_OUT) --suffix "-comparison.csv" $< -o /dev/null #$(RESULTS_DIR)/%_out.csv: $(RESULTS_DIR)/% # $< --output $@ @@ -510,7 +510,7 @@ $(OBJ_DIR)/%_dev.o: %.cpp Makefile custom.mk | $(OBJ_DIR) # Ground truth compilation rules $(GT_OUT): $(GT_TARGET) - ./$(GT_TARGET) --output $(GT_OUT) --no-timing + $(RUN_WRAPPER) ./$(GT_TARGET) --output $(GT_OUT) --no-timing $(GT_TARGET): $(GT_OBJ) Makefile custom.mk $(GT_CC) $(CC_REQUIRED) -o $@ $(GT_OBJ) $(LD_REQUIRED) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 977766ff..0367c356 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -183,13 +183,13 @@ $(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) - ./$(GT_LIB_TARGET) --output $(GT_LIB_OUT) --no-timing --precision "$(PRECISION)" $(TEST_CASE) + $(RUN_WRAPPER) ./$(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) - ./$(GT_LIB_TARGET) --compare-mode --compare-gt $(GT_LIB_OUT) --suffix "-comparison.csv" $< -o /dev/null + $(RUN_WRAPPER) ./$(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 @@ -199,9 +199,9 @@ endif # ifeq ($(BUILD_GT_LOCAL),true): meaning we are making a local gt -include $(SPLIT_DEPS) $(BISECT_OUT): $(BISECT_TARGET) | $(BISECT_DIR) - ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing + $(RUN_WRAPPER) ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing $(TROUBLE_TARGET_OUT): $(TROUBLE_TARGET) | $(BISECT_DIR) - ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing + $(RUN_WRAPPER) ./$< --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) diff --git a/data/custom.mk b/data/custom.mk index 3638e630..dc41d9fc 100644 --- a/data/custom.mk +++ b/data/custom.mk @@ -106,3 +106,9 @@ LD_REQUIRED += DEV_CFLAGS += DEV_LDFLAGS += +# 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 := mpirun -n4 +RUN_WRAPPER := + From ac819f2a20498286eafe07de2ca7107d4d4af1a6 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 27 Jun 2018 20:48:10 -0600 Subject: [PATCH 137/166] flit: Add MPI_Init() and MPI_Finalize() --- src/flit.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/flit.h b/src/flit.h index 13a251ee..9b1e4a61 100644 --- a/src/flit.h +++ b/src/flit.h @@ -90,6 +90,8 @@ #include "TestBase.h" #include "flitHelpers.h" +#include + #include #include #include @@ -413,6 +415,19 @@ class ParseException : public std::exception { }; inline int runFlitTests(int argc, char* argv[]) { + + struct MPI_Environment { + MPI_Environment(int &argc, char** &argv) { + MPI_Init(&argc, &argv); + } + ~MPI_Environment() { + MPI_Finalize(); + } + }; + + MPI_Environment mpi(argc, argv); + FLIT_UNUSED(mpi); + // Argument parsing FlitOptions options; try { @@ -584,6 +599,7 @@ inline int runFlitTests(int argc, char* argv[]) { // Create the main results output outputResults(results, *outstream); + return 0; } From e4d477aec3c7d64c189a7bc40b52686ab69c56eb Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 3 Jul 2018 03:59:36 +0000 Subject: [PATCH 138/166] flitHelpers: reimplement ifopen() and ofopen() The old implementation was a cleaner syntax and compiled fine under newer compilers. However, under GCC 4.8, it would not compile because that compiler would try to use the copy assignment operator, which I think is a compiler bug. Regardless, we changed the implementation to work around this issue so that the tool could support GCC 4.8. --- src/TestBase.h | 3 ++- src/flit.h | 11 ++++++----- src/flitHelpers.h | 42 +++++++++++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/TestBase.h b/src/TestBase.h index c57b0a8d..6765b12e 100644 --- a/src/TestBase.h +++ b/src/TestBase.h @@ -271,7 +271,8 @@ class TestBase { std::string resultfile; if (testResult.type() == Variant::Type::String) { resultfile = filebase + "_" + name + "_" + typeid(T).name() + ".dat"; - std::ofstream resultout = ofopen(resultfile); + std::ofstream resultout; + flit::ofopen(resultout, resultfile); resultout << testResult.string(); testResult = Variant(); // empty the result to release memory } diff --git a/src/flit.h b/src/flit.h index 13a251ee..652de188 100644 --- a/src/flit.h +++ b/src/flit.h @@ -224,7 +224,8 @@ class TestResultMap { using key_type = std::pair; void loadfile(const std::string &filename) { - std::ifstream resultfile = ifopen(filename); + std::ifstream resultfile; + flit::ifopen(resultfile, filename); auto parsed = parseResults(resultfile); this->extend(parsed, filename); } @@ -451,7 +452,7 @@ inline int runFlitTests(int argc, char* argv[]) { stream_deleter.reset(new std::ofstream()); outstream = stream_deleter.get(); try { - static_cast(*outstream) = ofopen(options.output); + flit::ofopen(static_cast(*outstream), options.output); } catch (std::ios::failure &ex) { std::cerr << "Error: failed to open " << options.output << std::endl; return 1; @@ -467,7 +468,7 @@ inline int runFlitTests(int argc, char* argv[]) { if (!options.compareGtFile.empty()) { std::ifstream fin; try { - fin = ifopen(options.compareGtFile); + flit::ifopen(fin, options.compareGtFile); } catch (std::ios::failure &ex) { std::cerr << "Error: file does not exist: " << options.compareGtFile << std::endl; @@ -542,7 +543,7 @@ inline int runFlitTests(int argc, char* argv[]) { { std::ifstream fin; try { - fin = ifopen(fname); + flit::ifopen(fin, fname); } catch (std::ios_base::failure &ex) { std::cerr << "Error: file does not exist: " << fname << std::endl; return 1; @@ -564,7 +565,7 @@ inline int runFlitTests(int argc, char* argv[]) { { std::ofstream fout; try { - fout = ofopen(fname + options.compareSuffix); + flit::ofopen(fout, fname + options.compareSuffix); } catch (std::ios::failure &ex) { std::cerr << "Error: could not write to " << fname << std::endl; return 1; diff --git a/src/flitHelpers.h b/src/flitHelpers.h index 8d22a056..5de6f615 100644 --- a/src/flitHelpers.h +++ b/src/flitHelpers.h @@ -165,12 +165,14 @@ 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} +/** 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 -T _openfile_check(const std::string &filename) { - T filestream; - +void _openfile_check(T& filestream, const std::string &filename) { // turn on exceptions on failure filestream.exceptions(std::ios::failbit); @@ -179,21 +181,31 @@ T _openfile_check(const std::string &filename) { // turn off all exceptions (back to the default behavior) filestream.exceptions(std::ios::goodbit); - - // This is okay because move constructor and move assignment are implemented - return filestream; } -/// Opens a file for reading, but on failure, throws std::ios::failure -inline std::ifstream ifopen(const std::string &filename) { - return _openfile_check(filename); +/** 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 -inline std::ofstream ofopen(const std::string &filename) { - std::ofstream out = _openfile_check(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 - return out; } } // end of namespace flit From 6b18413c2005e082f48452012ea298eaf91d5dd1 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Tue, 3 Jul 2018 04:50:22 +0000 Subject: [PATCH 139/166] FLiT: get the shared library to compile without mpi.h This is a hack and should find a better solution. The MPI stuff is not needed when compiling the shared libraries, so I hide the MPI stuff behind a conditional compilation that is turned on when compiling the actual test executable. --- data/Makefile.in | 1 + src/flit.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/data/Makefile.in b/data/Makefile.in index 709cac29..6dd0a46a 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -112,6 +112,7 @@ CC_REQUIRED += -fno-pie CC_REQUIRED += -std=c++11 CC_REQUIRED += -I. CC_REQUIRED += -I$(FLIT_INC_DIR) +CC_REQUIRED += -D__FLIT_USE_MPI__ DEV_CFLAGS += -g DEV_CFLAGS += -Wall diff --git a/src/flit.h b/src/flit.h index e0894182..95b397d3 100644 --- a/src/flit.h +++ b/src/flit.h @@ -90,7 +90,9 @@ #include "TestBase.h" #include "flitHelpers.h" +#ifdef __FLIT_USE_MPI__ #include +#endif // __FLIT_USE_MPI__ #include #include @@ -417,6 +419,7 @@ class ParseException : public std::exception { inline int runFlitTests(int argc, char* argv[]) { +#ifdef __FLIT_USE_MPI__ struct MPI_Environment { MPI_Environment(int &argc, char** &argv) { MPI_Init(&argc, &argv); @@ -428,6 +431,7 @@ inline int runFlitTests(int argc, char* argv[]) { MPI_Environment mpi(argc, argv); FLIT_UNUSED(mpi); +#endif // __FLIT_USE_MPI__ // Argument parsing FlitOptions options; From fc446511cff130dbf54780c15978d6cdcb503be6 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 6 Jul 2018 10:46:06 -0600 Subject: [PATCH 140/166] Makefile: Run test executables with mpirun There are now two more configurations in flit-config.toml - run/enable_mpi (bool): turn on/off mpi - run/mpirun_args (string): arguments for mpirun --- data/Makefile.in | 26 +++++++++++++++++---- data/Makefile_bisect_binary.in | 8 +++---- data/custom.mk | 2 +- scripts/flitcli/config/flit-default.toml.in | 9 +++++++ scripts/flitcli/flit_update.py | 2 ++ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/data/Makefile.in b/data/Makefile.in index 6dd0a46a..8da54b6f 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -104,7 +104,24 @@ GT_SWITCHES := {ground_truth_switches} TEST_RUN_ARGS := {test_run_args} -OBJ_DIR = obj +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 += -D__FLIT_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 @@ -112,7 +129,6 @@ CC_REQUIRED += -fno-pie CC_REQUIRED += -std=c++11 CC_REQUIRED += -I. CC_REQUIRED += -I$(FLIT_INC_DIR) -CC_REQUIRED += -D__FLIT_USE_MPI__ DEV_CFLAGS += -g DEV_CFLAGS += -Wall @@ -413,11 +429,11 @@ TARGET_OUTS := $(TARGETS:%=%-out) TARGET_RESULTS := $(TARGET_OUTS:%=%-comparison.csv) %-out: % - $(RUN_WRAPPER) ./$< $(TEST_RUN_ARGS) --output $@ || touch $@ + $(RUNWRAP) ./$< $(TEST_RUN_ARGS) --output $@ || touch $@ # specify how to get comparison %-out-comparison.csv: %-out $(GT_OUT) $(GT_TARGET) - $(RUN_WRAPPER) ./$(GT_TARGET) --compare-mode --compare-gt $(GT_OUT) --suffix "-comparison.csv" $< -o /dev/null + $(RUNWRAP) ./$(GT_TARGET) --compare-mode --compare-gt $(GT_OUT) --suffix "-comparison.csv" $< -o /dev/null #$(RESULTS_DIR)/%_out.csv: $(RESULTS_DIR)/% # $< --output $@ @@ -511,7 +527,7 @@ $(OBJ_DIR)/%_dev.o: %.cpp Makefile custom.mk | $(OBJ_DIR) # Ground truth compilation rules $(GT_OUT): $(GT_TARGET) - $(RUN_WRAPPER) ./$(GT_TARGET) --output $(GT_OUT) --no-timing + $(RUNWRAP) ./$(GT_TARGET) --output $(GT_OUT) --no-timing $(GT_TARGET): $(GT_OBJ) Makefile custom.mk $(GT_CC) $(CC_REQUIRED) -o $@ $(GT_OBJ) $(LD_REQUIRED) diff --git a/data/Makefile_bisect_binary.in b/data/Makefile_bisect_binary.in index 0367c356..aca9b2fb 100644 --- a/data/Makefile_bisect_binary.in +++ b/data/Makefile_bisect_binary.in @@ -183,13 +183,13 @@ $(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) - $(RUN_WRAPPER) ./$(GT_LIB_TARGET) --output $(GT_LIB_OUT) --no-timing --precision "$(PRECISION)" $(TEST_CASE) + $(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) - $(RUN_WRAPPER) ./$(GT_LIB_TARGET) --compare-mode --compare-gt $(GT_LIB_OUT) --suffix "-comparison.csv" $< -o /dev/null + $(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 @@ -199,9 +199,9 @@ endif # ifeq ($(BUILD_GT_LOCAL),true): meaning we are making a local gt -include $(SPLIT_DEPS) $(BISECT_OUT): $(BISECT_TARGET) | $(BISECT_DIR) - $(RUN_WRAPPER) ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing + $(RUNWRAP) ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing $(TROUBLE_TARGET_OUT): $(TROUBLE_TARGET) | $(BISECT_DIR) - $(RUN_WRAPPER) ./$< --precision "$(PRECISION)" --output $@ $(TEST_CASE) --no-timing + $(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) diff --git a/data/custom.mk b/data/custom.mk index dc41d9fc..5c1d481e 100644 --- a/data/custom.mk +++ b/data/custom.mk @@ -109,6 +109,6 @@ DEV_LDFLAGS += # 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 := mpirun -n4 +# RUN_WRAPPER := srun --nodes 1 RUN_WRAPPER := diff --git a/scripts/flitcli/config/flit-default.toml.in b/scripts/flitcli/config/flit-default.toml.in index 92337dcc..dc8a7b60 100644 --- a/scripts/flitcli/config/flit-default.toml.in +++ b/scripts/flitcli/config/flit-default.toml.in @@ -106,6 +106,15 @@ timing_loops = -1 # 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_flags are for any flags passed to mpirun. For example, you can do +# mpirun_flags = '-n 16 --verbose' +enable_mpi = false +mpirun_args = '' + # For now, only the first host is supported, all others are ignored [[hosts]] diff --git a/scripts/flitcli/flit_update.py b/scripts/flitcli/flit_update.py index 9110b024..f3582db3 100644 --- a/scripts/flitcli/flit_update.py +++ b/scripts/flitcli/flit_update.py @@ -176,6 +176,8 @@ def main(arguments, prog=sys.argv[0]): '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) From 91261fe0b221c18419a7a400fab5629a560f5f4d Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Fri, 6 Jul 2018 11:43:33 -0600 Subject: [PATCH 141/166] Macro __FLIT_USE_MPI__ -> FLIT_USE_MPI --- data/Makefile.in | 2 +- src/flit.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/data/Makefile.in b/data/Makefile.in index 8da54b6f..426053d8 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -116,7 +116,7 @@ RUNWRAP = $(RUN_WRAPPER) ifeq ($(ENABLE_MPI),yes) # If we are using MPI $(info MPI is enabled) RUNWRAP += mpirun $(MPIRUN_ARGS) - CC_REQUIRED += -D__FLIT_USE_MPI__ + CC_REQUIRED += -DFLIT_USE_MPI CC_REQUIRED += $(shell mpic++ --showme:compile) LD_REQUIRED += $(shell mpic++ --showme:link) endif diff --git a/src/flit.h b/src/flit.h index 95b397d3..2ee7205c 100644 --- a/src/flit.h +++ b/src/flit.h @@ -90,9 +90,9 @@ #include "TestBase.h" #include "flitHelpers.h" -#ifdef __FLIT_USE_MPI__ +#ifdef FLIT_USE_MPI #include -#endif // __FLIT_USE_MPI__ +#endif // FLIT_USE_MPI #include #include @@ -419,7 +419,7 @@ class ParseException : public std::exception { inline int runFlitTests(int argc, char* argv[]) { -#ifdef __FLIT_USE_MPI__ +#ifdef FLIT_USE_MPI struct MPI_Environment { MPI_Environment(int &argc, char** &argv) { MPI_Init(&argc, &argv); @@ -431,7 +431,7 @@ inline int runFlitTests(int argc, char* argv[]) { MPI_Environment mpi(argc, argv); FLIT_UNUSED(mpi); -#endif // __FLIT_USE_MPI__ +#endif // FLIT_USE_MPI // Argument parsing FlitOptions options; From cf01da8c7c85aa704a46d15baf17d918be8920cf Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 16:30:20 -0600 Subject: [PATCH 142/166] mpi: only output results from rank 0 --- litmus-tests/tests/RandHelper.h | 2 +- src/MpiEnvironment.cpp | 91 +++++++++++++++++++ src/MpiEnvironment.h | 152 ++++++++++++++++++++++++++++++++ src/flit.h | 57 ++++++------ 4 files changed, 273 insertions(+), 29 deletions(-) create mode 100644 src/MpiEnvironment.cpp create mode 100644 src/MpiEnvironment.h diff --git a/litmus-tests/tests/RandHelper.h b/litmus-tests/tests/RandHelper.h index 6e50a6d3..61fd7fe0 100644 --- a/litmus-tests/tests/RandHelper.h +++ b/litmus-tests/tests/RandHelper.h @@ -85,7 +85,7 @@ #include #include - + static const int RAND_SEED = 1; static const int RAND_VECT_SIZE = 256; diff --git a/src/MpiEnvironment.cpp b/src/MpiEnvironment.cpp new file mode 100644 index 00000000..838cead8 --- /dev/null +++ b/src/MpiEnvironment.cpp @@ -0,0 +1,91 @@ +/* -- 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 "MpiEnvironment.h" + +namespace flit { + +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/flit.h b/src/flit.h index 2ee7205c..05431c42 100644 --- a/src/flit.h +++ b/src/flit.h @@ -87,13 +87,10 @@ #ifndef FLIT_H #define FLIT_H 0 +#include "MpiEnvironment.h" #include "TestBase.h" #include "flitHelpers.h" -#ifdef FLIT_USE_MPI -#include -#endif // FLIT_USE_MPI - #include #include #include @@ -418,62 +415,61 @@ class ParseException : public std::exception { }; inline int runFlitTests(int argc, char* argv[]) { - -#ifdef FLIT_USE_MPI - struct MPI_Environment { - MPI_Environment(int &argc, char** &argv) { - MPI_Init(&argc, &argv); - } - ~MPI_Environment() { - MPI_Finalize(); - } - }; - - MPI_Environment mpi(argc, argv); - FLIT_UNUSED(mpi); -#endif // FLIT_USE_MPI + // 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) { - std::cout << 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(); } std::unique_ptr stream_deleter; std::ostream *outstream = &std::cout; std::string test_result_filebase(FLIT_FILENAME); - if (!options.output.empty()) { + 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; @@ -532,7 +528,7 @@ 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) { @@ -540,6 +536,7 @@ inline int runFlitTests(int argc, char* argv[]) { comparisonResults.loadfile(fname); } catch (std::ios::failure &ex) { std::cerr << "Error: failed to open file " << fname << std::endl; + mpi->abort(1); return 1; } } @@ -565,6 +562,7 @@ inline int runFlitTests(int argc, char* argv[]) { 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); @@ -587,6 +585,7 @@ inline int runFlitTests(int argc, char* argv[]) { 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( @@ -603,7 +602,9 @@ inline int runFlitTests(int argc, char* argv[]) { } // Create the main results output - outputResults(results, *outstream); + if (mpi->is_root()) { + outputResults(results, *outstream); + } return 0; } From ef0b79f1e6cf921cd75f0f0ca98463bac70499cf Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 16:44:50 -0600 Subject: [PATCH 143/166] mpi: Only record test results from MPI root process --- src/TestBase.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/TestBase.h b/src/TestBase.h index 6765b12e..7eccd34a 100644 --- a/src/TestBase.h +++ b/src/TestBase.h @@ -88,10 +88,10 @@ #ifndef TEST_BASE_HPP #define TEST_BASE_HPP +#include "MpiEnvironment.h" +#include "Variant.h" #include "flitHelpers.h" - #include "timeFunction.h" -#include "Variant.h" #include #include @@ -261,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; From 0a6558833bdf4c2fce711b55acdb5b2944a1bf0a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 17:00:48 -0600 Subject: [PATCH 144/166] mpi: disable auto-looping by setting it to 1 --- src/flit.cpp | 7 +++++++ src/flit.h | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/flit.cpp b/src/flit.cpp index 13511af8..56bb589b 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -376,6 +376,13 @@ 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" + " automatic loop tuning is disabled, otherwise a\n" + " deadlock could occur. If you try to use the\n" + " auto-tuning (which is the default behavior), then\n" + " the loops will be 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" diff --git a/src/flit.h b/src/flit.h index 05431c42..234632df 100644 --- a/src/flit.h +++ b/src/flit.h @@ -459,6 +459,16 @@ inline int runFlitTests(int argc, char* argv[]) { info_stream.show(); } + // When MPI is enabled, we cannot use the automatic timing loop algorithm, + // otherwise we could deadlock + if (mpi->enabled && options.timingLoops < 1) { + if (mpi->is_root()) { + std::cout << "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); From 89b6eef77e8397e941f78ea56b5c44540efed167 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 17:18:35 -0600 Subject: [PATCH 145/166] mpi: only emit warning about looping if timing is enabled --- src/flit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flit.h b/src/flit.h index 234632df..6e8f876f 100644 --- a/src/flit.h +++ b/src/flit.h @@ -461,7 +461,7 @@ inline int runFlitTests(int argc, char* argv[]) { // When MPI is enabled, we cannot use the automatic timing loop algorithm, // otherwise we could deadlock - if (mpi->enabled && options.timingLoops < 1) { + if (mpi->enabled && options.timing && options.timingLoops < 1) { if (mpi->is_root()) { std::cout << "Warning: cannot run auto-looping with MPI. " "looping set to 1\n"; From 54fe67bea00d990d0b92c622cd38bb5065ea119c Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 17:20:16 -0600 Subject: [PATCH 146/166] mpi: make warning go to stderr --- src/flit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flit.h b/src/flit.h index 6e8f876f..90e78612 100644 --- a/src/flit.h +++ b/src/flit.h @@ -463,7 +463,7 @@ inline int runFlitTests(int argc, char* argv[]) { // otherwise we could deadlock if (mpi->enabled && options.timing && options.timingLoops < 1) { if (mpi->is_root()) { - std::cout << "Warning: cannot run auto-looping with MPI. " + std::cerr << "Warning: cannot run auto-looping with MPI. " "looping set to 1\n"; } options.timingLoops = 1; From 23ae34a57ea5c8c4b5f4b337993ff73345c8c819 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 18:57:00 -0600 Subject: [PATCH 147/166] mpi: timing loops loosened to handle auto on mpirun -n 1 --- src/flit.cpp | 11 ++++++----- src/flit.h | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/flit.cpp b/src/flit.cpp index 56bb589b..f70543c6 100644 --- a/src/flit.cpp +++ b/src/flit.cpp @@ -377,11 +377,12 @@ std::string usage(std::string progName) { " 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" - " automatic loop tuning is disabled, otherwise a\n" - " deadlock could occur. If you try to use the\n" - " auto-tuning (which is the default behavior), then\n" - " the loops will be converted to one instead.\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" diff --git a/src/flit.h b/src/flit.h index 90e78612..bb668bd4 100644 --- a/src/flit.h +++ b/src/flit.h @@ -461,10 +461,10 @@ inline int runFlitTests(int argc, char* argv[]) { // When MPI is enabled, we cannot use the automatic timing loop algorithm, // otherwise we could deadlock - if (mpi->enabled && options.timing && options.timingLoops < 1) { + 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"; + std::cerr << "Warning: cannot run auto-looping with MPI; " + "Looping set to 1\n"; } options.timingLoops = 1; } From 364e44ad02c10fb3dbb3d3afd15eeab6c79385b0 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 18:59:33 -0600 Subject: [PATCH 148/166] mpi: Add automated tests Tests: - compilation with enable_mpi - running with mpirun - autolooping disabling - files only being output from rank 0 --- tests/flit_mpi/Makefile | 19 +++ tests/flit_mpi/data/MpiHello.cpp | 113 +++++++++++++++ tests/flit_mpi/data/flit-config.toml | 3 + tests/flit_mpi/tst_run_mpi.py | 201 +++++++++++++++++++++++++++ 4 files changed, 336 insertions(+) create mode 100644 tests/flit_mpi/Makefile create mode 100644 tests/flit_mpi/data/MpiHello.cpp create mode 100644 tests/flit_mpi/data/flit-config.toml create mode 100644 tests/flit_mpi/tst_run_mpi.py diff --git a/tests/flit_mpi/Makefile b/tests/flit_mpi/Makefile new file mode 100644 index 00000000..27649460 --- /dev/null +++ b/tests/flit_mpi/Makefile @@ -0,0 +1,19 @@ +RUNNER := python3 +SRC := $(wildcard tst_*.py) +RUN_TARGETS := $(SRC:%.py=run_%) + +.PHONY: check help clean build run_% +check: $(TARGETS) $(RUN_TARGETS) + +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 + @python $< 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..a67006f0 --- /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[0] +'Warning: cannot run auto-looping with MPI; Looping set to 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[0] +'MpiHello: hello from rank 0 of 1' + +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) From ad25bb90a24fbf92baf3ad22820922f8b6f687ff Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 19:45:52 -0600 Subject: [PATCH 149/166] docs: add empty pages for compiling, mpi and cuda --- README.md | 11 +++++++---- documentation/README.md | 11 +++++++---- documentation/compiling-your-tests.md | 17 +++++++++++++++++ documentation/cuda-support.md | 16 ++++++++++++++++ documentation/flit-command-line.md | 12 +++++++++--- documentation/flit-configuration-file.md | 14 +++++++++++++- documentation/mpi-support.md | 16 ++++++++++++++++ documentation/test-executable.md | 2 +- documentation/writing-test-cases.md | 4 ++-- scripts/flitcli/config/flit-default.toml.in | 4 ++-- 10 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 documentation/compiling-your-tests.md create mode 100644 documentation/cuda-support.md create mode 100644 documentation/mpi-support.md diff --git a/README.md b/README.md index 1729f0bb..75e39efb 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,16 @@ 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) +* [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/documentation/README.md b/documentation/README.md index fd9f9d82..a3b05d06 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -6,13 +6,16 @@ * [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) +* [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/compiling-your-tests.md b/documentation/compiling-your-tests.md new file mode 100644 index 00000000..44f39ef5 --- /dev/null +++ b/documentation/compiling-your-tests.md @@ -0,0 +1,17 @@ +# Compiling Your Tests + +[Prev](cuda-support.md) +| +[Table of Contents](README.md) +| +[Next](test-executable.md) + + + + +[Prev](cuda-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..dd1857e5 --- /dev/null +++ b/documentation/cuda-support.md @@ -0,0 +1,16 @@ +# CUDA Support + +[Prev](mpi-support.md) +| +[Table of Contents](README.md) +| +[Next](compiling-your-tests.md) + + + + +[Prev](mpi-support.md) +| +[Table of Contents](README.md) +| +[Next](compiling-your-tests.md) diff --git a/documentation/flit-command-line.md b/documentation/flit-command-line.md index 129573f5..75a895b6 100644 --- a/documentation/flit-command-line.md +++ b/documentation/flit-command-line.md @@ -121,9 +121,15 @@ queries on an SQLite3 database. ## 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. +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: diff --git a/documentation/flit-configuration-file.md b/documentation/flit-configuration-file.md index c3786bb2..e0beaecf 100644 --- a/documentation/flit-configuration-file.md +++ b/documentation/flit-configuration-file.md @@ -38,6 +38,8 @@ supported for the `type`. The only thing that needs to be specified is 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 @@ -46,7 +48,8 @@ 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`. +`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 @@ -58,6 +61,15 @@ These options are only for the full run done by either calling `flit make` or * `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]] diff --git a/documentation/mpi-support.md b/documentation/mpi-support.md new file mode 100644 index 00000000..98714916 --- /dev/null +++ b/documentation/mpi-support.md @@ -0,0 +1,16 @@ +# MPI Support + +[Prev](writing-test-cases.md) +| +[Table of Contents](README.md) +| +[Next](cuda-support.md) + + + + +[Prev](writing-test-cases.md) +| +[Table of Contents](README.md) +| +[Next](cuda-support.md) diff --git a/documentation/test-executable.md b/documentation/test-executable.md index cda148b1..84b61a95 100644 --- a/documentation/test-executable.md +++ b/documentation/test-executable.md @@ -1,6 +1,6 @@ # Test Executable -[Prev](writing-test-cases.md) +[Prev](compiling-your-tests.md) | [Table of Contents](README.md) | diff --git a/documentation/writing-test-cases.md b/documentation/writing-test-cases.md index 634a3f0b..6fe44905 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 @@ -68,4 +68,4 @@ precision taking up space in your results database. | [Table of Contents](README.md) | -[Next](test-executable.md) +[Next](mpi-support.md) diff --git a/scripts/flitcli/config/flit-default.toml.in b/scripts/flitcli/config/flit-default.toml.in index dc8a7b60..c7c5d054 100644 --- a/scripts/flitcli/config/flit-default.toml.in +++ b/scripts/flitcli/config/flit-default.toml.in @@ -110,8 +110,8 @@ timing_repeats = 3 # 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_flags are for any flags passed to mpirun. For example, you can do -# mpirun_flags = '-n 16 --verbose' +# 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 = '' From 4f89284e4d500d6eb95c5cc1dff963362e2f4a60 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sat, 7 Jul 2018 23:05:44 -0600 Subject: [PATCH 150/166] docs: update many documents Finish - Cuda support - MPI support - Writing test cases: this had some content but it is much more complete now - FLiT configuration file: just added the MPI stuff Todo: - Run wrapper and HPC support: Talk about RUN_WRAPPER and some examples of using it. I will also want to perform some manual tests at least with Slurm to verify it works as expected. - Compiling your tests: Talk about custom.mk and go through an example of getting it working on your code base (maybe Laghos and MFEM examples) --- documentation/README.md | 1 + documentation/compiling-your-tests.md | 6 +- documentation/cuda-support.md | 14 ++- documentation/flit-configuration-file.md | 3 + documentation/mpi-support.md | 86 ++++++++++++++ documentation/run-wrapper-and-hpc-support.md | 18 +++ documentation/writing-test-cases.md | 115 +++++++++++++++++++ 7 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 documentation/run-wrapper-and-hpc-support.md diff --git a/documentation/README.md b/documentation/README.md index a3b05d06..0daf08a5 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -10,6 +10,7 @@ * [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) diff --git a/documentation/compiling-your-tests.md b/documentation/compiling-your-tests.md index 44f39ef5..9c619039 100644 --- a/documentation/compiling-your-tests.md +++ b/documentation/compiling-your-tests.md @@ -1,6 +1,6 @@ # Compiling Your Tests -[Prev](cuda-support.md) +[Prev](run-wrapper-and-hpc-support.md) | [Table of Contents](README.md) | @@ -9,7 +9,9 @@ -[Prev](cuda-support.md) + + +[Prev](run-wrapper-and-hpc-support.md) | [Table of Contents](README.md) | diff --git a/documentation/cuda-support.md b/documentation/cuda-support.md index dd1857e5..60132c46 100644 --- a/documentation/cuda-support.md +++ b/documentation/cuda-support.md @@ -4,13 +4,23 @@ | [Table of Contents](README.md) | -[Next](compiling-your-tests.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](compiling-your-tests.md) +[Next](run-wrapper-and-hpc-support.md) diff --git a/documentation/flit-configuration-file.md b/documentation/flit-configuration-file.md index e0beaecf..72b88e03 100644 --- a/documentation/flit-configuration-file.md +++ b/documentation/flit-configuration-file.md @@ -163,6 +163,9 @@ timing = true timing_loops = -1 timing_repeats = 3 +enable_mpi = false +mpirun_args = '' + [[hosts]] diff --git a/documentation/mpi-support.md b/documentation/mpi-support.md index 98714916..af4c7ad6 100644 --- a/documentation/mpi-support.md +++ b/documentation/mpi-support.md @@ -7,6 +7,92 @@ [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) diff --git a/documentation/run-wrapper-and-hpc-support.md b/documentation/run-wrapper-and-hpc-support.md new file mode 100644 index 00000000..6c0f2a6a --- /dev/null +++ b/documentation/run-wrapper-and-hpc-support.md @@ -0,0 +1,18 @@ +# Run Wrapper and HPC Support + +[Prev](cuda-support.md) +| +[Table of Contents](README.md) +| +[Next](compiling-your-tests.md) + + + + + + +[Prev](cuda-support.md) +| +[Table of Contents](README.md) +| +[Next](compiling-your-tests.md) diff --git a/documentation/writing-test-cases.md b/documentation/writing-test-cases.md index 6fe44905..a805086a 100644 --- a/documentation/writing-test-cases.md +++ b/documentation/writing-test-cases.md @@ -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,6 +109,76 @@ 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) From f7d4d8b11f9a53dc52e106c3e5364cd6f6f1d1b6 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Jul 2018 15:01:20 +0000 Subject: [PATCH 151/166] tests: assumed python in path was python3 This has been fixed to explicitly call python3 --- tests/flit_cli/Makefile | 2 +- tests/flit_install/Makefile | 2 +- tests/flit_makefile/Makefile | 2 +- tests/flit_mpi/Makefile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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/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/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_mpi/Makefile b/tests/flit_mpi/Makefile index 27649460..242995ab 100644 --- a/tests/flit_mpi/Makefile +++ b/tests/flit_mpi/Makefile @@ -16,4 +16,4 @@ build: clean: run_% : %.py - @python $< + @$(RUNNER) $< From ef885f2ef3e3f92805c980478e315ebbf17a7099 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Jul 2018 15:02:13 +0000 Subject: [PATCH 152/166] flit-init: sort the copied files to have deterministic order This fixes one of the tests that assumes the files are in sorted order. --- scripts/flitcli/flit_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_init.py b/scripts/flitcli/flit_init.py index 08def398..125b48ba 100644 --- a/scripts/flitcli/flit_init.py +++ b/scripts/flitcli/flit_init.py @@ -128,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): From 1478463143e12aa8bb8dedd7150d01dea2751bda Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Jul 2018 15:03:04 +0000 Subject: [PATCH 153/166] tests: check for error when using tmpnam This is done by checking that the pointer returned by tmpnam is the same as the pointer that is passed in. --- tests/flit_src/tst_flit_cpp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/flit_src/tst_flit_cpp.cpp b/tests/flit_src/tst_flit_cpp.cpp index 388a5397..8971e0e1 100644 --- a/tests/flit_src/tst_flit_cpp.cpp +++ b/tests/flit_src/tst_flit_cpp.cpp @@ -103,7 +103,10 @@ struct TempFile { std::ofstream out; TempFile() { char fname_buf[L_tmpnam]; - std::tmpnam(fname_buf); // gives a warning, but I'm not worried + 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 From e249417443bad9b11c5ff8e21b8d36d38de6019b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Jul 2018 15:05:18 +0000 Subject: [PATCH 154/166] tests: Add compiled tests to .gitignore --- tests/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/.gitignore 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 From a1c01968759c3a182f15730b007473ef935646b5 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Jul 2018 15:38:59 +0000 Subject: [PATCH 155/166] tests-mpi: make more robust to messages from MPI_Init() The MPI_Init() function does some checks and can output errors and warnings to the console. These should not interfere with what is being tested, so the tests are now made to be more robust This was noticed in a Docker container where the warning issued had to do with a long line in /proc/mounts --- tests/flit_mpi/tst_run_mpi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/flit_mpi/tst_run_mpi.py b/tests/flit_mpi/tst_run_mpi.py index a67006f0..10d38069 100644 --- a/tests/flit_mpi/tst_run_mpi.py +++ b/tests/flit_mpi/tst_run_mpi.py @@ -166,8 +166,8 @@ 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[0] -'Warning: cannot run auto-looping with MPI; Looping set to 1' +>>> 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 @@ -179,8 +179,8 @@ 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[0] -'MpiHello: hello from rank 0 of 1' +>>> run_str_3.count('Warning: cannot run auto-looping with MPI; Looping set to 1') +0 Make sure the test was run multiple times From 1fadcff1c9aece186a34496fd14c311ab8869ea1 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Jul 2018 16:42:52 +0000 Subject: [PATCH 156/166] tests: skip MPI tests if MPI is not installed This will happen if one of the following is not found in the system PATH - mpirun - mpic++ Also, implemented colored output for this warning as well as the "All tests pass" at the end. --- tests/Makefile | 4 +++- tests/color_out.mk | 22 ++++++++++++++++++++++ tests/flit_mpi/Makefile | 18 +++++++++++++++--- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 tests/color_out.mk 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_mpi/Makefile b/tests/flit_mpi/Makefile index 242995ab..1d04452e 100644 --- a/tests/flit_mpi/Makefile +++ b/tests/flit_mpi/Makefile @@ -1,9 +1,21 @@ -RUNNER := python3 -SRC := $(wildcard tst_*.py) -RUN_TARGETS := $(SRC:%.py=run_%) +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" From e52f3deef12fbc738be22de621f15d61556472c2 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Jul 2018 14:19:54 -0600 Subject: [PATCH 157/166] Finish documentation for MPI changeset --- README.md | 1 + data/custom.mk | 4 +- documentation/compiling-your-tests.md | 245 +++++++++++++++++++ documentation/run-wrapper-and-hpc-support.md | 27 ++ 4 files changed, 275 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 75e39efb..e1a38e0d 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Contents: * [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) diff --git a/data/custom.mk b/data/custom.mk index 5c1d481e..2f7ef3f7 100644 --- a/data/custom.mk +++ b/data/custom.mk @@ -79,8 +79,8 @@ # 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. diff --git a/documentation/compiling-your-tests.md b/documentation/compiling-your-tests.md index 9c619039..7f1b3e51 100644 --- a/documentation/compiling-your-tests.md +++ b/documentation/compiling-your-tests.md @@ -7,8 +7,253 @@ [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) diff --git a/documentation/run-wrapper-and-hpc-support.md b/documentation/run-wrapper-and-hpc-support.md index 6c0f2a6a..0365d697 100644 --- a/documentation/run-wrapper-and-hpc-support.md +++ b/documentation/run-wrapper-and-hpc-support.md @@ -7,8 +7,35 @@ [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) From f2790bb3b987aa78b2b80f991de7a4cf71ffaea2 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Mon, 9 Jul 2018 14:25:45 -0600 Subject: [PATCH 158/166] docs-install: talk about installing MPI --- documentation/installation.md | 26 +++++++++++++++++++++----- documentation/test-executable.md | 4 +++- scripts/flitcli/README.md | 3 ++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/documentation/installation.md b/documentation/installation.md index 0a8b35e0..1bcdd8b4 100644 --- a/documentation/installation.md +++ b/documentation/installation.md @@ -7,12 +7,11 @@ Instruction Contents: * [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) +* [Uninstallation](#uninstallation) ## Prerequisites @@ -61,6 +60,21 @@ 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. +### Optional Dependencies + +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. + +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 + +```bash +sudo apt install openmpi-bin libopenmpi-dev +``` + ## FLiT Setup You will need FLiT available and compiled. It can be optionally installed. @@ -102,7 +116,9 @@ There should be nothing to setup since `sqlite3` should already be present. ## Uninstallation -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 +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 ```bash make install PREFIX=~/my-installs/ diff --git a/documentation/test-executable.md b/documentation/test-executable.md index 84b61a95..d2e7149a 100644 --- a/documentation/test-executable.md +++ b/documentation/test-executable.md @@ -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 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 From 3a930188502ffc9220b8268e13e16c94fd4fc50b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 18 Jul 2018 11:58:25 -0600 Subject: [PATCH 159/166] bisect: perform symbol bisect one file at a time --- scripts/flitcli/flit_bisect.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 6febf387..4cce71cf 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -831,12 +831,12 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): return result_is_bad - print('Searching for bad symbols in the bad sources:') - logging.info('Searching for bad symbols in the bad sources') + 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_sources, + 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}' \ @@ -1054,16 +1054,21 @@ def run_bisect(arguments, prog=sys.argv[0]): logging.info(' None') - try: - bad_symbols = search_for_symbol_problems(args, bisect_path, - replacements, sources, - bad_sources) - except subp.CalledProcessError: - print() - print(' Executable failed to run.') - print('Failed to search for bad symbols -- cannot continue') - logging.exception('Failed to search for bad symbols.') - return bisect_num, bad_libs, bad_sources, None, 1 + # 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') + logging.exception('Failed to search for bad symbols in %s', + bad_source) + bad_symbols.extend(file_bad_symbols) print(' bad symbols:') logging.info('BAD SYMBOLS:') From adc7744991c7ac3808ac3109e8c47cc0499379c0 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 18 Jul 2018 11:58:54 -0600 Subject: [PATCH 160/166] bisect: check to see if -fPIC destroys possibility of finding bad symbols --- scripts/flitcli/flit_bisect.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 4cce71cf..aa8aec8b 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -768,10 +768,18 @@ def bisect_build_and_check(trouble_src, gt_src): return bad_sources def search_for_symbol_problems(args, bisect_path, replacements, sources, - bad_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): ''' @@ -843,6 +851,16 @@ def bisect_symbol_build_and_check(trouble_symbols, gt_symbols): .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 From 39cee19df2c25719d0172bba2b3cfd7c4640cf55 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 18 Jul 2018 12:01:51 -0600 Subject: [PATCH 161/166] bisect: Fix unit test checking independence assumption --- scripts/flitcli/flit_bisect.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index aa8aec8b..fb7a3639 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -507,10 +507,9 @@ def bisect_search(is_bad, elements): # 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 - if len(bad_list) > 0: - good_list = list(set(elements).difference(bad_list)) - assert not is_bad(good_list, bad_list), \ - 'Assumption that bad elements are independent was 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 From f9f45d81539e108efdca3aafffc46d50ad034c06 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 18 Jul 2018 12:03:26 -0600 Subject: [PATCH 162/166] bisect: remove unused import itertools --- scripts/flitcli/flit_bisect.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index fb7a3639..7000f3fe 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -91,7 +91,6 @@ import datetime import glob import hashlib -import itertools import logging import multiprocessing as mp import os From 5971cf2c0ddcb2d522addd4f15fef7ce9f4b28bf Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 18 Jul 2018 12:47:12 -0600 Subject: [PATCH 163/166] bisect: print symbols found in each symbol search by file --- scripts/flitcli/flit_bisect.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 7000f3fe..160426fb 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1085,8 +1085,18 @@ def run_bisect(arguments, prog=sys.argv[0]): logging.exception('Failed to search for bad symbols in %s', bad_source) bad_symbols.extend(file_bad_symbols) + 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) + if len(file_bad_symbols) == 0: + print(' None') + logging.info(' None') - print(' bad symbols:') + print('All bad symbols:') logging.info('BAD SYMBOLS:') for sym in bad_symbols: message = ' {sym.fname}:{sym.lineno} {sym.symbol} -- {sym.demangled}' \ From 35c33ed47fee3b77e72cad60d48fdf74f29d6434 Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 18 Jul 2018 12:51:16 -0600 Subject: [PATCH 164/166] bisect: improve symbol findings printing --- scripts/flitcli/flit_bisect.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 160426fb..3ba3bdf1 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1085,23 +1085,21 @@ def run_bisect(arguments, prog=sys.argv[0]): logging.exception('Failed to search for bad symbols in %s', bad_source) bad_symbols.extend(file_bad_symbols) - 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) - if len(file_bad_symbols) == 0: - print(' None') - logging.info(' None') + 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) + print(message) logging.info('%s', message) if len(bad_symbols) == 0: print(' None') From 14e930cc44b1c3c10149dc8f1207e27fd4f5102f Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 18 Jul 2018 16:05:08 -0600 Subject: [PATCH 165/166] bisect: fix bad print statement --- scripts/flitcli/flit_bisect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/flitcli/flit_bisect.py b/scripts/flitcli/flit_bisect.py index 3ba3bdf1..fbcffa45 100644 --- a/scripts/flitcli/flit_bisect.py +++ b/scripts/flitcli/flit_bisect.py @@ -1081,7 +1081,8 @@ def run_bisect(arguments, prog=sys.argv[0]): except subp.CalledProcessError: print() print(' Executable failed to run.') - print('Failed to search for bad symbols in -- cannot continue') + 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) From 615d2ebfa6235ea1f302984e7c6da0a8d7baca7a Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Wed, 18 Jul 2018 16:09:06 -0600 Subject: [PATCH 166/166] Update version --- scripts/flitcli/config/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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