Compiler settings
THOR builds with a SYCL compiler that targets CPUs and GPUs across vendors: AdaptiveCpp, the primary development target, or the Intel oneAPI DPC++/C++ Compiler. Newer features may reach oneAPI later.
Choosing a SYCL compiler
For installation, see AdaptiveCpp or Intel oneAPI.
./build.sh selects the compiler: AdaptiveCpp (acpp on PATH) by default, or
Intel oneAPI with --intel (see below). For a direct CMake build, set
CXX=acpp or CXX=icpx before configuring.
AdaptiveCpp target selection
SYCL kernels are compiled either at build time (ahead of time, AOT) or when they
first run (just in time, JIT). THOR uses AdaptiveCpp's generic target, which
compiles kernels just in time:
| Target | Build | Devices | Kernel compilation |
|---|---|---|---|
generic (default) |
./build.sh |
CPU and GPU | At first kernel launch (JIT) |
omp |
./build.sh --omp |
CPU only | At build time (AOT) |
With generic, one build serves CPU and GPU; the YAML device: key and
ACPP_VISIBILITY_MASK choose the backend at run time. JIT also avoids building
THOR's many kernel variants ahead of time and folds runtime constants into the
compiled kernels. ./build.sh passes the target to CMake as ACPP_TARGETS (see
the AdaptiveCpp compilation docs).
On CPUs, THOR launches its transport, peeling and ray-tracing kernels with one work-item per work-group. AdaptiveCpp's JIT compiles one kernel variant per work-group size, so a fixed size means each kernel is compiled once per run instead of again for every new photon batch size. This is automatic and does not affect GPU runs. Individual Monte Carlo histories can change with scheduling, so compare results within scientific tolerances.
The first launch of each kernel includes its JIT compilation, which can take
minutes for the largest kernels on CPUs. AdaptiveCpp caches compiled kernels
under ~/.acpp (or $XDG_DATA_HOME/acpp); set ACPP_APPDB_DIR to move the
cache. Later runs with the same executable, device and simulation settings reuse
the cached kernels. On clusters, keeping the cache on a persistent filesystem lets
later jobs skip the compilation.
On the OpenMP backend, THOR's generic executable defaults to
ACPP_JITOPT_HOST_INLINING_POLICY=llvm to reduce JIT compilation time.
Set ACPP_JITOPT_HOST_INLINING_POLICY=force to select AdaptiveCpp's
forced-inlining policy. With Apptainer, pass the setting through --env.
Changing the policy can change floating-point results and uses separate JIT cache
entries.
On Linux, AdaptiveCpp generic builds select the linker for thor at
configure time. Set THOR_USE_LLD to choose the behavior.
AUTO(default) uses LLD when the link check passes and the compiler's default linker otherwise. An explicitCMAKE_LINKER_TYPEtakes precedence.ONrequires LLD.OFFuses the compiler's default linker.
If the final link fails, retry with the default linker and reuse the compiled objects.
Avoid other targets:
generic;omphas no benefit overgeneric, and such builds have compiled cleanly but failed on GPUs at kernel launch withUnresolved extern function ....- Hardware-specific targets such as
cuda:sm_XXorcuda.explicit-multipassgive up the single build for all devices.
Share ccache across worktrees
On the same machine, Release/generic builds in different worktrees can share cached compiler outputs when their inputs and relative build layouts match. Run this from each worktree root with ccache 4.5 or newer:
Each worktree keeps its own build directory. The flag sets a per-worktree
source root for path normalization and uses the existing ccache directory
with a namespace derived from the active compiler toolchain. Use a clean
build after changing the installed toolchain so the build system recompiles
existing objects. Apply the flag each time you invoke build.sh for this mode.
CPU vector instructions and frequency
Measure sustained CPU frequency and wall time on a representative run with the default CPU target. If clocks drop during vector-heavy work, try a lower instruction-set cap such as AVX2. Compare at the same core count and keep the cap if it reduces wall time.
On a Skylake Xeon, capping the Intel OpenCL JIT at AVX2 cut wall time for THOR in a Neufeld sphere regression test by 25%.
Some Intel Xeon processors apply instruction-dependent turbo limits. AMD EPYC boost depends on the workload, active cores, and power budget. Intel vector frequency guide AMD EPYC power management
Intel oneAPI
Build and run with oneAPI through ./build.sh --intel, which keeps its build
directory (cmake-build-release-intel) separate from AdaptiveCpp builds:
printf 'debugger=exclude\n' > /tmp/thor-oneapi.conf
source /opt/intel/oneapi/setvars.sh --config=/tmp/thor-oneapi.conf
./build.sh --intel --cmake-arg -DTHOR_OPTIMIZE_ARCHITECTURE=OFF
ONEAPI_DEVICE_SELECTOR=opencl:cpu ./cmake-build-release-intel/src/thor config.yaml
- Use
device: cpuin the YAML for the OpenCL CPU runtime. On supported GPUs, select the installed oneAPI GPU backend and usedevice: gpu; GPU support depends on the installed driver and runtime. - oneDPL is required, also without the PointCloud backend. CMake finds it
through
DPL_ROOTorONEAPI_ROOT; for a separate installation, pass--cmake-arg -DoneDPL_DIR=/path/to/lib/cmake/oneDPL. THOR_OPTIMIZE_ARCHITECTURE=OFFavoids-xHost, whose executables do not run on AMD CPUs.- The setvars configuration excludes the debugger component, whose bundled
yaml-cppcan override THOR's throughLD_LIBRARY_PATH(see Intel's setvars configuration documentation). --intelcannot be combined with--ompor--generic.- Kernels are compiled just in time by default, as with AdaptiveCpp's
generictarget. - For Intel OpenCL CPU runs, set
CL_CONFIG_CPU_TARGET_ARCH=core-avx2at launch to compare against a JIT target capped at AVX2. See CPU vector instructions and frequency.
Debug builds
Intel Debug builds keep full host debug information and source line tables for
device kernels, which limits executable size and build time while retaining
-O0 and per-kernel splitting. To inspect kernel-local variables and types,
enable full device debugging:
This can produce multi-gigabyte executables and much longer builds; on Linux it also enables Intel's large-device-image linker layout. The option affects only Intel Debug builds and is off by default.
Floating-point semantics
THOR builds with -O3 -fno-fast-math. It needs NaN and infinity handling for
validation, field masks, range reductions and sentinels; FMA contraction is
allowed. Do not add -ffast-math or -Ofast, even followed by -fno-fast-math:
some AdaptiveCpp versions keep JIT fast-math enabled in that combination.
CMake rejects fast-math and finite-only options, for example -ffast-math,
-Ofast, -ffp-model=fast or aggressive, and AdaptiveCpp's fast-math
kernel option. It checks CMAKE_CXX_FLAGS and its per-configuration and _INIT
variants, CMAKE_CXX_FLAGS_FORCE, THOR_CXX_FLAGS, and CXXFLAGS when CMake
initializes from it, including options forwarded through -Xclang= or
-mllvm=. It cannot inspect compiler wrappers, response files, target options
or external JIT options; those must keep NaN and infinity handling too.
Run the checks with:
./build.sh --omp --target thor_floating_point_smoke
ACPP_VISIBILITY_MASK=omp ./cmake-build-release-omp/tests/thor_floating_point_smoke
./build.sh --generic --target thor_floating_point_smoke
ACPP_VISIBILITY_MASK=omp ./cmake-build-release-generic/tests/thor_floating_point_smoke
python3 scripts/tests/test_floating_point_flags.py
On a CUDA host, also run the generic smoke test with ACPP_VISIBILITY_MASK=cuda.
The smoke test compiles with production flags and checks finite, infinite and NaN
values in float and double on the host and the selected device, skipping device
double without FP64 support. Both checks also run under CTest; the flag tests
need Python.