[yt-svn] commit/yt: xarthisius: Merged in MatthewTurk/yt (pull request #1877)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Dec 14 11:13:05 PST 2015
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/0447987365b1/
Changeset: 0447987365b1
Branch: yt
User: xarthisius
Date: 2015-12-14 19:12:55+00:00
Summary: Merged in MatthewTurk/yt (pull request #1877)
[WIP] Converting many pointers to memoryviews
Affected #: 2 files
diff -r 1dab4da5db3f6996f4301481a384c8a4fbc79298 -r 0447987365b19d53451bd04609832f070f7362b2 yt/geometry/particle_smooth.pxd
--- a/yt/geometry/particle_smooth.pxd
+++ b/yt/geometry/particle_smooth.pxd
@@ -41,31 +41,27 @@
cdef int maxn
cdef int curn
cdef bint periodicity[3]
- cdef np.int64_t *doffs
- cdef np.int64_t *pinds
- cdef np.int64_t *pcounts
- cdef np.float64_t *ppos
# Note that we are preallocating here, so this is *not* threadsafe.
cdef NeighborList *neighbors
cdef void (*pos_setup)(np.float64_t ipos[3], np.float64_t opos[3])
cdef void neighbor_process(self, int dim[3], np.float64_t left_edge[3],
- np.float64_t dds[3], np.float64_t *ppos,
+ np.float64_t dds[3], np.float64_t[:,:] ppos,
np.float64_t **fields,
- np.int64_t *doffs, np.int64_t **nind,
- np.int64_t *pinds, np.int64_t *pcounts,
+ np.int64_t[:] doffs, np.int64_t **nind,
+ np.int64_t[:] pinds, np.int64_t[:] pcounts,
np.int64_t offset, np.float64_t **index_fields,
OctreeContainer octree, np.int64_t domain_id,
- int *nsize, np.float64_t *oct_left_edges,
- np.float64_t *oct_dds)
+ int *nsize, np.float64_t[:,:] oct_left_edges,
+ np.float64_t[:,:] oct_dds)
cdef int neighbor_search(self, np.float64_t pos[3], OctreeContainer octree,
np.int64_t **nind, int *nsize,
np.int64_t nneighbors, np.int64_t domain_id,
Oct **oct = ?, int extra_layer = ?)
cdef void neighbor_process_particle(self, np.float64_t cpos[3],
- np.float64_t *ppos,
+ np.float64_t[:,:] ppos,
np.float64_t **fields,
- np.int64_t *doffs, np.int64_t **nind,
- np.int64_t *pinds, np.int64_t *pcounts,
+ np.int64_t[:] doffs, np.int64_t **nind,
+ np.int64_t[:] pinds, np.int64_t[:] pcounts,
np.int64_t offset,
np.float64_t **index_fields,
OctreeContainer octree, np.int64_t domain_id,
@@ -76,13 +72,13 @@
cdef void neighbor_find(self,
np.int64_t nneighbors,
np.int64_t *nind,
- np.int64_t *doffs,
- np.int64_t *pcounts,
- np.int64_t *pinds,
- np.float64_t *ppos,
+ np.int64_t[:] doffs,
+ np.int64_t[:] pcounts,
+ np.int64_t[:] pinds,
+ np.float64_t[:,:] ppos,
np.float64_t cpos[3],
- np.float64_t* oct_left_edges,
- np.float64_t* oct_dds)
+ np.float64_t[:,:] oct_left_edges,
+ np.float64_t[:,:] oct_dds)
cdef void process(self, np.int64_t offset, int i, int j, int k,
int dim[3], np.float64_t cpos[3], np.float64_t **fields,
np.float64_t **index_fields)
diff -r 1dab4da5db3f6996f4301481a384c8a4fbc79298 -r 0447987365b19d53451bd04609832f070f7362b2 yt/geometry/particle_smooth.pyx
--- a/yt/geometry/particle_smooth.pyx
+++ b/yt/geometry/particle_smooth.pyx
@@ -42,6 +42,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ at cython.initializedcheck(False)
cdef np.float64_t r2dist(np.float64_t ppos[3],
np.float64_t cpos[3],
np.float64_t DW[3],
@@ -80,6 +81,7 @@
self.nvals = nvals
self.nfields = nfields
self.maxn = max_neighbors
+
self.neighbors = <NeighborList *> malloc(
sizeof(NeighborList) * self.maxn)
self.neighbor_reset()
@@ -94,16 +96,17 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ @cython.initializedcheck(False)
def process_octree(self, OctreeContainer mesh_octree,
- np.ndarray[np.int64_t, ndim=1] mdom_ind,
- np.ndarray[np.float64_t, ndim=2] positions,
- np.ndarray[np.float64_t, ndim=2] oct_positions,
+ np.int64_t [:] mdom_ind,
+ np.float64_t[:,:] positions,
+ np.float64_t[:,:] oct_positions,
fields = None, int domain_id = -1,
int domain_offset = 0,
periodicity = (True, True, True),
index_fields = None,
OctreeContainer particle_octree = None,
- np.ndarray[np.int64_t, ndim=1] pdom_ind = None,
+ np.int64_t [:] pdom_ind = None,
geometry = "cartesian"):
# This will be a several-step operation.
#
@@ -134,10 +137,10 @@
pdom_ind = mdom_ind
cdef int nf, i, j, n
cdef int dims[3]
+ cdef np.float64_t[:] *field_check
cdef np.float64_t **field_pointers
cdef np.float64_t *field_vals
cdef np.float64_t pos[3]
- cdef np.float64_t *ppos
cdef np.float64_t dds[3]
cdef np.float64_t **octree_field_pointers
cdef int nsize = 0
@@ -146,15 +149,12 @@
cdef Oct *oct
cdef np.int64_t numpart, offset, local_ind, poff
cdef np.int64_t moff_p, moff_m
- cdef np.int64_t *doffs
- cdef np.int64_t *pinds
- cdef np.int64_t *pcounts
- cdef np.ndarray[np.int64_t, ndim=1] pind, doff, pdoms, pcount
- cdef np.ndarray[np.int64_t, ndim=2] doff_m
+ cdef np.int64_t[:] pind, doff, pdoms, pcount
+ cdef np.int64_t[:,:] doff_m
cdef np.ndarray[np.float64_t, ndim=1] tarr
cdef np.ndarray[np.float64_t, ndim=4] iarr
- cdef np.ndarray[np.float64_t, ndim=2] cart_positions
- cdef np.ndarray[np.float64_t, ndim=2] oct_left_edges, oct_dds
+ cdef np.float64_t[:,:] cart_positions
+ cdef np.float64_t[:,:] oct_left_edges, oct_dds
cdef OctInfo oinfo
if geometry == "cartesian":
self.pos_setup = cart_coord_setup
@@ -245,11 +245,6 @@
#raise RuntimeError
# Now doff is full of offsets to the first entry in the pind that
# refers to that oct's particles.
- ppos = <np.float64_t *> positions.data
- cart_pos = <np.float64_t *> cart_positions.data
- doffs = <np.int64_t*> doff.data
- pinds = <np.int64_t*> pind.data
- pcounts = <np.int64_t*> pcount.data
cdef np.ndarray[np.uint8_t, ndim=1] visited
visited = np.zeros(mdom_ind.shape[0], dtype="uint8")
cdef int nproc = 0
@@ -263,10 +258,10 @@
if offset < 0: continue
nproc += 1
self.neighbor_process(
- dims, moi.left_edge, moi.dds, cart_pos, field_pointers, doffs,
- &nind, pinds, pcounts, offset, index_field_pointers,
- particle_octree, domain_id, &nsize, &oct_left_edges[0, 0],
- &oct_dds[0, 0])
+ dims, moi.left_edge, moi.dds, cart_positions, field_pointers, doff,
+ &nind, pind, pcount, offset, index_field_pointers,
+ particle_octree, domain_id, &nsize, oct_left_edges,
+ oct_dds)
#print "VISITED", visited.sum(), visited.size,
#print 100.0*float(visited.sum())/visited.size
if nind != NULL:
@@ -275,6 +270,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ @cython.initializedcheck(False)
def process_particles(self, OctreeContainer particle_octree,
np.ndarray[np.int64_t, ndim=1] pdom_ind,
np.ndarray[np.float64_t, ndim=2] positions,
@@ -293,7 +289,6 @@
cdef int dims[3]
cdef np.float64_t **field_pointers
cdef np.float64_t *field_vals
- cdef np.float64_t *ppos
cdef np.float64_t dds[3]
cdef np.float64_t pos[3]
cdef np.float64_t **octree_field_pointers
@@ -304,10 +299,7 @@
cdef Oct **neighbors = NULL
cdef np.int64_t nneighbors, numpart, offset, local_ind
cdef np.int64_t moff_p, moff_m, pind0, poff
- cdef np.int64_t *doffs
- cdef np.int64_t *pinds
- cdef np.int64_t *pcounts
- cdef np.ndarray[np.int64_t, ndim=1] pind, doff, pdoms, pcount
+ cdef np.int64_t[:] pind, doff, pdoms, pcount
cdef np.ndarray[np.float64_t, ndim=1] tarr
cdef np.ndarray[np.float64_t, ndim=2] cart_positions
if geometry == "cartesian":
@@ -376,11 +368,6 @@
#raise RuntimeError
# Now doff is full of offsets to the first entry in the pind that
# refers to that oct's particles.
- ppos = <np.float64_t *> positions.data
- cart_pos = <np.float64_t *> cart_positions.data
- doffs = <np.int64_t*> doff.data
- pinds = <np.int64_t*> pind.data
- pcounts = <np.int64_t*> pcount.data
cdef int maxnei = 0
cdef int nproc = 0
for i in range(doff.shape[0]):
@@ -392,8 +379,8 @@
pind0 = pind[doff[i] + j]
for k in range(3):
pos[k] = positions[pind0, k]
- self.neighbor_process_particle(pos, cart_pos, field_pointers,
- doffs, &nind, pinds, pcounts, pind0,
+ self.neighbor_process_particle(pos, cart_positions, field_pointers,
+ doff, &nind, pind, pcount, pind0,
NULL, particle_octree, domain_id, &nsize)
#print "VISITED", visited.sum(), visited.size,
#print 100.0*float(visited.sum())/visited.size
@@ -468,6 +455,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ @cython.initializedcheck(False)
def process_grid(self, gobj,
np.ndarray[np.float64_t, ndim=2] positions,
fields = None):
@@ -524,16 +512,20 @@
if self.curn < self.maxn:
self.curn += 1
+ @cython.cdivision(True)
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
+ @cython.initializedcheck(False)
cdef void neighbor_find(self,
np.int64_t nneighbors,
np.int64_t *nind,
- np.int64_t *doffs,
- np.int64_t *pcounts,
- np.int64_t *pinds,
- np.float64_t *ppos,
+ np.int64_t[:] doffs,
+ np.int64_t[:] pcounts,
+ np.int64_t[:] pinds,
+ np.float64_t[:,:] ppos,
np.float64_t cpos[3],
- np.float64_t *oct_left_edges,
- np.float64_t *oct_dds,
+ np.float64_t[:,:] oct_left_edges,
+ np.float64_t[:,:] oct_dds,
):
# We are now given the number of neighbors, the indices into the
# domains for them, and the number of particles for each.
@@ -545,7 +537,7 @@
if nind[ni] == -1: continue
# terminate early if all 8 corners of oct are farther away than
# most distant currently known neighbor
- if oct_left_edges != NULL and self.curn == self.maxn:
+ if oct_left_edges != None and self.curn == self.maxn:
r2_trunc = self.neighbors[self.curn - 1].r2
# iterate over each dimension in the outer loop so we can
# consolidate temporary storage
@@ -555,8 +547,8 @@
r2 = 0.0
for k in range(3):
# We start at left edge, then do halfway, then right edge.
- ex[0] = oct_left_edges[3*nind[ni] + k]
- ex[1] = ex[0] + oct_dds[3*nind[ni] + k]
+ ex[0] = oct_left_edges[nind[ni], k]
+ ex[1] = ex[0] + oct_dds[nind[ni], k]
# There are three possibilities; we are between, left-of,
# or right-of the extrema. Thanks to
# http://stackoverflow.com/questions/5254838/calculating-distance-between-a-point-and-a-rectangular-box-nearest-point
@@ -581,19 +573,23 @@
for i in range(pc):
pn = pinds[offset + i]
for j in range(3):
- pos[j] = ppos[pn * 3 + j]
+ pos[j] = ppos[pn, j]
self.neighbor_eval(pn, pos, cpos)
+ @cython.cdivision(True)
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
+ @cython.initializedcheck(False)
cdef void neighbor_process(self, int dim[3], np.float64_t left_edge[3],
- np.float64_t dds[3], np.float64_t *ppos,
+ np.float64_t dds[3], np.float64_t[:,:] ppos,
np.float64_t **fields,
- np.int64_t *doffs, np.int64_t **nind,
- np.int64_t *pinds, np.int64_t *pcounts,
+ np.int64_t [:] doffs, np.int64_t **nind,
+ np.int64_t [:] pinds, np.int64_t[:] pcounts,
np.int64_t offset,
np.float64_t **index_fields,
OctreeContainer octree, np.int64_t domain_id,
- int *nsize, np.float64_t *oct_left_edges,
- np.float64_t *oct_dds):
+ int *nsize, np.float64_t[:,:] oct_left_edges,
+ np.float64_t[:,:] oct_dds):
# Note that we assume that fields[0] == smoothing length in the native
# units supplied. We can now iterate over every cell in the block and
# every particle to find the nearest. We will use a priority heap.
@@ -626,11 +622,15 @@
cpos[1] += dds[1]
cpos[0] += dds[0]
+ @cython.cdivision(True)
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
+ @cython.initializedcheck(False)
cdef void neighbor_process_particle(self, np.float64_t cpos[3],
- np.float64_t *ppos,
+ np.float64_t[:,:] ppos,
np.float64_t **fields,
- np.int64_t *doffs, np.int64_t **nind,
- np.int64_t *pinds, np.int64_t *pcounts,
+ np.int64_t[:] doffs, np.int64_t **nind,
+ np.int64_t[:] pinds, np.int64_t[:] pcounts,
np.int64_t offset,
np.float64_t **index_fields,
OctreeContainer octree,
@@ -649,7 +649,7 @@
nneighbors = self.neighbor_search(opos, octree,
nind, nsize, nneighbors, domain_id, &oct, 0)
self.neighbor_find(nneighbors, nind[0], doffs, pcounts, pinds, ppos,
- opos, NULL, NULL)
+ opos, None, None)
self.process(offset, i, j, k, dim, opos, fields, index_fields)
cdef class VolumeWeightedSmooth(ParticleSmoothOperation):
@@ -686,6 +686,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ @cython.initializedcheck(False)
cdef void process(self, np.int64_t offset, int i, int j, int k,
int dim[3], np.float64_t cpos[3], np.float64_t **fields,
np.float64_t **index_fields):
@@ -744,6 +745,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ @cython.initializedcheck(False)
cdef void process(self, np.int64_t offset, int i, int j, int k,
int dim[3], np.float64_t cpos[3], np.float64_t **fields,
np.float64_t **index_fields):
@@ -777,6 +779,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ @cython.initializedcheck(False)
cdef void process(self, np.int64_t offset, int i, int j, int k,
int dim[3], np.float64_t cpos[3], np.float64_t **fields,
np.float64_t **index_fields):
@@ -812,6 +815,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ @cython.initializedcheck(False)
cdef void process(self, np.int64_t offset, int i, int j, int k,
int dim[3], np.float64_t cpos[3], np.float64_t **fields,
np.float64_t **index_fields):
@@ -832,6 +836,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
+ @cython.initializedcheck(False)
cdef void process(self, np.int64_t offset, int i, int j, int k,
int dim[3], np.float64_t cpos[3], np.float64_t **fields,
np.float64_t **index_fields):
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