MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / main

Function main

subprojects/llama.cpp/tools/llama-bench/llama-bench.cpp:2036–2291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2034}
2035
2036int main(int argc, char ** argv) {
2037 // try to set locale for unicode characters in markdown
2038 setlocale(LC_CTYPE, ".UTF-8");
2039
2040#if !defined(NDEBUG)
2041 fprintf(stderr, "warning: asserts enabled, performance may be affected\n");
2042#endif
2043
2044#if (defined(_MSC_VER) && defined(_DEBUG)) || (!defined(_MSC_VER) && !defined(__OPTIMIZE__))
2045 fprintf(stderr, "warning: debug build, performance may be affected\n");
2046#endif
2047
2048#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__)
2049 fprintf(stderr, "warning: sanitizer enabled, performance may be affected\n");
2050#endif
2051
2052 // initialize backends
2053 ggml_backend_load_all();
2054
2055 cmd_params params = parse_cmd_params(argc, argv);
2056
2057 auto * cpu_dev = ggml_backend_dev_by_type(GGML_BACKEND_DEVICE_TYPE_CPU);
2058 if (!cpu_dev) {
2059 fprintf(stderr, "%s: error: CPU backend is not loaded\n", __func__);
2060 return 1;
2061 }
2062 auto * cpu_reg = ggml_backend_dev_backend_reg(cpu_dev);
2063 auto * ggml_threadpool_new_fn = (decltype(ggml_threadpool_new) *) ggml_backend_reg_get_proc_address(cpu_reg, "ggml_threadpool_new");
2064 auto * ggml_threadpool_free_fn = (decltype(ggml_threadpool_free) *) ggml_backend_reg_get_proc_address(cpu_reg, "ggml_threadpool_free");
2065
2066 // initialize llama.cpp
2067 if (!params.verbose) {
2068 llama_log_set(llama_null_log_callback, NULL);
2069 }
2070 llama_backend_init();
2071 llama_numa_init(params.numa);
2072
2073 if (!set_process_priority(params.prio)) {
2074 fprintf(stderr, "%s: error: failed to set process priority\n", __func__);
2075 return 1;
2076 }
2077
2078 // initialize printer
2079 std::unique_ptr<printer> p = create_printer(params.output_format);
2080 std::unique_ptr<printer> p_err = create_printer(params.output_format_stderr);
2081
2082 if (p) {
2083 p->fout = stdout;
2084 p->print_header(params);
2085 }
2086
2087 if (p_err) {
2088 p_err->fout = stderr;
2089 p_err->print_header(params);
2090 }
2091
2092 std::vector<cmd_params_instance> params_instances = get_cmd_params_instances(params);
2093

Callers

nothing calls this directly

Calls 15

ggml_backend_load_allFunction · 0.85
parse_cmd_paramsFunction · 0.85
ggml_backend_dev_by_typeFunction · 0.85
llama_log_setFunction · 0.85
llama_backend_initFunction · 0.85
llama_numa_initFunction · 0.85
set_process_priorityFunction · 0.85
get_cmd_params_instancesFunction · 0.85
llama_model_freeFunction · 0.85

Tested by

no test coverage detected