demo_example_replay not working

98 views
Skip to first unread message

James Dieffenderfer

unread,
Sep 15, 2020, 6:06:01 PM9/15/20
to mcx-users
Hello, 
I'm new to using MMCLAB and I'd like to do something very similar to the demo_example_replay file found in the example folder of mmclab.

When I run the example I get an output that says:
Progress: [==============================================================] 100%
kernel complete:  240 ms
retrieving flux ... detected 711 photons, total: 711 transfer complete:        252 ms
simulated 711 photons (711) with 1 devices (ray-tet 242223)
MCX simulation speed: 2.99 photon/ms
total simulated energy: 711.00 absorbed: 36.38608%
(loss due to initial specular reflection is excluded in the total)
done 681
replay failed :-(

Does anyone know why the replay is failing? I have added paths in matlab to mmclab, mmc, and iso2mesh and most of the other examples seem to work fine.

Any and all help is appreciated, 
James 

Fang, Qianqian

unread,
Sep 15, 2020, 6:24:39 PM9/15/20
to mcx-...@googlegroups.com

Hi James,

 

Thanks for reporting this  – I had indeed noticed this issue before announcing the release. This only happens when using OpenCL on the GPU. For the majority of the replay, it worked ok – meaning that all photons were able to retrace their paths in the baseline simulation, and became recaptured (please see the below message you attached: a total of 711 photons were replayed and all of them were “recaptured”, this is an indication that the replay mechanism is working).

 

What failed in this example originates from this line:

 

https://github.com/fangq/mmc/blob/master/mmclab/example/demo_example_replay.m#L64

 

where I compare the detected photon from original and replayed simulations, and expect them to be the same (up to 10 decimal places). What I found was that there is one photon fails to match its data up to the desired precision among 700 photons. I tested several other configurations and the difference remains to be 1 photon.

 

I have a feeling that this is related to the GPU precision when massively parallel threads are used. I am not yet able to step-by-step debug the failed photon, but I suspect it is mostly ok, but has a small floating-point round-off error.

 

If you set cfg.gpuid=-1 and use CPU based mmc, this error will go away (but of course, a lot slower).

 

I believe this is a minor issue, but I’ve created a ticket anyways to keep track of this problem until a fix is found.

 

https://github.com/fangq/mmc/issues/56

 

Qianqian

--
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcx-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/c3094949-e18e-42b9-9dbd-d4613b7e2654n%40googlegroups.com.

 

James Dieffenderfer

unread,
Sep 17, 2020, 8:24:27 PM9/17/20
to mcx-users
Hi Qianqian,
Thank you for the quick response!

I tried setting  cfg.gpuid=-1 in the beginning of the example and I'm getting this error:
The logical indices in position 2 contain a true value outside of the array bounds.

Error in demo_example_replay (line 52)
newcfg.seed=seeds.data(:,detp.data(1,:)==newcfg.replaydet);

Is there something else I need to set for it to use CPU based mmc?

Thank you again,
James

Fang, Qianqian

unread,
Sep 17, 2020, 10:24:50 PM9/17/20
to mcx-...@googlegroups.com, Shijie Yan

Hi James

 

Just want to you let you know that my student Shijie Yan had submitted a patch and fixed the error you initially reported when using OpenCL based mmclab, see

 

https://github.com/fangq/mmc/issues/56

 

I’ve also recompiled nightly build packages, please go to http://mcx.space/nightly/ to get the fixed mmclab.

 

For the issue that you reported below when gpuid=-1, I was also able to reproduce and will look into a fix for that as well.

Reply all
Reply to author
Forward
0 new messages