thorin2
thorin2 copied to clipboard
Scheduler returns wrong position dynamically
The generated code is:
.con eta_f_1436134 _1436139::[a_1436177: .Idx 4294967296, return_1436141: .Cn .Idx 4294967296] @(0:(.Idx 2)) = {
.let _1436184: .Idx 4294967296 = %core.wrap.add 4294967296 0 (2:(.Idx 4294967296), a_1436177);
return_1436141 _1436184
};
.con eta_f_1436234 _1436235::[a_1436239: .Idx 4294967296, return_1436237: .Cn .Idx 4294967296] @(0:(.Idx 2)) = {
.let _1436246: .Idx 4294967296 = %core.wrap.add 4294967296 0 (2:(.Idx 4294967296), a_1436239);
return_1436237 _1436246
};
.con .extern main __1436033::[mem_1436050: %mem.M, .Idx 4294967296, %mem.Ptr (%mem.Ptr (.Idx 256, 0), 0), return_1436037: .Cn [%mem.M, .Idx 4294967296]] @(0:(.Idx 2)) = {
.con eta_f_cps_cont_1436350 _1436381: .Idx 4294967296 @(0:(.Idx 2)) = {
.con eta_f_cps_cont_1436287 _1436318: .Idx 4294967296 @(0:(.Idx 2)) = {
return_1436037 (mem_1436050, _1436381) // Start code
};
eta_f_1436234 (38:(.Idx 4294967296), eta_f_cps_cont_1436287)
};
eta_f_1436134 (_1436318, eta_f_cps_cont_1436350)
};
First we start with
.con .extern main __1436033::[mem_1436050: %mem.M, .Idx 4294967296, %mem.Ptr (%mem.Ptr (.Idx 256, 0), 0), return_1436037: .Cn [%mem.M, .Idx 4294967296]] @(0:(.Idx 2)) = {
return_1436037 (mem_1436050, _1436381) // Start code
};
We look at the simple case:
We place eta_f_1436234 (38:(.Idx 4294967296), eta_f_cps_cont_1436287)
with the computed entry nominal main
and construct the scope and scheduler.
The resulting place is main
. We place the app in default fashion by moving the body of main.
.con .extern main __1436033::[mem_1436050: %mem.M, .Idx 4294967296, %mem.Ptr (%mem.Ptr (.Idx 256, 0), 0), return_1436037: .Cn [%mem.M, .Idx 4294967296]] @(0:(.Idx 2)) = {
eta_f_1436234 (38:(.Idx 4294967296), eta_f_cps_cont_1436287)
};
.con eta_f_cps_cont_1436287 _1436318: .Idx 4294967296 @(0:(.Idx 2)) = {
return_1436037 (mem_1436050, _1436381)
};
.con eta_f_1436234 _1436235::[a_1436239: .Idx 4294967296, return_1436237: .Cn .Idx 4294967296] @(0:(.Idx 2)) = {
.let _1436246: .Idx 4294967296 = %core.wrap.add 4294967296 0 (2:(.Idx 4294967296), a_1436239);
return_1436237 _1436246
};
To place eta_f_1436134 (_1436318, eta_f_cps_cont_1436350)
, we again compute the scope entry main
, construct the scope, the scheduler.
But the scheduler suggests the place main resulting in the wrong order above.
The correct place would be eta_f_cps_cont_1436287
as the tuple requires the argument _1436318
of eta_f_cps_cont_1436287
.
Code used to place:
// entry is computed
Scope scope(entry);
Scheduler sched_(scope);
auto place = sched_.smart(app);