[med-svn] [Git][med-team/libatomic-queue][upstream] New upstream version 0.0+git20220518.83774a2

Étienne Mollier (@emollier) gitlab at salsa.debian.org
Fri Jul 1 17:48:02 BST 2022



Étienne Mollier pushed to branch upstream at Debian Med / libatomic-queue


Commits:
9911a904 by Étienne Mollier at 2022-07-01T18:24:16+02:00
New upstream version 0.0+git20220518.83774a2
- - - - -


3 changed files:

- README.md
- html/benchmarks.js
- include/atomic_queue/defs.h


Changes:

=====================================
README.md
=====================================
@@ -24,6 +24,8 @@ Available containers are:
 * `AtomicQueue2` - a fixed size ring-buffer for non-atomic elements.
 * `OptimistAtomicQueue2` - a faster fixed size ring-buffer for non-atomic elements which busy-waits when empty or full.
 
+In the above, _atomic elements_ are those, for which [`std::atomic<T>{T{}}.is_lock_free()`][10] returns `true`. In other words, the CPU can load, store and compare-and-exchange such elements atomically natively. On x86-64 such elements are all the [C++ standard arithmetic and pointer types][11].
+
 These containers have corresponding `AtomicQueueB`, `OptimistAtomicQueueB`, `AtomicQueueB2`, `OptimistAtomicQueueB2` versions where the buffer size is specified as an argument to the constructor.
 
 Totally ordered mode is supported. In this mode consumers receive messages in the same FIFO order the messages were posted. This mode is supported for `push` and `pop` functions, but for not the `try_` versions. On Intel x86 the totally ordered mode has 0 cost, as of 2019.
@@ -167,3 +169,5 @@ Copyright (c) 2019 Maxim Egorushkin. MIT License. See the full licence in file L
 [7]: https://man7.org/linux/man-pages/man2/perf_event_open.2.html
 [8]: https://github.com/torvalds/linux/blob/master/include/uapi/linux/hw_breakpoint.h
 [9]: https://stackoverflow.com/a/25168942/412080
+[10]: https://en.cppreference.com/w/cpp/atomic/atomic/is_lock_free
+[11]: https://en.cppreference.com/w/cpp/language/type


=====================================
html/benchmarks.js
=====================================
@@ -58,32 +58,30 @@ $(function() {
         const tooltips = []; // Build a tooltip once and then reuse it..
         const tooltip_formatter = function() {
             const threads = this.x;
-            let tooltip = tooltips[threads];
-            if(!tooltip) {
-                const data = [];
-                for(const p of this.points) {
-                    const stats = p.series.options.atomic_queue_stats[p.point.index];
-                    data[p.series.options.index] = {
-                        name: p.series.name,
-                        color: p.series.color,
-                        min: Highcharts.numberFormat(stats[1], 0),
-                        max: Highcharts.numberFormat(stats[2], 0),
-                        mean: Highcharts.numberFormat(stats[3], 0),
-                        stdev: Highcharts.numberFormat(stats[4], 0)
-                    };
-                }
-
-                let html = `<span class="tooltip_scalability_title">${threads} producers, ${threads} consumers</span>`;
-                html += '<table class="tooltip_scalability"><tr><th></th><th>mean</th><th>stdev</th><th>min</th><th>max</th></tr>';
-                for(const d of data)
-                    if(d)
-                        html += `<tr><td style="color: ${d.color}">${d.name}: </td><td><strong>${d.mean}</strong></td><td><strong>${d.stdev}</strong></td><td>${d.min}</td><td>${d.max}</td></tr>`;
-                html += '</table>';
+            const tooltip = tooltips[threads];
+            if(tooltip)
+                return tooltip;
 
-                tooltip = html;
-                tooltips[threads] = tooltip;
+            const data = [];
+            for(const p of this.points) {
+                const stats = p.series.options.atomic_queue_stats[p.point.index];
+                data[p.series.options.index] = {
+                    name: p.series.name,
+                    color: p.series.color,
+                    min: Highcharts.numberFormat(stats[1], 0),
+                    max: Highcharts.numberFormat(stats[2], 0),
+                    mean: Highcharts.numberFormat(stats[3], 0),
+                    stdev: Highcharts.numberFormat(stats[4], 0)
+                };
             }
-            return tooltip;
+            const tbody = data.reduce((s, d) => d ? s + `<tr><td style="color: ${d.color}">${d.name}: </td><td><strong>${d.mean}</strong></td><td><strong>${d.stdev}</strong></td><td>${d.min}</td><td>${d.max}</td></tr>` : s, "");
+            return tooltips[threads] = `
+                <span class="tooltip_scalability_title">${threads} producers, ${threads} consumers</span>
+                <table class="tooltip_scalability">
+                <tr><th></th><th>mean</th><th>stdev</th><th>min</th><th>max</th></tr>
+                ${tbody}
+                </table>
+                `;
         }
 
         const chart = Highcharts.chart(div_id, {
@@ -125,8 +123,8 @@ $(function() {
                 atomic_queue_stats: stats
             };
         });
-        series.sort((a, b) => { return a.index - b.index; });
-        const categories = series.map(s => { return s.name; });
+        series.sort((a, b) => a.index - b.index);
+        const categories = series.map(s => s.name);
 
         const tooltip_formatter = function() {
             const stats = this.series.options.atomic_queue_stats;


=====================================
include/atomic_queue/defs.h
=====================================
@@ -47,6 +47,13 @@ namespace atomic_queue {
 constexpr int CACHE_LINE_SIZE = 256; // TODO: Review that this is the correct value.
 static inline void spin_loop_pause() noexcept {} // TODO: Find the right instruction to use here, if any.
 } // namespace atomic_queue
+#elif defined(__riscv)
+namespace atomic_queue {
+constexpr int CACHE_LINE_SIZE = 64;
+static inline void spin_loop_pause() noexcept {
+    asm volatile (".insn i 0x0F, 0, x0, x0, 0x010");
+}
+} // namespace atomic_queue
 #else
 #warning "Unknown CPU architecture. Using L1 cache line size of 64 bytes and no spinloop pause instruction."
 namespace atomic_queue {



View it on GitLab: https://salsa.debian.org/med-team/libatomic-queue/-/commit/9911a9046b02317145f11e9fd6e1e2955d184e1f

-- 
View it on GitLab: https://salsa.debian.org/med-team/libatomic-queue/-/commit/9911a9046b02317145f11e9fd6e1e2955d184e1f
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20220701/0e38e848/attachment-0001.htm>


More information about the debian-med-commit mailing list