From 462cb2fc3971ebb521a8e917b5ae70261c208dc4 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Fri, 9 Sep 2011 13:06:25 -0400 Subject: toggle 3d color in Camera class updates screen. --- camera.py | 1 + 1 file changed, 1 insertion(+) diff --git a/camera.py b/camera.py index 15b0916..e913624 100755 --- a/camera.py +++ b/camera.py @@ -540,6 +540,7 @@ class Camera(multiprocessing.Process): elif event.key == K_g: self.green_magenta = not self.green_magenta + self.update() elif event.key == K_F12: self.screenshot() -- cgit From b66dc0272af2072ae751b2bc6e84ac98d3c375d9 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Sat, 10 Sep 2011 13:38:25 -0400 Subject: change color of pmt shell. --- solids/pmts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solids/pmts.py b/solids/pmts.py index 4c8d288..4bcf276 100644 --- a/solids/pmts.py +++ b/solids/pmts.py @@ -38,7 +38,7 @@ def build_pmt_shell(filename, outer_material=water, nsteps=16): # convert mm -> m profile /= 1000.0 - return Solid(rotate_extrude(profile[:,0], profile[:,1], nsteps), glass, outer_material, color=0x99ffffff) + return Solid(rotate_extrude(profile[:,0], profile[:,1], nsteps), glass, outer_material, color=0xccffffff) def build_pmt(filename, glass_thickness, outer_material=water, nsteps=16): profile = read_csv(filename) -- cgit From 3c50c82458242d012216661e2e7eca2255f38207 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Sat, 10 Sep 2011 13:41:30 -0400 Subject: update documentation and rename create_context -> create_cuda_context. --- gpu.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gpu.py b/gpu.py index 671c872..26ecbe7 100644 --- a/gpu.py +++ b/gpu.py @@ -15,7 +15,6 @@ from pycuda import gpuarray as ga import chroma.src from chroma.tools import timeit from chroma.geometry import standard_wavelengths -from chroma.color import map_to_color from chroma import event cuda.init() @@ -26,7 +25,7 @@ cuda_options = ('--use_fast_math',)#, '--ptxas-options=-v'] @pycuda.tools.context_dependent_memoize def get_cu_module(name, options=None, include_source_directory=True): """Returns a pycuda.compiler.SourceModule object from a CUDA source file - located in the chroma src directory at src/[name].cu.""" + located in the chroma src directory at src/[name].""" if options is None: options = [] elif isinstance(options, tuple): @@ -45,7 +44,10 @@ def get_cu_module(name, options=None, include_source_directory=True): return pycuda.compiler.SourceModule(source, options=options, no_extern_c=True) +@pycuda.tools.memoize def get_cu_source(name): + """Get the source code for a CUDA source file located in the chroma src + directory at src/[name].""" srcdir = os.path.dirname(os.path.abspath(chroma.src.__file__)) with open('%s/%s' % (srcdir, name)) as f: source = f.read() @@ -140,8 +142,6 @@ class GPUPhotons(object): self.last_hit_triangles = ga.to_gpu(photons.last_hit_triangles.astype(np.int32)) self.flags = ga.to_gpu(photons.flags.astype(np.uint32)) - #cuda_options = ('--use_fast_math', '-w')#, '--ptxas-options=-v'] - module = get_cu_module('propagate.cu', options=cuda_options) self.gpu_funcs = GPUFuncs(module) @@ -676,8 +676,8 @@ class GPUPDF(object): return hitcount, pdf_value, pdf_value * pdf_frac_uncert -def create_context(device_id=None): - """Initialize and return a GPU context on the specified device. +def create_cuda_context(device_id=None): + """Initialize and return a CUDA context on the specified device. If device_id is None, the default device is used.""" try: cuda.mem_get_info() -- cgit From 1e192ba2349bc70efb1090c72f318470d8920970 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Sat, 10 Sep 2011 13:42:27 -0400 Subject: update benchmark.py --- benchmark.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmark.py b/benchmark.py index 329986c..f21a796 100755 --- a/benchmark.py +++ b/benchmark.py @@ -147,23 +147,23 @@ if __name__ == '__main__': from chroma import detectors import gc - lbne = detectors.build_lbne_200kton() + lbne = detectors.lbne() lbne.build(bits=11) - gpu_instance = gpu.GPU() + context = gpu.create_cuda_context() gpu_geometry = gpu.GPUGeometry(lbne) - gpu_instance.print_mem_info() print '%s ray intersections/sec.' % \ tools.ufloat_to_str(intersect(gpu_geometry)) + # run garbage collection since there is a reference loop + # in the GPUArray class. gc.collect() - gpu_instance.print_mem_info() print '%s photons loaded/sec.' % tools.ufloat_to_str(load_photons()) gc.collect() - gpu_instance.print_mem_info() print '%s photons propagated/sec.' % \ tools.ufloat_to_str(propagate(gpu_geometry)) gc.collect() - gpu_instance.print_mem_info() print '%s 100 MeV events histogrammed/s' % \ tools.ufloat_to_str(pdf(gpu_geometry, max(lbne.pmtids))) + + context.pop() -- cgit From 254a0713a85c869e96425522df4ae182f3ab8e13 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Sat, 10 Sep 2011 14:35:30 -0400 Subject: new alpha rendering scheme. --- solids/pmts.py | 2 +- src/render.cu | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/solids/pmts.py b/solids/pmts.py index 4bcf276..43aed3f 100644 --- a/solids/pmts.py +++ b/solids/pmts.py @@ -38,7 +38,7 @@ def build_pmt_shell(filename, outer_material=water, nsteps=16): # convert mm -> m profile /= 1000.0 - return Solid(rotate_extrude(profile[:,0], profile[:,1], nsteps), glass, outer_material, color=0xccffffff) + return Solid(rotate_extrude(profile[:,0], profile[:,1], nsteps), glass, outer_material, color=0xeeffffff) def build_pmt(filename, glass_thickness, outer_material=water, nsteps=16): profile = read_csv(filename) diff --git a/src/render.cu b/src/render.cu index c1e8ea1..d9ce1b1 100644 --- a/src/render.cu +++ b/src/render.cu @@ -142,11 +142,7 @@ render(int nthreads, float3 *_origin, float3 *_direction, Geometry *geometry, float fg = 0.0f; float fb = 0.0f; for (i=0; i < n; i++) { - float alpha; - if (i < alpha_depth-1) - alpha = color_a[i].w; - else - alpha = 1.0; + float alpha = color_a[i].w; fr += scale*color_a[i].x*alpha; fg += scale*color_a[i].y*alpha; @@ -158,10 +154,10 @@ render(int nthreads, float3 *_origin, float3 *_direction, Geometry *geometry, if (n < alpha_depth) a = floorf(255*(1.0f-scale)); else - a = 255; - unsigned int r = floorf(fr); - unsigned int g = floorf(fg); - unsigned int b = floorf(fb); + a = 255; + unsigned int r = floorf(fr/(1.0f-scale)); + unsigned int g = floorf(fg/(1.0f-scale)); + unsigned int b = floorf(fb/(1.0f-scale)); pixels[id] = a << 24 | r << 16 | g << 8 | b; } -- cgit