projects
/
model-checker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9d9b912
)
scanalysis: fixup spacing
author
Brian Norris
<banorris@uci.edu>
Tue, 16 Apr 2013 02:41:50 +0000
(19:41 -0700)
committer
Brian Norris
<banorris@uci.edu>
Tue, 16 Apr 2013 18:38:00 +0000
(11:38 -0700)
scanalysis.cc
patch
|
blob
|
history
scanalysis.h
patch
|
blob
|
history
diff --git
a/scanalysis.cc
b/scanalysis.cc
index 01c53cdc677cb21d2ab152efb1e8a3897ae27ebc..d3120fc3f612518f5bca1b5b80aed3f813454147 100644
(file)
--- a/
scanalysis.cc
+++ b/
scanalysis.cc
@@
-7,9
+7,9
@@
SCAnalysis::SCAnalysis(const ModelExecution *execution) :
execution(execution)
{
SCAnalysis::SCAnalysis(const ModelExecution *execution) :
execution(execution)
{
- cvmap
=new HashTable
<const ModelAction *, ClockVector *, uintptr_t, 4>();
- cycleset
=new HashTable
<const ModelAction *, const ModelAction *, uintptr_t, 4>();
- threadlists
=new SnapVector
<action_list_t>(1);
+ cvmap
= new HashTable
<const ModelAction *, ClockVector *, uintptr_t, 4>();
+ cycleset
= new HashTable
<const ModelAction *, const ModelAction *, uintptr_t, 4>();
+ threadlists
= new SnapVector
<action_list_t>(1);
}
SCAnalysis::~SCAnalysis() {
}
SCAnalysis::~SCAnalysis() {
@@
-32,64
+32,64
@@
void SCAnalysis::print_list(action_list_t *list) {
model_print("CYC");
act->print();
}
model_print("CYC");
act->print();
}
- hash = hash
^(hash<<3)^
((*it)->hash());
+ hash = hash
^ (hash << 3) ^
((*it)->hash());
}
model_print("HASH %u\n", hash);
model_print("---------------------------------------------------------------------\n");
}
}
model_print("HASH %u\n", hash);
model_print("---------------------------------------------------------------------\n");
}
-void SCAnalysis::analyze(action_list_t *
actions) {
+void SCAnalysis::analyze(action_list_t *actions) {
buildVectors(actions);
computeCV(actions);
buildVectors(actions);
computeCV(actions);
- action_list_t *list
=
generateSC(actions);
+ action_list_t *list
=
generateSC(actions);
print_list(list);
}
print_list(list);
}
-bool SCAnalysis::merge(ClockVector *
cv, const ModelAction *
act, ClockVector *cv2) {
- if (cv2->getClock(act->get_tid())
>=
act->get_seq_number() && act->get_seq_number() != 0) {
+bool SCAnalysis::merge(ClockVector *
cv, const ModelAction *
act, ClockVector *cv2) {
+ if (cv2->getClock(act->get_tid())
>=
act->get_seq_number() && act->get_seq_number() != 0) {
cycleset->put(act, act);
}
return cv->merge(cv2);
}
ModelAction * SCAnalysis::getNextAction() {
cycleset->put(act, act);
}
return cv->merge(cv2);
}
ModelAction * SCAnalysis::getNextAction() {
- ModelAction *act
=
NULL;
- for
(int i=0;i<=maxthreads;
i++) {
- action_list_t *
threadlist=
&(*threadlists)[i];
+ ModelAction *act
=
NULL;
+ for
(int i = 0; i <= maxthreads;
i++) {
+ action_list_t *
threadlist =
&(*threadlists)[i];
if (threadlist->empty())
continue;
if (threadlist->empty())
continue;
- ModelAction *first
=
threadlist->front();
- if (act
==
NULL) {
- act
=
first;
+ ModelAction *first
=
threadlist->front();
+ if (act
==
NULL) {
+ act
=
first;
continue;
}
continue;
}
- ClockVector *cv
=
cvmap->get(act);
+ ClockVector *cv
=
cvmap->get(act);
if (cv->synchronized_since(first)) {
if (cv->synchronized_since(first)) {
- act
=
first;
+ act
=
first;
}
}
}
}
- if (act
==
NULL)
+ if (act
==
NULL)
return act;
//print cycles in a nice way to avoid confusion
//make sure thread starts appear after the create
if (act->is_thread_start()) {
return act;
//print cycles in a nice way to avoid confusion
//make sure thread starts appear after the create
if (act->is_thread_start()) {
- ModelAction *createact
=
execution->get_thread(act)->get_creation();
+ ModelAction *createact
=
execution->get_thread(act)->get_creation();
if (createact) {
if (createact) {
- action_list_t *threadlist
=
&(*threadlists)[id_to_int(createact->get_tid())];
+ action_list_t *threadlist
=
&(*threadlists)[id_to_int(createact->get_tid())];
if (!threadlist->empty()) {
if (!threadlist->empty()) {
- ModelAction *first
=
threadlist->front();
+ ModelAction *first
=
threadlist->front();
if (first->get_seq_number() <= createact->get_seq_number())
if (first->get_seq_number() <= createact->get_seq_number())
- act
=
first;
+ act
=
first;
}
}
}
//make sure that joins appear after the thread is finished
if (act->is_thread_join()) {
}
}
}
//make sure that joins appear after the thread is finished
if (act->is_thread_join()) {
- int jointhread
=
id_to_int(act->get_thread_operand()->get_id());
- action_list_t *threadlist
=
&(*threadlists)[jointhread];
+ int jointhread
=
id_to_int(act->get_thread_operand()->get_id());
+ action_list_t *threadlist
=
&(*threadlists)[jointhread];
if (!threadlist->empty()) {
if (!threadlist->empty()) {
- act
=
threadlist->front();
+ act
=
threadlist->front();
}
}
}
}
@@
-97,12
+97,12
@@
ModelAction * SCAnalysis::getNextAction() {
}
action_list_t * SCAnalysis::generateSC(action_list_t *list) {
}
action_list_t * SCAnalysis::generateSC(action_list_t *list) {
- action_list_t *sclist
=
new action_list_t();
+ action_list_t *sclist
=
new action_list_t();
while (true) {
while (true) {
- ModelAction *
act=
getNextAction();
- if (act
==
NULL)
+ ModelAction *
act =
getNextAction();
+ if (act
==
NULL)
break;
break;
- thread_id_t tid
=
act->get_tid();
+ thread_id_t tid
=
act->get_tid();
//remove action
(*threadlists)[id_to_int(tid)].pop_front();
//add ordering constraints from this choice
//remove action
(*threadlists)[id_to_int(tid)].pop_front();
//add ordering constraints from this choice
@@
-117,27
+117,27
@@
action_list_t * SCAnalysis::generateSC(action_list_t *list) {
}
void SCAnalysis::buildVectors(action_list_t *list) {
}
void SCAnalysis::buildVectors(action_list_t *list) {
- maxthreads
=
0;
+ maxthreads
=
0;
for (action_list_t::iterator it = list->begin(); it != list->end(); it++) {
ModelAction *act = *it;
for (action_list_t::iterator it = list->begin(); it != list->end(); it++) {
ModelAction *act = *it;
- int threadid
=
id_to_int(act->get_tid());
+ int threadid
=
id_to_int(act->get_tid());
if (threadid > maxthreads) {
if (threadid > maxthreads) {
- threadlists->resize(threadid
+
1);
- maxthreads
=
threadid;
+ threadlists->resize(threadid
+
1);
+ maxthreads
=
threadid;
}
(*threadlists)[threadid].push_back(act);
}
}
bool SCAnalysis::updateConstraints(ModelAction *act) {
}
(*threadlists)[threadid].push_back(act);
}
}
bool SCAnalysis::updateConstraints(ModelAction *act) {
- bool changed
=
false;
+ bool changed
=
false;
ClockVector *actcv = cvmap->get(act);
ClockVector *actcv = cvmap->get(act);
- for
(int i=0;i<=maxthreads;
i++) {
- thread_id_t tid
=
int_to_id(i);
- if (tid
==
act->get_tid())
+ for
(int i = 0; i <= maxthreads;
i++) {
+ thread_id_t tid
=
int_to_id(i);
+ if (tid
==
act->get_tid())
continue;
continue;
- action_list_t *
list=
&(*threadlists)[id_to_int(tid)];
+ action_list_t *
list =
&(*threadlists)[id_to_int(tid)];
for (action_list_t::iterator rit = list->begin(); rit != list->end(); rit++) {
ModelAction *write = *rit;
if (!write->is_write())
for (action_list_t::iterator rit = list->begin(); rit != list->end(); rit++) {
ModelAction *write = *rit;
if (!write->is_write())
@@
-148,7
+148,7
@@
bool SCAnalysis::updateConstraints(ModelAction *act) {
if (write->get_location() == act->get_location()) {
//write is sc after act
merge(writecv, write, actcv);
if (write->get_location() == act->get_location()) {
//write is sc after act
merge(writecv, write, actcv);
- changed
=
true;
+ changed
=
true;
break;
}
}
break;
}
}
@@
-157,21
+157,21
@@
bool SCAnalysis::updateConstraints(ModelAction *act) {
}
bool SCAnalysis::processRead(ModelAction *read, ClockVector *cv) {
}
bool SCAnalysis::processRead(ModelAction *read, ClockVector *cv) {
- bool changed
=
false;
+ bool changed
=
false;
/* Merge in the clock vector from the write */
/* Merge in the clock vector from the write */
- const ModelAction *write
=
read->get_reads_from();
- ClockVector *writecv
=
cvmap->get(write);
+ const ModelAction *write
=
read->get_reads_from();
+ ClockVector *writecv
=
cvmap->get(write);
changed |= writecv == NULL || (merge(cv, read, writecv) && (*read < *write));
changed |= writecv == NULL || (merge(cv, read, writecv) && (*read < *write));
- for
(int i=0;i<=maxthreads;
i++) {
- thread_id_t tid
=
int_to_id(i);
- if (tid
==
read->get_tid())
+ for
(int i = 0; i <= maxthreads;
i++) {
+ thread_id_t tid
=
int_to_id(i);
+ if (tid
==
read->get_tid())
continue;
continue;
- if (tid
==
write->get_tid())
+ if (tid
==
write->get_tid())
continue;
continue;
- action_list_t *
list=
execution->get_actions_on_obj(read->get_location(), tid);
- if (list
==
NULL)
+ action_list_t *
list =
execution->get_actions_on_obj(read->get_location(), tid);
+ if (list
==
NULL)
continue;
for (action_list_t::reverse_iterator rit = list->rbegin(); rit != list->rend(); rit++) {
ModelAction *write2 = *rit;
continue;
for (action_list_t::reverse_iterator rit = list->rbegin(); rit != list->rend(); rit++) {
ModelAction *write2 = *rit;
@@
-202,27
+202,26
@@
bool SCAnalysis::processRead(ModelAction *read, ClockVector *cv) {
return changed;
}
return changed;
}
-
void SCAnalysis::computeCV(action_list_t *list) {
void SCAnalysis::computeCV(action_list_t *list) {
- bool changed
=
true;
- bool firsttime
=
true;
- ModelAction **last_act
=(ModelAction **)model_calloc(1,(maxthreads+1)*
sizeof(ModelAction *));
- while(changed) {
- changed
=
changed&firsttime;
- firsttime
=
false;
+ bool changed
=
true;
+ bool firsttime
=
true;
+ ModelAction **last_act
= (ModelAction **)model_calloc(1, (maxthreads + 1) *
sizeof(ModelAction *));
+ while
(changed) {
+ changed
=
changed&firsttime;
+ firsttime
=
false;
for (action_list_t::iterator it = list->begin(); it != list->end(); it++) {
ModelAction *act = *it;
ModelAction *lastact = last_act[id_to_int(act->get_tid())];
if (act->is_thread_start())
for (action_list_t::iterator it = list->begin(); it != list->end(); it++) {
ModelAction *act = *it;
ModelAction *lastact = last_act[id_to_int(act->get_tid())];
if (act->is_thread_start())
- lastact
=
execution->get_thread(act)->get_creation();
- ClockVector *lastcv
=
(lastact != NULL) ? cvmap->get(lastact) : NULL;
- last_act[id_to_int(act->get_tid())]
=
act;
- ClockVector *cv
=
cvmap->get(act);
- if (
cv == NULL
) {
+ lastact
=
execution->get_thread(act)->get_creation();
+ ClockVector *lastcv
=
(lastact != NULL) ? cvmap->get(lastact) : NULL;
+ last_act[id_to_int(act->get_tid())]
=
act;
+ ClockVector *cv
=
cvmap->get(act);
+ if (
cv == NULL
) {
cv = new ClockVector(lastcv, act);
cvmap->put(act, cv);
cv = new ClockVector(lastcv, act);
cvmap->put(act, cv);
- } else if (
lastcv != NULL
) {
+ } else if (
lastcv != NULL
) {
merge(cv, act, lastcv);
}
if (act->is_thread_join()) {
merge(cv, act, lastcv);
}
if (act->is_thread_join()) {
@@
-232,12
+231,12
@@
void SCAnalysis::computeCV(action_list_t *list) {
changed |= (finishcv == NULL) || merge(cv, act, finishcv);
}
if (act->is_read()) {
changed |= (finishcv == NULL) || merge(cv, act, finishcv);
}
if (act->is_read()) {
- changed
|=
processRead(act, cv);
+ changed
|=
processRead(act, cv);
}
}
/* Reset the last action array */
if (changed) {
}
}
/* Reset the last action array */
if (changed) {
- bzero(last_act, (maxthreads
+1)*
sizeof(ModelAction *));
+ bzero(last_act, (maxthreads
+ 1) *
sizeof(ModelAction *));
}
}
model_free(last_act);
}
}
model_free(last_act);
diff --git
a/scanalysis.h
b/scanalysis.h
index 7e300e0c1e71451905a2dee56f99a3e1e3605681..0cd2d67e704d942c93fdf93404c8d63010e490ed 100644
(file)
--- a/
scanalysis.h
+++ b/
scanalysis.h
@@
-18,11
+18,11
@@
class SCAnalysis : public TraceAnalysis {
action_list_t * generateSC(action_list_t *);
bool processRead(ModelAction *read, ClockVector *cv);
ModelAction * getNextAction();
action_list_t * generateSC(action_list_t *);
bool processRead(ModelAction *read, ClockVector *cv);
ModelAction * getNextAction();
- bool merge(ClockVector *
cv, const ModelAction *
act, ClockVector *cv2);
+ bool merge(ClockVector *
cv, const ModelAction *
act, ClockVector *cv2);
int maxthreads;
int maxthreads;
- HashTable<const ModelAction *,
ClockVector *, uintptr_t, 4 > *
cvmap;
- HashTable<const ModelAction *,
const ModelAction *, uintptr_t, 4 > *
cycleset;
- SnapVector<action_list_t> *
threadlists;
+ HashTable<const ModelAction *,
ClockVector *, uintptr_t, 4 > *
cvmap;
+ HashTable<const ModelAction *,
const ModelAction *, uintptr_t, 4 > *
cycleset;
+ SnapVector<action_list_t> *threadlists;
const ModelExecution *execution;
};
#endif
const ModelExecution *execution;
};
#endif