Skip to content

Commit

Permalink
Merge pull request #7 from bh107/xraysim-workaround
Browse files Browse the repository at this point in the history
Xraysim workaround
  • Loading branch information
madsbk committed May 23, 2016
2 parents c348137 + 714a17e commit 4be409c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ dist/
benchmarks/**/bin
MANIFEST
bh-job-*
benchmarks/_utils/cil/Utilities/obj
*.mdb

benchmarks/_utils/cil/Utilities/obj
benchmarks/black_scholes/cil/src/obj
benchmarks/black_scholes/cs_cil/src/obj
benchmarks/black_scholes/csharp_numcil/src/obj
benchmarks/heat_equation/csharp_numcil/src/obj
benchmarks/heat_equation_fixed/csharp_numcil/src/obj
benchmarks/jacobi/csharp_numcil/src/obj
black_scholes.userprefs
jacobi.userprefs
benchmarks/jacobi_fixed/csharp_numcil/src/obj
benchmarks/jacobi_solve/csharp_numcil/src/obj
benchmarks/jacobi_stencil/csharp_numcil/src/obj
benchmarks/nbody/csharp_numcil/src/obj
benchmarks/shallow_water/csharp_numcil/src/obj
benchmarks/nbody_nice/csharp_numcil/src/obj
shallow_water.userprefs
benchmarks/reactiondiffusion/csharp_numcil/src/obj
reactiondiffusion.userprefs
benchmarks/heat_equation/csharp_numcil/src/obj
benchmarks/heat_equation_fixed/csharp_numcil/src/obj
benchmarks/shallow_water/csharp_numcil/src/obj
benchmarks/xraysim/python_numpy/materials

*.userprefs
11 changes: 4 additions & 7 deletions benchmarks/xraysim/python_numpy/xraysim.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,11 @@ def xraysim(sourcelist,
#raydst is now to be correlated with material/attenuation grid
t = sceneattenuates[...,np.newaxis] * raydst
#We sums the three dimensions
t = np.add.reduce(t)
t = np.add.reduce(t)
t = np.add.reduce(t)
t = np.sum(t, axis=(0, 1, 2))
dtectattenuates = t.reshape(detector_resolution, detector_resolution)

pixelintensity = ((np.ones(raylengths.shape) * source[power] * Const.invsqr) / raylengths).reshape(dshape)
pixelintensity = ((Const.invsqr * source[power] * np.ones(raylengths.shape[0])[..., np.newaxis]) / raylengths).reshape(dshape)
area = np.dot( rayudirs, pixelareavector.reshape(3,1) ).reshape(dshape)
result += pixelintensity * area * np.exp(- dtectattenuates)
result += pixelintensity * area * np.exp(-dtectattenuates)
ret.append(result)
if visualize:
low = np.minimum.reduce(result.flatten())
Expand Down Expand Up @@ -180,7 +177,7 @@ def main():

B.start()
for _ in xrange(iterations):
detector_results = xraysim(*scene, visualize=B.visualize)
detector_results = xraysim(*scene, visualize=B.visualize)
if util.Benchmark().bohrium:
B.flush()

Expand Down
4 changes: 1 addition & 3 deletions benchmarks/xraysim/python_numpy/xraysimgeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def raygeometry(src, detpixpos):
origin = np.array([src[0],src[1],src[2]])
rays = detpixpos.reshape(raycount,3)[:,0:3] - origin

raydistances = np.sqrt( np.add.reduce( rays*rays , axis=1) ).reshape(raycount,1)
raydistances = np.sqrt(np.sum(rays*rays, axis=1)).reshape(raycount,1)
unitrays = rays / raydistances

rayinverses = np.ones(unitrays.shape) / unitrays
Expand Down Expand Up @@ -149,5 +149,3 @@ def runAABB( scenegrid,

voxelraydistances = (t_out-t_in)*(t_out>=t_in)
return voxelraydistances


0 comments on commit 4be409c

Please sign in to comment.