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

Function solve

examples/sudoku.cpp:370–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370std::tuple<unsigned, unsigned, unsigned, std::chrono::steady_clock::duration>
371solve(stdexec::parallel_scheduler sch, unsigned short const *init_values)
372{
373 nSols = 0;
374 nTasks = 0;
375 nRaces = 0;
376 std::unique_ptr<board_element[]> start_board{new board_element[BOARD_SIZE]};
377 init_board(start_board.get(), init_values);
378 auto start = std::chrono::steady_clock::now();
379 stdexec::inplace_stop_source stop;
380 auto canceled = []()
381 {
382 if (verbose)
383 {
384 printf("\ncanceled \n\n");
385 }
386 };
387 stdexec::inplace_stop_token::template callback_type<decltype(canceled)> callback(stop.get_token(),
388 canceled);
389 stdexec::simple_counting_scope scope;
390 spawn_partial_solve(sch, scope, stop, std::move(start_board), 0);
391 stdexec::sync_wait(scope.join());
392 return std::make_tuple((unsigned) nSols,
393 (unsigned) nTasks,
394 (unsigned) nRaces,
395 std::chrono::steady_clock::now() - start);
396}
397
398using double_sec = std::chrono::duration<double>;
399

Callers 1

mainFunction · 0.85

Calls 5

init_boardFunction · 0.85
spawn_partial_solveFunction · 0.85
getMethod · 0.45
get_tokenMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected