Skip to content

Commit b11ca80

Browse files
committed
Fix LL; parse args without regex
1 parent 82053b8 commit b11ca80

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ prp-*/
1212
ll-*/
1313
proof-*/
1414
config.txt
15+
txt/

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
# or export those into environment, or pass on the command line e.g.
1111
# make all DEBUG=1 CXX=g++-12
1212

13-
COMMON_FLAGS = -Wall -std=c++20 -static-libstdc++ -static-libgcc
13+
COMMON_FLAGS = -Wall -std=c++20
14+
# -static-libstdc++ -static-libgcc
1415
# -fext-numeric-literals
1516

1617

@@ -32,7 +33,9 @@ endif
3233

3334
SRCS1 = TuneEntry.cpp Primes.cpp tune.cpp CycleFile.cpp TrigBufCache.cpp Event.cpp Queue.cpp TimeInfo.cpp Profile.cpp bundle.cpp Saver.cpp SaveMan.cpp KernelCompiler.cpp Kernel.cpp gpuid.cpp File.cpp Proof.cpp log.cpp Worktodo.cpp common.cpp main.cpp Gpu.cpp clwrap.cpp Task.cpp timeutil.cpp Args.cpp state.cpp Signal.cpp FFTConfig.cpp AllocTrac.cpp sha3.cpp md5.cpp version.cpp
3435

35-
SRCS=$(addprefix src/, $(SRCS1))
36+
SRCS2 = test.cpp
37+
38+
# SRCS=$(addprefix src/, $(SRCS1))
3639

3740
OBJS = $(SRCS1:%.cpp=$(BIN)/%.o)
3841
DEPDIR := $(BIN)/.d
@@ -47,6 +50,9 @@ prpll: $(BIN)/prpll
4750

4851
amd: $(BIN)/prpll-amd
4952

53+
#$(BIN)/test: $(BIN)/test.o
54+
# $(CXX) $(CXXFLAGS) -o $@ $< $(LIBPATH) ${STRIP}
55+
5056
$(BIN)/prpll: ${OBJS}
5157
$(CXX) $(CXXFLAGS) -o $@ ${OBJS} $(LIBPATH) -lOpenCL ${STRIP}
5258

@@ -80,3 +86,4 @@ src/version.inc: FORCE
8086
FORCE:
8187

8288
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS1))))
89+
# include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS2))))

src/Args.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <vector>
1111
#include <string>
12-
#include <regex>
1312
#include <cstring>
1413
#include <cassert>
1514
#include <cstdlib>
@@ -35,18 +34,30 @@ string Args::mergeArgs(int argc, char **argv) {
3534
vector<KeyVal> Args::splitArgLine(const string& inputLine) {
3635
vector<KeyVal> ret;
3736

38-
// The line must be ended with at least one space for the regex to function correctly.
39-
string line = inputLine + ' ';
40-
std::regex rx("\\s*(-+\\w+)\\s+([^-]\\S*)?\\s*([^-]*)");
41-
for (std::sregex_iterator it(line.begin(), line.end(), rx); it != std::sregex_iterator(); ++it) {
42-
smatch m = *it;
43-
// printf("'%s' '%s' '%s'\n", m.str(1).c_str(), m.str(2).c_str(), m.str(3).c_str());
44-
string prefix = m.prefix().str();
45-
string suffix = m.str(3);
46-
if (!prefix.empty()) { log("Args: unexpected '%s' before '%s'\n", prefix.c_str(), m.str(0).c_str()); }
47-
if (!suffix.empty()) { log("Args: unexpected '%s' in '%s'\n", suffix.c_str(), m.str(0).c_str()); }
48-
if (!prefix.empty() || !suffix.empty()) { throw "Argument syntax"; }
49-
ret.push_back({m.str(1), m.str(2)});
37+
string prev;
38+
for (const string& s : split(inputLine, ' ')) {
39+
if (s.empty()) { continue; }
40+
41+
if (prev.empty()) {
42+
if (s[0] != '-') {
43+
log("Args: expected '-' before '%s'\n", s.c_str());
44+
throw "Argument syntax";
45+
}
46+
47+
prev = s;
48+
} else {
49+
if (s[0] == '-') {
50+
ret.push_back({prev, {}});
51+
prev = s;
52+
} else {
53+
ret.push_back({prev, s});
54+
prev.clear();
55+
}
56+
}
57+
}
58+
if (!prev.empty()) {
59+
assert(prev[0] == '-');
60+
ret.push_back({prev, {}});
5061
}
5162
return ret;
5263
}

src/Gpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class Gpu {
264264

265265
void carryFusedMul(Buffer<double>& a, Buffer<double>& b);
266266

267-
void carryFusedLL(Buffer<double>& a, Buffer<double>& b) { kCarryFusedLL(updateCarryPos(1<<0), a, b);}
267+
void carryFusedLL(Buffer<double>& a, Buffer<double>& b) { kCarryFusedLL(a, b, updateCarryPos(1<<0));}
268268

269269
void writeIn(Buffer<int>& buf, const vector<u32> &words);
270270

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int main(int argc, char **argv) {
117117
gpuWorker(shared, &queues[0], 0);
118118
}
119119

120-
log("No more work. Add work to worktodo.txt , see -h for details.\n");
120+
// log("No more work. Add work to worktodo.txt , see -h for details.\n");
121121
}
122122
} catch (const char *mes) {
123123
log("Exiting because \"%s\"\n", mes);

0 commit comments

Comments
 (0)