[Yt-svn] commit/yt: MatthewTurk: Adding cython optimizations to the QuadTree

Bitbucket commits-noreply at bitbucket.org
Mon Jun 6 17:10:44 PDT 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/7fd1f6ffe8fd/
changeset:   7fd1f6ffe8fd
branches:    
user:        MatthewTurk
date:        2011-06-07 02:10:37
summary:     Adding cython optimizations to the QuadTree
affected #:  1 file (290 bytes)

--- a/yt/utilities/_amr_utils/QuadTree.pyx	Mon Jun 06 15:32:54 2011 -0700
+++ b/yt/utilities/_amr_utils/QuadTree.pyx	Mon Jun 06 17:10:37 2011 -0700
@@ -147,6 +147,8 @@
                 total += self.count_total_cells(root.children[i][j])
         return total + 1
 
+    @cython.boundscheck(False)
+    @cython.wraparound(False)
     cdef int fill_buffer(self, QuadTreeNode *root, int curpos,
                           np.ndarray[np.int32_t, ndim=1] refined,
                           np.ndarray[np.float64_t, ndim=2] values,
@@ -164,6 +166,8 @@
                                  refined, values, wval)
         return curpos
 
+    @cython.boundscheck(False)
+    @cython.wraparound(False)
     cdef int unfill_buffer(self, QuadTreeNode *root, int curpos,
                           np.ndarray[np.int32_t, ndim=1] refined,
                           np.ndarray[np.float64_t, ndim=2] values,
@@ -186,6 +190,8 @@
         return curpos
 
 
+    @cython.boundscheck(False)
+    @cython.wraparound(False)
     def frombuffer(self, np.ndarray[np.int32_t, ndim=1] refined,
                          np.ndarray[np.float64_t, ndim=2] values,
                          np.ndarray[np.float64_t, ndim=1] wval):
@@ -197,6 +203,8 @@
                 curpos = self.unfill_buffer(self.root_nodes[i][j], curpos,
                                  refined, values, wval)
 
+    @cython.boundscheck(False)
+    @cython.wraparound(False)
     def tobuffer(self):
         cdef int total = 0
         for i in range(self.top_grid_dims[0]):
@@ -226,7 +234,7 @@
                  int level, np.int64_t pos[2],
                  np.float64_t *val,
                  np.float64_t weight_val):
-        cdef int i, j
+        cdef int i, j, L
         cdef QuadTreeNode *node
         node = self.find_on_root_level(pos, level)
         cdef np.int64_t fac
@@ -240,6 +248,7 @@
             node = node.children[i][j]
         QTN_add_value(node, val, weight_val)
             
+    @cython.cdivision(True)
     cdef QuadTreeNode *find_on_root_level(self, np.int64_t pos[2], int level):
         # We need this because the root level won't just have four children
         # So we find on the root level, then we traverse the tree.
@@ -266,6 +275,7 @@
             pos[0] = pxs[p]
             pos[1] = pys[p]
             self.add_to_position(level, pos, vals, pweight_vals[p])
+        return
 
     def add_grid_to_tree(self, int level,
                          np.ndarray[np.int64_t, ndim=1] start_index,

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list