My Project
kernel.hpp
1 
20 #ifndef _KERNEL_HPP_
21 #define _KERNEL_HPP_ 1
22 
23 #include <functional>
24 #include <utility>
25 #include <cstdint>
26 #include <setjmp.h>
27 
28 #include "port.hpp"
29 #include "signalvars.hpp"
30 #include "rafttypes.hpp"
31 
33 class MapBase;
34 class Schedule;
35 class kernel_container;
36 class Map;
37 class basic_parallel;
38 
39 #ifndef CLONE
40 namespace raft
41 {
42  class kernel;
43 }
44 
45 #define CLONE() \
46 virtual raft::kernel* clone()\
47 { \
48  auto *ptr( \
49  new typename std::remove_reference< decltype( *this ) >::type( ( *(\
50  (typename std::decay< decltype( *this ) >::type * ) \
51  this ) ) ) );\
52  return( ptr );\
53 }
54 #endif
55 
56 namespace raft {
57 class kernel
58 {
59 public:
61  kernel();
62 
64  kernel( void * const ptr,
65  const std::size_t nbytes );
66 
67  virtual ~kernel();
68 
69 
77  virtual raft::kstatus run() = 0;
78 
79 
80  template < class T ,
81  class ... Args >
82  static kernel* make( Args&&... params )
83  {
84  return( new T( std::forward< Args >( params )... ) );
85  }
86 
96  virtual raft::kernel* clone()
97  {
98  //FIXME, needs to throw an exception
99  assert( false );
100  return( nullptr );
101  }
102 
103  std::size_t get_id();
104 protected:
108  virtual std::size_t addPort();
109 
110  virtual void lock();
111  virtual void unlock();
112 
117  Port input = { this };
118  Port output = { this };
119 
120 
121  friend class ::MapBase;
122  friend class ::Map;
123  friend class ::Schedule;
124  friend class ::GraphTools;
125  friend class ::kernel_container;
126  friend class ::basic_parallel;
127 
133  static std::size_t kernel_count;
134 
135 private:
137  bool dup_enabled = false;
138  bool dup_candidate = false;
139  const std::size_t kernel_id;
140 };
141 }
142 #endif /* END _KERNEL_HPP_ */
Port input
Definition: kernel.hpp:117
Definition: basicparallel.hpp:48
kernel()
Definition: kernel.cpp:11
Definition: mapbase.hpp:100
virtual void unlock()
Definition: kernel.cpp:51
virtual raft::kstatus run()=0
Definition: map.hpp:47
virtual raft::kernel * clone()
Definition: kernel.hpp:96
virtual void lock()
Definition: kernel.cpp:44
Definition: port.hpp:57
Definition: schedule.hpp:34
Definition: kernel.hpp:57
Definition: globalmap.cpp:3
Definition: kernelcontainer.hpp:36
static std::size_t kernel_count
Definition: kernel.hpp:133