[Yt-svn] yt: 2 new changesets

hg at spacepope.org hg at spacepope.org
Tue May 11 23:11:16 PDT 2010


hg Repository: yt
details:   yt/rev/14671ff20807
changeset: 1663:14671ff20807
user:      Matthew Turk <matthewturk at gmail.com>
date:
Tue May 11 21:43:26 2010 -0700
description:
Shuffling the order of field generation should improve performance for particle
fields.

hg Repository: yt
details:   yt/rev/5046b8e91114
changeset: 1664:5046b8e91114
user:      Matthew Turk <matthewturk at gmail.com>
date:
Tue May 11 23:03:53 2010 -0700
description:
Some modifications to HOP to avoid some pointer dereferencing.  Because of the
shuffling of the particles and avoiding copying too much of the arrays I think
that the kd->p[in].np_index call is still necessary.c  There might be another
way around that, however.

diffstat:

 yt/lagos/BaseDataTypes.py |   8 ++++----
 yt/lagos/hop/EnzoHop.c    |  20 ++++++++++----------
 yt/lagos/hop/hop_numpy.h  |   6 +++---
 yt/lagos/hop/kd.h         |   6 +++---
 4 files changed, 20 insertions(+), 20 deletions(-)

diffs (95 lines):

diff -r 92c6af9b8383 -r 5046b8e91114 yt/lagos/BaseDataTypes.py
--- a/yt/lagos/BaseDataTypes.py	Mon May 10 22:57:55 2010 -0700
+++ b/yt/lagos/BaseDataTypes.py	Tue May 11 23:03:53 2010 -0700
@@ -1643,10 +1643,6 @@
         for field in fields_to_get:
             if self.data.has_key(field):
                 continue
-            mylog.info("Getting field %s from %s", field, len(self._grids))
-            if field not in self.hierarchy.field_list and not in_grids:
-                if self._generate_field(field):
-                    continue # True means we already assigned it
             # There are a lot of 'ands' here, but I think they are all
             # necessary.
             if force_particle_read == False and \
@@ -1655,6 +1651,10 @@
                self.pf.h.io._particle_reader:
                 self[field] = self.particles[field]
                 continue
+            mylog.info("Getting field %s from %s", field, len(self._grids))
+            if field not in self.hierarchy.field_list and not in_grids:
+                if self._generate_field(field):
+                    continue # True means we already assigned it
             self[field] = na.concatenate(
                 [self._get_data_from_grid(grid, field)
                  for grid in self._grids])
diff -r 92c6af9b8383 -r 5046b8e91114 yt/lagos/hop/EnzoHop.c
--- a/yt/lagos/hop/EnzoHop.c	Mon May 10 22:57:55 2010 -0700
+++ b/yt/lagos/hop/EnzoHop.c	Tue May 11 23:03:53 2010 -0700
@@ -137,11 +137,11 @@
                     PyArray_DescrFromType(NPY_FLOAT64));
 
     fprintf(stdout, "Copying arrays for %d particles\n", num_particles);
-    kd->np_masses = mass;
-    kd->np_pos[0] = xpos;
-    kd->np_pos[1] = ypos;
-    kd->np_pos[2] = zpos;
-    kd->np_densities = particle_density;
+    kd->np_masses = (npy_float64*) mass->data;
+    kd->np_pos[0] = (npy_float64*) xpos->data;
+    kd->np_pos[1] = (npy_float64*) ypos->data;
+    kd->np_pos[2] = (npy_float64*) zpos->data;
+    kd->np_densities = (npy_float64*) particle_density->data;
     kd->totalmass = totalmass;
 	for (i = 0; i < num_particles; i++) kd->p[i].np_index = i;
 
@@ -274,11 +274,11 @@
     totalmass /= normalize_to;
 
 
-    self->kd->np_masses = self->mass;
-    self->kd->np_pos[0] = self->xpos;
-    self->kd->np_pos[1] = self->ypos;
-    self->kd->np_pos[2] = self->zpos;
-    self->kd->np_densities = self->densities;
+    self->kd->np_masses = (npy_float64 *)self->mass->data;
+    self->kd->np_pos[0] = (npy_float64 *)self->xpos->data;
+    self->kd->np_pos[1] = (npy_float64 *)self->ypos->data;
+    self->kd->np_pos[2] = (npy_float64 *)self->zpos->data;
+    self->kd->np_densities = (npy_float64 *)self->densities->data;
     self->kd->totalmass = totalmass;
 
     PrepareKD(self->kd);
diff -r 92c6af9b8383 -r 5046b8e91114 yt/lagos/hop/hop_numpy.h
--- a/yt/lagos/hop/hop_numpy.h	Mon May 10 22:57:55 2010 -0700
+++ b/yt/lagos/hop/hop_numpy.h	Tue May 11 23:03:53 2010 -0700
@@ -3,10 +3,10 @@
 #include "numpy/ndarrayobject.h"
 
 #define NP_DENS(kd, in) \
-    (*(npy_float64*)PyArray_GETPTR1(kd->np_densities, kd->p[in].np_index))
+    kd->np_densities[kd->p[in].np_index]
 #define NP_POS(kd, in, dim) \
-    (*(npy_float64*)PyArray_GETPTR1(kd->np_pos[dim], kd->p[in].np_index))
+    kd->np_pos[dim][kd->p[in].np_index]
 #define NP_MASS(kd, in) \
-    (*(npy_float64*)PyArray_GETPTR1(kd->np_masses, kd->p[in].np_index))/kd->totalmass
+    (kd->np_masses[kd->p[in].np_index]/kd->totalmass)
 
 #endif
diff -r 92c6af9b8383 -r 5046b8e91114 yt/lagos/hop/kd.h
--- a/yt/lagos/hop/kd.h	Mon May 10 22:57:55 2010 -0700
+++ b/yt/lagos/hop/kd.h	Tue May 11 23:03:53 2010 -0700
@@ -91,9 +91,9 @@
 	KDN *kdNodes;
 	int uSecond;
 	int uMicro;
-    PyArrayObject *np_densities;
-    PyArrayObject *np_pos[3];
-    PyArrayObject *np_masses;
+    npy_float64 *np_densities;
+    npy_float64 *np_pos[3];
+    npy_float64 *np_masses;
     float totalmass;
 	} * KD;
 



More information about the yt-svn mailing list