From 4c554d621d9b66c595397a0667d212bc4ea57be1 Mon Sep 17 00:00:00 2001 From: Stan Seibert Date: Sat, 10 Sep 2011 15:05:49 -0400 Subject: Add the ability to propagate the same photons multiple times on the the GPU, and run the DAQ multiple times on the same photons in a likelihood calculation. Propagating the same photons in a warp speeds up propagation by a factor of 3 (and we could do this even better if we wanted), and this improves the statistics in a likelihood evaluation quite a bit. Running the DAQ multiple times is also an inexpensive way to improve the quality of the PDF estimates. --- sim.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sim.py') diff --git a/sim.py b/sim.py index 7ba6472..7c9720a 100755 --- a/sim.py +++ b/sim.py @@ -119,7 +119,7 @@ class Simulation(object): return self.gpu_pdf.get_pdfs() - def eval_pdf(self, event_channels, iterable, min_twidth, trange, min_qwidth, qrange, min_bin_content=20, nreps=1, time_only=True): + def eval_pdf(self, event_channels, iterable, min_twidth, trange, min_qwidth, qrange, min_bin_content=20, nreps=1, ndaq=1, time_only=True): """Returns tuple: 1D array of channel hit counts, 1D array of PDF probability densities.""" self.gpu_pdf.setup_pdf_eval(event_channels.hit, @@ -137,16 +137,15 @@ class Simulation(object): if isinstance(first_element, event.Event): iterable = self.photon_generator.generate_events(iterable) - if nreps > 1: - iterable = repeating_iterator(iterable, nreps) - for ev in iterable: - gpu_photons = gpu.GPUPhotons(ev.photons_beg) + gpu_photons = gpu.GPUPhotons(ev.photons_beg, ncopies=nreps) gpu_photons.propagate(self.gpu_geometry, self.rng_states, nthreads_per_block=self.nthreads_per_block, max_blocks=self.max_blocks) - gpu_channels = self.gpu_daq.acquire(gpu_photons, self.rng_states, nthreads_per_block=self.nthreads_per_block, max_blocks=self.max_blocks) - self.gpu_pdf.accumulate_pdf_eval(gpu_channels) + for gpu_photon_slice in gpu_photons.iterate_copies(): + for idaq in xrange(ndaq): + gpu_channels = self.gpu_daq.acquire(gpu_photon_slice, self.rng_states, nthreads_per_block=self.nthreads_per_block, max_blocks=self.max_blocks) + self.gpu_pdf.accumulate_pdf_eval(gpu_channels) return self.gpu_pdf.get_pdf_eval() -- cgit