promise: add is_compatible_exclusive()
authorBrian Norris <banorris@uci.edu>
Tue, 5 Feb 2013 22:03:28 +0000 (14:03 -0800)
committerBrian Norris <banorris@uci.edu>
Wed, 6 Feb 2013 21:44:39 +0000 (13:44 -0800)
Check if a Promise is both compatible *and* exclusive to a particular
thread. This allows ordering optimizations when we can guarantee that a
particular thread must fulfill the promise.

promise.cc
promise.h

index fdd45791f40657556f344c96b579ade87bc90736..ea5e7e635cf47df48a2ffc15fa0cd35d73b76025 100644 (file)
@@ -83,5 +83,16 @@ bool Promise::has_failed() const
  */
 bool Promise::is_compatible(const ModelAction *write) const
 {
  */
 bool Promise::is_compatible(const ModelAction *write) const
 {
-       return thread_is_available(write->get_tid());
+       return thread_is_available(write->get_tid()) && read->same_var(write);
+}
+
+/**
+ * @brief Check if a promise is compatible with a store and is exclusive to its
+ * thread
+ * @param write The store to check against
+ * @return True if we are compatible and exclusive; false otherwise
+ */
+bool Promise::is_compatible_exclusive(const ModelAction *write) const
+{
+       return get_num_available_threads() == 1 && is_compatible(write);
 }
 }
index e040e169e83e1657f53230c107f7805b8416fc2e..178b86e7d4b3cedba32f2240f2493e63655efb4d 100644 (file)
--- a/promise.h
+++ b/promise.h
@@ -42,6 +42,7 @@ class Promise {
        const ModelAction * get_write() const { return write; }
        int get_num_available_threads() const { return num_available_threads; }
        bool is_compatible(const ModelAction *write) const;
        const ModelAction * get_write() const { return write; }
        int get_num_available_threads() const { return num_available_threads; }
        bool is_compatible(const ModelAction *write) const;
+       bool is_compatible_exclusive(const ModelAction *write) const;
 
        void print() const;
 
 
        void print() const;