Skip to content
  • Allison Vacanti's avatar
    Ensure that Pair and Vec are trivial classes. · 4cd79193
    Allison Vacanti authored
    For std::copy to optimize a copy to memcpy, the valuetype must be both
    trivially constructable and trivially copyable.
    
    The new copy benchmarks highlighted an issue that std::copy'ing pairs
    and vecs were not optimized to memcpy. For a 256 MiB buffer on my
    laptop w/ GCC, the serial copy speeds were:
    
    UInt8:                 10.10 GiB/s
    Vec<UInt8, 2>           3.12 GiB/s
    Pair<UInt32, Float32>   6.92 GiB/s
    
    After this patch, the optimization occurs and a bitwise copy occurs:
    
    UInt8:                 10.12 GiB/s
    Vec<UInt8, 2>           9.66 GiB/s
    Pair<UInt32, Float32>   9.88 GiB/s
    
    Check were also added to the Vec and Pair unit tests to ensure that
    this classes continue to be trivial.
    
    The ArrayHandleSwizzle test was refactored a bit to eliminate a new
    'possibly uninitialized memory' warning introduced with the default
    Vec ctors.
    4cd79193