Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Alex van Houten <sparrow2867 <at> yahoo.com>
Subject: report on a succesful Cython project using threads
Newsgroups: gmane.comp.python.cython.user
Date: Monday 25th July 2011 11:10:12 UTC (over 5 years ago)
Hello, I would like to report on a successful Cython project. Successful in
the
sense that it was much faster than all code written by my predecessors
mainly
because the speed scales almost linearly with the number of cores. Also,
the
code is shorter and much easier to read and maintain. 
The task is to compute the elemements of a 3D volume (Numpy array) multiple
times. The problem is "embarrassingly parallel", so the number of threads
is
naturally set to the number of cores and the 3D volume is split up in sets
of
slabs, so on a dual core that set would comprise half of all the slabs.

First, a primary quantity is computed for every element in the 3D volume,
this
is straightforward algebra and easy to code in Cython "with nogil".
Next a convolution is done, I have used pyfftw:

@classmethod
def ScatterContribution(cls, cnp.ndarray[cnp.float32_t,ndim=3] scatter,
cnp.ndarray[cnp.float32_t,ndim=3] total, int zlow, int zhigh):
cdef Py_ssize_t z

for z from zlow<= z 
				
			
 
CD: 3ms