Artifacts Associated With Ticket 3567063fffffffff
Ticket change [c45e20bfb7] (rid 111839) by dgp on 2012-09-12 15:42:42:
- assignee initialized to: "mistachkin"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The unix implementation of Tcl threading support is built on the pthread library, and the routine pthread_create() is at the core of all Tcl thread creation on unix. pthread_create() documents how it manages the initialization of the floating point environment in the created thread: "The floating-point environment shall be inherited from the creating thread." This is a very useful default behavior for programs performing multi-threaded calculations, keeping all threads computing in a consistent way. Empirically, we do not see this desirable behavior from Tcl_CreateThread() on Windows. In particular, when the master thread is computing using 80-bit extended precision computations, all threads created by T_CT() do their computations using only the default 64-bit precision operations. Even code explicitly written using C "long double" variables gets only 64-bit precision function when run in a Tcl non-master thread. The consequence is that computed results are not portable. Tcl_CreateThread() takes an argument for a thread initialization procedure, so those programs that care about this detail have the ability to use that routine to workaround this problem. The disadvantage is that the code to query and set the floating point environment is a nonportable mess, depending on hardware and OS and compiler and other details. Coding a portable solution to forcing fp environment inheritence is a big, thorny problem. It's exactly the kind of portability chore that programs rely on the Tcl library to solve in other scenarios. It's a tall order, but I'd like it if Tcl_CreateThread() aimed at making the fp environment inheritance of pthread_create() a cross-platform feature as much as possible. - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "49. Threading"
- title initialized to: "portable Tcl_CreateThread inherit of fp settings"
- type initialized to: "RFE"
Ticket change [22a86398c1] (rid 130791) by mistachkin on 2012-09-12 23:45:46:
- icomment:
I'll investigate doing this for MinGW and MSVC. Do we need to support other compilers on Windows for this feature?
- login: "mistachkin"
- mimetype: "text/plain"
- username: "mistachkin"
- icomment:
Ticket change [94ca017fed] (rid 106057) by mistachkin on 2012-09-13 23:57:17:
- icomment:
I assume that these changes are targeted towards Tcl 8.4 and higher? Also, do you have any tests in the suite that demonstrate the floating point problem(s) with created threads?
- login: "mistachkin"
- mimetype: "text/plain"
- username: "mistachkin"
- icomment:
Ticket change [90c631e8d8] (rid 120508) by dgp on 2012-09-14 00:52:18:
- icomment:
I'll leave the extent of backporting to be determined later. Just getting something working on more platforms than pthreads is an improvement. Every additional port helps. MinGW + MSVC appears to take care of the vast majority of the issue. I'll see if I can collect something to demonstrate the issue from the original reporter. The problem happens on windows with programs built with gcc, then linked against Active Tcl libraries (built with MSVC). Since I don't work on windows myself, I don't have the demo programs at my fingertips.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [706d5300ab] (rid 100477) by mistachkin on 2012-09-14 02:47:32:
- icomment:
I think the code on the new Fossil branch "bug-3567063" will do what you need. Is there some way we can work on validating this?
- login: "mistachkin"
- mimetype: "text/plain"
- username: "mistachkin"
- icomment:
Ticket change [b96c151684] (rid 129138) by dgp on 2012-11-14 04:20:07:
- icomment:
merged to dev branches
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [ff5c45f539] (rid 132597) by jan.nijtmans on 2013-07-02 13:02:26:
- closedate changed to: "2456476.04336494"
- closer changed to: "jan.nijtmans"
- comment changed to:
The unix implementation of Tcl threading support is built on the pthread library, and the routine pthread_create() is at the core of all Tcl thread creation on unix. pthread_create() documents how it manages the initialization of the floating point environment in the created thread: "The floating-point environment shall be inherited from the creating thread." This is a very useful default behavior for programs performing multi-threaded calculations, keeping all threads computing in a consistent way. Empirically, we do not see this desirable behavior from Tcl_CreateThread() on Windows. In particular, when the master thread is computing using 80-bit extended precision computations, all threads created by T_CT() do their computations using only the default 64-bit precision operations. Even code explicitly written using C "long double" variables gets only 64-bit precision function when run in a Tcl non-master thread. The consequence is that computed results are not portable. Tcl_CreateThread() takes an argument for a thread initialization procedure, so those programs that care about this detail have the ability to use that routine to workaround this problem. The disadvantage is that the code to query and set the floating point environment is a nonportable mess, depending on hardware and OS and compiler and other details. Coding a portable solution to forcing fp environment inheritence is a big, thorny problem. It's exactly the kind of portability chore that programs rely on the Tcl library to solve in other scenarios. It's a tall order, but I'd like it if Tcl_CreateThread() aimed at making the fp environment inheritance of pthread_create() a cross-platform feature as much as possible. - icomment: "Already implemented in 8.6"
- login: "jan.nijtmans"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- severity changed to: "Minor"
- status changed to: "Closed"