template <typename ViewType, char Value, std::size_t Index>
struct Write {
KOKKOS_FUNCTION
void operator()()
const noexcept {
}
};
template <Kokkos::ExecutionSpace Exec>
public:
static constexpr std::string_view
pattern =
"SORRY HERACLES";
public:
,
data(Kokkos::view_alloc(this->exec,
"data")) {
}
const auto mirror = Kokkos::create_mirror_view_and_copy(
data);
const std::string_view got{mirror.data(),
pattern.size()};
std::printf(
"%s\n",
std::format(
"The Lernaean hydra has {} heads. They all spoke at once, inside the graph, and said: '{}'.",
got)
.c_str());
throw std::runtime_error(
std::format(
"Heracles got to a head: got '{}', expected '{}'. Fetch Iolaus and a torch.", got,
pattern));
std::printf(
"Every head survived the labours. Want a bigger monster? Add characters to 'pattern'.\n");
}
auto sndr = [&]<std::size_t... Is>(std::index_sequence<Is...>) {
return stdexec::when_all(
| stdexec::then(Write<
view_t,
pattern.at(Is), Is>{.data = data}))...);
}(std::make_index_sequence<
pattern.size()>{});
this->exec.fence();
stdexec::sync_wait(std::move(sndr));
}
protected:
};
}
int main(
int argc,
char* argv[]) {
const Kokkos::ScopeGuard guard{argc, argv};
{
}
return EXIT_SUCCESS;
}
int main(int argc, char **argv)
Kokkos::View< char[pattern.size()+1], Exec > view_t
One extra slot, zero-initialized, so the result is always null-terminated.
static constexpr std::string_view pattern
One branch (head) per character. To grow another head, extend the string.
Kokkos::utils::tests::scoped::ExecutionSpace< Exec > base_t
void operator()() const noexcept
Execution context using Kokkos::Experimental::Graph under the hood.
auto get_scheduler() const noexcept -> GraphImpl::Scheduler< execution_space >