1. Pypy
  2. Untitled project
  3. extradoc

Commits

Maciej Fijalkowski  committed 3988bd9

finish porting convolution

  • Participants
  • Parent commits 8f85b55
  • Branches extradoc

Comments (0)

Files changed (4)

File talk/iwtc11/benchmarks/benchmark.sh

View file
     ./runner.py -n 5 -c "$* -lstdc++" image/sobel.cc 1002 1002
     rm a.out
 else
-    #./runner.py -n 10 sqrt/sqrt.py main int
-    #./runner.py -n 10 sqrt/sqrt.py main float
-    #./runner.py -n 10 sqrt/sqrt.py main Fix16
+    ./runner.py -n 10 sqrt/sqrt.py main int
+    ./runner.py -n 10 sqrt/sqrt.py main float
+    ./runner.py -n 10 sqrt/sqrt.py main Fix16
     ./runner.py convolution/convolution.py conv3 1
-    ./runner.py convolution/convolution.py conv3 100
-    ./runner.py convolution/convolution.py conv3 1000
-
-#    $* sqrt/time_sqrt.py float
-#    $* sqrt/time_sqrt.py int
-#    $* sqrt/time_sqrt.py Fix16
-#    $* convolution/time_conv.py 1
-#    $* convolution/time_conv.py 100
-#    $* convolution/time_conv.py 1000
-#    $* convolution/time_conv2d.py
+    ./runner.py convolution/convolution.py conv5 1
+    ./runner.py -n 10 convolution/convolution.py conv3 100
+    ./runner.py -n 10 convolution/convolution.py conv5 100
+    ./runner.py -n 10 convolution/convolution.py conv3 1000
+    ./runner.py -n 10 convolution/convolution.py conv5 1000
+    ./runner.py -n 10 convolution/convolution.py conv3x3 1000000 3
+    ./runner.py -n 10 convolution/convolution.py conv3x3 1000 1000
+    ./runner.py -n 10 convolution/convolution.py dilate3x3 1000 1000
 #    $* image/noborder.py NoBorderImagePadded
 #    $* image/noborder.py NoBorderImage
 #    $* image/time_sobel.py NoBorderImagePadded

File talk/iwtc11/benchmarks/convolution/convolution.py

View file
 from array import array
+from math import log10
 
 def _conv3(a, k, n=1):
     assert len(k)==3
 def conv3(args):
     n = int(args[0])
     _conv3(array('d', [1]) * (100000000/n),
-          array('d', [-1, 0, 1]), n)
-
+           array('d', [-1, 0, 1]), n)
+    return 'conv3(1e%d)' % log10(100000000/n)
 
 def _conv5(a, k, n=1):
     assert len(k)==5
             b[i] = k[4]*a[i] + k[3]*a[i+1] + k[2]*a[i+2] + k[1]*a[i+3] + k[0]*a[i+4]
     return b
 
+def conv5(args):
+    n = int(args[0])
+    _conv5(array('d', [1]) * (100000000/n),
+           array('d', [1, 4, 6, 4, 1]), n)
+    return 'conv5(1e%d)' % log10(100000000/n)
+
 class Array2D(object):
     def __init__(self, w, h):
         self.width = w
                       k[2,0]*a[x-1, y+1] + k[1,0]*a[x, y+1] + k[0,0]*a[x+1, y+1]
     return b
 
-def _morphology3x3(a, k, func):
+def morphology3x3(a, k, func):
     assert k.width == k.height == 3
     b = Array2D(a.width, a.height)
     for y in xrange(1, a.height-1):
 
 def _erode3x3(a, k):
     return morphology3x3(a, k, min)
+
+def conv3x3(args):
+    _conv3x3(Array2D(int(args[0]), int(args[1])), Array2D(3,3))
+    return 'conv3x3(%s)' % args[1]
+
+def dilate3x3(args):
+    _dilate3x3(Array2D(int(args[0]), int(args[1])), Array2D(3,3))
+    return 'dilate3x3(%s)' % args[1]

File talk/iwtc11/benchmarks/runner.py

View file
     parser.add_option('-c', dest='compile_command',
                       help='for *.c a compile command')
     options, args = parser.parse_args()
+    try:
+        import pypyjit
+    except ImportError:
+        pass
+    else:
+        pypyjit.set_param(trace_limit=20000)
     if args[0].endswith('.py'):
         mod = py.path.local(args[0]).pyimport()
         sys.stderr.write("warming up")
         all = []
         for i in range(options.no):
             t0 = time.time()
-            func(args)
+            name = func(args)
             all.append(time.time() - t0)
             print >>sys.stderr, "Next:", all[-1]
-        name = mod.name
     else:
         # not needed
         options.warmup = 0

File talk/iwtc11/benchmarks/sqrt/sqrt.py

View file
         return  Fix16((Fix16(other).val << 16) / self.val, False)
 
 def main(argv):
-    global name
-    name = 'sqrt(%s)' % argv[0]
     sqrt(eval(argv[0])(123456), 100000000)
+    return 'sqrt(%s)' % argv[0]