Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions alloy/litmus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ using namespace std;
// instances.
class LoadStore {
public:
LoadStore() : var(), value(-1), value2(-1), cbarInstance(-1) {}
LoadStore() : var(), value(-1), value2(-1), cbarInstance(-1), workgroup(-1) {}
string var;
int value;
int value2;
int cbarInstance;
int workgroup;
};

// Track what instruction fields are set for each instruction.
Expand All @@ -141,14 +142,14 @@ class InstructionState {
int getReadValue(int instnum) const
{
if (!isRead(instnum)) {
printf("WARNING: calling getReadValue on a non-read");
printf("WARNING: calling getReadValue on a non-read\n");
}
return loadStore[instnum].value;
}
int getWriteValue(int instnum) const
{
if (!isWrite(instnum)) {
printf("WARNING: calling getWriteValue on a non-write");
printf("WARNING: calling getWriteValue on a non-write\n");
}
return (isRead(instnum) && isWrite(instnum)) ? loadStore[instnum].value2 : loadStore[instnum].value;
}
Expand Down Expand Up @@ -340,6 +341,7 @@ int main(int argc, char *argv[])

stringstream o;

int workgroupnum = 0;
int threadnum = 0;
int numEvents = 0;
int bitwidth = 0;
Expand Down Expand Up @@ -390,6 +392,7 @@ int main(int argc, char *argv[])
o << " no ("; sequenceInSuffix(o, 0, instnum+1, true, ") & X.swg");
firstInstInWG = instnum+1;
}
workgroupnum++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also increment this for "NEWQF"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell from the existing tests, NEWQF is always followed by NEWWG, so incrementing the counter for both would cause it to increment twice. Also, the threadnum counter is only incremented for NEWTHREAD.

But both versions should work, since the exact workgroup ID doesn’t really matter, as long as all threads in the same workgroup get the same workgroup ID.

continue;
}

Expand Down Expand Up @@ -452,6 +455,7 @@ int main(int argc, char *argv[])
line = line.substr(firstspace);
line = line.substr(line.find_first_not_of(" "));
instState.loadStore[instnum].cbarInstance = atoi(line.c_str());
instState.loadStore[instnum].workgroup = workgroupnum;
} else {
line = line.substr(firstspace);
line = line.substr(line.find_first_not_of(" ="));
Expand Down Expand Up @@ -602,12 +606,16 @@ int main(int argc, char *argv[])
set<int> cbarInsts;
for (int j = 0; j <= instnum; ++j) {
int v = instState.loadStore[j].cbarInstance;
int w = instState.loadStore[j].workgroup;
if (v != -1 && cbarInsts.find(v) == cbarInsts.end()) {
cbarInsts.insert(v);
o << " ";
bool first = true;
for (int i = j+1; i <= instnum; ++i) {
if (instState.loadStore[i].cbarInstance == v) {
if (instState.loadStore[i].workgroup != w) {
printf("WARNING: matching control barriers in different workgroups\n");
}
if (!first) {
o << "+";
}
Expand Down
4 changes: 2 additions & 2 deletions alloy/tests/scopeaccum.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ cbar.scopewg.semsc0.rel.acq 1
NEWSG
NEWTHREAD
cbar.scopewg.semsc0.rel.acq 1
cbar.scopedev.semsc0.rel.acq 2
st.atom.rel.scopedev.sc0.semsc0 y = 1
NEWWG
NEWSG
NEWTHREAD
cbar.scopedev.semsc0.rel.acq 2
ld.atom.acq.scopedev.sc0.semsc0 y = 1
ld.vis.scopedev.sc0 x
SATISFIABLE consistent[X] && #dr=0
NOSOLUTION consistent[X] && #dr>0
8 changes: 4 additions & 4 deletions alloy/tests/test6.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ cbar.acq.rel.scopewg.semsc0 0
NEWSG
NEWTHREAD
cbar.acq.rel.scopewg.semsc0 0
cbar.acq.rel.scopedev.semsc0 1
st.atom.rel.scopedev.sc0.semsc0 y = 1
NEWWG
NEWSG
NEWTHREAD
cbar.acq.rel.scopedev.semsc0 1
cbar.acq.rel.scopewg.semsc0 2
ld.atom.acq.scopedev.sc0.semsc0 y = 1
cbar.acq.rel.scopewg.semsc0 1
NEWSG
NEWTHREAD
cbar.acq.rel.scopewg.semsc0 2
cbar.acq.rel.scopewg.semsc0 1
ld.vis.scopedev.sc0 a
SATISFIABLE consistent[X] && #dr=0
NOSOLUTION consistent[X] && #dr>0
8 changes: 4 additions & 4 deletions alloy/tests/test7.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ cbar.acq.rel.scopewg.semsc0 0
NEWSG
NEWTHREAD
cbar.acq.rel.scopewg.semsc0 0
cbar.acq.rel.scopedev.semsc1 1
st.atom.rel.scopedev.sc0.semsc1 y = 1
NEWWG
NEWSG
NEWTHREAD
cbar.acq.rel.scopedev.semsc1 1
cbar.acq.rel.scopewg.semsc0 2
ld.atom.acq.scopedev.sc0.semsc1 y = 1
cbar.acq.rel.scopewg.semsc0 1
NEWSG
NEWTHREAD
cbar.acq.rel.scopewg.semsc0 2
cbar.acq.rel.scopewg.semsc0 1
ld.vis.scopedev.sc0 a
NOSOLUTION consistent[X] && #dr=0
SATISFIABLE consistent[X] && #dr>0