summaryrefslogtreecommitdiff
path: root/chroma/gpu/tools.py
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2012-05-24 11:33:19 -0400
committertlatorre <tlatorre@uchicago.edu>2021-05-09 08:42:39 -0700
commit57424359aefd4221c64582573c8424c61fd7dc51 (patch)
tree448457af247bc24838fdb9ebc26c4f9ca9e0d809 /chroma/gpu/tools.py
parentb62149c08f835068215b48110df876ae8d481969 (diff)
downloadchroma-57424359aefd4221c64582573c8424c61fd7dc51.tar.gz
chroma-57424359aefd4221c64582573c8424c61fd7dc51.tar.bz2
chroma-57424359aefd4221c64582573c8424c61fd7dc51.zip
Put triangles and vertices back onto the GPU if there is sufficient room.
This is an optimization that is helpful for smaller detectors, even if giant water Cherenkov detectors cannot take advantage of it. Modified Mapped() helper function to pass through GPU arrays, which makes it much easier to flip between arrays on the CPU and the GPU.
Diffstat (limited to 'chroma/gpu/tools.py')
-rw-r--r--chroma/gpu/tools.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/chroma/gpu/tools.py b/chroma/gpu/tools.py
index 34b4166..98c7e6a 100644
--- a/chroma/gpu/tools.py
+++ b/chroma/gpu/tools.py
@@ -185,8 +185,15 @@ def format_array(name, array):
def Mapped(array):
'''Analog to pycuda.driver.InOut(), but indicates this array
- is memory mapped to the device space and should not be copied.'''
- return np.intp(array.base.get_device_pointer())
+ is memory mapped to the device space and should not be copied.
+
+ To simplify coding, Mapped() will pass anything with a gpudata
+ member, like a gpuarray, through unchanged.
+ '''
+ if hasattr(array, 'gpudata'):
+ return array
+ else:
+ return np.intp(array.base.get_device_pointer())
def mapped_alloc(pagelocked_alloc_func, shape, dtype, write_combined):
'''Returns a pagelocked host array mapped into the CUDA device