-
Notifications
You must be signed in to change notification settings - Fork 26
Fixes the data race in raytracing (#203) #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The function extractFace() was written to return a pointer to a faceType struct. The return value was copied from a local variable which I had made static to avoid compiler warnings. However of course static variables are shared over threads, so this was causing a data race condition. I fixed this by having the function return a faceType struct directly rather than a pointer to one. That allows me to avoid the static declaration inside the function.
In raytrace, a recent change clamped all the rays on the circle of the projected model boundary to zero. This had been done within the parallel block however which gave rise to a data race. The clamp has now been moved outside the parallel block.
|
Maybe there are some dangling pointers from earlier parts which then confuse valgrind? Does memcheck complain about anything? On the other hand spurious error messages are not unheard of. If you run with -DTEST a few times, are the results identical on bit-level? If so, there's probably no error. BTW, it could be worth looking at parallelising the (unparallelised) regions that drd complained about. At least that interpolation part sometimes takes a non-negligible amount of time. (There's also a cosmetic issue that the progress bar/percentage doesn't take into account time spent there, so it may get stuck at near 100% for a while.) |
No.
Yes.
Maybe later - for now I just want to fix #203 and issue a patch. |
Oops - I looked too quick. There are zero errors, but there are some leaks. Probably unrelated to the drd problem, but I'll fix them anyway. |
|
Not related to drd warnings, but something I noticed when I was looking at the code: what is xySquared (starting from line 999 of raytrace.c) used for? Nothing, it seems... |
|
Hmm yeah, seems like fossilized code. I'll nix it. |
|
If the drd problems still remain, they could maybe be related to some dangling pointers confusing valgrind (it seems generally pointers are not NULLed in LIME after freeing). I might have a look at this later, but in my opinion you could merge this PR. |
I should make the caveat that the valgrind tool DRD still reports problems; however since these all occur outside the parallel section of raytrace.c, I don't understand what is going on. I attach the log file. Any ideas @tlunttil, or anybody else?
dlog.txt
To generate this I did
BTW I was not able to squash the 'Minor' commit message via rebasing. Git seems to get confused after a merge.