BNLNPPS / esi-g4ox

0 stars 0 forks source link

Comparing photon states produced with CPU and GPU pipelines #30

Open plexoos opened 1 week ago

plexoos commented 1 week ago

Example command:

build/src/simg4ox -g esi-g4ox/geom/raindrop.gdml -m esi-g4ox/run.mac

Assuming the environment variables:

export TMP=/tmp/myname
export GEOM=mygeom
export OPTICKS_EVENT_MODE=DebugHeavy

the output is saved to /tmp/myname/GEOM/mygeom/simg4ox/ALL0/

import opticks.sysrap.sevt as s
a = s.SEvt.Load("/tmp/myname/GEOM/mygeom/simg4ox/ALL0/A000/")
b = s.SEvt.Load("/tmp/myname/GEOM/mygeom/simg4ox/ALL0/B000/")
a.f.record
b.f.record

Issue: Initial photon states are not included in the CPU output (?)

plexoos commented 1 week ago

I think we should have a test comparing the CPU and GPU outputs. It would help significantly with debugging and refactoring.

In [16]: np.allclose(a.f.record[0,1:4], b.f.record[0,0:3])
Out[16]: True

In [17]: (a.f.record[0,1:4] == b.f.record[0,0:3]).all()
Out[17]: False
buddhasystem commented 1 week ago

I think we should have a test comparing the CPU and GPU outputs. It would help significantly with debugging and refactoring.

In [16]: np.allclose(a.f.record[0,1:4], b.f.record[0,0:3])
Out[16]: True

In [17]: (a.f.record[0,1:4] == b.f.record[0,0:3]).all()
Out[17]: False

Do you expect absolute precision? There are Python methods that allow you to define the precision in tests like this one.

plexoos commented 1 week ago

No, I don't expect identical results for floating point numbers. The numpy's allclose function has reasonable defaults but can be tweaked if necessary.

buddhasystem commented 1 week ago

Right on...

plexoos commented 1 week ago

A test comparing photon states produced with CPU and GPU pipelines is implemented in #31 8 out of 100 photons have different histories but the values seem to be reproducible.