Refactor spinlock_test and atomic_test, primarily to add command-line arguments 
that allow for multiple time trials and "wedges" over many thread counts.  For 
example,

    $ build/macosx/libOpenImageIO/spinlock_test --trials 3 --threads 32 --wedge

results in this output:

    threads     time (best of 3)
    -------     ----------
     1      1.2s          1.2s, range 0.0       (160000000 iters/thread)
     2      1.8s          1.8s, range 0.1       (80000000 iters/thread)
     4      2.5s          2.5s, range 0.1       (40000000 iters/thread)
     8      2.4s          2.4s, range 0.0       (20000000 iters/thread)
    12      2.4s          2.4s, range 0.1       (13333333 iters/thread)
    16      2.4s          2.4s, range 0.1       (10000000 iters/thread)
    20      2.1s          2.1s, range 0.3       (8000000 iters/thread)
    24      2.4s          2.4s, range 0.0       (6666666 iters/thread)
    28      2.2s          2.2s, range 0.3       (5714285 iters/thread)
    32      2.4s          2.4s, range 0.1       (5000000 iters/thread)

Of couse, with no command-line arguments, it just tries one test with 16 
threads, as it always did, for the sake of the unit tests (it has various 
assertions to verify that the spinlocks are working correctly).  Same kind of 
thing for atomic_test.

Added a time_trial template to timer.h to help with such things.

New test: spin_rw_test, is like spinlock_test, but it tests the spin_rw_mutex 
class (reader/writer class), because I was worried about its correctness and 
speed.  (Worked fine, BTW.)

Finally, I add some macros to sysutil.h that make it easy to align things to 
cache lines. (Currently works for all x86 and x86_64, may require more cases if 
porting to other hardware architectures.)  I don't use these anywhere quite yet 
(in reviewed or checked in code), but intend to use them in the future for some 
additional threading improvements I'm working on.




You can merge this Pull Request by running:

  git pull https://github.com/lgritz/oiio lg-threadtests

Or you can view, comment on it, or merge it online at:

  https://github.com/OpenImageIO/oiio/pull/382

-- Commit Summary --

* Handy time_trial template runs function n times, reports best time and range.
* atomic_test and spinlock_test: add multiple time trials, wedges of 
numthreads, and other refactoring.
* New spin_rw_test: test and times spin_rw_mutex.
* Macros for memory and cache alignment

-- File Changes --

M src/include/sysutil.h (24)
M src/include/timer.h (26)
M src/libOpenImageIO/CMakeLists.txt (4)
M src/libOpenImageIO/atomic_test.cpp (102)
A src/libOpenImageIO/spin_rw_test.cpp (162)
M src/libOpenImageIO/spinlock_test.cpp (53)

-- Patch Links --

  https://github.com/OpenImageIO/oiio/pull/382.patch
  https://github.com/OpenImageIO/oiio/pull/382.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenImageIO/oiio/pull/382
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to