kokkos-utils 0.0.1
 
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_Core.hpp"
5#include "Kokkos_Profiling_ProfileSection.hpp"
6#include "Kokkos_Profiling_ScopedRegion.hpp"
7
9
11{
12
13template <Kokkos::utils::concepts::ExecutionSpace Exec>
15{
16 struct MyFunctor
17 {
18 template <std::integral T>
19 KOKKOS_FUNCTION
20 void operator()(const T) const {}
21 };
22
23 void execute(const Exec& exec) const
24 {
25 Kokkos::Profiling::ProfilingSection profile_section("profile section");
26
27 profile_section.start();
28
29 {
30 const Kokkos::Profiling::ScopedRegion guard_level_0("computation - level 0");
31
32 Kokkos::parallel_for(
33 "computation - level 0 - pfor",
34 Kokkos::RangePolicy(exec, 0, 1),
35 MyFunctor{}
36 );
37 exec.fence("computation - level 0 - fence after pfor");
38
39 Kokkos::Profiling::markEvent("buried marker");
40
41 {
42 const Kokkos::Profiling::ScopedRegion guard_level_1("computation - level 1");
43
44 // Another kernel, a parallel reduce on the default execution space instance.
45 double my_result;
46 Kokkos::parallel_reduce(
47 "computation - level 1 - preduce on default exec",
48 Kokkos::RangePolicy(0, 1),
49 KOKKOS_LAMBDA (const typename Exec::size_type, const double&) {},
50 my_result
51 );
52 }
53 }
54
55 profile_section.stop();
56
57 exec.fence("other fence after stopping the profile section");
58 }
59};
60
61} // namespace Kokkos::utils::tests::callbacks
62
63#endif // KOKKOS_UTILS_TESTS_CALLBACKS_TESTWORKLOAD_HPP
KOKKOS_FUNCTION void operator()(const T) const