fix conflict
authorroot <root@dw-6.eecs.uci.edu>
Mon, 22 Jul 2019 23:04:26 +0000 (16:04 -0700)
committerroot <root@dw-6.eecs.uci.edu>
Mon, 22 Jul 2019 23:04:26 +0000 (16:04 -0700)
1  2 
action.h
cmodelint.cc
execution.cc
execution.h
funcnode.cc
funcnode.h
history.cc
history.h
model.cc

diff --cc action.h
Simple merge
diff --cc cmodelint.cc
@@@ -8,11 -8,11 +8,12 @@@
  #include "cmodelint.h"
  #include "snapshot-interface.h"
  #include "threads-model.h"
 +#include "datarace.h"
  
- memory_order orders[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
+       memory_order_release, memory_order_acq_rel, memory_order_seq_cst,
+       volatile_order
  };
  
  static void ensureModel() {
@@@ -93,53 -93,106 +94,94 @@@ void model_rmwc_action_helper(void *obj
        model->switch_to_master(new ModelAction(ATOMIC_RMWC, position, orders[atomic_index], obj));
  }
  
+ // 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));
+ }
+ // 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));
+ }
  // cds atomic inits
 -void cds_atomic_init8(void * obj, uint8_t val, const char * position) {
 -      ensureModel();
 -      model->switch_to_master(new ModelAction(ATOMIC_INIT, position, memory_order_relaxed, obj, (uint64_t) val));
 -}
 -void cds_atomic_init16(void * obj, uint16_t val, const char * position) {
 -      ensureModel();
 -      model->switch_to_master(new ModelAction(ATOMIC_INIT, position, memory_order_relaxed, obj, (uint64_t) val));
 -}
 -void cds_atomic_init32(void * obj, uint32_t val, const char * position) {
 -      ensureModel();
 -      model->switch_to_master(new ModelAction(ATOMIC_INIT, position, memory_order_relaxed, obj, (uint64_t) val));
 -}
 -void cds_atomic_init64(void * obj, uint64_t val, const char * position) {
 -      ensureModel();
 -      model->switch_to_master(new ModelAction(ATOMIC_INIT, position, memory_order_relaxed, obj, val));
 -}
 +#define CDSATOMICINT(size)                                              \
 +      void cds_atomic_init ## size (void * obj, uint ## size ## _t val, const char * position) { \
 +              ensureModel();                                                      \
 +              model->switch_to_master(new ModelAction(ATOMIC_INIT, position, memory_order_relaxed, obj, (uint64_t) val)); \
 +              *((uint ## size ## _t *)obj) = val;                                 \
 +              thread_id_t tid = thread_current()->get_id();           \
 +              for(int i=0;i < size / 8;i++) {                       \
 +                      recordWrite(tid, (void *)(((char *)obj)+i));          \
 +              }                                                       \
 +      }
  
 +CDSATOMICINT(8)
 +CDSATOMICINT(16)
 +CDSATOMICINT(32)
 +CDSATOMICINT(64)
  
  // cds atomic loads
 -uint8_t cds_atomic_load8(void * obj, int atomic_index, const char * position) {
 -      ensureModel();
 -      return (uint8_t) model->switch_to_master(
 -              new ModelAction(ATOMIC_READ, position, orders[atomic_index], obj));
 -}
 -uint16_t cds_atomic_load16(void * obj, int atomic_index, const char * position) {
 -      ensureModel();
 -      return (uint16_t) model->switch_to_master(
 -              new ModelAction(ATOMIC_READ, position, orders[atomic_index], obj));
 -}
 -uint32_t cds_atomic_load32(void * obj, int atomic_index, const char * position) {
 -      ensureModel();
 -      return (uint32_t) model->switch_to_master(
 -              new ModelAction(ATOMIC_READ, position, orders[atomic_index], obj)
 -              );
 -}
 -uint64_t cds_atomic_load64(void * obj, int atomic_index, const char * position) {
 -      ensureModel();
 -      return model->switch_to_master(
 -              new ModelAction(ATOMIC_READ, position, orders[atomic_index], obj));
 -}
 +#define CDSATOMICLOAD(size)                                             \
 +      uint ## size ## _t cds_atomic_load ## size(void * obj, int atomic_index, const char * position) { \
 +              ensureModel();                                                      \
 +              return (uint ## size ## _t)model->switch_to_master( \
 +                      new ModelAction(ATOMIC_READ, position, orders[atomic_index], obj)); \
 +      }
 +
 +CDSATOMICLOAD(8)
 +CDSATOMICLOAD(16)
 +CDSATOMICLOAD(32)
 +CDSATOMICLOAD(64)
  
  // cds atomic stores
 -void cds_atomic_store8(void * obj, uint8_t val, int atomic_index, const char * position) {
 -      ensureModel();
 -      model->switch_to_master(new ModelAction(ATOMIC_WRITE, position, orders[atomic_index], obj, (uint64_t) val));
 -}
 -void cds_atomic_store16(void * obj, uint16_t val, int atomic_index, const char * position) {
 -      ensureModel();
 -      model->switch_to_master(new ModelAction(ATOMIC_WRITE, position, orders[atomic_index], obj, (uint64_t) val));
 -}
 -void cds_atomic_store32(void * obj, uint32_t val, int atomic_index, const char * position) {
 -      ensureModel();
 -      model->switch_to_master(new ModelAction(ATOMIC_WRITE, position, orders[atomic_index], obj, (uint64_t) val));
 -}
 -void cds_atomic_store64(void * obj, uint64_t val, int atomic_index, const char * position) {
 -      ensureModel();
 -      model->switch_to_master(new ModelAction(ATOMIC_WRITE, position, orders[atomic_index], obj, (uint64_t) val));
 -}
 +#define CDSATOMICSTORE(size)                                            \
 +      void cds_atomic_store ## size(void * obj, uint ## size ## _t val, int atomic_index, const char * position) { \
 +              ensureModel();                                                        \
 +              model->switch_to_master(new ModelAction(ATOMIC_WRITE, position, orders[atomic_index], obj, (uint64_t) val)); \
 +              *((uint ## size ## _t *)obj) = val;                     \
 +              thread_id_t tid = thread_current()->get_id();           \
 +              for(int i=0;i < size / 8;i++) {                       \
 +                      recordWrite(tid, (void *)(((char *)obj)+i));          \
 +              }                                                       \
 +      }
 +
 +CDSATOMICSTORE(8)
 +CDSATOMICSTORE(16)
 +CDSATOMICSTORE(32)
 +CDSATOMICSTORE(64)
 +
  
  #define _ATOMIC_RMW_(__op__, size, addr, val, atomic_index, position)            \
        ({                                                                      \
diff --cc execution.cc
Simple merge
diff --cc execution.h
Simple merge
diff --cc funcnode.cc
@@@ -3,10 -3,12 +3,12 @@@
  FuncNode::FuncNode() :
        func_inst_map(),
        inst_list(),
-       entry_insts()
+       entry_insts(),
+       thrd_read_map(),
+       read_locations()
  {}
  
 -/* Check whether FuncInst with the same type, position, and location 
 +/* Check whether FuncInst with the same type, position, and location
   * as act has been added to func_inst_map or not. If so, return it;
   * if not, add it and return it.
   *
diff --cc funcnode.h
@@@ -30,11 -36,8 +36,8 @@@ private
        uint32_t func_id;
        const char * func_name;
  
 -      /* Use source line number as the key of hashtable, to check if 
 +      /* Use source line number as the key of hashtable, to check if
         * atomic operation with this line number has been added or not
-        *
-        * To do: cds_atomic_compare_exchange contains three atomic operations
-        * that are feeded with the same source line number by llvm pass
         */
        HashTable<const char *, FuncInst *, uintptr_t, 4, model_malloc, model_calloc, model_free> func_inst_map;
  
diff --cc history.cc
@@@ -149,16 -135,15 +135,15 @@@ FuncNode * ModelHistory::get_func_node(
  
  void ModelHistory::print()
  {
-       for (uint32_t i = 0;i < func_atomics.size();i++ ) {
-               FuncNode * funcNode = func_atomics[i];
-               if (funcNode == NULL)
-                       continue;
+       /* function id starts with 1 */
+       for (uint32_t i = 1; i < func_nodes.size(); i++) {
+               FuncNode * func_node = func_nodes[i];
  
-               func_inst_list_mt * entry_insts = funcNode->get_entry_insts();
+               func_inst_list_mt * entry_insts = func_node->get_entry_insts();
+               model_print("function %s has entry actions\n", func_node->get_func_name());
  
-               model_print("function %s has entry actions\n", funcNode->get_func_name());
                func_inst_list_mt::iterator it;
 -              for (it = entry_insts->begin(); it != entry_insts->end(); it++) {
 +              for (it = entry_insts->begin();it != entry_insts->end();it++) {
                        FuncInst *inst = *it;
                        model_print("type: %d, at: %s\n", inst->get_type(), inst->get_position());
                }
diff --cc history.h
+++ b/history.h
@@@ -28,10 -28,10 +28,10 @@@ public
  private:
        uint32_t func_counter;
  
 -      /* map function names to integer ids */ 
 +      /* map function names to integer ids */
        HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> func_map;
 -      /* map integer ids to function names */ 
 +      /* map integer ids to function names */
        ModelVector<const char *> func_map_rev;
  
-       ModelVector<FuncNode *> func_atomics;
+       ModelVector<FuncNode *> func_nodes;
  };
diff --cc model.cc
Simple merge