Files
psat/main.c
gothictomato 53a580d0ec CSFLOC rewrite
Signed-off-by: gothictomato <gothictomato@pm.me>
2022-09-04 10:52:28 -04:00

162 lines
3.1 KiB
C

#include <stdio.h>
#include "gpusolver.h"
#include "time.h"
#include "tests/masterTest.h"
#include "gmp.h"
#include "rng.h"
#include "ncnf.h"
#include "cpusolver.h"
void printbits(unsigned a) {
for (unsigned i = 0; i < 32; ++i) {
unsigned ind = 31 - i;
printf("%u", (a >> ind) & 1U);
}
}
#define TESTS (274877906944LU >> 10U)
#define CSZE (83LU)
#define eqprob (0.01f)
void mul(u32* c, u32 len, u32* a, u32 b) {
u32 carry = 0;
for (u32 i = 0; i < len; ++i) {
u32 ncarry;
u32 blo = a[i] & 0xFFFFU;
u32 bhi = a[i] >> 16U;
u32 ilo = b & 0xFFFFU;
u32 ihi = b >> 16U;
*(c + i) = ilo * blo;
u32 b1 = ilo * bhi;
u32 c1 = ihi * blo;
ncarry = ihi * bhi;
b1 += c1;
ncarry += (b1 < c1) << 16U;
u32 bblo = b1 & 0xFFFFU;
u32 bbhi = b1 >> 16U;
bblo <<= 16U;
*(c + i) += bblo;
u8 acarry = *(c + i) < bblo;
ncarry += bbhi + acarry;
c[i] += carry;
ncarry += c[i] < carry;
carry = ncarry;
}
}
i32 runuf20lol() {
u32 passed = 0;
u64 tottime = 0;
for (u32 i = 0; i < 1000; ++i) {
char buf[128];
i32 len = sprintf(buf, "/home/lev/Downloads/uf20/uf20-0%u.cnf", i + 1);
debugsolve(buf);
passed++;
}
return 1;
}
i32 runuf50lol() {
u32 passed = 0;
u64 tottime = 0;
for (u32 i = 0; i < 1000; ++i) {
char buf[128];
i32 len = sprintf(buf, "/home/lev/Downloads/uf50/uf50-0%u.cnf", i + 1);
debugsolve(buf);
passed++;
}
return 1;
}
int main() {
// debugsolve("/home/lev/Downloads/uf50/uf50-01.cnf");
// runuf20lol();
runTests();
/*
srand( utime());
u32 cnt = 4096;
printf("p cnf %u %u\n", cnt, cnt);
for (u32 i = 0; i < cnt; ++i) {
printf("%s%u 0\n", (rand() & 1U) ? ("") : ("-"), i + 1);
if ((i & 0xFF) == 0) {
srand(utime() ^ rand());
}
}
return 0;
*/
/*
for (uint i = 0; i < 1000; ++i) {
char buf[128];
i32 len = sprintf(buf, "/home/lev/Downloads/uf50/uf50-0%u.cnf", i + 1);
}
*/
/* Expects a path to a DIMACS file */
/*
cnf* c = readDIMACS("/home/lev/Downloads/uf20/uf20-03.cnf");
sortlastnum(c);
// gpusolve(c);
gpusolver* gs = initSolver();
if (gs == NULL) return -1;
i32 res = gpusolve2(gs, c);
freeSolver(gs);
freecnf(c);
return 0;
*/
// runTests();
// return 0;
/*
// printf("%u\n", c->litcnt);
// for (u32 i = 0; i < c->clausecnt; ++i) printf("%u ", c->lastvars[i]);
//printf("\ntomato\n");
sortlastnum(c, c->litcnt);
// printf("%u\n", c->lastvars[c->clauses[0]]);
//printf("%u %u %u\n\n", c->litcnt, c->varcnt, c->clausecnt);
u64 start = utime();
i32 res = gpusolve(c);
u64 stop = utime();
// printf("%s : %d\n", buf, res);
printf("Took %f seconds\n", ((f64) (stop - start)) / 1000000.0);
// printf("please don't\n");
// if (res == 1) break;
freecnf(c);
return 0;*/
}