MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / main

Function main

src/src/main.cpp:462–725  ·  view source on GitHub ↗

@brief main function @param argc the number of arguments @param argv the arguments @return the exit code

Source from the content-addressed store, hash-verified

460///@param argv the arguments
461///@return the exit code
462int main(int argc, char* argv[]) {
463#ifdef _WIN32
464 SetConsoleOutputCP(CP_UTF8);
465 SetConsoleCP(CP_UTF8);
466#else
467 // Preload bundled libraries from executable directory
468 preload_bundled_libraries();
469#endif
470
471 // Parse command line arguments using Boost Program Options
472 program_args_t parsed_args;
473 if (!arg_utils::parse_options(argc, argv, parsed_args)) {
474 return 1; // Help was already printed by Boost Program Options
475 }
476
477
478 // Get the command, model tag, and force flag
479 std::string exe_dir = utils::get_executable_directory();
480 std::string config_path = utils::find_model_list();
481 // Get the models directory from environment variable or default
482 std::string models_dir = utils::get_models_directory();
483
484
485 model_list availble_models(config_path, models_dir);
486
487 // Extract parsed values
488 bool got_power_mode = (parsed_args.power_mode != "performance"); // Check if user explicitly set power mode
489 bool stable_stack = false;
490
491 // Set process priority to high for better performance
492#ifdef _WIN32
493 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
494#endif
495
496 // Check if the commands and args valid
497 if (parsed_args.command == "validate") {
498 stable_stack = sanity_check_npu_stack(parsed_args.command != "validate", parsed_args.command == "validate" && parsed_args.json_output);
499 return stable_stack ? 0 : 1;
500 }
501
502 if (parsed_args.command == "run" || parsed_args.command == "serve" || parsed_args.command == "pull" || parsed_args.command == "remove" || parsed_args.command == "check" || parsed_args.command == "bench") {
503 if (parsed_args.model_tag != "model-faker" && (!availble_models.is_model_supported(parsed_args.model_tag))) {
504 header_print("ERROR", "Model not found: " << parsed_args.model_tag << "; Please check with `flm list` and try again.");
505 return 1;
506 }
507 }
508
509 if (parsed_args.command == "serve" || parsed_args.command == "run" || parsed_args.command == "bench"){
510 // Configure AMD XRT for the specified power mode
511 if (parsed_args.power_mode == "default" || parsed_args.power_mode == "powersaver" || parsed_args.power_mode == "balanced" ||
512 parsed_args.power_mode == "performance" || parsed_args.power_mode == "turbo") {
513#ifdef _WIN32
514 std::string xrt_cmd = "cd \"C:\\Windows\\System32\\AMD\" && .\\xrt-smi.exe configure --pmode " + parsed_args.power_mode + " > NUL 2>&1";
515 header_print("FLM", "Configuring NPU Power Mode to " + parsed_args.power_mode + (got_power_mode ? "" : " (flm default)"));
516 (void)system(xrt_cmd.c_str());
517#endif
518 }
519 else{

Callers

nothing calls this directly

Calls 15

parse_optionsFunction · 0.85
get_executable_directoryFunction · 0.85
find_model_listFunction · 0.85
get_models_directoryFunction · 0.85
sanity_check_npu_stackFunction · 0.85
get_server_portFunction · 0.85
run_benchmarksFunction · 0.85
create_lm_serverFunction · 0.85
is_model_supportedMethod · 0.80
get_model_infoMethod · 0.80

Tested by

no test coverage detected