profiling and ~64x perf improvements

lean
Avril 4 years ago
parent a2167bd106
commit 5d4a44ab57
Signed by: flanchan
GPG Key ID: 284488987C31F630

1
.gitignore vendored

@ -3,3 +3,4 @@ obj
build/
test/
shuffle3-*
profiling/

@ -16,6 +16,8 @@ RELEASE_LDFLAGS?= -O3 -flto
DEBUG_CFLAGS?= -g -O0
DEBUG_LDFLAGS?= -O0
STRIP=strip
OBJ = $(addprefix obj/,$(SRC:.c=.o))
.PHONY: release
@ -35,7 +37,7 @@ $(BUILD)/$(PROJECT)-release: CFLAGS+= $(RELEASE_CFLAGS)
$(BUILD)/$(PROJECT)-release: LDFLAGS+= $(RELEASE_LDFLAGS)
$(BUILD)/$(PROJECT)-release: $(OBJ)
$(CC) $^ $(CFLAGS) -o $@ $(LDFLAGS)
strip $@
$(STRIP) $@
$(BUILD)/$(PROJECT)-debug: CFLAGS+= $(DEBUG_CFLAGS)
$(BUILD)/$(PROJECT)-debug: LDFLAGS+= $(DEBUG_LDFLAGS)

@ -16,7 +16,9 @@ CXX_OPT_FLAGS?= $(OPT_FLAGS) -felide-constructors
CFLAGS += $(COMMON_FLAGS) --std=gnu11
CXXFLAGS += $(COMMON_FLAGS) --std=gnu++20 -fno-exceptions
LDFLAGS += -lfmt
LDFLAGS += -lfmt
STRIP=strip
RELEASE_CFLAGS?= -O3 -flto $(OPT_FLAGS)
RELEASE_CXXFLAGS?= -O3 -flto $(CXX_OPT_FLAGS)
@ -58,7 +60,7 @@ $(PROJECT)-release: CXXFLAGS += $(RELEASE_CXXFLAGS)
$(PROJECT)-release: LDFLAGS += $(RELEASE_LDFLAGS)
$(PROJECT)-release: $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
strip $@
$(STRIP) $@
$(PROJECT)-debug: CFLAGS+= $(DEBUG_CFLAGS)
$(PROJECT)-debug: CXXFLAGS += $(DEBUG_CXXFLAGS)

@ -23,7 +23,7 @@ namespace rng {
inline void unshuffle(R& rng, span<T> span)
{
if(!span.size()) return;
std::vector<std::size_t> rng_values;
std::vector<std::size_t> rng_values(span.size());
fmt::print(" -> unshuffling {} objects...", span.size());
for(std::size_t i=span.size()-1;i>0;i--)

@ -13,37 +13,9 @@
_Static_assert(sizeof(float)==sizeof(uint32_t), "float is not 32 bits");
struct prog_args {
int argc;
char ** argv;
};
/*
static void shuffle_file(const char* filename)
{
panic("unimplemented");
}
static void unshuffle_file(const char* filename)
{
panic("unimplemented");
}*/
//XXX: Not using this anymore
static void* map_callback(mmap_t map, void* user)
{
struct prog_args args = *(struct prog_args*)user;
dprintf("fd %d mapped (sz %lu) (ptr %p)\n", map.fd, map.len, map.ptr);
return NULL;
}
int main(int argc, char** argv)
{
struct prog_args args = {.argc = argc, .argv = argv};
//struct prog_args args = {.argc = argc, .argv = argv};
//rng_test();
@ -62,26 +34,3 @@ int main(int argc, char** argv)
return 0;
}
#ifdef _TEST
static void do_reinterpret_test()
{
char* string = "Hello world.. how are you?????";
size_t string_sz = strlen(string);
size_t outsz;
uint64_t* string_as_longs = bytes_to_long((uint8_t*)string, string_sz, &outsz);
printf("%s (%lu) -> u64 %lu\n", string, string_sz, outsz);
for (register int i=0;i<outsz;i++) {
printf(" %lu\n", string_as_longs[i]);
}
printf("OK!\n\n");
float* string_as_floats = bytes_to_float((uint8_t*)string, string_sz, &outsz);
printf("%s (%lu) -> f32 %lu\n", string, string_sz, outsz);
for (register int i=0;i<outsz;i++) {
printf(" %f\n", string_as_floats[i]);
}
printf("OK!\n\n");
}
#endif

@ -17,12 +17,16 @@ std::tuple<T, T> minmax_t(const span<T>& array, Fn keep)
{
T highest;
T lowest;
bool init=false;
for(std::size_t i=0;i<array.size();i++)
{
if(!keep(array[i])) continue;
auto item = array[i];
if(!i) lowest = highest = item;
if(!init) {
init = true;
lowest = highest = item;
}
else if(item < lowest) lowest = item;
else if(item > highest) highest = item;
}

Loading…
Cancel
Save