* [gentoo-commits] proj/auto-numerical-bench:accuracy commit in: accuracy/, numbench/modules/internal/, accuracy/actions/
@ 2012-09-17 8:10 Andrea Arteaga
0 siblings, 0 replies; only message in thread
From: Andrea Arteaga @ 2012-09-17 8:10 UTC (permalink / raw
To: gentoo-commits
commit: 7fed21ff2a634b11ce17d9b1bd71f318f6f7e28b
Author: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
AuthorDate: Mon Sep 3 16:22:28 2012 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Mon Sep 3 16:22:28 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=7fed21ff
Accuracy module: output interpreter and result storage.
---
accuracy/TestAccuracy.hpp | 58 +++++++++++++++++++++-------
accuracy/actions/ActionGESV.hpp | 7 +++-
numbench/modules/internal/accuracyBase.py | 59 +++++++++++++++++++++++++---
3 files changed, 101 insertions(+), 23 deletions(-)
diff --git a/accuracy/TestAccuracy.hpp b/accuracy/TestAccuracy.hpp
index b0a6cc1..a79b17a 100644
--- a/accuracy/TestAccuracy.hpp
+++ b/accuracy/TestAccuracy.hpp
@@ -5,6 +5,8 @@
#include <cmath>
#include <vector>
#include <iostream>
+#include <fstream>
+#include <cstdio>
#include "utilities/Timer.hpp"
@@ -31,28 +33,49 @@ std::vector<int> getLogSizes(
return sizes;
}
+template<typename value_t> void writeToFile(
+ const std::vector<int>& sizes,
+ const std::vector<value_t>& means,
+ const std::vector<value_t>& stds,
+ const std::string& filename
+ )
+{
+ std::ofstream fs(filename.c_str());
+ fs.precision(10);
+ const int N = sizes.size();
+
+ for(int i = 0; i < N; ++i)
+ fs << sizes[i] << " " << means[i] << " " << stds[i] << "\n";
+
+ fs.close();
+}
+
-template<
- template<class> class Action,
- typename value_t
->
-std::pair<value_t, value_t> testAccuracy(
+template< template<class> class Action, typename value_t >
+void testAccuracy(
const int& minsize = 4,
const int& maxsize = 1000,
- const unsigned& N = 100u)
+ const unsigned& N = 100u
+ )
{
- std::vector<int> sizes = getLogSizes(minsize, maxsize, N);
+ const std::string filename = Action<value_t>::fileName();
+ std::cout << "Beginning operation on file " << filename << std::endl;
+
+ const std::vector<int> sizes = getLogSizes(minsize, maxsize, N);
+ std::vector<value_t> means(N), stds(N);
+
Timer t;
- for (std::vector<int>::const_iterator i = sizes.begin(), e = sizes.end();
- i != e; ++i) {
+ for (int i = 0; i < N; ++i) {
- int size = *i;
- std::cout << " -- Size: " << size << " - " << std::flush;
+ int size = sizes[i];
+ std::printf(" -- Size %6i - ", size);
+ std::cout << std::flush;
- t.start();
int N = 0;
double e, emean = 0., e2mean = 0.;
+
+ t.start();
do {
Action<value_t> action(size, N);
action.compute();
@@ -61,15 +84,20 @@ std::pair<value_t, value_t> testAccuracy(
e2mean += e*e;
} while(++N < 100 && t.elapsed() < 1. || N < 4);
- std::cout << N << " samples - " << t.elapsed() << " seconds - ";
+ std::printf("%3i samples - %6f seconds - ", N, t.elapsed());
emean /= N;
e2mean /= N;
e2mean = std::sqrt(e2mean - emean*emean);
- std::cout << emean << " +/- " << e2mean << std::endl;
-
+ std::printf("%3e +/- %3e", emean, e2mean);
+ std::cout << std::endl;
+ means[i] = emean;
+ stds[i] = e2mean;
}
+
+ std::cout << "Writing results to file " << filename << "\n" << std::endl;
+ writeToFile(sizes, means, stds, filename);
}
#endif // TESTACCURACY_HPP
diff --git a/accuracy/actions/ActionGESV.hpp b/accuracy/actions/ActionGESV.hpp
index 454e5f6..cd73164 100644
--- a/accuracy/actions/ActionGESV.hpp
+++ b/accuracy/actions/ActionGESV.hpp
@@ -3,6 +3,7 @@
#include <vector>
#include <iostream>
+#include <string>
#include "LinearCongruential.hpp"
extern "C" {
@@ -44,7 +45,11 @@ public:
return dnrm2_(&size, &b[0], &ONE)/dnrm2_(&size, &bcopy[0], &ONE);
}
-//private:
+ static std::string fileName() {
+ return "accuracy_general_solve.dat";
+ }
+
+private:
const int size;
rangen_t rg;
storage_t A, Acopy, x, b, bcopy;
diff --git a/numbench/modules/internal/accuracyBase.py b/numbench/modules/internal/accuracyBase.py
index 92a4b28..c25e023 100644
--- a/numbench/modules/internal/accuracyBase.py
+++ b/numbench/modules/internal/accuracyBase.py
@@ -1,5 +1,5 @@
from os.path import dirname, join as pjoin
-import os, subprocess as sp
+import os, re, subprocess as sp
from numbench import benchchildren, benchconfig as cfg
from numbench.utils import alternatives as alt, benchutils as bu
@@ -24,7 +24,6 @@ def compileExe(test, libname, implementation):
test['compileenv']['LIBRARY_PATH'] = libenvc
libenvr = libenv + test['runenv'].get('LD_LIBRARY_PATH', '')
- print "\n\nLIBENV: ", libenvr, "\n\n"
test['runenv']['LD_LIBRARY_PATH'] = libenvr
# Set compile-time environment
@@ -66,6 +65,7 @@ def compileExe(test, libname, implementation):
def runExe(test, implementation, exe, args):
logdir = pjoin(test['logdir'], implementation)
+ testdir = pjoin(test['testdir'], implementation)
# Check linking
logfs = file(pjoin(logdir, 'accuracyLinking.log'), 'w')
@@ -87,7 +87,6 @@ def runExe(test, implementation, exe, args):
# Open pipe
try:
- testdir = pjoin(test['testdir'], implementation)
proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=errfs, \
env=test['runenv'], cwd=testdir)
benchchildren.append(proc)
@@ -96,11 +95,9 @@ def runExe(test, implementation, exe, args):
Print('Command line: ' + ' '.join(args))
return -1, None
- result = {}
-
# Interpret output
Print('Begin execution')
- # TODO: interpret output, store results,...
+ result = interpretOutput(proc.stdout, logfs, testdir)
proc.wait()
Print("Execution finished with return code " + str(proc.returncode))
@@ -111,12 +108,60 @@ def runExe(test, implementation, exe, args):
if errp == 0:
os.unlink(errfname)
-
# Close, return
logfs.close()
return proc.returncode, result
+def interpretOutput(stdout, logfs, testdir):
+ result = {}
+
+ operationre = 'Beginning operation on file (accuracy_(.*).dat)'
+ while True:
+ operation = None
+ while operation is None:
+ line = stdout.readline()
+ if not line:
+ break
+
+ try:
+ resfile, operation = re.match(operationre, line).groups()
+ logfs.write(line)
+ except:
+ pass
+
+ # Check is program is terminated
+ if operation is None:
+ break
+
+ result[operation] = pjoin(testdir, resfile)
+ Print(operation + " -> " + resfile)
+
+
+ # Many different sizes for each operation test
+ Print.down()
+
+ while True:
+ outline = stdout.readline()
+
+ if not outline:
+ Print.up()
+ Print('Execution error')
+ return None
+
+ logfs.write(outline)
+ logfs.flush()
+
+ if not outline.startswith(' -- Size'):
+ break
+
+ Print(outline[4:].strip())
+
+ Print.up()
+
+ return result
+
+
def runTest(self, test, implementation):
exe = compileExe(test, self.libname, implementation)[1]
runExe(test, implementation, exe, self.tests)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-09-17 8:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17 8:10 [gentoo-commits] proj/auto-numerical-bench:accuracy commit in: accuracy/, numbench/modules/internal/, accuracy/actions/ Andrea Arteaga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox