kokkos-utils 0.0.6
Loading...
Searching...
No Matches
TestWorkload.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_UTILS_TESTS_CALLBACKS_TESTWORKLOAD_HPP
2#define KOKKOS_UTILS_TESTS_CALLBACKS_TESTWORKLOAD_HPP
3
4#include "Kokkos_Macros.hpp"
5#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
6import kokkos.core;
7#else
8#include "Kokkos_Core.hpp"
9#endif
10
11#include "Kokkos_Profiling_ProfileSection.hpp"
12#include "Kokkos_Profiling_ScopedRegion.hpp"
13
15{
16
17template <Kokkos::ExecutionSpace Exec>
19{
20 struct MyFunctor
21 {
22 template <std::integral T>
23 KOKKOS_FUNCTION
24 void operator()(const T) const {}
25 };
26
27 void execute(const Exec& exec) const
28 {
29 Kokkos::Profiling::ProfilingSection profile_section("profile section");
30
31 profile_section.start();
32
33 {
34 const Kokkos::Profiling::ScopedRegion guard_level_0("computation - level 0");
35
36 Kokkos::parallel_for(
37 "computation - level 0 - pfor",
38 Kokkos::RangePolicy(exec, 0, 1),
39 MyFunctor{}
40 );
41 exec.fence("computation - level 0 - fence after pfor");
42
43 Kokkos::Profiling::markEvent("buried marker");
44
45 {
46 const Kokkos::Profiling::ScopedRegion guard_level_1("computation - level 1");
47
48 // Another kernel, a parallel reduce on the default execution space instance.
49 double my_result;
50 Kokkos::parallel_reduce(
51 "computation - level 1 - preduce on default exec",
52 Kokkos::RangePolicy(0, 1),
53 KOKKOS_LAMBDA (const typename Exec::size_type, const double&) {},
54 my_result
55 );
56 }
57 }
58
59 profile_section.stop();
60
61 exec.fence("other fence after stopping the profile section");
62 }
63};
64
65} // namespace Kokkos::utils::tests::callbacks
66
67#endif // KOKKOS_UTILS_TESTS_CALLBACKS_TESTWORKLOAD_HPP
KOKKOS_FUNCTION void operator()(const T) const