MCPcopy Create free account
hub / github.com/NVIDIA/stdexec / main

Function main

examples/sudoku.cpp:400–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398using double_sec = std::chrono::duration<double>;
399
400int main(int argc, char *argv[])
401{
402 bool silent = false;
403
404 std::vector<std::string_view> args(argv + 1, argv + argc);
405 for (auto arg: args)
406 {
407 if (arg == "find-one")
408 {
409 find_one = true;
410 }
411 else if (arg == "verbose")
412 {
413 verbose = true;
414 }
415 else if (arg == "silent")
416 {
417 silent = true;
418 }
419 else
420 {
421 printf("unrecognized argument: -> %.*s", (int) arg.size(), arg.data());
422 }
423 }
424
425 if (silent)
426 verbose = false;
427
428 auto one_solve = [&](unsigned short const *init_values)
429 {
430 auto [number, tasks, races, solve_time] = solve(stdexec::get_parallel_scheduler(), init_values);
431 if (!silent)
432 {
433 if (find_one)
434 {
435 printf("Sudoku: Time for first solution using %5u tasks with %5u "
436 "races: %9.6fs\n",
437 tasks,
438 races,
439 std::chrono::duration_cast<double_sec>(solve_time).count());
440 }
441 else
442 {
443 printf("Sudoku: Time for all %6u solutions using %7u tasks: %9.6fs\n",
444 number,
445 tasks,
446 std::chrono::duration_cast<double_sec>(solve_time).count());
447 }
448 }
449 fflush(stdout);
450 };
451
452 for (int iv = 0; iv < 4; ++iv)
453 {
454 unsigned short const *init_values = all_init_values[iv];
455 find_one = false;
456 one_solve(init_values);
457 find_one = true;

Callers

nothing calls this directly

Calls 4

solveFunction · 0.85
get_parallel_schedulerFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected