source: benchmark/tls-fetch_add.c @ 7a8f5246

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 7a8f5246 was 7a8f5246, checked in by tdelisle <tdelisle@…>, 5 years ago

Added benchmark for relaxed atomic store to tls

  • Property mode set to 100644
File size: 528 bytes
Line 
1#include <stdbool.h>
2#include <stdio.h>
3
4#include "bench.h"
5
6#define thread_local _Thread_local
7
8volatile thread_local bool value;
9
10void __attribute__((noinline)) do_call() {
11        __atomic_store_n( &value, true, __ATOMIC_RELAXED );
12        __atomic_signal_fence(__ATOMIC_ACQUIRE);
13        asm volatile ("");
14        __atomic_store_n( &value, false, __ATOMIC_RELAXED );
15        __atomic_signal_fence(__ATOMIC_RELEASE);
16}
17
18int main(int argc, char* argv[]) {
19        BENCH(
20                for (size_t i = 0; i < n; i++) {
21                        do_call();
22                },
23                result
24        )
25
26        printf("%llu\n", result);
27}
Note: See TracBrowser for help on using the repository browser.