Hi,
I am trying to use VoxelRayTracers.jl package to trace a ray through cubic voxels.
I want to improve the performance of ray tracing by reducing execution time because in my application I have to use many rays in three dimensions.
I wrote a simple example to show my case. I only used one ray
, but variable itr
represents number of rays. Then I have to sum traced voxel values in each ray.
using VoxelRayTracers
using BenchmarkTools
edges = (-2.0:0.1:2.0, -2.0:0.1:2.0)
ray = (position=[4.946152422706632, 3.433012701892219], velocity=[-0.8660254037844393,-0.5])
all_val = rand(41,41)
itr = 400000
function exit_data(ray, edges, val, itr)
for i in 1:itr
out = 0.0
for hit in eachtraversal(ray, edges)
out += val[hit.voxelindex]
end
end
end
I have checked execution time and memory allocation by using @btime
@btime exit_data($ray, $edges, $all_val, $itr)
and the result is as below:
710.617 ms (2949120 allocations: 145.00 MiB)
In my real case, I have more than 1.5M rays and points will be 3 dimensions… so, execution time and memory allocation will be very high… Moreover, I have to iterate this whole process more than 1000 times using another algorithm. So, can anyone suggest some ideas to improve performance in terms of execution time and memory allocation?