Commit d736f872 authored by Guilherme Lima's avatar Guilherme Lima 😬
Browse files

[VECGEOM-578] Fix an FP comparison that was failing on the GPU

The same condition was returning different results in CPU vs. GPU.
As a result, a CMS polycone was getting an extra 0-length ZSection
on the GPU, which was later causing discrepancies in the CPU vs. GPU
tracking.

Adding a tolerance parameter to the FP comparison fixed the divergence.
parent b8c28bab
......@@ -237,7 +237,9 @@ struct PolyconeStruct {
// i has to be at least one to complete a section
if (i > 0) {
if (((z > prevZ) && (dirZ > 0)) || ((z < prevZ) && (dirZ < 0))) {
// GL: I had to add kTolerance here, otherwise this polycone would get an
// extra 0-length ZSection on the GPU -- see VECGEOM-578
if (((z > prevZ + kTolerance) && (dirZ > 0)) || ((z < prevZ - kTolerance) && (dirZ < 0))) {
if (dirZ * (z - prevZ) < 0) {
#ifndef VECCORE_CUDA
std::cerr << "Cannot create a Polycone with different Z directions.Use GenericPolycone." << std::endl
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment