Interface Documentation
Version: invalid
task_attributes.hh
Go to the documentation of this file.
1 /*
2  @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3  /@@///// /@@ @@////@@ @@////// /@@
4  /@@ /@@ @@@@@ @@ // /@@ /@@
5  /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6  /@@//// /@@/@@@@@@@/@@ ////////@@/@@
7  /@@ /@@/@@//// //@@ @@ /@@/@@
8  /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9  // /// ////// ////// //////// //
10 
11  Copyright (c) 2016, Triad National Security, LLC
12  All rights reserved.
13  */
14 #pragma once
15 
18 #if !defined(__FLECSI_PRIVATE__)
19 #error Do not include this file directly
20 #endif
21 
22 #include "flecsi/util/debruijn.hh"
23 
24 #include <bitset>
25 
26 namespace flecsi {
27 
39 enum task_attributes_mask_t : size_t {
40  leaf = 0x01,
41  inner = 0x02,
42  idempotent = 0x04,
43  loc = 0x08,
44  toc = 0x10,
45  mpi = 0x20
46 }; // task_attributes_mask_t
47 
48 namespace exec {
49 
54 enum class task_type_t : size_t { leaf, inner, idempotent }; // task_type_t
55 
60 enum class task_processor_type_t : size_t {
61  loc,
62  toc,
63  mpi
64 }; // task_processor_type_t
65 
66 // Bits for representing task attributes
67 constexpr size_t task_attributes_bits = 8;
68 constexpr size_t task_type_bits = 3;
69 
70 using task_attributes_bitset_t = std::bitset<task_attributes_bits>;
71 
72 inline task_type_t
73 mask_to_task_type(size_t mask) {
74  return static_cast<task_type_t>(util::debruijn32_t::index(mask));
75 } // mask_to_task_type
76 
77 constexpr task_processor_type_t
78 mask_to_processor_type(size_t mask) {
79  const size_t processor_mask = mask >> task_type_bits;
80 
81  // flog_assert(processor_mask && !(processor_mask & (processor_mask - 1)),
82  // "only one processor type can be specified");
83 
84  return static_cast<task_processor_type_t>(
85  util::debruijn32_t::index(processor_mask));
86 } // mask_to_processor_type
87 
88 constexpr bool
89 leaf_task(task_attributes_bitset_t const & bs) {
90  return bs[static_cast<size_t>(task_type_t::leaf)];
91 }
92 
93 constexpr bool
94 inner_task(task_attributes_bitset_t const & bs) {
95  return bs[static_cast<size_t>(task_type_t::inner)];
96 }
97 
98 constexpr bool
99 idempotent_task(task_attributes_bitset_t const & bs) {
100  return bs[static_cast<size_t>(task_type_t::idempotent)];
101 }
102 
103 } // namespace exec
104 } // namespace flecsi
task_processor_type_t
Definition: task_attributes.hh:60
task_attributes_mask_t
Definition: task_attributes.hh:39
static constexpr uint32_t index(const uint32_t b)
Definition: debruijn.hh:89
task_type_t
Definition: task_attributes.hh:54
Definition: control.hh:31