Skip to content

Commit 6a99fcc

Browse files
authored
Use _Atomic instead of volatile for thread safety where C11 is supported
Suggested by dodomorandi in #660
1 parent 0ab5bf1 commit 6a99fcc

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

driver/level3/level3_gemm3m_thread.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@
9191
#endif
9292

9393
typedef struct {
94-
volatile BLASLONG working[MAX_CPU_NUMBER][CACHE_LINE_SIZE * DIVIDE_RATE];
94+
#if _STDC_VERSION__ >= 201112L
95+
_Atomic
96+
#else
97+
volatile
98+
#endif
99+
BLASLONG working[MAX_CPU_NUMBER][CACHE_LINE_SIZE * DIVIDE_RATE];
95100
} job_t;
96101

97102

driver/level3/level3_syrk_threaded.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@
6767
#endif
6868

6969
typedef struct {
70-
volatile BLASLONG working[MAX_CPU_NUMBER][CACHE_LINE_SIZE * DIVIDE_RATE];
70+
#if _STDC_VERSION__ >= 201112L
71+
_Atomic
72+
#else
73+
volatile
74+
#endif
75+
BLASLONG working[MAX_CPU_NUMBER][CACHE_LINE_SIZE * DIVIDE_RATE];
7176
} job_t;
7277

7378

driver/level3/level3_thread.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@
9191
#endif
9292

9393
typedef struct {
94-
volatile BLASLONG working[MAX_CPU_NUMBER][CACHE_LINE_SIZE * DIVIDE_RATE];
94+
#if _STDC_VERSION__ >= 201112L
95+
_Atomic
96+
#else
97+
volatile
98+
#endif
99+
BLASLONG working[MAX_CPU_NUMBER][CACHE_LINE_SIZE * DIVIDE_RATE];
95100
} job_t;
96101

97102

0 commit comments

Comments
 (0)