File tree Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -36,5 +36,8 @@ void CUFFreeDevice(void *);
3636void *CUFAllocManaged (std::size_t );
3737void CUFFreeManaged (void *);
3838
39+ void *CUFAllocUnified (std::size_t );
40+ void CUFFreeUnified (void *);
41+
3942} // namespace Fortran::runtime::cuda
4043#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
Original file line number Diff line number Diff line change @@ -19,8 +19,9 @@ static constexpr unsigned kDefaultAllocator = 0;
1919static constexpr unsigned kPinnedAllocatorPos = 1 ;
2020static constexpr unsigned kDeviceAllocatorPos = 2 ;
2121static constexpr unsigned kManagedAllocatorPos = 3 ;
22+ static constexpr unsigned kUnifiedAllocatorPos = 4 ;
2223
23- #define MAX_ALLOCATOR 5
24+ #define MAX_ALLOCATOR 7 // 3 bits are reserved in the descriptor.
2425
2526namespace Fortran ::runtime {
2627
Original file line number Diff line number Diff line change @@ -1860,9 +1860,10 @@ static unsigned getAllocatorIdx(const Fortran::semantics::Symbol &sym) {
18601860 return kPinnedAllocatorPos ;
18611861 if (*cudaAttr == Fortran::common::CUDADataAttr::Device)
18621862 return kDeviceAllocatorPos ;
1863- if (*cudaAttr == Fortran::common::CUDADataAttr::Managed ||
1864- *cudaAttr == Fortran::common::CUDADataAttr::Unified)
1863+ if (*cudaAttr == Fortran::common::CUDADataAttr::Managed)
18651864 return kManagedAllocatorPos ;
1865+ if (*cudaAttr == Fortran::common::CUDADataAttr::Unified)
1866+ return kUnifiedAllocatorPos ;
18661867 }
18671868 return kDefaultAllocator ;
18681869}
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ void CUFRegisterAllocator() {
2626 kDeviceAllocatorPos , {&CUFAllocDevice, CUFFreeDevice});
2727 allocatorRegistry.Register (
2828 kManagedAllocatorPos , {&CUFAllocManaged, CUFFreeManaged});
29+ allocatorRegistry.Register (
30+ kUnifiedAllocatorPos , {&CUFAllocUnified, CUFFreeUnified});
2931}
3032
3133void *CUFAllocPinned (std::size_t sizeInBytes) {
@@ -57,4 +59,14 @@ void CUFFreeManaged(void *p) {
5759 CUDA_REPORT_IF_ERROR (cuMemFree (reinterpret_cast <CUdeviceptr>(p)));
5860}
5961
62+ void *CUFAllocUnified (std::size_t sizeInBytes) {
63+ // Call alloc managed for the time being.
64+ return CUFAllocManaged (sizeInBytes);
65+ }
66+
67+ void CUFFreeUnified (void *p) {
68+ // Call free managed for the time being.
69+ CUFFreeManaged (p);
70+ }
71+
6072} // namespace Fortran::runtime::cuda
You can’t perform that action at this time.
0 commit comments