Skip to content

Commit 6dd0089

Browse files
Throw if specified nodees exceeds maximum configured
starUpperBound should never return 0. Fixes for SYCL
1 parent b5d5b37 commit 6dd0089

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

models/starComplexity.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ linkRep edge(unsigned i, unsigned j)
3939

4040
void StarComplexityGen::generateElementaryStars(unsigned nodes)
4141
{
42+
if (nodes>maxNodes)
43+
throw runtime_error("nodes requested exceeds maximum configured: "+to_string(maxNodes));
4244
for (unsigned i=0; i<nodes; ++i)
4345
{
4446
linkRep star=0;
@@ -617,7 +619,6 @@ unsigned StarComplexityGen::starUpperBound(const linkRep& x) const
617619
{
618620
unsigned ub=::starUpperBound(x, elemStars.size());
619621
unsigned complementUb=::starUpperBound(~x, elemStars.size());
620-
if (ub==0) return complementUb;
621-
if (complementUb==0) return ub;
622-
return min(::starUpperBound(x, elemStars.size()), ::starUpperBound(~x,elemStars.size()));
622+
assert(ub>0 && complementUb>0);
623+
return min(ub, complementUb);
623624
}

models/starComplexity.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// hard code maximum number of nodes
2-
constexpr unsigned maxNodes=8, maxStars=2*maxNodes-1;
2+
constexpr unsigned maxNodes=10, maxStars=2*maxNodes-1;
33

44
//using linkRep=unsigned long long;
55

@@ -51,7 +51,7 @@ class linkRepImpl
5151
bool operator()(unsigned i,unsigned j) const {
5252
if (i<j) std::swap(i,j);
5353
auto d=div(i*(i-1)/2+j, int(8*sizeof(Impl)));
54-
return (data[d.quot] & (Impl(1)<<d.rem))!=0;
54+
return Impl(data[d.quot] & (Impl(1)<<d.rem));
5555
}
5656
bool empty() const {
5757
for (unsigned i=0; i<size; ++i)

models/starComplexity.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from starComplexity import starC
55
from datetime import datetime
6-
nodes=7
6+
nodes=10
77
# computed from max_{l\in[0,L]}min(n+L-l,2l) where L=n(n-1)/2
88
maxStars=0
99
L=int(0.5*nodes*(nodes-1))
@@ -12,7 +12,7 @@
1212
maxStars=max(maxStars,v)
1313

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

1717
#starC.blockSize(256)
1818
starC.blockSize(4096)
@@ -26,14 +26,17 @@
2626
print('completed',numStars,datetime.now())
2727
starC.canonicaliseStarMap()
2828
with open(f'{nodes}-{maxStars}.csv','w') as out:
29-
print('id,links','*','C','C*','omega(g)','omega(g\')',sep=',',file=out)
29+
print('id,g,links','*','bar{*}','C','C*','omega(g)',sep=',',file=out)
3030
id=0
3131
for i in starC.starMap.keys():
3232
c=starC.complexity(i)
3333
links=0
34+
num=0
35+
m=1
3436
for j in i:
3537
links+=bin(j).count('1')
36-
37-
#print(id,links,starC.symmStar(i)-1,c.complexity(),c.starComplexity(),starC.counts[i],sep=',',file=out)
38-
print(id,bin(i[0]),starC.starMap[i],starC.starUpperBound(i));
38+
num+=m*j
39+
m*=1<<32
40+
41+
print(id,bin(num),links,starC.symmStar(i)-1,starC.starUpperBound(i)-1,c.complexity(),c.starComplexity(),starC.counts[i],sep=',',file=out)
3942
id+=1

models/vecBitSet.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class VecBitSet: public sycl::vec<T,N>
7474
VecBitSet()=default;
7575
template <class U>
7676
explicit VecBitSet(const U& x): sycl::vec<T,N>(x) {}
77+
explicit VecBitSet(Vec&& x): sycl::vec<T,N>(std::move(x)) {}
7778
VecBitSet& operator=(T x) {sycl::vec<T,N>::operator=(x); return *this;}
7879
VecBitSet& operator=(const Vec& x) {sycl::vec<T,N>::operator=(x); return *this;}
7980
operator bool() const {
@@ -129,6 +130,12 @@ class VecBitSet: public sycl::vec<T,N>
129130
}
130131
}
131132

133+
bool operator==(const VecBitSet& x) const {
134+
for (unsigned i=0; i<N; ++i)
135+
if ((*this)[i]!=x[i])
136+
return false;
137+
return true;
138+
}
132139
auto operator<=>(const VecBitSet& x) const {
133140
for (unsigned i=0; i<N; ++i)
134141
if (auto r=(*this)[i]<=>x[i]; r!=0)

0 commit comments

Comments
 (0)