[riot-notifications] [RIOT-OS/RIOT] sys/atomic_utils: Functions for atomic access (#14331)

Marian Buschsieweke notifications at github.com
Wed Nov 4 09:52:45 CET 2020


On AVR the results are pretty stable. For e.g. atomic loads and stores I get some value between 50020 µs and 50084 µs for both atomic utils and C11 atomics all of the time. (So when they differ, it is due to noise - which makes sense, as the are implemented in the very same way.) So we should take all numbers below with an uncertainty of at least 64 µs.

Apart from that the only surprise is that volatile loads and stores perform slower than atomic loads and stores for word sized accesses. But everything else behaves as if it would be a text book result.

```
+------+----------+------+------------------+------------------+------------------+
| mode |       op | bits |         volatile |      atomic util |       c11 atomic |
+------+----------+------+------------------+------------------+------------------+
| atom |    store |    8 |         75096 µs |         50020 µs |         50084 µs |
| atom |    store |   16 |         87592 µs |         93836 µs |        206336 µs |
| atom |    store |   32 |         87592 µs |        118836 µs |        250152 µs |
| atom |    store |   64 |        137592 µs |        168900 µs |        368900 µs |
| atom |     load |    8 |         75092 µs |         50020 µs |         50020 µs |
| atom |     load |   16 |         87592 µs |         93836 µs |        187588 µs |
| atom |     load |   32 |         87532 µs |        118836 µs |        462780 µs |
| atom |     load |   64 |        137596 µs |        168904 µs |        275152 µs |
| atom |      add |    8 |        118780 µs |        100088 µs |        206404 µs |
| atom |      add |   16 |        100092 µs |        131336 µs |        256404 µs |
| atom |      add |   32 |        162592 µs |        193900 µs |        587780 µs |
| atom |      add |   64 |        381472 µs |        412716 µs |       1019288 µs |
| atom |      sub |    8 |        118840 µs |        100084 µs |        212584 µs |
| atom |      sub |   16 |        100096 µs |        131336 µs |        262648 µs |
| atom |      sub |   32 |        162592 µs |        193836 µs |        600348 µs |
| atom |      sub |   64 |        381408 µs |        412780 µs |       1019224 µs |
| atom |       or |    8 |        118844 µs |        100084 µs |        206336 µs |
| atom |       or |   16 |         93840 µs |        125084 µs |        256400 µs |
| atom |       or |   32 |        143840 µs |        175152 µs |        587784 µs |
| atom |       or |   64 |        243908 µs |        275148 µs |        687848 µs |
| atom |      xor |    8 |        118840 µs |        100020 µs |        206400 µs |
| atom |      xor |   16 |        100028 µs |        131336 µs |        256400 µs |
| atom |      xor |   32 |        150092 µs |        181400 µs |        587784 µs |
| atom |      xor |   64 |        243908 µs |        275148 µs |        687848 µs |
| atom |      and |    8 |        118840 µs |        100020 µs |        206400 µs |
| atom |      and |   16 |        100028 µs |        131336 µs |        256400 µs |
| atom |      and |   32 |        162596 µs |        193904 µs |        587780 µs |
| atom |      and |   64 |        243908 µs |        275152 µs |        687844 µs |
| atom |      set |    8 |        118844 µs |        100024 µs |        206400 µs |
| atom |      set |   16 |        143844 µs |        125088 µs |        243900 µs |
| atom |      set |   32 |        193908 µs |        175084 µs |        575280 µs |
| atom |      set |   64 |        243912 µs |        275152 µs |        675344 µs |
| atom |    clear |    8 |        118840 µs |        100088 µs |        200084 µs |
| atom |    clear |   16 |        143844 µs |        125088 µs |        243904 µs |
| atom |    clear |   32 |        193908 µs |        175084 µs |        581596 µs |
| atom |    clear |   64 |        243908 µs |        275152 µs |        675344 µs |
| semi |      add |    8 |        118844 µs |         68836 µs |        200084 µs |
| semi |      add |   16 |        100028 µs |        131336 µs |        256404 µs |
| semi |      add |   32 |        162592 µs |        193900 µs |        587780 µs |
| semi |      add |   64 |        381472 µs |        412716 µs |       1019292 µs |
| semi |      sub |    8 |        118844 µs |         68836 µs |        206336 µs |
| semi |      sub |   16 |        100092 µs |        131336 µs |        262652 µs |
| semi |      sub |   32 |        162592 µs |        193836 µs |        600348 µs |
| semi |      sub |   64 |        381412 µs |        412784 µs |       1019228 µs |
| semi |       or |    8 |        118844 µs |         68836 µs |        200084 µs |
| semi |       or |   16 |         93776 µs |        125084 µs |        256400 µs |
| semi |       or |   32 |        143844 µs |        175084 µs |        587844 µs |
| semi |       or |   64 |        243844 µs |        275216 µs |        687844 µs |
| semi |      xor |    8 |        118844 µs |         68836 µs |        200088 µs |
| semi |      xor |   16 |        100092 µs |        131336 µs |        256404 µs |
| semi |      xor |   32 |        150092 µs |        181336 µs |        587848 µs |
| semi |      xor |   64 |        243908 µs |        275152 µs |        687848 µs |
| semi |      and |    8 |        118844 µs |         68836 µs |        212584 µs |
| semi |      and |   16 |        100096 µs |        131336 µs |        256400 µs |
| semi |      and |   32 |        162596 µs |        193904 µs |        587780 µs |
| semi |      and |   64 |        243908 µs |        275152 µs |        687848 µs |
+------+----------+------+------------------+------------------+------------------+
```

Maybe we should add a gnuplot command stream output mode to our benchmarks? :laughing: I really would like to see those graphically :-)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/14331#issuecomment-721598794
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201104/9c4fd55e/attachment-0001.htm>


More information about the notifications mailing list