diff --git a/selfdrive/modeld/test/dmon_lag/repro.cc b/selfdrive/modeld/test/dmon_lag/repro.cc index 2c0f234894..1ff01f6ab6 100644 --- a/selfdrive/modeld/test/dmon_lag/repro.cc +++ b/selfdrive/modeld/test/dmon_lag/repro.cc @@ -1,6 +1,7 @@ // clang++ -mcpu=cortex-a57 -O2 repro.cc -#include +#include +#include #include #include @@ -24,14 +25,6 @@ int set_realtime_priority(int level) { #define MODEL_HEIGHT 640 #define input_lambda(x) (x - 128.f) * 0.0078125f -template -static inline T *get_buffer(std::vector &buf, const size_t size) { - if (buf.size() < size) { - buf.resize(size); - } - return buf.data(); -} - void inner(uint8_t *resized_buf, float *net_input_buf) { int resized_width = MODEL_WIDTH; int resized_height = MODEL_HEIGHT; @@ -57,15 +50,15 @@ void inner(uint8_t *resized_buf, float *net_input_buf) { } float trial() { - std::vector vec_resized_buf; - std::vector vec_net_input_buf; - int resized_width = MODEL_WIDTH; int resized_height = MODEL_HEIGHT; - uint8_t *resized_buf = get_buffer(vec_resized_buf, resized_width*resized_height*3/2); int yuv_buf_len = (MODEL_WIDTH/2) * (MODEL_HEIGHT/2) * 6; // Y|u|v -> y|y|y|y|u|v - float *net_input_buf = get_buffer(vec_net_input_buf, yuv_buf_len); + + uint8_t *resized_buf = (uint8_t*)malloc(resized_width*resized_height*3/2); + float *net_input_buf = (float*)malloc(yuv_buf_len*sizeof(float)); + + printf("allocate -- %p 0x%x -- %p 0x%lx\n", resized_buf, resized_width*resized_height*3/2, net_input_buf, yuv_buf_len*sizeof(float)); float avg = 0.0; for (int i = 0; i < 20; i++) { @@ -96,12 +89,18 @@ float trial() { exit(0); } + + // don't free + //free(resized_buf); + //free(net_input_buf); + return avg; } int main() { // the realtime priority seems to be what breaks it - set_realtime_priority(51); + // nope, breaks without it too + //set_realtime_priority(51); while (1) { float ret = trial();