Skip to content

v1.4.0 — GPU-accelerated ray tracing with OpenCL

Choose a tag to compare

@dccote dccote released this 01 Mar 02:31
· 41 commits to master since this release
48b40df

What's New in v1.4.0

GPU-accelerated ray tracing with OpenCL

Trace 100k–1M+ rays through optical systems with 10–100x speedup using your GPU.

  • traceMany() automatically uses the GPU when available, and silently falls back to native Python if OpenCL is not installed or no GPU is found
  • traceManyOpenCL() provides direct GPU access with clear error messages if pyopencl is missing
  • traceManyNative() is the explicit CPU-only path

Compact ray storage for GPU transfer

  • CompactRays: flat numpy structured array (24 bytes/ray) for efficient CPU↔GPU transfer
  • CompactRay: lightweight view into the shared buffer with the same API as Ray
  • Vectorized yValues/thetaValues properties (~100x faster than iteration)
  • Vectorized fillWithRandomUniform() (~85x faster than Python loop)

New trace result classes

  • RayTrace / RayTraces: unified interface for trace results with lastRay / lastRays properties
  • CompactRaytrace / CompactRaytraces: GPU-optimized equivalents

Other improvements

  • Graceful handling of missing pyopencl, tkinter, and mytk dependencies
  • Thorlabs lens catalog merged and consolidated (thorlabs.py)
  • Fixed ABCD matrix multiplication bug in OpenCL kernel
  • Fixed maxCount bug and duplicate entry ray in MatrixGroup.trace()
  • Added Sphinx documentation for OpenCL at raytracing.readthedocs.io
  • 675 tests passing

Installation

pip install raytracing==1.4.0

# Optional: for GPU acceleration
pip install pyopencl

Quick example

from raytracing import *

path = ImagingPath()
path.append(Space(d=50))
path.append(Lens(f=50, diameter=25))
path.append(Space(d=120))

rays = CompactRays(100000)
rays.fillWithRandomUniform(-10, 10, -0.1, 0.1)

traces = path.traceMany(rays)  # Uses GPU if available