volatile support
authorBrian Demsky <bdemsky@uci.edu>
Mon, 22 Jul 2019 23:27:29 +0000 (16:27 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Mon, 22 Jul 2019 23:27:29 +0000 (16:27 -0700)
action.h
cmodelint.cc
include/memoryorder.h

index 0ecb5c365b080ec5d9dee4827ece1a959080cfc5..7c79f435cff8aba9b248fba38af5ee40b8aac84c 100644 (file)
--- a/action.h
+++ b/action.h
@@ -25,7 +25,6 @@ using std::memory_order_acquire;
 using std::memory_order_release;
 using std::memory_order_acq_rel;
 using std::memory_order_seq_cst;
-using std::volatile_order;
 
 /**
  * @brief A recognizable don't-care value for use in the ModelAction::value
@@ -73,8 +72,6 @@ typedef enum action_type {
        ATOMIC_NOTIFY_ALL,      // < A notify all action
        ATOMIC_WAIT,    // < A wait action
        ATOMIC_ANNOTATION,      // < An annotation action to pass information to a trace analysis
-       VOLATILE_READ,
-       VOLATILE_WRITE,
        NOOP    // no operation, which returns control to scheduler
 } action_type_t;
 
index 67364d5abf7a9a3a51178a8dc4f5f37fea0f7283..d3b64b156c79b72a27662e2fd6ab92ca3e1a01fc 100644 (file)
@@ -13,7 +13,6 @@
 memory_order orders[8] = {
        memory_order_relaxed, memory_order_consume, memory_order_acquire,
        memory_order_release, memory_order_acq_rel, memory_order_seq_cst,
-       volatile_order
 };
 
 static void ensureModel() {
@@ -95,46 +94,29 @@ void model_rmwc_action_helper(void *obj, int atomic_index, const char *position)
 }
 
 // cds volatile loads
-uint8_t cds_volatile_load8(void * obj, int atomic_index, const char * position) {
-       ensureModel();
-       return (uint8_t) model->switch_to_master(
-               new ModelAction(VOLATILE_READ, position, orders[atomic_index], obj));
-}
-uint16_t cds_volatile_load16(void * obj, int atomic_index, const char * position) {
-       ensureModel();
-       return (uint16_t) model->switch_to_master(
-               new ModelAction(VOLATILE_READ, position, orders[atomic_index], obj));
-}
-uint32_t cds_volatile_load32(void * obj, int atomic_index, const char * position) {
-       ensureModel();
-       return (uint32_t) model->switch_to_master(
-               new ModelAction(VOLATILE_READ, position, orders[atomic_index], obj)
-               );
-}
-uint64_t cds_volatile_load64(void * obj, int atomic_index, const char * position) {
-       ensureModel();
-       return model->switch_to_master(
-               new ModelAction(VOLATILE_READ, position, orders[atomic_index], obj));
-}
+#define VOLATILELOAD(size) \
+  uint ## size ## _t cds_volatile_load ## size(void * obj, const char * position) { \
+    ensureModel();                                                     \
+    return (uint ## size ## _t) model->switch_to_master(new ModelAction(ATOMIC_READ, position, memory_order_relaxed, obj)); \
+  }
+
+VOLATILELOAD(8)
+VOLATILELOAD(16)
+VOLATILELOAD(32)
+VOLATILELOAD(64)
 
 // cds volatile stores
-void cds_volatile_store8(void * obj, uint8_t val, int atomic_index, const char * position) {
-       ensureModel();
-       model->switch_to_master(new ModelAction(VOLATILE_WRITE, position, orders[atomic_index], obj, (uint64_t) val));
-}
-void cds_volatile_store16(void * obj, uint16_t val, int atomic_index, const char * position) {
-       ensureModel();
-       model->switch_to_master(new ModelAction(VOLATILE_WRITE, position, orders[atomic_index], obj, (uint64_t) val));
-}
-void cds_volatile_store32(void * obj, uint32_t val, int atomic_index, const char * position) {
-       ensureModel();
-       model->switch_to_master(new ModelAction(VOLATILE_WRITE, position, orders[atomic_index], obj, (uint64_t) val));
-}
-void cds_volatile_store64(void * obj, uint64_t val, int atomic_index, const char * position) {
-       ensureModel();
-       model->switch_to_master(new ModelAction(VOLATILE_WRITE, position, orders[atomic_index], obj, (uint64_t) val));
+#define VOLATILESTORE(size) \
+  void cds_volatile_store ## size (void * obj, uint ## size ## _t val, const char * position) {        \
+    ensureModel();                                                     \
+    model->switch_to_master(new ModelAction(ATOMIC_WRITE, position, memory_order_relaxed, obj, (uint64_t) val)); \
 }
 
+VOLATILESTORE(8)
+VOLATILESTORE(16)
+VOLATILESTORE(32)
+VOLATILESTORE(64)
+
 // cds atomic inits
 #define CDSATOMICINT(size)                                              \
        void cds_atomic_init ## size (void * obj, uint ## size ## _t val, const char * position) { \
index 2e617a90c5d75b044a88d26f239b819cd8114061..2117b5eb75fffbdf133267902390006839523ca9 100644 (file)
@@ -14,8 +14,7 @@ namespace std {
 
 typedef enum memory_order {
        memory_order_relaxed, memory_order_consume, memory_order_acquire,
-       memory_order_release, memory_order_acq_rel, memory_order_seq_cst,
-       volatile_order
+       memory_order_release, memory_order_acq_rel, memory_order_seq_cst
 } memory_order;
 
 #ifdef __cplusplus