MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / main

Function main

examples/parallel/parallel.cpp:156–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156int main(int argc, char ** argv) {
157 std::setlocale(LC_NUMERIC, "C");
158
159 srand(1234);
160
161 common_params params;
162
163 params.n_predict = 128;
164 params.n_junk = 1;
165
166 common_init();
167
168 if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_PARALLEL)) {
169 return 1;
170 }
171
172 // number of simultaneous "clients" to simulate
173 const int32_t n_clients = params.n_parallel;
174
175 // dedicate one sequence to the system prompt
176 params.n_parallel += 1;
177
178 // requests to simulate
179 const int32_t n_seq = params.n_sequences;
180
181 // insert new requests as soon as the previous one is done
182 const bool cont_batching = params.cont_batching;
183
184 // is the system prompt shared in the cache
185 const bool is_sp_shared = params.is_pp_shared;
186
187 // extra text to insert in each client's prompt in order to make it larger
188 const int32_t n_junk = std::max(1, params.n_junk);
189
190 // signed seed, use negative values to indicate different seeds for the different clients
191 const int32_t & sseed = params.sampling.seed;
192
193 // init llama.cpp
194 llama_backend_init();
195 llama_numa_init(params.numa);
196
197 // load the target model
198 auto llama_init = common_init_from_params(params);
199
200 auto * model = llama_init->model();
201 auto * ctx = llama_init->context();
202
203 auto * mem = llama_get_memory(ctx);
204
205 const llama_vocab * vocab = llama_model_get_vocab(model);
206
207 // load the prompts from an external file if there are any
208 if (params.prompt.empty()) {
209 LOG_INF("\033[32mNo new questions so proceed with build-in defaults.\033[0m\n");
210 } else {
211 // Output each line of the input params.prompts vector and copy to k_prompts
212 int index = 0;
213 LOG_INF("\033[32mNow printing the external prompt file %s\033[0m\n\n", params.prompt_file.c_str());

Callers

nothing calls this directly

Calls 15

common_initFunction · 0.85
common_params_parseFunction · 0.85
maxFunction · 0.85
llama_backend_initFunction · 0.85
llama_numa_initFunction · 0.85
common_init_from_paramsFunction · 0.85
llama_get_memoryFunction · 0.85
llama_model_get_vocabFunction · 0.85
split_stringFunction · 0.85
llama_n_ctxFunction · 0.85
common_sampler_initFunction · 0.85
common_tokenizeFunction · 0.85

Tested by

no test coverage detected