|
From: <sv...@va...> - 2009-05-26 19:06:21
|
Author: bart
Date: 2009-05-26 20:05:11 +0100 (Tue, 26 May 2009)
New Revision: 10153
Log:
- Renamed into DRD_(thread_update_cs_after_sync)() into
DRD_(thread_update_conflict_set)().
- Optimized DRD_(thread_new_segment)().
Modified:
branches/DRDDEV/drd/drd_barrier.c
branches/DRDDEV/drd/drd_rwlock.c
branches/DRDDEV/drd/drd_thread.c
branches/DRDDEV/drd/drd_thread.h
Modified: branches/DRDDEV/drd/drd_barrier.c
===================================================================
--- branches/DRDDEV/drd/drd_barrier.c 2009-05-25 01:58:02 UTC (rev 10152)
+++ branches/DRDDEV/drd/drd_barrier.c 2009-05-26 19:05:11 UTC (rev 10153)
@@ -480,7 +480,7 @@
&r->sg[p->post_iteration]->vc);
}
}
- DRD_(thread_update_cs_after_sync)(tid, &old_vc);
+ DRD_(thread_update_conflict_set)(tid, &old_vc);
DRD_(vc_cleanup)(&old_vc);
}
Modified: branches/DRDDEV/drd/drd_rwlock.c
===================================================================
--- branches/DRDDEV/drd/drd_rwlock.c 2009-05-25 01:58:02 UTC (rev 10152)
+++ branches/DRDDEV/drd/drd_rwlock.c 2009-05-26 19:05:11 UTC (rev 10153)
@@ -180,7 +180,7 @@
&q->last_unlock_segment->vc);
}
}
- DRD_(thread_update_cs_after_sync)(tid, &old_vc);
+ DRD_(thread_update_conflict_set)(tid, &old_vc);
DRD_(vc_cleanup)(&old_vc);
}
Modified: branches/DRDDEV/drd/drd_thread.c
===================================================================
--- branches/DRDDEV/drd/drd_thread.c 2009-05-25 01:58:02 UTC (rev 10152)
+++ branches/DRDDEV/drd/drd_thread.c 2009-05-26 19:05:11 UTC (rev 10153)
@@ -954,17 +954,13 @@
new_sg = DRD_(sg_new)(tid, tid);
thread_append_segment(tid, new_sg);
- if (new_sg->prev == NULL
- || conflict_set_update_needed(tid, &new_sg->prev->vc, &new_sg->vc))
- {
- thread_compute_conflict_set(&DRD_(g_conflict_set),
- DRD_(g_drd_running_tid));
- s_conflict_set_new_segment_count++;
- }
- else if (tid == DRD_(g_drd_running_tid))
- {
- tl_assert(thread_conflict_set_up_to_date(DRD_(g_drd_running_tid)));
- }
+ /*
+ * Note: after creation of a new segment and before the conflict set has
+ * been updated the conflict set can be temporarily out of sync. The
+ * following assert statement would fail when enabled:
+ *
+ * tl_assert(thread_conflict_set_up_to_date(DRD_(g_drd_running_tid)));
+ */
thread_discard_ordered_segments();
@@ -1017,7 +1013,8 @@
DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[tid].last->vc);
DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc, vc);
- DRD_(thread_update_cs_after_sync)(tid, &old_vc);
+ thread_discard_ordered_segments();
+ DRD_(thread_update_conflict_set)(tid, &old_vc);
DRD_(vc_cleanup)(&old_vc);
}
else
@@ -1027,26 +1024,6 @@
}
/**
- * Update the conflict set after the vector clock of thread tid has been updated
- * from old_vc to DRD_(g_threadinfo)[tid].last->vc.
- */
-void DRD_(thread_update_cs_after_sync)(DrdThreadId tid, VectorClock* old_vc)
-{
- tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
- && tid != DRD_INVALID_THREADID);
- tl_assert(old_vc);
-
- thread_discard_ordered_segments();
-
- if (conflict_set_update_needed(tid, old_vc,
- &DRD_(g_threadinfo)[tid].last->vc))
- {
- thread_compute_conflict_set(&DRD_(g_conflict_set), tid);
- s_conflict_set_combine_vc_count++;
- }
-}
-
-/**
* Call this function whenever a thread is no longer using the memory
* [ a1, a2 [, e.g. because of a call to free() or a stack pointer
* increase.
@@ -1266,8 +1243,9 @@
}
/**
- * Compute a bitmap that represents the union of all memory accesses of all
- * segments that are unordered to the current segment of the thread tid.
+ * Compute the conflict set: a bitmap that represents the union of all memory
+ * accesses of all segments that are unordered to the current segment of the
+ * thread tid.
*/
static void thread_compute_conflict_set(struct bitmap** conflict_set,
const DrdThreadId tid)
@@ -1375,6 +1353,32 @@
}
}
+/**
+ * Update the conflict set after the vector clock of thread tid has been
+ * updated from old_vc to its current value, either because a new segment has
+ * been created or because of a synchronization operation.
+ */
+void DRD_(thread_update_conflict_set)(const DrdThreadId tid,
+ const VectorClock* const old_vc)
+{
+ const VectorClock* new_vc;
+
+ tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
+ && tid != DRD_INVALID_THREADID);
+ tl_assert(old_vc);
+
+
+ new_vc = &DRD_(g_threadinfo)[tid].last->vc;
+
+ if (conflict_set_update_needed(tid, old_vc, new_vc))
+ {
+ thread_compute_conflict_set(&DRD_(g_conflict_set), tid);
+ s_conflict_set_combine_vc_count++;
+ }
+
+ tl_assert(thread_conflict_set_up_to_date(DRD_(g_drd_running_tid)));
+}
+
/** Report the number of context switches performed. */
ULong DRD_(thread_get_context_switch_count)(void)
{
Modified: branches/DRDDEV/drd/drd_thread.h
===================================================================
--- branches/DRDDEV/drd/drd_thread.h 2009-05-25 01:58:02 UTC (rev 10152)
+++ branches/DRDDEV/drd/drd_thread.h 2009-05-26 19:05:11 UTC (rev 10153)
@@ -151,7 +151,8 @@
void DRD_(thread_combine_vc_join)(const DrdThreadId joiner,
const DrdThreadId joinee);
void DRD_(thread_combine_vc_sync)(const DrdThreadId tid, const Segment* sg);
-void DRD_(thread_update_cs_after_sync)(DrdThreadId tid, VectorClock* old_vc);
+void DRD_(thread_update_conflict_set)(const DrdThreadId tid,
+ const VectorClock* const old_vc);
void DRD_(thread_stop_using_mem)(const Addr a1, const Addr a2);
void DRD_(thread_start_recording)(const DrdThreadId tid);
|