Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose parts of <cuda/std/memory> #2502

Merged
merged 33 commits into from
Oct 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6ebc811
Add assume_aligned
fbusato Oct 3, 2024
5956f96
documentation
fbusato Oct 3, 2024
95d8fb0
place nodiscard first
fbusato Oct 3, 2024
28e0b3a
Missing <cstdint> header
fbusato Oct 4, 2024
fff1271
Use proper header guard name
miscco Oct 4, 2024
4323dd7
Move detection of `__builtin_assume_aligned` into `builtin.h`
miscco Oct 4, 2024
c35a2fa
Drop superfluous macros
miscco Oct 4, 2024
2523c57
Drop superfluous function annotations
miscco Oct 4, 2024
c19f6d0
Add error message to static assert (also required for C++14
miscco Oct 4, 2024
2c5598f
Drop `<memory>` include
miscco Oct 4, 2024
f2b4dc8
Drop more standard include
miscco Oct 4, 2024
dd67610
Drop qualifier from types in the right namespace
miscco Oct 4, 2024
364361b
Add tests
miscco Oct 4, 2024
276624e
Expose `<cuda/std/memory>`
miscco Oct 4, 2024
5827d73
Improve documentation
miscco Oct 4, 2024
aa29b33
Expose more of construct at earlier
miscco Oct 4, 2024
6e2e53b
Merge branch 'main' into pr/fbusato/2502
miscco Oct 4, 2024
0be4304
Fix docs
miscco Oct 4, 2024
ae284be
Fix static assert without message
miscco Oct 4, 2024
e7bf1b4
Disable test for nvrtc
miscco Oct 4, 2024
f30d3e1
Disable builtin for old NVCC
miscco Oct 4, 2024
87ed0d1
Try and make it work always
miscco Oct 4, 2024
cfdce0b
Cannot work without is_constant_evaluated
miscco Oct 4, 2024
e63b515
Make it a bit cleaner
miscco Oct 4, 2024
3404f9f
Use if else to potentially avoid conditional
miscco Oct 4, 2024
2418456
Use the macro :see_no_evil:
miscco Oct 4, 2024
d041193
Silence warnings
miscco Oct 4, 2024
df3fbd7
Improve builtin detection
fbusato Oct 4, 2024
88db322
nvcc detection is a stupid idea
fbusato Oct 4, 2024
f8c6816
revert (too) prudent preprocessing conditions
fbusato Oct 4, 2024
a650aa6
Merge branch 'main' into assume_aligned
fbusato Oct 4, 2024
a0292c2
Merge branch 'NVIDIA:main' into assume_aligned
fbusato Oct 8, 2024
7c15395
Merge branch 'main' into assume_aligned
miscco Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use if else to potentially avoid conditional
miscco committed Oct 4, 2024
commit 3404f9f515ed3fb0862d5b6b703e38d099531f68
11 changes: 6 additions & 5 deletions libcudacxx/include/cuda/std/__memory/assume_aligned.h
Original file line number Diff line number Diff line change
@@ -33,18 +33,19 @@ template <size_t _Align, class _Tp>
_CCCL_NODISCARD _LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _Tp* assume_aligned(_Tp* __ptr) noexcept
{
static_assert(_CUDA_VSTD::has_single_bit(_Align), "std::assume_aligned requires the alignment to be a power of 2!");
#if defined(_CCCL_BUILTIN_IS_CONSTANT_EVALUATED)
#if defined(_CCCL_BUILTIN_IS_CONSTANT_EVALUATED) && defined(_CCCL_BUILTIN_ASSUME_ALIGNED)
if (!_CCCL_BUILTIN_IS_CONSTANT_EVALUATED())
{
# if !defined(_CCCL_COMPILER_MSVC) // MSVC checks within the builtin
_CCCL_ASSERT(reinterpret_cast<uintptr_t>(__ptr) % _Align == 0, "Alignment assumption is violated");
# endif // !_CCCL_COMPILER_MSVC
# if defined(_CCCL_BUILTIN_ASSUME_ALIGNED)
return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Align));
# endif // _CCCL_BUILTIN_ASSUME_ALIGNED
}
#endif // _CCCL_BUILTIN_IS_CONSTANT_EVALUATED
return __ptr;
else
#endif // _CCCL_BUILTIN_IS_CONSTANT_EVALUATED && _CCCL_BUILTIN_ASSUME_ALIGNED
{
return __ptr;
}
}

_LIBCUDACXX_END_NAMESPACE_STD