diff --git a/SConstruct b/SConstruct index d41cbc16cd..d5f46f8d9d 100644 --- a/SConstruct +++ b/SConstruct @@ -51,6 +51,11 @@ AddOption('--external-sconscript', dest='external_sconscript', help='add an external SConscript to the build') +AddOption('--no-thneed', + action='store_true', + dest='no_thneed', + help='avoid using thneed') + real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() if platform.system() == "Darwin": arch = "Darwin" diff --git a/selfdrive/modeld/SConscript b/selfdrive/modeld/SConscript index a0548ee362..8e4f2569e0 100644 --- a/selfdrive/modeld/SConscript +++ b/selfdrive/modeld/SConscript @@ -26,14 +26,17 @@ thneed_src = [ "runners/thneedmodel.cc", ] +use_thneed = not GetOption('no_thneed') + if arch == "aarch64" or arch == "larch64": libs += ['gsl', 'CB'] libs += ['gnustl_shared'] if arch == "aarch64" else ['pthread', 'dl'] - common_src += thneed_src - dlsym_offset = get_dlsym_offset() - lenv['CXXFLAGS'].append("-DUSE_THNEED") - lenv['CXXFLAGS'].append(f"-DDLSYM_OFFSET={dlsym_offset}") + if use_thneed: + common_src += thneed_src + dlsym_offset = get_dlsym_offset() + lenv['CXXFLAGS'].append("-DUSE_THNEED") + lenv['CXXFLAGS'].append(f"-DDLSYM_OFFSET={dlsym_offset}") else: libs += ['pthread'] @@ -58,7 +61,7 @@ else: common_model = lenv.Object(common_src) # build thneed model -if arch == "aarch64" or arch == "larch64": +if use_thneed and arch in ("aarch64", "larch64"): compiler = lenv.Program('thneed/compile', ["thneed/compile.cc"]+common_model, LIBS=libs) cmd = f"cd {Dir('.').abspath} && {compiler[0].abspath} ../../models/supercombo.dlc ../../models/supercombo.thneed --binary" @@ -75,4 +78,3 @@ lenv.Program('_modeld', [ "modeld.cc", "models/driving.cc", ]+common_model, LIBS=libs) - diff --git a/selfdrive/modeld/models/driving.cc b/selfdrive/modeld/models/driving.cc index ba48af051e..8bb46ee0a3 100644 --- a/selfdrive/modeld/models/driving.cc +++ b/selfdrive/modeld/models/driving.cc @@ -61,7 +61,7 @@ void model_init(ModelState* s, cl_device_id device_id, cl_context context) { constexpr int output_size = OUTPUT_SIZE + TEMPORAL_SIZE; s->output.resize(output_size); -#if defined(QCOM) || defined(QCOM2) +#if (defined(QCOM) || defined(QCOM2)) && defined(USE_THNEED) s->m = std::make_unique("../../models/supercombo.thneed", &s->output[0], output_size, USE_GPU_RUNTIME); #else s->m = std::make_unique("../../models/supercombo.dlc", &s->output[0], output_size, USE_GPU_RUNTIME);