Skip to content

Commit

Permalink
Merge pull request #6 from bh107/create-quasicrystal-benchmark
Browse files Browse the repository at this point in the history
Create quasicrystal benchmark
  • Loading branch information
madsbk committed Mar 11, 2016
2 parents a5ffaec + e4ab747 commit fe4d665
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 19 deletions.
Empty file.
42 changes: 42 additions & 0 deletions benchmarks/quasicrystal/python_numpy/quasicrystal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
from benchpress import util
import numpy as np

def main():
B = util.Benchmark()

k = B.size[0] # number of plane waves
stripes = B.size[1] # number of stripes per wave
N = B.size[2] # image size in pixels
ite = B.size[3] # iterations

phases = np.arange(0, 2*np.pi, 2*np.pi/ite)
image = np.empty((N, N), dtype=B.dtype)
d = np.arange(-N/2, N/2, dtype=B.dtype)

xv, yv = np.meshgrid(d, d)
theta = np.arctan2(yv, xv)
r = np.log(np.sqrt(xv*xv + yv*yv))
r[np.isinf(r) == True] = 0

tcos = theta * np.cos(np.arange(0, np.pi, np.pi/k))[:, np.newaxis, np.newaxis]
rsin = r * np.sin(np.arange(0, np.pi, np.pi/k))[:, np.newaxis, np.newaxis]
inner = (tcos - rsin) * stripes

cinner = np.cos(inner)
sinner = np.sin(inner)

B.start()

for phase in phases:
image[:] = np.sum(cinner * np.cos(phase) - sinner * np.sin(phase), axis=0) + k
util.Benchmark().flush()

B.stop()
B.pprint()

if B.outputfn:
B.tofile(B.outputfn, {'res': image})

if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions benchmarks/quasicrystal/readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Quasicrystal simulation

Params example (k * stripes * image_size * iterations)::

--size=5*37*4096*30
2 changes: 1 addition & 1 deletion contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Simon A. F. Lund
Mads R. B. Kristensen
Troels Blum
Kenneth Skovhede

Mads Ohm Larsen
16 changes: 8 additions & 8 deletions doc/autodoc_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def draw_sep(self, widths=None, sep='-'):
return "+%s+" % "+".join(seps)

def render(self):
first = True
first = True
rows = []
sepper = "-"
for row in self.rows:
Expand All @@ -116,7 +116,7 @@ def modify_column(func, rows):
return delta

def section_ref(text):

return ":ref:`%s`" % text if text.strip() else text

def benchmark_index(benchmarks):
Expand All @@ -129,7 +129,7 @@ def benchmark_index(benchmarks):

rerow = []
for ridx, row in enumerate(rows):
rerow.append(row)
rerow.append(row)
if ((ridx+1) % 15) == 0:
rerow.append(tool_header)
rows = rerow
Expand All @@ -150,20 +150,20 @@ def benchmark_index(benchmarks):
cidx += ntools
header_row.append(lang_labels[lang])
header_widths.append(width)

row = []
for col, width in zip(header_row, header_widths):
row.append(col.ljust(width))

matrix = table.draw_sep(header_widths)+"\n"
matrix += table.draw_row(header_row, header_widths)+"\n"
matrix += table.render()

matrix += """
.. [ISU] The implementation has issues... such as not using of Benchpress, segfaults, or does not run with Bohrium.
.. [BH] The implementation makes use of Bohrium specific features, which means that Bohrum is required to run it.
.. [IBNP] The implementation does `import bohrium as np`, which breaks the Bohrium dogma "High-Performance NumPy without changing a single line of code.
.. [BH] The implementation makes use of Bohrium specific features, which means that Bohrium is required to run it.
.. [IBNP] The implementation does ``import bohrium as np``, which breaks the Bohrium dogma "High-Performance NumPy without changing a single line of code.
"""

return matrix
Expand Down Expand Up @@ -246,7 +246,7 @@ def benchmark_sections(benchmarks):

def main():
benchmarks = implementations(".."+os.sep+"benchmarks")

index = benchmark_index(benchmarks)
with open(os.sep.join(["source", "benchmarks", "autodoc_index.rst"]), 'w') as fd:
fd.write("==========\n")
Expand Down
18 changes: 18 additions & 0 deletions doc/source/benchmarks/alain.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


.. _alain:

Alain
=====

.. include:: ../../../benchmarks/alain/readme.rst


.. _alain_python_numpy:

Python Numpy
------------


.. literalinclude:: ../../../benchmarks/alain/python_numpy/alain.py
:language: python
18 changes: 18 additions & 0 deletions doc/source/benchmarks/alain_counterexample.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


.. _alain_counterexample:

Alain Counterexample
====================

.. include:: ../../../benchmarks/alain_counterexample/readme.rst


.. _alain_counterexample_python_numpy:

Python Numpy
------------


.. literalinclude:: ../../../benchmarks/alain_counterexample/python_numpy/alain_counterexample.py
:language: python
24 changes: 17 additions & 7 deletions doc/source/benchmarks/autodoc_index.rst

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions doc/source/benchmarks/idl_init_1loop.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


.. _idl_init_1loop:

Idl Init 1Loop
==============


.. _idl_init_1loop_python_numpy:

Python Numpy
------------


.. literalinclude:: ../../../benchmarks/idl_init_1loop/python_numpy/idl_init_1loop.py
:language: python
16 changes: 16 additions & 0 deletions doc/source/benchmarks/idl_init_explode.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


.. _idl_init_explode:

Idl Init Explode
================


.. _idl_init_explode_python_numpy:

Python Numpy
------------


.. literalinclude:: ../../../benchmarks/idl_init_explode/python_numpy/idl_init_explode.py
:language: python
18 changes: 18 additions & 0 deletions doc/source/benchmarks/quasicrystal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


.. _quasicrystal:

Quasicrystal
============

.. include:: ../../../benchmarks/quasicrystal/readme.rst


.. _quasicrystal_python_numpy:

Python Numpy
------------


.. literalinclude:: ../../../benchmarks/quasicrystal/python_numpy/quasicrystal.py
:language: python
12 changes: 10 additions & 2 deletions doc/source/usage_bp-grapher.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ usage: bp-grapher [-h] [--output-path OUTPUT_PATH] [--title TITLE]
[--scripts-to-display RegEx]
[--scripts-not-to-display RegEx] [--warmups WARMUPS]
[--baseline BASELINE] [--order ORDER [ORDER ...]]
[--ymax YMAX] [--ymin YMIN] [--fontsize FONTSIZE]
[--ymax YMAX] [--ymin YMIN] [--ylog] [--ylabel YLABEL]
[--xticklabel-rotation XTICKLABEL_ROTATION] [--no-legend]
[--fontsize FONTSIZE]
[--stack-map RegEx:label,...,RegEx:label]
[--script-map RegEx:label,...,RegEx:label]
results
Expand Down Expand Up @@ -51,7 +53,13 @@ optional arguments:
Ordering of the ticks. (default: None)
--ymax YMAX Max value of the y-axis (default: None)
--ymin YMIN Min value of the y-axis (default: None)
--fontsize FONTSIZE Fontsize. (default: 12)
--ylog Makes the y-axis logarithmic (default: False)
--ylabel YLABEL Label on the y-axis (default: None)
--xticklabel-rotation XTICKLABEL_ROTATION
The rotation of the tick label on the x-axis (default:
90)
--no-legend Hide the legend box (default: False)
--fontsize FONTSIZE Fontsize (default: 12)
--stack-map RegEx:label,...,RegEx:label
Comma separated list of original-to-new-stack names
(default: None)
Expand Down
2 changes: 1 addition & 1 deletion suites/python_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
('Monte Carlo PI', 'mc', '--size=50000000*10'),
('Matrix Multiplication', 'mxmul', '--size=250'),
('nbody', 'nbody', '--size=2000*10'),
('Quasicrystal', 'quasicrystal', '--size=5*37*1014*30'),
('1D Stencil', 'ndstencil', '--size=27*10*1'),
('2D Stencil', 'ndstencil', '--size=27*10*2'),
('3D Stencil', 'ndstencil', '--size=27*10*3'),
Expand All @@ -28,4 +29,3 @@
'launchers': [python_numpy],
'bohrium': bh_stack_none
}]

0 comments on commit fe4d665

Please sign in to comment.