• Show log

    Commit

  • Hash : 4e028ecd
    Author : DRC
    Date : 2023-02-02T08:55:37

    SIMD/x86: Initialize simd_support before every use
    
    As long as a libjpeg instance is only used by one thread at a time, a
    program is technically within its rights to call jpeg_start_*compress()
    in one thread and jpeg_(read|write)_*(), with the same libjpeg instance,
    in a second thread.  However, because the various jsimd_can*() functions
    are called within the body of jpeg_start_*compress() and simd_support is
    now thread-local (due to f579cc11b33e5bfeb9931e37cc74b4a33c95d2e6), that
    led to a situation in which simd_support was initialized in the first
    thread but not the second.  The uninitialized value of simd_support is
    0xFFFFFFFF, which the second thread interpreted to mean that it could
    use any instruction set, and when it attempted to use AVX2 instructions
    on a CPU that didn't support them, an illegal instruction error
    occurred.
    
    This issue was known to affect libvips.
    
    This commit modifies the i386 and x86-64 SIMD dispatchers so that the
    various jsimd_*() functions always call init_simd(), if simd_support is
    uninitialized, prior to dispatching based on the value of simd_support.
    Note that the other SIMD dispatchers don't need this, because only the
    x86 SIMD extensions currently support multiple instruction sets.
    
    This patch has been verified to be performance-neutral to within
    +/- 0.4% with 32-bit and 64-bit code running on a 2.8 GHz Intel Xeon
    W3530 and a 3.6 GHz Intel Xeon W2123.
    
    Fixes #649
    

  • Properties

  • Git HTTP https://git.kmx.io/kc3-lang/libjpeg-turbo.git
    Git SSH git@git.kmx.io:kc3-lang/libjpeg-turbo.git
    Public access ? public
    Description

    Fork of libjpeg with SIMD

    Users
    thodg_m kc3_lang_org thodg_w www_kmx_io thodg_l thodg
    Tags