修改参数为 cmdline 方式
This commit is contained in:
parent
c168c7a8dd
commit
c620e058c6
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
build
|
||||
build
|
||||
.nfs*
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.ejs": "html",
|
||||
"cstring": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"iostream": "cpp",
|
||||
@ -74,6 +75,7 @@
|
||||
"regex": "cpp",
|
||||
"scoped_allocator": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"valarray": "cpp"
|
||||
"valarray": "cpp",
|
||||
"strstream": "cpp"
|
||||
}
|
||||
}
|
12
build.sh
12
build.sh
@ -6,17 +6,15 @@ COMPILE_THREADS=16
|
||||
|
||||
# build kissat
|
||||
|
||||
cd kissat-inc
|
||||
./configure
|
||||
make -j $COMPILE_THREADS
|
||||
cd ..
|
||||
# cd kissat-inc
|
||||
# ./configure
|
||||
# make -j $COMPILE_THREADS
|
||||
# cd ..
|
||||
|
||||
# build and copy light-solver
|
||||
|
||||
make -C src-light-solver -j $COMPILE_THREADS
|
||||
cp src-light-solver/build/light-solver .
|
||||
|
||||
# build and copy light-master
|
||||
|
||||
make -C src-light-master -j $COMPILE_THREADS
|
||||
cp src-light-master/build/light-master .
|
||||
make -C src-light-master -j $COMPILE_THREADS
|
BIN
light-master
BIN
light-master
Binary file not shown.
1
light-master
Symbolic link
1
light-master
Symbolic link
@ -0,0 +1 @@
|
||||
./src-light-master/build/light-master
|
BIN
light-solver
BIN
light-solver
Binary file not shown.
1
light-solver
Symbolic link
1
light-solver
Symbolic link
@ -0,0 +1 @@
|
||||
./src-light-solver/build/light-solver
|
18
makefile
18
makefile
@ -1,18 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
build-kissat:
|
||||
cd kissat-inc
|
||||
ls
|
||||
sh ./configure
|
||||
make
|
||||
|
||||
|
||||
all: build-kissat
|
||||
make -C src-light-master
|
||||
make -C src-light-solver
|
||||
cp src-light-master/build/light-master .
|
||||
cp src-light-solver/build/light-solver .
|
||||
|
@ -2,28 +2,9 @@
|
||||
|
||||
#include "master.h"
|
||||
|
||||
// struct {
|
||||
// std::string ip_addr;
|
||||
// std::vector<std::string> solver_ip_addrs;
|
||||
// std::string instance;
|
||||
// }opt;
|
||||
|
||||
// void parse_input(const nlohmann::json& config) {
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// void run_master(const nlohmann::json& config) {
|
||||
// parse_input(config);
|
||||
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
int main() {
|
||||
printf("This is master!\n");
|
||||
printf("=====================================\n");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
||||
#include "utils/cmdline.h"
|
||||
|
||||
light::light():
|
||||
finalResult (0),
|
||||
winner_period (1e9),
|
||||
@ -19,7 +21,6 @@ light::~light() {
|
||||
workers.clear(true);
|
||||
}
|
||||
|
||||
|
||||
void light::configure_from_file(const char* file) {
|
||||
if (!strcmp(file, "")) {
|
||||
configure_name = new vec<char*>[OPT(threads)];
|
||||
@ -64,28 +65,43 @@ void light::configure_from_file(const char* file) {
|
||||
}
|
||||
|
||||
void light::arg_parse(int argc, char **argv) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
char *arg = argv[i];
|
||||
if (arg[0] != '-' || arg[1] != '-') {
|
||||
filename = arg; continue;
|
||||
}
|
||||
int l = strlen(arg), pos = 0;
|
||||
for (int i = 2; i < l; i++)
|
||||
if (arg[i] == '=') pos = i;
|
||||
if (!pos) continue;
|
||||
char name[50];
|
||||
strncpy(name, arg + 2, pos - 2);
|
||||
name[pos - 2] = '\0';
|
||||
char* val = arg + pos + 1;
|
||||
if (opt->map_int.count(name)) opt->set_para(name, atoi(val));
|
||||
else if (opt->map_double.count(name)) opt->set_para(name, atof(val));
|
||||
else opt->set_para(name, val);
|
||||
}
|
||||
opt->sync_paras();
|
||||
printf("%s\n", OPT(config).c_str());
|
||||
cmdline::parser parser;
|
||||
|
||||
// define argument list
|
||||
parser.add<std::string>("inst", 'i', "CNF format instance", true, "");
|
||||
|
||||
#define PARA(N, T, D, L, H, C) \
|
||||
if (!strcmp(#T, "int")) parser.add<int>(#N, '\0', C, false, D, cmdline::range((int)L, (int)H)); \
|
||||
else parser.add<double>(#N, '\0', C, false, D, cmdline::range((double)L, (double)H));
|
||||
PARAS
|
||||
#undef PARA
|
||||
|
||||
parser.parse_check(argc, argv);
|
||||
|
||||
// set cnf filename
|
||||
std::string file_string = parser.get<std::string>("inst");
|
||||
filename = new char[file_string.size() + 1];
|
||||
memcpy(filename, file_string.c_str(), file_string.length());
|
||||
filename[file_string.length()] = '\0';
|
||||
|
||||
#define PARA(N, T, D, L, H, C) \
|
||||
if (!strcmp(#T, "int")) OPT(N) = parser.get<int>(#N); \
|
||||
else OPT(N) = parser.get<double>(#N);
|
||||
PARAS
|
||||
#undef PARA
|
||||
|
||||
// print arguments
|
||||
printf("------------ arguments ------------\n");
|
||||
|
||||
printf("%-20s: %s\n", "inst", filename);
|
||||
|
||||
#define PARA(N, T, D, L, H, C) \
|
||||
if (!strcmp(#T, "int")) printf("%-20s: %-10d\n", #N, OPT(N)); \
|
||||
else printf("%-20s: %-10.2f\n", #N, OPT(N));
|
||||
PARAS
|
||||
#undef PARA
|
||||
|
||||
printf("-----------------------------------\n");
|
||||
|
||||
configure_from_file(OPT(config).c_str());
|
||||
printf("444\n");
|
||||
opt->sync_paras();
|
||||
opt->print_change();
|
||||
printf("c filename: %s\n", filename);
|
||||
}
|
@ -7,14 +7,6 @@
|
||||
#include "utils/cmdline.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
cmdline::parser a;
|
||||
|
||||
a.add<std::string>("inst", 'i', "CNF format instance", true, "");
|
||||
|
||||
a.parse_check(argc, argv);
|
||||
|
||||
solve(argc, argv);
|
||||
|
||||
return 0;
|
||||
}
|
@ -6,7 +6,7 @@ OBJECTS := $(addprefix build/,$(SOURCES:%=%.o))
|
||||
|
||||
# 声明编译器和编译选项
|
||||
CXX := g++
|
||||
CXXFLAGS := -O3 -Wall -Wextra -MMD -MP -flto
|
||||
CXXFLAGS := -O0 -Wall -Wextra -MMD -MP -g
|
||||
|
||||
LIBS := -lkissat -L../kissat-inc/build -I ../kissat-inc/ \
|
||||
-lm4ri -Lpreprocess/m4ri-20140914/.libs -I preprocess/m4ri-20140914/ \
|
||||
|
@ -176,14 +176,17 @@ int light::solve() {
|
||||
}
|
||||
|
||||
int light::run() {
|
||||
|
||||
init_workers();
|
||||
diversity_workers();
|
||||
|
||||
if (OPT(simplify)) {
|
||||
pre = new preprocess();
|
||||
int res = pre->do_preprocess(filename);
|
||||
if (!res) return 20;
|
||||
}
|
||||
else worker_sign = filename;
|
||||
|
||||
parse_input();
|
||||
if (OPT(share)) share();
|
||||
int res = solve();
|
||||
|
Loading…
x
Reference in New Issue
Block a user