Compare commits

...

7 Commits

Author SHA1 Message Date
Avril d888db66b3
Fix unresolving `std::terminate()`
3 years ago
Avril 040ddbfa56
fix pgo partial rebuilds
4 years ago
Avril f7997ca157
fixed array initialisation bug
4 years ago
Avril fc8e1a89e7
whoops
4 years ago
Avril 499efe45e8
reorder
4 years ago
Avril 645500989a
reorganise
4 years ago
Avril 82d8fd44c7
rearrange
4 years ago

@ -66,7 +66,10 @@ $(PROJECT)-debug: $(OBJ)
pgo-generate: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
pgo-profile: pgo-generate
pgo-reset:
find ./profile -name \*.gcda -exec rm {} +
pgo-profile: | pgo-reset pgo-generate
for i in {1..$(PGO_ITERATIONS)}; do \
dd if=/dev/urandom of=/tmp/$(PROJECT)-pgo-test bs=1024 count=$(PGO_DATASET_SIZE) >> /dev/null 2>&1; \
printf "\rIteration $$i / $(PGO_ITERATIONS)"; \

@ -31,6 +31,9 @@ namespace hv {
{
int pos = (x & 0xFF) * 2;
char ch = lut[pos];
#ifdef DEBUG
if ( (i*2+1) >=16) std::terminate();
#endif
s[i * 2] = ch;
ch = lut[pos + 1];

@ -1,5 +1,6 @@
#pragma once
#include <exception>
#include <cstdint>
#include <cmath>

@ -61,7 +61,7 @@ inline void hex02(std::uint8_t byte, char buffer[2])
}
template<std::size_t N>
inline __attribute((always_inline)) void print_exact(const char* ar)
inline __attribute__((always_inline)) void print_exact(const char* ar)
{
fwrite(ar, 1, N, stdout);
}
@ -75,17 +75,6 @@ inline __attribute__((always_inline)) void print_exact(const char (&ar)[N])
inline static void u64_to_hex(std::uint64_t num, char* s)
{
hv::lookup_hex_string(num, s);
#if 0
std::uint64_t x = num;
x = ((x & 0xFFFF) << 32) | ((x & 0xFFFF0000) >> 16);
x = ((x & 0x0000FF000000FF00) >> 8) | (x & 0x000000FF000000FF) << 16;
x = ((x & 0x00F000F000F000F0) >> 4) | (x & 0x000F000F000F000F) << 8;
uint64_t mask = ((x + 0x0606060606060606) >> 4) & 0x0101010101010101;
x += 0x27 * mask;
*(uint64_t *)s = x;
#endif
}
namespace hv {
@ -99,26 +88,28 @@ namespace hv {
#define S
#define P_EX(n, buf) print_exact(buf)
#endif
char posbuf[3 + 16 + 2] = { '0' };
char posbuf[3 + 16 + 2];
posbuf[0] = '\n';
posbuf[1] = '0';
posbuf[2] = 'x';
#ifdef DEBUG
std::memset(posbuf+3, '0', 16);
#endif
posbuf[3 + 16] = ' ';
posbuf[3 + 16 + 1] = ' ';
u64_to_hex(offset, posbuf+3);
prints(posbuf+1);
char hxbuf[3];
char hxbuf[3] = { ' ', ' ', ' ' };
std::size_t i=0;
char r_ascii[2 + ROW_SZ];
r_ascii[0] = ' ';
r_ascii[1] = ' ';
char* ascii = r_ascii + 2;
const auto memsize = memory.size();
hxbuf[2] = ' ';
for(;i<memory.size();i++) {
for(;i<memsize;i++) {
if (i && i % ROW_SZ == 0) { //TODO: Change to i +=16 so we don't have to branch here on every byte. Make sure to not overrun buffer tho
P_EX(S, r_ascii);
@ -131,9 +122,9 @@ namespace hv {
ascii[i%ROW_SZ] = ascii_map[idx];
}
if (memory.size() % ROW_SZ != 0)
if (memsize % ROW_SZ != 0)
{
auto rest = memory.size() % ROW_SZ;
auto rest = memsize % ROW_SZ;
ascii[rest] = 0;
constexpr const char output[3] = { ' ', ' ', ' ' };
for(std::size_t j=0;j< ROW_SZ - rest;j++)

Loading…
Cancel
Save