Skip to content

Commit 8ddcfe9

Browse files
committed
work around codegen bug in nvc++
1 parent 26676cf commit 8ddcfe9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/exec/trampoline_scheduler.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,15 @@ namespace exec {
212212
void __trampoline_state<_Operation>::__drain() noexcept {
213213
while (__head_ != nullptr) {
214214
// pop the head of the list
215+
#if STDEXEC_NVHPC()
216+
// there appears to be a codegen bug in nvhpc where the optimizer does not see the
217+
// assign to __head_ that happens in the std::exchange call below, causing it to
218+
// erroneously optimize away the `if (__head_ != nullptr)` check later on.
219+
_Operation* __op = __head_;
220+
__head_ = __head_->__next_;
221+
#else
215222
_Operation* __op = std::exchange(__head_, __head_->__next_);
223+
#endif
216224
__op->__next_ = nullptr;
217225
__op->__prev_ = nullptr;
218226
if (__head_ != nullptr) {

0 commit comments

Comments
 (0)