Skip to content

Instantly share code, notes, and snippets.

@wence-
Created February 7, 2014 16:11
Show Gist options
  • Select an option

  • Save wence-/8865915 to your computer and use it in GitHub Desktop.

Select an option

Save wence-/8865915 to your computer and use it in GitHub Desktop.
from firedrake import *
from pyop2 import op2
from copy import copy
op2.init(likwid=True, simd_isa='avx', compiler='gnu')
from pyop2 import profiling as p
#m = UnitTriangleMesh()
m = Mesh('spacefilling6.node')
m = ExtrudedMesh(m, layers=51, layer_height=0.1)
h_fses = (('DG', 0), ('DG', 1),
('CG', 1), ('CG', 2), ('CG', 3))
v_fses = (('DG', 0), ('DG', 1),
('CG', 1), ('CG', 2), ('CG', 3))
results = {}
for (fam, deg) in h_fses:
for (vfam, vdeg) in v_fses:
V = FunctionSpace(m, fam, deg, vfamily=vfam, vdegree=vdeg)
name = "%s%dx%s%d" % (fam, deg, vfam, vdeg)
f = Function(V)
f.assign(10)
f.dat._force_evaluation()
k = op2.Kernel('''
static inline void %(name)s(double x[%(dim)d]) {
for ( int i = 0; i < %(dim)d; i++ ) x[i] += 1.0;
}''' % {'name': name,
'dim': V.cell_node_map().arity},
name=name)
op2.par_loop(k, m.cell_set, f.dat(op2.INC, V.cell_node_map()[op2.i[0]]))
f.dat._force_evaluation()
# Don't measure times including compilation
p.reset()
for i in range(10):
f.assign(10)
f.dat._force_evaluation()
op2.par_loop(k, m.cell_set, f.dat(op2.INC, V.cell_node_map()[op2.i[0]]))
f.dat._force_evaluation()
print "=" * 100
print " Summary results for %s (%d dofs)\n" % (name, f.dat.dataset.size)
p.summary()
print "=" * 100
print ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment