Skip to content

Commit 70b69cf

Browse files
iomaganarishavogt
authored andcommitted
Fix Clang warning with __builtin_assume (#1788)
Building the project with `Clang` generates the following warning: ``` the argument to '__builtin_assume' has side effects that will be discarded [-Wassume] ``` Seems like Clang doesn't handle the hint well unless we pass a const/pure attribute to the function call inside the assume. See: llvm/llvm-project#55636 and llvm/llvm-project#93077 With this change performance for the fn fused nabla examples is significantly improved on clang-cuda and is now much faster than (our old) nvcc, which doesn't have `assume` support.
1 parent 2dde2b4 commit 70b69cf

File tree

7 files changed

+86928
-86071
lines changed

7 files changed

+86928
-86071
lines changed

include/gridtools/fn/unstructured.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ namespace gridtools::fn {
7070
int m_index;
7171
};
7272

73+
/// gnu::pure attribute is necessary to enable __builtin_assume() optimization with Clang
7374
template <class Tag, class Ptr, class Strides, class Domain>
74-
GT_FUNCTION constexpr bool can_deref(iterator<Tag, Ptr, Strides, Domain> const &it) {
75+
[[gnu::pure]] GT_FUNCTION constexpr bool can_deref(iterator<Tag, Ptr, Strides, Domain> const &it) {
7576
return it.m_index != -1;
7677
}
7778

0 commit comments

Comments
 (0)