From: "Andrea Arteaga" <andyspiros@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/auto-numerical-bench:unstable commit in: /
Date: Fri, 5 Aug 2011 17:23:15 +0000 (UTC) [thread overview]
Message-ID: <c103439560e69536ed281066867672b92b4e5949.spiros@gentoo> (raw)
commit: c103439560e69536ed281066867672b92b4e5949
Author: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
AuthorDate: Fri Aug 5 17:22:58 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Fri Aug 5 17:22:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=c1034395
Implemented METIS tests (pmetis, kmetis).
---
metis.py | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
testdescr.py | 10 +++-
2 files changed, 170 insertions(+), 2 deletions(-)
diff --git a/metis.py b/metis.py
new file mode 100644
index 0000000..c65d8a8
--- /dev/null
+++ b/metis.py
@@ -0,0 +1,162 @@
+import os, shlex, numpy as np, subprocess as sp
+from os.path import realpath, exists as pexists, join as pjoin
+from random import randint
+
+import basemodule
+import benchconfig as cfg
+from benchutils import mkdir
+from benchprint import Print
+
+inputsdir = pjoin(cfg.testsdir, 'metis-input')
+mkdir(inputsdir)
+
+avail_graph = ['pmetis-8', 'kmetis-8', 'pmetis-64', 'kmetis-64']
+avail_mesh = []
+avail_matrix = []
+
+class Module(basemodule.BaseModule):
+
+ #classmethod
+ def _initialize(cls):
+ cls.avail = avail_graph + avail_mesh + avail_matrix
+
+ def _parse_args(self, args):
+ tests = []
+
+ # Parse arguments
+ for i in args:
+ if i in self.avail:
+ tests.append(i)
+ else:
+ raise Exception("Argument not recognized: " + i)
+
+ if len(tests) == 0:
+ # If not test provided, perform all
+ self.tests = self.avail
+ else:
+ # Sort tests
+ self.tests = [i for i in self.avail if i in tests]
+
+ @staticmethod
+ def get_impls(*args, **kwargs):
+ return ('metis',)
+
+ def save_results(self, results):
+ basemodule.BaseModule.save_results(self, results, 'loglog', 'Seconds')
+
+ def getTest(self, root, impl, testdir, logdir):
+ t = MetisTest(root, testdir, logdir, self.tests)
+ return t
+
+
+class MetisTest:
+ sizes = None
+
+ def __init__(self, root, testdir, logdir, tests):
+ self.root = root
+ self.testdir = testdir
+ self.logdir = logdir
+ self.tests = tests
+ mkdir(logdir)
+ mkdir(testdir)
+
+ @classmethod
+ def _getSizes(cls):
+ if cls.sizes is None:
+ cls.sizes = [int(i) for i in np.logspace(3, 6, 100)]
+ return cls.sizes
+
+ def _generateFiles(self):
+ Print("Generating input files...")
+ # Graph
+ if len([i for i in self.tests if i in avail_graph]) != 0:
+ for size in self._getSizes():
+ fname = pjoin(inputsdir, 'input_%i.graph' % size)
+ if not pexists(fname):
+ writeGraph(size, fname)
+ Print("Done")
+
+
+ def run_test(self, changes={}):
+ self._generateFiles()
+ result = {}
+
+ for t in [i for i in self.tests if i in avail_graph]:
+ Print('Doing ' + t)
+ Print.down()
+ res = []
+
+ for s,size in enumerate(self._getSizes(), 1):
+ inputfile = pjoin(inputsdir, 'input_%i.graph' % size)
+
+ # Setting environment
+ env = os.environ.copy()
+ envpath = env.has_key('PATH') and env['PATH'] or ''
+ env['PATH'] = ':'.join([pjoin(self.root, p) for p in \
+ ('bin', 'usr/bin')]) + ':' + envpath
+ envlib = env.has_key('LD_LIBARY_PATH') and \
+ env['LD_LIBARY_PATH'] or ''
+ env['LD_LIBRARY_PATH'] = ':'.join([pjoin(self.root,p) for p in \
+ ('usr/lib', 'usr/lib64', 'usr/lib32')]) + ':' + envlib
+
+ # Get executable
+ exe, parts = t.split('-')
+ exe = pjoin(self.root, 'usr/bin', exe)
+
+ # Check dynamic linking
+ logf = file(pjoin(self.logdir, 'ldd.log'), 'w')
+ p = sp.Popen(\
+ ['ldd', '-v', exe], stdout=logf, stderr=sp.STDOUT, env=env
+ )
+ p.wait()
+
+ # Execute
+ logname = pjoin(self.logdir, t + '_%i.log' % size)
+ cmd = [exe, inputfile, parts]
+ pr = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.STDOUT, env=env)
+ lines = pr.communicate()[0].split('\n')
+
+ # Interpret output
+ for i,line in enumerate(lines):
+ if line[:18] == "Timing Information":
+ begin_timing = i+1
+ break
+
+ lines = [i[:-1] for i in lines[begin_timing+1:]]
+ for l in lines:
+ if l.strip()[:13] == "Partitioning:":
+ time = float(shlex.split(l)[1])
+ break
+ res.append((size,time))
+ Print("size: %6i %2.3f sec. (%i/%i)" % (size, time, s, 100))
+
+ Print.up()
+
+ # Write sizes / times to result file
+ resfname = pjoin(self.testdir, t+'.dat')
+ resfs = file(resfname, 'w')
+ for i in res:
+ print >> resfs, i[0], i[1]
+ resfs.close()
+ result[t] = resfname
+ return result
+
+
+def writeGraph(size, filename):
+ edges = [[] for i in xrange(size)]
+ nedges = 0
+ for e1 in xrange(len(edges)):
+ n = 0
+ tot = randint(1, min(size / 4, 5))
+ while n < tot:
+ e2 = randint(0, size - 1)
+ if e2 not in edges[e1] and e1 != e2:
+ edges[e1].append(e2)
+ edges[e2].append(e1)
+ n += 1
+ nedges += 1
+ fs = file(filename, 'w')
+ print >> fs, size, nedges
+ for s in edges:
+ print >> fs, ' '.join([str(i+1) for i in s])
+ fs.close()
diff --git a/testdescr.py b/testdescr.py
index a6f0fe4..51ad714 100644
--- a/testdescr.py
+++ b/testdescr.py
@@ -1,5 +1,5 @@
testdescr = {
-# (C)BLAS
+# (C)BLAS
'axpy' : 'y = a*x + y',
'axpby' : 'y = a*x + b*y',
'rot': 'Apply Givens rotation',
@@ -27,5 +27,11 @@ testdescr = {
'FFTW_1D_Forward_Measure': 'FFTW 1D Forward (Measure)',
'FFTW_1D_Backward_Measure': 'FFTW 1D Backward (Measure)',
'FFTW_1D_Forward_Estimate': 'FFTW 1D Forward (Estimate)',
-'FFTW_1D_Backward_Estimate': 'FFTW 1D Backward (Estimate)'
+'FFTW_1D_Backward_Estimate': 'FFTW 1D Backward (Estimate)',
+
+# METIS
+'pmetis-8': 'Graph partitioning using pmetis - 8 partitions',
+'kmetis-8': 'Graph partitioning using kmetis - 8 partitions',
+'pmetis-64': 'Graph partitioning using pmetis - 64 partitions',
+'kmetis-64': 'Graph partitioning using kmetis - 64 partitions',
}
next reply other threads:[~2011-08-05 17:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-05 17:23 Andrea Arteaga [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-08-14 12:35 [gentoo-commits] proj/auto-numerical-bench:master commit in: / Andrea Arteaga
2011-08-14 11:15 ` [gentoo-commits] proj/auto-numerical-bench:unstable " Andrea Arteaga
2011-08-14 11:15 Andrea Arteaga
2011-08-09 0:00 [gentoo-commits] proj/auto-numerical-bench:master " Andrea Arteaga
2011-08-14 11:15 ` [gentoo-commits] proj/auto-numerical-bench:unstable " Andrea Arteaga
2011-08-08 11:53 Andrea Arteaga
2011-08-08 11:53 Andrea Arteaga
2011-07-25 11:23 Andrea Arteaga
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c103439560e69536ed281066867672b92b4e5949.spiros@gentoo \
--to=andyspiros@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox