[flang-commits] [flang] [llvm] [flang][cuda] Introduce cuf.set_allocator_idx operation (PR #148717)
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Tue Jul 22 05:47:31 PDT 2025
================
@@ -72,3 +72,13 @@ TEST(AllocatableCUFTest, DescriptorAllocationTest) {
EXPECT_TRUE(desc != nullptr);
RTNAME(CUFFreeDescriptor)(desc);
}
+
+TEST(AllocatableCUFTest, CUFSetAllocatorIndex) {
+ using Fortran::common::TypeCategory;
+ RTNAME(CUFRegisterAllocator)();
+ // REAL(4), DEVICE, ALLOCATABLE :: a(:)
+ auto a{createAllocatable(TypeCategory::Real, 4)};
+ EXPECT_EQ((int)kDefaultAllocator, a->GetAllocIdx());
+ RTNAME(CUFSetAllocatorIndex)(*a, kDeviceAllocatorPos, __FILE__, __LINE__);
----------------
Meinersbur wrote:
I get a compilation error here (even after 9e9fdd433adfd4c1da46e475f4bbe8fdbf7c04f9):
```
../../../../_src/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp:82:3: error: no matching function for call to '_FortranACUFSetAllocatorIndex'
82 | RTNAME(CUFSetAllocatorIndex)(*a, kDeviceAllocatorPos, __FILE__, __LINE__);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../_src/flang/include/flang/Runtime/entry-names.h:27:22: note: expanded from macro 'RTNAME'
27 | #define RTNAME(name) NAME_WITH_PREFIX_AND_REVISION(_Fortran, A, name)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../_src/flang/include/flang/Runtime/entry-names.h:26:3: note: expanded from macro 'NAME_WITH_PREFIX_AND_REVISION'
26 | prefix##revision##name
| ^~~~~~~~~~~~~~~~~~~~~~
<scratch space>:42:1: note: expanded from here
42 | _FortranACUFSetAllocatorIndex
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../_src/flang/include/flang/Runtime/CUDA/descriptor.h:45:6: note: candidate function not viable: no known conversion from 'Fortran::runtime::Descriptor' to 'Descriptor *' for 1st argument; take the address of the argument with &
45 | void RTDECL(CUFSetAllocatorIndex)(Descriptor *, int index,
| ^ ~~~~~~~~~~~~
../../../../_src/flang/include/flang/Runtime/entry-names.h:31:35: note: expanded from macro 'RTDECL'
31 | #define RTDECL(name) RT_API_ATTRS RTNAME(name)
| ^
../../../../_src/flang/include/flang/Runtime/entry-names.h:27:22: note: expanded from macro 'RTNAME'
27 | #define RTNAME(name) NAME_WITH_PREFIX_AND_REVISION(_Fortran, A, name)
| ^
../../../../_src/flang/include/flang/Runtime/entry-names.h:26:3: note: expanded from macro 'NAME_WITH_PREFIX_AND_REVISION'
26 | prefix##revision##name
| ^
<scratch space>:16:1: note: expanded from here
16 | _FortranACUFSetAllocatorIndex
| ^
1 error generated.
```
```suggestion
RTNAME(CUFSetAllocatorIndex)(a, kDeviceAllocatorPos, __FILE__, __LINE__);
```
https://github.com/llvm/llvm-project/pull/148717
More information about the flang-commits
mailing list