-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PTX: Add
cuda::ptx:barrier_cluster_{arrive,wait}
(#1366)
* Add `cuda::ptx::barrier.cluster.{arrive,wait}` * Add note about .aligned variants
- Loading branch information
1 parent
cbf7da9
commit 2f09e3d
Showing
3 changed files
with
258 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
libcudacxx/test/libcudacxx/cuda/ptx/ptx.barrier.cluster.compile.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of libcu++, the C++ Standard Library for your entire system, | ||
// under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// UNSUPPORTED: libcpp-has-no-threads | ||
|
||
// <cuda/ptx> | ||
|
||
#include <cuda/ptx> | ||
#include <cuda/std/utility> | ||
|
||
/* | ||
* We use a special strategy to force the generation of the PTX. This is mainly | ||
* a fight against dead-code-elimination in the NVVM layer. | ||
* | ||
* The reason we need this strategy is because certain older versions of ptxas | ||
* segfault when a non-sensical sequence of PTX is generated. So instead, we try | ||
* to force the instantiation and compilation to PTX of all the overloads of the | ||
* PTX wrapping functions. | ||
* | ||
* We do this by writing a function pointer of each overload to the kernel | ||
* parameter `fn_ptr`. | ||
* | ||
* Because `fn_ptr` is possibly visible outside this translation unit, the | ||
* compiler must compile all the functions which are stored. | ||
* | ||
*/ | ||
|
||
__global__ void test_barrier_cluster(void ** fn_ptr) { | ||
#if __cccl_ptx_isa >= 780 | ||
NV_IF_TARGET(NV_PROVIDES_SM_90, ( | ||
// barrier.cluster.arrive; | ||
*fn_ptr++ = reinterpret_cast<void*>(static_cast<void (*)()>(cuda::ptx::barrier_cluster_arrive)); | ||
)); | ||
#endif // __cccl_ptx_isa >= 780 | ||
|
||
#if __cccl_ptx_isa >= 780 | ||
NV_IF_TARGET(NV_PROVIDES_SM_90, ( | ||
// barrier.cluster.wait; | ||
*fn_ptr++ = reinterpret_cast<void*>(static_cast<void (*)()>(cuda::ptx::barrier_cluster_wait)); | ||
)); | ||
#endif // __cccl_ptx_isa >= 780 | ||
|
||
#if __cccl_ptx_isa >= 800 | ||
NV_IF_TARGET(NV_PROVIDES_SM_90, ( | ||
// barrier.cluster.arrive.release; | ||
*fn_ptr++ = reinterpret_cast<void*>(static_cast<void (*)(cuda::ptx::sem_release_t)>(cuda::ptx::barrier_cluster_arrive)); | ||
)); | ||
#endif // __cccl_ptx_isa >= 800 | ||
|
||
#if __cccl_ptx_isa >= 800 | ||
NV_IF_TARGET(NV_PROVIDES_SM_90, ( | ||
// barrier.cluster.arrive.relaxed; | ||
*fn_ptr++ = reinterpret_cast<void*>(static_cast<void (*)(cuda::ptx::sem_relaxed_t)>(cuda::ptx::barrier_cluster_arrive)); | ||
)); | ||
#endif // __cccl_ptx_isa >= 800 | ||
|
||
#if __cccl_ptx_isa >= 800 | ||
NV_IF_TARGET(NV_PROVIDES_SM_90, ( | ||
// barrier.cluster.wait.acquire; | ||
*fn_ptr++ = reinterpret_cast<void*>(static_cast<void (*)(cuda::ptx::sem_acquire_t)>(cuda::ptx::barrier_cluster_wait)); | ||
)); | ||
#endif // __cccl_ptx_isa >= 800 | ||
} | ||
|
||
int main(int, char**) | ||
{ | ||
return 0; | ||
} |