Skip to content

Commit 1b01bc2

Browse files
starUpperBound fixes for SYCL.
1 parent 6dd0089 commit 1b01bc2

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

models/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ $(MODELS:=.so): %.so: %.o ../lib/libecolab$(ECOLIBS_EXT).a
4444
$(MODELS:=.app): %.app: %
4545
$(ECOLAB_HOME)/utils/mkmacapp $<
4646

47+
# required because gcc builds do not inlcude vecBitSet.h
48+
starComplexity.o: vecBitSet.cd
49+
4750
ifneq ($(MAKECMDGOALS),clean)
4851
include $(MODELS:=.d)
4952
endif

models/starComplexity.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ NautyRep toNautyRep(linkRep g, unsigned nodes)
438438
for (unsigned i=0; i<nodes; ++i)
439439
for (unsigned j=0; j<i; ++j)
440440
if (!(g&(linkRep(1)<<(i*(i-1)/2+j))).empty())
441+
//if (g(i,j))
441442
n(i,j)=n(j,i)=true;
442443
return n;
443444
}
@@ -575,7 +576,7 @@ unsigned starUpperBound(linkRep x, unsigned nodes)
575576

576577
// calculate node degree
577578
map<unsigned,unsigned> nodeDegree;
578-
for (unsigned i=0; i<maxNodes; ++i)
579+
for (unsigned i=0; i<nodes; ++i)
579580
for (unsigned j=0; j<i; ++j)
580581
if (x(i,j))
581582
{
@@ -617,8 +618,9 @@ unsigned starUpperBound(linkRep x, unsigned nodes)
617618

618619
unsigned StarComplexityGen::starUpperBound(const linkRep& x) const
619620
{
620-
unsigned ub=::starUpperBound(x, elemStars.size());
621-
unsigned complementUb=::starUpperBound(~x, elemStars.size());
621+
unsigned n=elemStars.size();
622+
unsigned ub=::starUpperBound(x, n);
623+
unsigned complementUb=::starUpperBound((~x).maskOut(n), n);
622624
assert(ub>0 && complementUb>0);
623625
return min(ub, complementUb);
624626
}

models/starComplexity.h

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// hard code maximum number of nodes
2-
constexpr unsigned maxNodes=10, maxStars=2*maxNodes-1;
3-
4-
//using linkRep=unsigned long long;
2+
constexpr unsigned maxNodes=22, maxStars=2*maxNodes-1;
53

64
#include "netcomplexity.h"
75

@@ -41,17 +39,32 @@ class linkRepImpl
4139
return r;
4240
}
4341
linkRepImpl operator<<(int n) {
44-
linkRepImpl r;
42+
linkRepImpl r(0);
4543
auto d=div(n, int(8*sizeof(Impl)));
4644
for (unsigned i=0; i<size-d.quot; ++i)
4745
r.data[i+d.quot]=data[i]<<d.rem;
4846
return r;
4947
}
48+
/// mask out bits not used, give a node count
49+
linkRepImpl& maskOut(unsigned nodes) {
50+
unsigned numBits=nodes*(nodes-1)/2;
51+
// divide data up into chunks of size of unsigned
52+
auto d=div(numBits, int(8*sizeof(unsigned)));
53+
auto uData=reinterpret_cast<unsigned*>(data);
54+
uData[d.quot]&=(1<<d.rem)-1;
55+
// check that data is a multiple of unsigned
56+
static_assert(sizeof(data)%sizeof(unsigned)==0);
57+
for (unsigned i=d.quot+1; i<sizeof(data)/(sizeof(unsigned)); ++i)
58+
uData[i]=0;
59+
return *this;
60+
}
5061
// return true if there is a link between nodes i and j
5162
bool operator()(unsigned i,unsigned j) const {
52-
if (i<j) std::swap(i,j);
53-
auto d=div(i*(i-1)/2+j, int(8*sizeof(Impl)));
54-
return Impl(data[d.quot] & (Impl(1)<<d.rem));
63+
if (i==j) return false; // no self-links
64+
if (i<j) std::swap(i,j);
65+
auto d=div(i*(i-1)/2+j, int(8*sizeof(unsigned)));
66+
auto uData=reinterpret_cast<const unsigned*>(data);
67+
return uData[d.quot] & 1<<d.rem;
5568
}
5669
bool empty() const {
5770
for (unsigned i=0; i<size; ++i)

models/starComplexity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
maxStars=max(maxStars,v)
1313

1414
print('maxStars=',maxStars)
15-
maxStars=9
15+
maxStars=10
1616

1717
#starC.blockSize(256)
1818
starC.blockSize(4096)

0 commit comments

Comments
 (0)