http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46447

           Summary: std::atomic_flag slower than std::atomic_uchar
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: kyle.kloep...@riverbed.com


It seems to me that the operations for atomic_flag could be reimplemented with
an atomic_uchar. However it looks as though a atomic_uchar performs those
operations faster.

atomic_flag::test_and_set() took 24.0051 cycles (averaged over 10000 trials)
atomic_flag::clear() took 17.0037 cycles (averaged over 10000 trials)
atomic_int::operator|=(1) took 20.0046 cycles (averaged over 10000 trials)
atomic_int::operator=(0) took 10.2529 cycles (averaged over 10000 trials)
atomic_uchar::operator|=(1) took 20.0053 cycles (averaged over 10000 trials)
atomic_uchar::operator=(0) took 10.2522 cycles (averaged over 10000 trials)
sizeof(aint) = 4 sizeof(auchar) = 1 sizeof(std::atomic_flag) = 1

Reply via email to