version: sunnypilot v2025.003.000 (dev) date: 2026-02-09T02:04:38 master commit: 254f55ac15a40343d7255f2f098de3442e0c4a6f
33 lines
719 B
C++
33 lines
719 B
C++
#include "sunnypilot/modeld/thneed/thneed.h"
|
|
|
|
#include <cassert>
|
|
|
|
#include "common/clutil.h"
|
|
#include "common/timing.h"
|
|
|
|
Thneed::Thneed(bool do_clinit, cl_context _context) {
|
|
context = _context;
|
|
if (do_clinit) clinit();
|
|
char *thneed_debug_env = getenv("THNEED_DEBUG");
|
|
debug = (thneed_debug_env != NULL) ? atoi(thneed_debug_env) : 0;
|
|
}
|
|
|
|
void Thneed::execute(float **finputs, float *foutput, bool slow) {
|
|
uint64_t tb, te;
|
|
if (debug >= 1) tb = nanos_since_boot();
|
|
|
|
// ****** copy inputs
|
|
copy_inputs(finputs);
|
|
|
|
// ****** run commands
|
|
clexec();
|
|
|
|
// ****** copy outputs
|
|
copy_output(foutput);
|
|
|
|
if (debug >= 1) {
|
|
te = nanos_since_boot();
|
|
printf("model exec in %lu us\n", (te-tb)/1000);
|
|
}
|
|
}
|