Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ff5c45f53954db22e37f68a8c06b0be68dc8ac16
Ticket: 3567063fffffffffffffffffffffffffffffffff
portable Tcl_CreateThread inherit of fp settings
User & Date: jan.nijtmans on 2013-07-02 13:02:26
Changes

  1. closedate changed to: "2456476.04336494"
  2. closer changed to: "jan.nijtmans"
  3. 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.
    
  4. icomment: "Already implemented in 8.6"
  5. login: "jan.nijtmans"
  6. mimetype: "text/plain"
  7. resolution changed to: "Fixed"
  8. severity changed to: "Minor"
  9. status changed to: "Closed"