87
tests/masterTest.c
Normal file
87
tests/masterTest.c
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "masterTest.h"
|
||||
#include <stdio.h>
|
||||
#include "../cnf.h"
|
||||
#include "../gpusolver.h"
|
||||
#include "../time.h"
|
||||
|
||||
i32 runTests() {
|
||||
i32 res = runuf20();
|
||||
if (res != 0) return res;
|
||||
res = runuf50();
|
||||
if (res != 0) return res;
|
||||
res = runuuf50();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
i32 runuf20() {
|
||||
printf("Running against uf20\n");
|
||||
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);
|
||||
|
||||
cnf* c = readDIMACS(buf);
|
||||
|
||||
sortlastnum(c, c->litcnt);
|
||||
|
||||
u64 start = utime();
|
||||
i32 res = gpusolve(c);
|
||||
u64 stop = utime();
|
||||
tottime += (stop - start);
|
||||
|
||||
freecnf(c);
|
||||
if (res == 0) passed++;
|
||||
}
|
||||
printf("Passed %u / 1000 tests\n", passed);
|
||||
printf("Took %lf s total, %lf s on avg\n", ((f64) tottime) / 1000000.0, ((f64) tottime) / 1000000000.0);
|
||||
}
|
||||
|
||||
i32 runuf50() {
|
||||
printf("Running against uf50\n");
|
||||
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);
|
||||
|
||||
cnf* c = readDIMACS(buf);
|
||||
|
||||
sortlastnum(c, c->litcnt);
|
||||
|
||||
u64 start = utime();
|
||||
i32 res = gpusolve(c);
|
||||
u64 stop = utime();
|
||||
tottime += (stop - start);
|
||||
|
||||
freecnf(c);
|
||||
if (res == 0) passed++;
|
||||
}
|
||||
printf("Passed %u / 1000 tests\n", passed);
|
||||
printf("Took %lf s total, %lf s on avg\n", ((f64) tottime) / 1000000.0, ((f64) tottime) / 1000000000.0);
|
||||
}
|
||||
|
||||
i32 runuuf50() {
|
||||
printf("Running against uuf50\n");
|
||||
u32 passed = 0;
|
||||
u64 tottime = 0;
|
||||
for (u32 i = 0; i < 1000; ++i) {
|
||||
char buf[128];
|
||||
i32 len = sprintf(buf, "/home/lev/Downloads/uuf50/uuf50-0%u.cnf", i + 1);
|
||||
|
||||
cnf* c = readDIMACS(buf);
|
||||
|
||||
sortlastnum(c, c->litcnt);
|
||||
|
||||
u64 start = utime();
|
||||
i32 res = gpusolve(c);
|
||||
u64 stop = utime();
|
||||
tottime += (stop - start);
|
||||
|
||||
freecnf(c);
|
||||
if (res == 0) passed++;
|
||||
}
|
||||
printf("Passed %u / 1000 tests\n", passed);
|
||||
printf("Took %lf s total, %lf s on avg\n", ((f64) tottime) / 1000000.0, ((f64) tottime) / 1000000000.0);
|
||||
}
|
||||
Reference in New Issue
Block a user