Managed Memory

Managed Memory#

hipFORT API Reference: Managed Memory

This section describes the managed memory management functions of HIP runtime API. More...

Collaboration diagram for Managed Memory:

Functions/Subroutines

integer(c_int) function hipfort_hipmalloc::hipmallocmanaged::hipmallocmanaged_ (ptr, sizebytes, flags)
 Allocates memory that will be automatically managed by HIP.
 

Detailed Description

This section describes the managed memory management functions of HIP runtime API.

Note
The managed memory management APIs are implemented on Linux, under development on Windows.

Function/Subroutine Documentation

◆ hipmallocmanaged_()

integer(c_int) function hipfort_hipmalloc::hipmallocmanaged::hipmallocmanaged_ ( type(c_ptr)  ptr,
integer(c_size_t), value  sizebytes,
integer(c_int), value  flags 
)

Allocates memory that will be automatically managed by HIP.



This API is used for managed memory, allows data be shared and accessible to both CPU and GPU using a single pointer.

The API returns the allocation pointer, managed by HMM, can be used further to execute kernels on device and fetch data between the host and device as needed.

If HMM is not supported, the function behaves the same as hipMallocHost .

Note
It is recommend to do the capability check before call this API.
Parameters
[out]ptr- pointer to allocated device memory
[in]sizeBytes- requested allocation size in bytes, it should be granularity of 4KB
[in]flags- must be either hipMemAttachGlobal or hipMemAttachHost (defaults to hipMemAttachGlobal)
Returns
hipSuccess, hipErrorMemoryAllocation, hipErrorNotSupported, hipErrorInvalidValue