From 897794c16903725500508c4368a272655e7ab47d Mon Sep 17 00:00:00 2001 From: khizmax Date: Fri, 5 Jun 2015 12:26:46 +0300 Subject: [PATCH] Added total-relaxed memory model for testing purposes --- cds/opt/options.h | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/cds/opt/options.h b/cds/opt/options.h index 9c8d208d..4df72745 100644 --- a/cds/opt/options.h +++ b/cds/opt/options.h @@ -548,16 +548,16 @@ namespace opt { /// [type-option] Option setter for C++ memory model /** The cds library supports following memory ordering constraints for atomic operations in container implementation: - - v::relaxed_ordering - relaxed C++ memory model. This mode supports full set of memory ordering constraints: + - \p v::relaxed_ordering - relaxed C++ memory model. This mode supports full set of memory ordering constraints: \p memory_order_relaxed, \p memory_order_acquire, \p memory_order_release and so on. - - v::sequential_consistent - sequentially consistent C++ memory model (default memory ordering for C++). In + - \p v::sequential_consistent - sequentially consistent C++ memory model (default memory ordering for C++). In this mode any memory ordering constraint maps to \p memory_order_seq_cst. - The \p Type template parameter can be v::relaxed_ordering or v::sequential_consistent. + The \p Type template parameter can be \p v::relaxed_ordering or \p v::sequential_consistent. You may mix different memory ordering options for different containers: one declare as sequentially consistent, another declare as relaxed. - Usually, v::relaxed_ordering is the default memory ordering for cds containers. + Usually, \p v::relaxed_ordering is the default memory ordering for libcds containers. */ template struct memory_model { @@ -572,14 +572,13 @@ namespace opt { namespace v { /// Relaxed memory ordering model /** - In this memory model the memory constraints are defined according to C++ Memory Model specification. + In this memory model the memory constraints are defined according to C++ Memory Model specification: + each constraint is mapped to \p std::memory_order constraints one-to-one - See opt::memory_model for explanations + See \p opt::memory_model for explanations */ struct relaxed_ordering { //@cond - - // For new C++11 (cds-1.1.0) static const atomics::memory_order memory_order_relaxed = atomics::memory_order_relaxed; static const atomics::memory_order memory_order_consume = atomics::memory_order_consume; static const atomics::memory_order memory_order_acquire = atomics::memory_order_acquire; @@ -593,12 +592,10 @@ namespace opt { /** In this memory model any memory constraint is equivalent to \p memory_order_seq_cst. - See opt::memory_model for explanations + See \p opt::memory_model for explanations */ struct sequential_consistent { //@cond - - // For new C++11 (cds-1.1.0) static const atomics::memory_order memory_order_relaxed = atomics::memory_order_seq_cst; static const atomics::memory_order memory_order_consume = atomics::memory_order_seq_cst; static const atomics::memory_order memory_order_acquire = atomics::memory_order_seq_cst; @@ -607,6 +604,25 @@ namespace opt { static const atomics::memory_order memory_order_seq_cst = atomics::memory_order_seq_cst; //@endcond }; + + /// Totally relaxed memory ordering model (do not use!) + /** + In this memory model any memory constraint is equivalent to \p memory_order_relaxed. + @warn Do not use this model! It intended for testing purposes only + to verify debugging instruments like Thread Sanitizer. + + See \p opt::memory_model for explanations + */ + struct total_relaxed_ordering { + //@cond + static const atomics::memory_order memory_order_relaxed = atomics::memory_order_relaxed; + static const atomics::memory_order memory_order_consume = atomics::memory_order_relaxed; + static const atomics::memory_order memory_order_acquire = atomics::memory_order_relaxed; + static const atomics::memory_order memory_order_release = atomics::memory_order_relaxed; + static const atomics::memory_order memory_order_acq_rel = atomics::memory_order_relaxed; + static const atomics::memory_order memory_order_seq_cst = atomics::memory_order_relaxed; + //@endcond + }; } // namespace v /// [type-option] Base type traits option setter -- 2.34.1