bool FuncInst::is_read() const
{
- return type == ATOMIC_READ || type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS;
+ return type == ATOMIC_READ || type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS; /* type == ATOMIC_RMW ? */
}
+
+bool FuncInst::is_write() const
+{
+ return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == ATOMIC_UNINIT || type == NONATOMIC_WRITE;
+}
+
+#ifndef __FUNCINST_H__
+#define __FUNCINST_H__
+
#include "action.h"
#include "hashtable.h"
func_inst_list_mt * get_succs() { return &successors; }
bool is_read() const;
+ bool is_write() const;
MEMALLOC
private:
func_inst_list_mt predecessors;
func_inst_list_mt successors;
};
+
+#endif /* __FUNCINST_H__ */
+
#include "funcnode.h"
+#include "predicate.h"
FuncNode::FuncNode() :
func_inst_map(),
thrd_read_map[tid]->reset();
}
+void FuncNode::generate_predicate(FuncInst *func_inst)
+{
+
+}
+
/* @param tid thread id
* Print the values read by the last read actions for each memory location
*/
+#ifndef __FUNCNODE_H__
+#define __FUNCNODE_H__
+
#include "action.h"
#include "funcinst.h"
#include "hashtable.h"
-class ModelAction;
-
typedef ModelList<FuncInst *> func_inst_list_mt;
typedef HashTable<void *, uint64_t, uintptr_t, 4, model_malloc, model_calloc, model_free> read_map_t;
uint64_t query_last_read(void * location, uint32_t tid);
void clear_read_map(uint32_t tid);
+ /* TODO: generate EQUALITY or NULLITY predicate based on write_history in history.cc */
+ void generate_predicate(FuncInst * func_inst);
+
void print_last_read(uint32_t tid);
MEMALLOC
ModelVector<read_map_t *> thrd_read_map;
ModelList<void *> read_locations;
};
+
+#endif /* __FUNCNODE_H__ */
func_counter(1), /* function id starts with 1 */
func_map(),
func_map_rev(),
- func_nodes()
+ func_nodes(),
+ write_history()
{}
void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
if (inst->is_read())
func_node->store_read(act, tid);
+ if (inst->is_write())
+ add_to_write_history(act->get_location(), act->get_write_value());
+
/* add to curr_inst_list */
func_inst_list_t * curr_inst_list = func_inst_lists->back();
ASSERT(curr_inst_list != NULL);
return last_read_val;
}
+void ModelHistory::add_to_write_history(void * location, uint64_t write_val)
+{
+ if ( !write_history.contains(location) )
+ write_history.put(location, new write_set_t() );
+
+ write_set_t * write_set = write_history.get(location);
+ write_set->add(write_val);
+}
+
void ModelHistory::print()
{
/* function id starts with 1 */
+#ifndef __HISTORY_H__
+#define __HISTORY_H__
+
#include "stl-model.h"
#include "common.h"
#include "hashtable.h"
+#include "hashset.h"
#include "threads-model.h"
+typedef HashSet<uint64_t, uint64_t, 4, model_malloc, model_calloc, model_free> write_set_t;
+
class ModelHistory {
public:
ModelHistory();
FuncNode * get_func_node(uint32_t func_id);
uint64_t query_last_read(void * location, thread_id_t tid);
+ void add_to_write_history(void * location, uint64_t write_val);
+
void print();
MEMALLOC
ModelVector<const char *> func_map_rev;
ModelVector<FuncNode *> func_nodes;
+ HashTable<void *, write_set_t *, uintptr_t, 4, model_malloc, model_calloc, model_free> write_history;
};
+
+#endif /* __HISTORY_H__ */
--- /dev/null
+#include "predicate.h"
+
+inline bool operator==(const predicate_expr& expr_A, const predicate_expr& expr_B)
+{
+ if (expr_A.token != expr_B.token)
+ return false;
+
+ if (expr_A.token == EQUALITY && expr_A.location != expr_B.location)
+ return false;
+
+ if (expr_A.value != expr_B.value)
+ return false;
+
+ return true;
+}
+
+void Predicate::add_predicate(predicate_expr predicate)
+{
+ ModelList<predicate_expr>::iterator it;
+ for (it = predicates.begin(); it != predicates.end(); it++) {
+ if (predicate == *it)
+ return;
+ }
+
+ predicates.push_back(predicate);
+}
--- /dev/null
+#include "funcinst.h"
+
+typedef enum predicate_token {
+ EQUALITY, NULLITY
+} token_t;
+
+/* If token is EQUALITY, then the predicate asserts whether
+ * this load should read the same value as the last value
+ * read at memory location specified in predicate_expr.
+ */
+struct predicate_expr {
+ token_t token;
+ void * location;
+ bool value;
+};
+
+class Predicate {
+public:
+ Predicate();
+ ~Predicate();
+
+ FuncInst * get_func_inst() { return func_inst; }
+ ModelList<predicate_expr> * get_predicates() { return &predicates; }
+ void add_predicate(predicate_expr predicate);
+
+ MEMALLOC
+private:
+ FuncInst * func_inst;
+ /* may have multiple precicates */
+ ModelList<predicate_expr> predicates;
+};