diff options
author | Stan Seibert <stan@mtrr.org> | 2011-09-16 15:02:02 -0400 |
---|---|---|
committer | Stan Seibert <stan@mtrr.org> | 2011-09-16 15:02:02 -0400 |
commit | 142b3c3caff164deb9bc7b2848e58e52387723ff (patch) | |
tree | 417da3ad69a2756aff7a21dca4b08733d3e87afb /test/test_ray_intersection.py | |
parent | 084dfd08b714faefaea77cb7dc04d2e93dc04b1d (diff) | |
download | chroma-142b3c3caff164deb9bc7b2848e58e52387723ff.tar.gz chroma-142b3c3caff164deb9bc7b2848e58e52387723ff.tar.bz2 chroma-142b3c3caff164deb9bc7b2848e58e52387723ff.zip |
Move CUDA source inside chroma package, rename tests directory to test
Diffstat (limited to 'test/test_ray_intersection.py')
-rw-r--r-- | test/test_ray_intersection.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/test_ray_intersection.py b/test/test_ray_intersection.py new file mode 100644 index 0000000..7d0c53c --- /dev/null +++ b/test/test_ray_intersection.py @@ -0,0 +1,27 @@ +import unittest +import chroma +import numpy as np +import os +from pycuda import gpuarray as ga + +class TestRayIntersection(unittest.TestCase): + def setUp(self): + self.context = chroma.gpu.create_cuda_context() + self.module = chroma.gpu.get_cu_module('mesh.h') + self.gpu_funcs = chroma.gpu.GPUFuncs(self.module) + self.box = chroma.gpu.GPUGeometry(chroma.build(chroma.make.cube())) + + pos, dir = chroma.project.from_film() + self.pos_gpu = ga.to_gpu(chroma.gpu.to_float3(pos)) + self.dir_gpu = ga.to_gpu(chroma.gpu.to_float3(dir)) + + testdir = os.path.dirname(os.path.abspath(chroma.tests.__file__)) + self.dx_standard = np.load(os.path.join(testdir, + 'data/ray_intersection.npz')) + def test_intersection_distance(self): + dx = ga.zeros(self.pos_gpu.size, dtype=np.float32) + self.gpu_funcs.distance_to_mesh(np.int32(self.pos_gpu.size), self.pos_gpu, self.dir_gpu, self.box.gpudata, dx, block=(64,1,1), grid=(self.pos_gpu.size//64+1,1)) + self.assertTrue((dx.get() == self.dx_standard).all()) + + def tearDown(self): + self.context.pop() |