Ignore:
Timestamp:
Aug 29, 2011, 7:02:47 PM (8 years ago)
Author:
sam
Message:

test: improve the benchmark code to measure a lot more half precision
number conversions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/half.cpp

    r873 r877  
    197197}
    198198
     199/* Constructor from float. Uses the non-branching version because benchmarks
     200 * indicate it is always twice as fast. The penalty of loading the lookup
     201 * tables does not seem important. */
    199202half half::makefast(float f)
    200203{
     
    203206}
    204207
     208/* Constructor from float with better precision. */
    205209half half::makeslow(float f)
    206210{
     
    209213}
    210214
     215/* Cast to float. Uses the branching version because loading the tables
     216 * for only one value is going to be cache-expensive. */
    211217half::operator float() const
    212218{
     219    /* FIXME: there is a hidden "this" in this method. Export more
     220     * code so that it can all work in registers instead. */
    213221    union { float f; uint32_t x; } u;
    214222    u.x = half_to_float_branch(bits);
     
    216224}
    217225
    218 size_t half::copy(half *dst, float const *src, size_t nelem)
     226size_t half::convert(half *dst, float const *src, size_t nelem)
    219227{
    220228    for (size_t i = 0; i < nelem; i++)
     
    228236}
    229237
    230 size_t half::copy(float *dst, half const *src, size_t nelem)
     238size_t half::convert(float *dst, half const *src, size_t nelem)
    231239{
    232240    for (size_t i = 0; i < nelem; i++)
Note: See TracChangeset for help on using the changeset viewer.