From 86652738c0b085f4ed06635e5d0a008ced520e4b Mon Sep 17 00:00:00 2001 From: Evghenii Date: Thu, 14 Nov 2013 22:54:37 +0100 Subject: [PATCH] working on rt --- examples_cuda/rt/Makefile_gpu | 7 ++++--- examples_cuda/rt/rt.ispc | 20 +++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/examples_cuda/rt/Makefile_gpu b/examples_cuda/rt/Makefile_gpu index 5c1aac0b..82d1d5d2 100644 --- a/examples_cuda/rt/Makefile_gpu +++ b/examples_cuda/rt/Makefile_gpu @@ -1,6 +1,6 @@ PROG=rt_cu ISPC_SRC=rt1.ispc -CXX_SRC=rt_cu.cpp +CXX_SRC=rt_cu.cpp CXX=g++ CXXFLAGS=-O3 -I$(CUDATK)/include @@ -8,7 +8,7 @@ LD=g++ LDFLAGS=-lcuda ISPC=ispc -ISPCFLAGS=-O3 --math-lib=default --target=nvptx64,avx +ISPCFLAGS=-O3 --math-lib=default --target=nvptx64 --opt=fast-math LLVM32 = $(HOME)/usr/local/llvm/bin-3.2 LLVM = $(HOME)/usr/local/llvm/bin-3.3 @@ -27,6 +27,7 @@ CXX_OBJ=$(CXX_SRC:%.cpp=%.o) all: $(PROG) +$(CXX_OBJ) : kernel.ptx $(PROG): $(CXX_OBJ) kernel.ptx /bin/cp kernel.ptx __kernels.ptx $(LD) -o $@ $(CXX_OBJ) $(LDFLAGS) @@ -36,7 +37,7 @@ $(PROG): $(CXX_OBJ) kernel.ptx %_ispc_nvptx64.bc: %.ispc - $(ISPC) $(ISPCFLAGS) --emit-llvm -o `basename $< .ispc`_ispc.bc -h `basename $< .ispc`_ispc.h $< --emit-llvm + $(ISPC) $(ISPCFLAGS) --emit-llvm -o `basename $< .ispc`_ispc_nvptx64.bc -h `basename $< .ispc`_ispc.h $< --emit-llvm %.ptx: %.bc $(LLVM32DIS) $< diff --git a/examples_cuda/rt/rt.ispc b/examples_cuda/rt/rt.ispc index 230a5288..fbd611fd 100644 --- a/examples_cuda/rt/rt.ispc +++ b/examples_cuda/rt/rt.ispc @@ -295,21 +295,15 @@ static inline void raytrace_tile(uniform int x0, uniform int x1, uniform float widthScale = (float)(baseWidth) / (float)(width); uniform float heightScale = (float)(baseHeight) / (float)(height); -// foreach_tiled (y = y0 ... y1, x = x0 ... x1) - for (uniform int y = y0; y < y1; y++) - for (uniform int xb = x0; xb < x1; xb += programCount) + foreach_tiled (y = y0 ... y1, x = x0 ... x1) { - const int x = xb + programIndex; - Ray ray; - generateRay(raster2camera, camera2world, x*widthScale, y*heightScale, ray); - BVHIntersect(nodes, triangles, ray); + Ray ray; + generateRay(raster2camera, camera2world, x*widthScale, y*heightScale, ray); + BVHIntersect(nodes, triangles, ray); - int offset = y * width + x; - if (x < x1) - { - image[offset] = ray.maxt; - id[offset] = ray.hitId; - } + int offset = y * width + x; + image[offset] = ray.maxt; + id[offset] = ray.hitId; } }