Add support for annotations
authorBrian Demsky <bdemsky@uci.edu>
Thu, 26 Sep 2013 17:53:49 +0000 (02:53 +0900)
committerBrian Demsky <bdemsky@uci.edu>
Thu, 26 Sep 2013 17:53:49 +0000 (02:53 +0900)
Makefile
action.cc
action.h
include/cdsannotate.h [new file with mode: 0644]
libannotate.cc [new file with mode: 0644]

index 37bdcd11ce415d4eb5eafdee8791b5458fa21837..f44a8953ff12bde501fbd91d966f784b75a3b864 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ OBJECTS := libthreads.o schedule.o model.o threads.o librace.o action.o \
           nodestack.o clockvector.o main.o snapshot-interface.o cyclegraph.o \
           datarace.o impatomic.o cmodelint.o \
           snapshot.o malloc.o mymemory.o common.o mutex.o promise.o conditionvariable.o \
-          context.o scanalysis.o execution.o plugins.o
+          context.o scanalysis.o execution.o plugins.o libannotate.o
 
 CPPFLAGS += -Iinclude -I.
 LDFLAGS := -ldl -lrt -rdynamic
index 3d38e81c93d1111bf8828448fd5a52718c17eea6..2010a0b61fd76a66bc2102a8ed2f4562491ad3e5 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -192,6 +192,11 @@ bool ModelAction::is_initialization() const
        return type == ATOMIC_INIT;
 }
 
+bool ModelAction::is_annotation() const
+{
+       return type == ATOMIC_ANNOTATION;
+}
+
 bool ModelAction::is_relaxed() const
 {
        return order == std::memory_order_relaxed;
@@ -547,7 +552,8 @@ const char * ModelAction::get_type_str() const
                case ATOMIC_TRYLOCK: return "trylock";
                case ATOMIC_WAIT: return "wait";
                case ATOMIC_NOTIFY_ONE: return "notify one";
-               case ATOMIC_NOTIFY_ALL: return "notify all";
+         case ATOMIC_NOTIFY_ALL: return "notify all";
+         case ATOMIC_ANNOTATION: return "atomic annotation";
                default: return "unknown type";
        };
 }
index d7d86ced55de125a0a8dbd6e167e30c47bf0bdd8..ad3b828a6a5da33e61140eb0f9fa57831c00fefc 100644 (file)
--- a/action.h
+++ b/action.h
@@ -70,7 +70,9 @@ typedef enum action_type {
        ATOMIC_UNLOCK,        /**< An unlock action */
        ATOMIC_NOTIFY_ONE,    /**< A notify_one action */
        ATOMIC_NOTIFY_ALL,    /**< A notify all action */
-       ATOMIC_WAIT           /**< A wait action */
+       ATOMIC_WAIT,          /**< A wait action */
+       ATOMIC_ANNOTATION     /**< An annotation action to pass information
+                                                                                                        to a trace analysis */
 } action_type_t;
 
 /* Forward declaration */
@@ -142,6 +144,7 @@ public:
        bool is_rmw() const;
        bool is_fence() const;
        bool is_initialization() const;
+       bool is_annotation() const;
        bool is_relaxed() const;
        bool is_acquire() const;
        bool is_release() const;
diff --git a/include/cdsannotate.h b/include/cdsannotate.h
new file mode 100644 (file)
index 0000000..bb6e3d6
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef CDS_ANNOTATE_H
+#define CDS_ANNOTATE_H
+#include <stdint.h>
+
+void cdsannotate(uint64_t analysistype, void *annotation);
+
+#endif
diff --git a/libannotate.cc b/libannotate.cc
new file mode 100644 (file)
index 0000000..b1fad8a
--- /dev/null
@@ -0,0 +1,14 @@
+#include <cdsannotate.h>
+#include "common.h"
+#include "action.h"
+#include "model.h"
+
+/** Pass in an annotation that a trace analysis will use.  The
+ *  analysis type is a unique number that specifies which trace
+ *  analysis needs the annotation.  The reference is to a data
+ *  structure that the trace understands. */
+
+void cdsannotate(uint64_t analysistype, void *annotation) {
+       /* seq_cst is just a 'don't care' parameter */
+       model->switch_to_master(new ModelAction(ATOMIC_ANNOTATION, std::memory_order_seq_cst, annotation, analysistype));
+}