GPU/CPU Differences

When running a same simulation, you may face differences between GPU and CPU results. This may be due to different reasons. This page is dedicated to present the behavior difference between CPU and GPU, and the possible good practice to get equivalent results if there are any.

Radiance Sensor and Ray File Case

When the Ray File source is set exactly on the plane of the Radiance sensor frame, some rays may be generated inside the Radiance sensor, and some rays outside. This creates a difference in the rays integration between CPU and GPU simulations:
  • In CPU, the CPU does not integrate the rays of a Ray File source which start inside the Radiance sensor (meaning between the frame and the observer point).
  • In GPU, the GPU does integrate the rays of a Ray File source which start inside the Radiance sensor (meaning between the frame and the observer point).

Ray tracer precision

The Ray tracer precision use differs between CPU simulations and GPU simulations:
  • On CPU, you can set the Ray tracer precision to Automatic, Double, or Single.
  • On GPU, you can only set the Ray tracer precision to Single.

Propagation Errors Case

Behavior: Irradiance Sensor

For more information on the different propagation errors, refer to Understanding the Propagation Errors.

Summary: A ray intersecting the sensor is always integrated on GPU result, whereas a ray intersecting the sensor is never integrated on CPU result if it has encountered a propagation error.

On GPU, a ray is integrated into the Irradiance Sensor as soon as it hits the sensor.
  • If the ray has encountered a propagation error (before or after the sensor), the ray is integrated into the sensor.
  • If the ray has not encountered a propagation error, the ray is integrated into the sensor.
On CPU, the full ray is propagated, then Speos parses the ray trace to know if it has intersected the sensor:
  • If the ray has encountered a propagation error (before or after the sensor), the ray is not integrated into the sensor.
  • If the ray has not encountered a propagation error, the ray is integrated into the sensor.

Good Practice

Reduce the propagation errors for the CPU Simulation to get nearly the same result as the GPU Simulation, by reducing the Geometrical Distance Tolerance.

Maximum Number of Surface Interaction Case

  • On GPU, when a ray is stopped by the Maximum number of surface interaction option, if the ray is stopped after the intersection with the sensor, it will be integrated on the sensor.
  • On CPU, when a ray is stopped by the Maximum number of surface interaction option, if the ray is stopped after the intersection with the sensor, it will not be integrated on the sensor.

Project Origin Case

In small systems shifted from the Speos origin, some differences can appear between CPU and GPU results.

To reduce the differences, make sure to position the system as close as possible to the Speos origin.

Output Faces Case

In simulation:
  • In CPU, for each pixel per pass, if the ray emitted by the CPU does not intersect an output face, the CPU will emit again a ray until the ray intersects an output face.
  • In GPU, for each pixel per pass, the GPU emits one ray whatever it intersects or not an output face. GPU does not emit again if the ray does not intersect an output face.

That means, for a same number of pass, CPU does converge better than GPU. To get the same result on GPU, you need to increase the number of pass.

Stop Conditions: On Number of Passes Limit

For more information on the option, refer to Creating an Inverse Simulation.

In case of a GPU simulation, the number of passes defined corresponds to the minimum threshold of rays received per pixel. That means while a pixel has not received this minimum number of rays, the simulation still runs.

If you activated the dispersion, this minimum threshold is multiplied by the sensor sampling. That means for a number of pass of 100 and a sampling of 13, each pixel will need to receive at least 1300 rays (the progress of the number of rays per pixel is indicated in the Simulation Progress Bar).

In case of a CPU simulation, the number of pass, there is no minimum threshold of rays to be received per pixel, the simulation stops when the number of pass is reached.

Dispersion Calculation Case

For information on the Dispersion case, refer directly to Dispersion.

Ray File Reading Algorithm

In case of a GPU Simulation: read rays from file are checked at simulation initialization. The Ray file validity is checked and you are notified if the ray file is corrupted with a warning message. If a corrupted ray file is used, it could lead to biased results because rays are not rechecked at simulation run.

In case of a CPU Simulation: rays are checked when simulation is running. No warning message is displayed if the Ray file is corrupted. If a corrupted ray file is used, it could lead to biased results.

Surface Source with Exit Geometries

In case of a CPU Simulation: rays from the Exit Geometries are only propagated forward according to the emitted rays from the Surface Source.

In case of a GPU Simulation: rays from the Exit Geometries can be propagated forward and backwards