File tree 4 files changed +20
-3
lines changed 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -36,5 +36,8 @@ void CUFFreeDevice(void *);
36
36
void *CUFAllocManaged (std::size_t );
37
37
void CUFFreeManaged (void *);
38
38
39
+ void *CUFAllocUnified (std::size_t );
40
+ void CUFFreeUnified (void *);
41
+
39
42
} // namespace Fortran::runtime::cuda
40
43
#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;
19
19
static constexpr unsigned kPinnedAllocatorPos = 1 ;
20
20
static constexpr unsigned kDeviceAllocatorPos = 2 ;
21
21
static constexpr unsigned kManagedAllocatorPos = 3 ;
22
+ static constexpr unsigned kUnifiedAllocatorPos = 4 ;
22
23
23
- #define MAX_ALLOCATOR 5
24
+ #define MAX_ALLOCATOR 7 // 3 bits are reserved in the descriptor.
24
25
25
26
namespace Fortran ::runtime {
26
27
Original file line number Diff line number Diff line change @@ -1860,9 +1860,10 @@ static unsigned getAllocatorIdx(const Fortran::semantics::Symbol &sym) {
1860
1860
return kPinnedAllocatorPos ;
1861
1861
if (*cudaAttr == Fortran::common::CUDADataAttr::Device)
1862
1862
return kDeviceAllocatorPos ;
1863
- if (*cudaAttr == Fortran::common::CUDADataAttr::Managed ||
1864
- *cudaAttr == Fortran::common::CUDADataAttr::Unified)
1863
+ if (*cudaAttr == Fortran::common::CUDADataAttr::Managed)
1865
1864
return kManagedAllocatorPos ;
1865
+ if (*cudaAttr == Fortran::common::CUDADataAttr::Unified)
1866
+ return kUnifiedAllocatorPos ;
1866
1867
}
1867
1868
return kDefaultAllocator ;
1868
1869
}
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ void CUFRegisterAllocator() {
26
26
kDeviceAllocatorPos , {&CUFAllocDevice, CUFFreeDevice});
27
27
allocatorRegistry.Register (
28
28
kManagedAllocatorPos , {&CUFAllocManaged, CUFFreeManaged});
29
+ allocatorRegistry.Register (
30
+ kUnifiedAllocatorPos , {&CUFAllocUnified, CUFFreeUnified});
29
31
}
30
32
31
33
void *CUFAllocPinned (std::size_t sizeInBytes) {
@@ -57,4 +59,14 @@ void CUFFreeManaged(void *p) {
57
59
CUDA_REPORT_IF_ERROR (cuMemFree (reinterpret_cast <CUdeviceptr>(p)));
58
60
}
59
61
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
+
60
72
} // namespace Fortran::runtime::cuda
You can’t perform that action at this time.
0 commit comments