0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-30 17:34:04 +01:00

ircd::gpt: Remove branch by assuming loop body always taken.

This commit is contained in:
Jason Volk 2021-07-31 23:23:23 -07:00
parent f8137c50d0
commit 5518daf197

View file

@ -805,8 +805,30 @@ ircd::gpt::adamw(task &task,
reinterpret_cast<f32x4 *>(m_[1]) + off,
};
for(uint i(0); i < num / 4; ++i)
off = adamw(p[0][i], p[1][i], p[2][i], grad, opts.alpha, opts.beta[0], opts.beta[1], ctrl.epic.step, off);
assert(num >= 4);
const uint n
{
uint(num) / 4
};
// Assume loop body always taken w/o soundness; otherwise extra branch.
assert(n > 0);
uint i(0); do
{
off = adamw
(
p[0][i],
p[1][i],
p[2][i],
grad,
opts.alpha,
opts.beta[0],
opts.beta[1],
ctrl.epic.step,
off
);
}
while(++i < n);
return off;
}