Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#4379 from rmlarsen/init_lut
Browse files Browse the repository at this point in the history
Speed up initLUT in flute.cpp by ~14x
  • Loading branch information
maliberty committed Dec 18, 2023
2 parents 75f2f32 + 7f01342 commit 56a562f
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions src/stt/src/flt/flute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,24 @@ static unsigned char charNum(unsigned char c)
return 0;
}

inline const char* readDecimalInt(const char* s, int& value)
{
value = 0;
bool negative = (*s == '-');
if (negative || *s == '+') {
++s;
}
constexpr int zero_code = int('0');
while (*s >= '0' && *s <= '9') {
value = 10 * value + (int(*s) - zero_code);
++s;
}
if (negative) {
value = -value;
}
return s;
}

// Init LUTs from base64 encoded string variables.
static void initLUT(int to_d, LUT_TYPE LUT, NUMSOLN_TYPE numsoln)
{
Expand All @@ -293,19 +311,21 @@ static void initLUT(int to_d, LUT_TYPE LUT, NUMSOLN_TYPE numsoln)
#endif

for (int d = 4; d <= to_d; d++) {
int char_cnt;
sscanf(pwv, "d=%d%n", &d, &char_cnt);
pwv += char_cnt + 1;
if (pwv[0] == 'd' && pwv[1] == '=') {
pwv = readDecimalInt(pwv + 2, d);
}
++pwv;
#if FLUTE_ROUTING == 1
sscanf(prt, "d=%d%n", &d, &char_cnt);
prt += char_cnt + 1;
if (prt[0] == 'd' && prt[1] == '=') {
prt = readDecimalInt(prt + 2, d);
}
++prt;
#endif
for (int k = 0; k < numgrp[d]; k++) {
int ns = charNum(*pwv++);
if (ns == 0) { // same as some previous group
int kk;
sscanf(pwv, "%d%n", &kk, &char_cnt);
pwv += char_cnt + 1;
pwv = readDecimalInt(pwv, kk) + 1;
numsoln[d][k] = numsoln[d][kk];
LUT[d][k] = LUT[d][kk];
} else {
Expand Down

0 comments on commit 56a562f

Please sign in to comment.