Skip to content

Commit

Permalink
__HIP_DEVICE_COMPILE__ do_not_optimize (broken)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwpearson committed Nov 4, 2022
1 parent 210a2e6 commit 3392fd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/scope/do_not_optimize.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

namespace scope {
template <class Tp>
__device__
void __attribute__((always_inline)) do_not_optimize(Tp const& value) {
asm volatile("" : : "r,m"(value) : "memory");
}

template <class Tp>
__device__
void __attribute__((always_inline)) do_not_optimize(Tp& value) {
asm volatile("" : "+r,m"(value) : : "memory");
}
}
1 change: 1 addition & 0 deletions include/scope/scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#if defined(SCOPE_USE_HIP)
#include "scope/hip.hpp"
#if defined(__HIP_DEVICE_COMPILE__)
#include "scope/do_not_optimize.hpp"
#endif // __HIP_DEVICE_COMPILE__
#endif // SCOPE_USE_HIP

Expand Down

0 comments on commit 3392fd0

Please sign in to comment.