Skip to content

Commit 4ea3411

Browse files
committed
fixed a bug
1 parent a21791b commit 4ea3411

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

examples/sdk-WorkersParams/main.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ class Tasks : public Reactor {
346346
effects(&req).
347347
function(
348348
[&](LogicalAction<int> &sch, MultiportOutput<int> &req) {
349+
if (req_itr == n_tasks) {
350+
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
351+
<< fqn() << " Tasks queue empty" << std::endl;
352+
return;
353+
}
349354
auto index = *sch.get();
350355
if (index < 0) {
351356
for (int i = 0; i < n_pools; ++i) {
@@ -384,18 +389,20 @@ class Tasks : public Reactor {
384389
[&](MultiportInput<int> &rsp, LogicalAction<int> &sch) {
385390
for (int i = 0; i < n_pools; ++i) {
386391
if (rsp[i].is_present()) {
392+
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
393+
<< "Received response of task:" << *rsp[i].get() << "\n";
387394
++rsp_itr;
388-
if (req_itr < n_tasks) {
389-
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
390-
<< fqn() << " Scheduling task_id:" << req_itr << " to pool:" << i << std::endl;
391-
sch.schedule (i, std::chrono::duration_cast<reactor::Duration>(std::chrono::nanoseconds(0)));
392-
}
395+
busy[i] = 0;
393396
}
394397
}
395398
if (rsp_itr == n_tasks) {
396399
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
397400
<< "Terminating Run\n";
398401
request_stop();
402+
} else {
403+
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
404+
<< fqn() << " Scheduling tasks\n";
405+
sch.schedule (-1, std::chrono::duration_cast<reactor::Duration>(std::chrono::nanoseconds(0)));
399406
}
400407
}
401408
);

examples/sdk-WorkersParams/src/Workers.lf

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ reactor Tasks (bank_index:size_t = 0, n_tasks:int = 10, n_pools:int = 1) {
148148
=}
149149

150150
reaction (sch) -> sch, req {=
151+
if (req_itr == n_tasks) {
152+
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
153+
<< fqn() << " Tasks queue empty" << std::endl;
154+
return;
155+
}
151156
auto index = *sch.get();
152157
if (index < 0) {
153158
for (int i = 0; i < n_pools; ++i) {
@@ -180,18 +185,20 @@ reactor Tasks (bank_index:size_t = 0, n_tasks:int = 10, n_pools:int = 1) {
180185
reaction (rsp) -> sch {=
181186
for (int i = 0; i < n_pools; ++i) {
182187
if (rsp[i].is_present()) {
188+
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
189+
<< "Received response of task:" << *rsp[i].get() << "\n";
183190
++rsp_itr;
184-
if (req_itr < n_tasks) {
185-
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
186-
<< fqn() << " Scheduling task_id:" << req_itr << " to pool:" << i << std::endl;
187-
sch.schedule (i, std::chrono::duration_cast<reactor::Duration>(std::chrono::nanoseconds(0)));
188-
}
191+
busy[i] = 0;
189192
}
190193
}
191194
if (rsp_itr == n_tasks) {
192195
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
193196
<< "Terminating Run\n";
194197
request_stop();
198+
} else {
199+
std::cout << "(" << get_elapsed_logical_time().count() << ", " << get_microstep() << ") physical_time:" << get_elapsed_physical_time().count()
200+
<< fqn() << " Scheduling tasks\n";
201+
sch.schedule (-1, std::chrono::duration_cast<reactor::Duration>(std::chrono::nanoseconds(0)));
195202
}
196203
=}
197204

include/reactor-sdk/SystemParameters.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public:
8989
template <typename... Args>
9090
void register_parameters(Args&... args) {
9191
register_parameters_(reactor->fqn(), reactor->homog_fqn(), args...);
92-
print();
92+
// print();
9393
}
9494

9595
void populate_params(std::set<std::string> &types, std::map<std::string, std::string> &homog_map_entries, std::map<std::string, std::string> &hetero_map_entries) {

0 commit comments

Comments
 (0)