[flang] [llvm] [flang][cuda] Add CUFSetAssociatedStream entry point (PR #181313)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 12 22:17:48 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- flang-rt/lib/cuda/allocator.cpp flang-rt/unittests/Runtime/CUDA/Allocatable.cpp flang/include/flang/Runtime/CUDA/allocator.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang-rt/lib/cuda/allocator.cpp b/flang-rt/lib/cuda/allocator.cpp
index 7aeabc2e1..48ffce6a4 100644
--- a/flang-rt/lib/cuda/allocator.cpp
+++ b/flang-rt/lib/cuda/allocator.cpp
@@ -149,7 +149,6 @@ void RTDECL(CUFSetAssociatedStream)(void *p, cudaStream_t stream) {
     insertAllocation(p, 0, stream);
   }
 }
-
 }
 
 void *CUFAllocPinned(
diff --git a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
index 38d215fd0..fc263db80 100644
--- a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
@@ -174,30 +174,30 @@ TEST(AllocatableAsyncTest, StreamDeviceAllocatable) {
 }
 
 TEST(AllocatableAsyncTest, SetStreamTest) {
-    using Fortran::common::TypeCategory;
-    RTNAME(CUFRegisterAllocator)();
-    // REAL(4), DEVICE, ALLOCATABLE :: a(:)
-    auto a{createAllocatable(TypeCategory::Real, 4)};
-    a->SetAllocIdx(kDeviceAllocatorPos);
-    EXPECT_EQ((int)kDeviceAllocatorPos, a->GetAllocIdx());
-    EXPECT_FALSE(a->HasAddendum());
-    RTNAME(AllocatableSetBounds)(*a, 0, 1, 10);
-  
-    cudaStream_t stream;
-    cudaStreamCreate(&stream);
-    EXPECT_EQ(cudaSuccess, cudaGetLastError());
-  
-    RTNAME(AllocatableAllocate)
-    (*a, /*asyncObject=*/nullptr, /*hasStat=*/false,
-        /*errMsg=*/nullptr, __FILE__, __LINE__);
-    EXPECT_TRUE(a->IsAllocated());
-    cudaDeviceSynchronize();
-    EXPECT_EQ(cudaSuccess, cudaGetLastError());
-    cudaStream_t defaultStream = 0;
-    cudaStream_t s = RTDECL(CUFGetAssociatedStream)(a->raw().base_addr);
-    EXPECT_EQ(s, defaultStream);
-
-    RTDECL(CUFSetAssociatedStream)(a->raw().base_addr, stream);
-    s = RTDECL(CUFGetAssociatedStream)(a->raw().base_addr);
-    EXPECT_EQ(s, stream);
-  }
+  using Fortran::common::TypeCategory;
+  RTNAME(CUFRegisterAllocator)();
+  // REAL(4), DEVICE, ALLOCATABLE :: a(:)
+  auto a{createAllocatable(TypeCategory::Real, 4)};
+  a->SetAllocIdx(kDeviceAllocatorPos);
+  EXPECT_EQ((int)kDeviceAllocatorPos, a->GetAllocIdx());
+  EXPECT_FALSE(a->HasAddendum());
+  RTNAME(AllocatableSetBounds)(*a, 0, 1, 10);
+
+  cudaStream_t stream;
+  cudaStreamCreate(&stream);
+  EXPECT_EQ(cudaSuccess, cudaGetLastError());
+
+  RTNAME(AllocatableAllocate)
+  (*a, /*asyncObject=*/nullptr, /*hasStat=*/false,
+      /*errMsg=*/nullptr, __FILE__, __LINE__);
+  EXPECT_TRUE(a->IsAllocated());
+  cudaDeviceSynchronize();
+  EXPECT_EQ(cudaSuccess, cudaGetLastError());
+  cudaStream_t defaultStream = 0;
+  cudaStream_t s = RTDECL(CUFGetAssociatedStream)(a->raw().base_addr);
+  EXPECT_EQ(s, defaultStream);
+
+  RTDECL(CUFSetAssociatedStream)(a->raw().base_addr, stream);
+  s = RTDECL(CUFGetAssociatedStream)(a->raw().base_addr);
+  EXPECT_EQ(s, stream);
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/181313


More information about the llvm-commits mailing list