Annotation Support
authorbdemsky <bdemsky@uci.edu>
Sat, 25 Jan 2014 22:04:13 +0000 (14:04 -0800)
committerbdemsky <bdemsky@uci.edu>
Sat, 25 Jan 2014 22:04:13 +0000 (14:04 -0800)
Makefile
action.cc
action.h
include/cdsannotate.h [new file with mode: 0644]
libannotate.cc [new file with mode: 0644]

index 37bdcd1..f44a895 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 3d38e81..2010a0b 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 d7d86ce..ad3b828 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));
+}