MCPcopy Create free account
hub / github.com/RaftLib/RaftLib / kernelHasInputData

Method kernelHasInputData

src/schedule.cpp:132–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130
131
132bool
133Schedule::kernelHasInputData( raft::kernel *kernel )
134{
135 auto &port_list( kernel->input );
136 if( ! port_list.hasPorts() )
137 {
138 /** only output ports, keep calling till exits **/
139 return( true );
140 }
141 /**
142 * NOTE: this was added as a reqeuest, need to update wiki,
143 * the first hit to this one will take an extra few cycles
144 * to process the jmp, however, after that, the branch
145 * taken is incredibly easy and we should be able to do
146 * this as if the switch statement wasn't there at all.
147 * - an alternative to using the kernel variable would
148 * be to implement a new subclass of kernel...that's doable
149 * too but we'd have to make dependent template functions
150 * that would use the type info to select the right behavior
151 * which we're doing dynamically below in the switch statement.
152 */
153 switch( kernel->sched_behav )
154 {
155 case( raft::any_port ):
156 {
157 for( auto &port : port_list )
158 {
159 const auto size( port.size() );
160 if( size > 0 )
161 {
162 return( true );
163 }
164 }
165 }
166 break;
167 case( raft::all_port ):
168 {
169 for( auto &port : port_list )
170 {
171 const auto size( port.size() );
172 /** no data avail on this port, return false **/
173 if( size == 0 )
174 {
175 return( false );
176 }
177 }
178 /** all ports have data, return true **/
179 return( true );
180 }
181 break;
182 default:
183 {
184 //TODO add exception class here
185 std::cerr << "invalid scheduling behavior set, exiting!\n";
186 exit( EXIT_FAILURE );
187 }
188 }
189 /** we should have returned before here, keep compiler happy **/

Callers

nothing calls this directly

Calls 1

hasPortsMethod · 0.80

Tested by

no test coverage detected