[yt-svn] commit/yt: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Jul 10 13:50:55 PDT 2017
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/70ce1e3eca3f/
Changeset: 70ce1e3eca3f
User: MatthewTurk
Date: 2017-07-10 18:31:45+00:00
Summary: Explicitly allocate/deallocate IntegrationAccumulator.
Affected #: 1 file
diff -r 6e1264f48f8060e56cbaab4a367d7dd67e803485 -r 70ce1e3eca3f4a4e0ae8ed376804f4159052318c yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -1426,7 +1426,8 @@
cdef np.ndarray[np.uint8_t, ndim=3, cast=True] child_mask
cdef int i
cdef int total = 0
- cdef IntegrationAccumulator ia
+ cdef IntegrationAccumulator *ia
+ ia = <IntegrationAccumulator *> malloc(sizeof(IntegrationAccumulator))
cdef VolumeContainer vc
mask = np.zeros(gobj.ActiveDimensions, dtype='uint8')
t = np.zeros(gobj.ActiveDimensions, dtype="float64")
@@ -1445,13 +1446,14 @@
vc.dds[i] = gobj.dds[i]
vc.idds[i] = 1.0/gobj.dds[i]
vc.dims[i] = dt.shape[i]
- walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> &ia)
+ walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> ia)
for i in range(dt.shape[0]):
for j in range(dt.shape[1]):
for k in range(dt.shape[2]):
if dt[i, j, k] >= 0:
mask[i, j, k] = 1
total += 1
+ free(ia)
if total == 0: return None
return mask.astype("bool")
@@ -1463,7 +1465,8 @@
cdef np.ndarray[np.float64_t, ndim=1] tr, dtr
cdef np.ndarray[np.uint8_t, ndim=3, cast=True] child_mask
cdef int i, j, k, ni
- cdef IntegrationAccumulator ia
+ cdef IntegrationAccumulator *ia
+ ia = <IntegrationAccumulator *> malloc(sizeof(IntegrationAccumulator))
cdef VolumeContainer vc
t = np.zeros(gobj.ActiveDimensions, dtype="float64")
dt = np.zeros(gobj.ActiveDimensions, dtype="float64") - 1
@@ -1481,7 +1484,7 @@
vc.dds[i] = gobj.dds[i]
vc.idds[i] = 1.0/gobj.dds[i]
vc.dims[i] = dt.shape[i]
- walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> &ia)
+ walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> ia)
tr = np.zeros(ia.hits, dtype="float64")
dtr = np.zeros(ia.hits, dtype="float64")
ni = 0
@@ -1494,6 +1497,7 @@
ni += 1
if not (ni == ia.hits):
print ni, ia.hits
+ free(ia)
return dtr, tr
@cython.boundscheck(False)
@@ -1507,7 +1511,8 @@
cdef np.float64_t LE[3]
cdef np.float64_t RE[3]
cdef np.float64_t pos
- cdef IntegrationAccumulator ia
+ cdef IntegrationAccumulator *ia
+ ia = <IntegrationAccumulator *> malloc(sizeof(IntegrationAccumulator))
cdef np.ndarray[np.float64_t, ndim=2] coords
cdef np.ndarray[np.int64_t, ndim=2] indices
indices = mesh.connectivity_indices
@@ -1543,11 +1548,12 @@
vc.idds[j] = 1.0/vc.dds[j]
vc.dims[j] = 1
t[0,0,0] = dt[0,0,0] = -1
- walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> &ia)
+ walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> ia)
if dt[0,0,0] >= 0:
tr[ni] = t[0,0,0]
dtr[ni] = dt[0,0,0]
ni += 1
+ free(ia)
return dtr, tr
cdef int select_point(self, np.float64_t pos[3]) nogil:
@@ -1563,26 +1569,30 @@
@cython.cdivision(True)
cdef int select_bbox(self, np.float64_t left_edge[3],
np.float64_t right_edge[3]) nogil:
- cdef int i
- cdef np.uint8_t cm = 1
+ cdef int i, rv
cdef VolumeContainer vc
- cdef IntegrationAccumulator ia
- cdef np.float64_t dt, t
+ cdef IntegrationAccumulator *ia
+ ia = <IntegrationAccumulator *> malloc(sizeof(IntegrationAccumulator))
+ cdef np.float64_t dt[1], t[1]
+ cdef np.uint8_t cm[1]
for i in range(3):
vc.left_edge[i] = left_edge[i]
vc.right_edge[i] = right_edge[i]
vc.dds[i] = right_edge[i] - left_edge[i]
vc.idds[i] = 1.0/vc.dds[i]
vc.dims[i] = 1
- t = dt = 0.0
- ia.t = &t
- ia.dt = &dt
- ia.child_mask = &cm
+ t[0] = dt[0] = 0.0
+ cm[0] = 1
+ ia.t = t
+ ia.dt = dt
+ ia.child_mask = cm
ia.hits = 0
- walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> &ia)
+ walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> ia)
+ rv = 0
if ia.hits > 0:
- return 1
- return 0
+ rv = 1
+ free(ia)
+ return rv
@cython.boundscheck(False)
@cython.wraparound(False)
https://bitbucket.org/yt_analysis/yt/commits/0f517c77aa35/
Changeset: 0f517c77aa35
User: ngoldbaum
Date: 2017-07-10 20:50:43+00:00
Summary: Merge pull request #1485 from MatthewTurk/octree_raytracing
Explicitly allocate/deallocate IntegrationAccumulator. Fixes #1484.
Affected #: 1 file
diff -r 2447f34f2682526765e4b9dd5dd247f062cd3d5a -r 0f517c77aa3560d5c4497e5508971294e3396dc7 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -1426,7 +1426,8 @@
cdef np.ndarray[np.uint8_t, ndim=3, cast=True] child_mask
cdef int i
cdef int total = 0
- cdef IntegrationAccumulator ia
+ cdef IntegrationAccumulator *ia
+ ia = <IntegrationAccumulator *> malloc(sizeof(IntegrationAccumulator))
cdef VolumeContainer vc
mask = np.zeros(gobj.ActiveDimensions, dtype='uint8')
t = np.zeros(gobj.ActiveDimensions, dtype="float64")
@@ -1445,13 +1446,14 @@
vc.dds[i] = gobj.dds[i]
vc.idds[i] = 1.0/gobj.dds[i]
vc.dims[i] = dt.shape[i]
- walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> &ia)
+ walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> ia)
for i in range(dt.shape[0]):
for j in range(dt.shape[1]):
for k in range(dt.shape[2]):
if dt[i, j, k] >= 0:
mask[i, j, k] = 1
total += 1
+ free(ia)
if total == 0: return None
return mask.astype("bool")
@@ -1463,7 +1465,8 @@
cdef np.ndarray[np.float64_t, ndim=1] tr, dtr
cdef np.ndarray[np.uint8_t, ndim=3, cast=True] child_mask
cdef int i, j, k, ni
- cdef IntegrationAccumulator ia
+ cdef IntegrationAccumulator *ia
+ ia = <IntegrationAccumulator *> malloc(sizeof(IntegrationAccumulator))
cdef VolumeContainer vc
t = np.zeros(gobj.ActiveDimensions, dtype="float64")
dt = np.zeros(gobj.ActiveDimensions, dtype="float64") - 1
@@ -1481,7 +1484,7 @@
vc.dds[i] = gobj.dds[i]
vc.idds[i] = 1.0/gobj.dds[i]
vc.dims[i] = dt.shape[i]
- walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> &ia)
+ walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> ia)
tr = np.zeros(ia.hits, dtype="float64")
dtr = np.zeros(ia.hits, dtype="float64")
ni = 0
@@ -1494,6 +1497,7 @@
ni += 1
if not (ni == ia.hits):
print ni, ia.hits
+ free(ia)
return dtr, tr
@cython.boundscheck(False)
@@ -1507,7 +1511,8 @@
cdef np.float64_t LE[3]
cdef np.float64_t RE[3]
cdef np.float64_t pos
- cdef IntegrationAccumulator ia
+ cdef IntegrationAccumulator *ia
+ ia = <IntegrationAccumulator *> malloc(sizeof(IntegrationAccumulator))
cdef np.ndarray[np.float64_t, ndim=2] coords
cdef np.ndarray[np.int64_t, ndim=2] indices
indices = mesh.connectivity_indices
@@ -1543,11 +1548,12 @@
vc.idds[j] = 1.0/vc.dds[j]
vc.dims[j] = 1
t[0,0,0] = dt[0,0,0] = -1
- walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> &ia)
+ walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> ia)
if dt[0,0,0] >= 0:
tr[ni] = t[0,0,0]
dtr[ni] = dt[0,0,0]
ni += 1
+ free(ia)
return dtr, tr
cdef int select_point(self, np.float64_t pos[3]) nogil:
@@ -1563,26 +1569,30 @@
@cython.cdivision(True)
cdef int select_bbox(self, np.float64_t left_edge[3],
np.float64_t right_edge[3]) nogil:
- cdef int i
- cdef np.uint8_t cm = 1
+ cdef int i, rv
cdef VolumeContainer vc
- cdef IntegrationAccumulator ia
- cdef np.float64_t dt, t
+ cdef IntegrationAccumulator *ia
+ ia = <IntegrationAccumulator *> malloc(sizeof(IntegrationAccumulator))
+ cdef np.float64_t dt[1], t[1]
+ cdef np.uint8_t cm[1]
for i in range(3):
vc.left_edge[i] = left_edge[i]
vc.right_edge[i] = right_edge[i]
vc.dds[i] = right_edge[i] - left_edge[i]
vc.idds[i] = 1.0/vc.dds[i]
vc.dims[i] = 1
- t = dt = 0.0
- ia.t = &t
- ia.dt = &dt
- ia.child_mask = &cm
+ t[0] = dt[0] = 0.0
+ cm[0] = 1
+ ia.t = t
+ ia.dt = dt
+ ia.child_mask = cm
ia.hits = 0
- walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> &ia)
+ walk_volume(&vc, self.p1, self.vec, dt_sampler, <void*> ia)
+ rv = 0
if ia.hits > 0:
- return 1
- return 0
+ rv = 1
+ free(ia)
+ return rv
@cython.boundscheck(False)
@cython.wraparound(False)
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