Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/include/device.h
Show First 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | |||||
typedef std::set<HostDataToTargetTy, std::less<>> HostDataToTargetListTy; | typedef std::set<HostDataToTargetTy, std::less<>> HostDataToTargetListTy; | ||||
struct LookupResult { | struct LookupResult { | ||||
struct { | struct { | ||||
unsigned IsContained : 1; | unsigned IsContained : 1; | ||||
unsigned ExtendsBefore : 1; | unsigned ExtendsBefore : 1; | ||||
unsigned ExtendsAfter : 1; | unsigned ExtendsAfter : 1; | ||||
unsigned OnlyBaseFound : 1; | |||||
} Flags; | } Flags; | ||||
HostDataToTargetListTy::iterator Entry; | HostDataToTargetListTy::iterator Entry; | ||||
LookupResult() : Flags({0, 0, 0}), Entry() {} | LookupResult() : Flags({0, 0, 0, 0}), Entry() {} | ||||
}; | }; | ||||
/// This struct will be returned by \p DeviceTy::getTargetPointer which provides | /// This struct will be returned by \p DeviceTy::getTargetPointer which provides | ||||
/// more data than just a target pointer. | /// more data than just a target pointer. | ||||
struct TargetPointerResultTy { | struct TargetPointerResultTy { | ||||
struct { | struct { | ||||
/// If the map table entry is just created | /// If the map table entry is just created | ||||
unsigned IsNewEntry : 1; | unsigned IsNewEntry : 1; | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | struct DeviceTy { | ||||
DeviceTy(const DeviceTy &D) = delete; | DeviceTy(const DeviceTy &D) = delete; | ||||
DeviceTy &operator=(const DeviceTy &D) = delete; | DeviceTy &operator=(const DeviceTy &D) = delete; | ||||
~DeviceTy(); | ~DeviceTy(); | ||||
// Return true if data can be copied to DstDevice directly | // Return true if data can be copied to DstDevice directly | ||||
bool isDataExchangable(const DeviceTy &DstDevice); | bool isDataExchangable(const DeviceTy &DstDevice); | ||||
LookupResult lookupMapping(void *HstPtrBegin, int64_t Size); | LookupResult lookupMapping(void *HstPtrBase, void *HstPtrBegin, int64_t Size); | ||||
/// Get the target pointer based on host pointer begin and base. If the | /// Get the target pointer based on host pointer begin and base. If the | ||||
/// mapping already exists, the target pointer will be returned directly. In | /// mapping already exists, the target pointer will be returned directly. In | ||||
/// addition, if required, the memory region pointed by \p HstPtrBegin of size | /// addition, if required, the memory region pointed by \p HstPtrBegin of size | ||||
/// \p Size will also be transferred to the device. If the mapping doesn't | /// \p Size will also be transferred to the device. If the mapping doesn't | ||||
/// exist, and if unified shared memory is not enabled, a new mapping will be | /// exist, and if unified shared memory is not enabled, a new mapping will be | ||||
/// created and the data will also be transferred accordingly. nullptr will be | /// created and the data will also be transferred accordingly. nullptr will be | ||||
/// returned because of any of following reasons: | /// returned because of any of following reasons: | ||||
/// - Data allocation failed; | /// - Data allocation failed; | ||||
/// - The user tried to do an illegal mapping; | /// - The user tried to do an illegal mapping; | ||||
/// - Data transfer issue fails. | /// - Data transfer issue fails. | ||||
TargetPointerResultTy | TargetPointerResultTy | ||||
getTargetPointer(void *HstPtrBegin, void *HstPtrBase, int64_t Size, | getTargetPointer(void *HstPtrBegin, void *HstPtrBase, int64_t Size, | ||||
map_var_info_t HstPtrName, bool HasFlagTo, | map_var_info_t HstPtrName, bool HasFlagTo, | ||||
bool HasFlagAlways, bool IsImplicit, bool UpdateRefCount, | bool HasFlagAlways, bool IsImplicit, bool UpdateRefCount, | ||||
bool HasCloseModifier, bool HasPresentModifier, | bool HasCloseModifier, bool HasPresentModifier, | ||||
bool HasHoldModifier, AsyncInfoTy &AsyncInfo); | bool HasHoldModifier, AsyncInfoTy &AsyncInfo); | ||||
void *getTgtPtrBegin(void *HstPtrBegin, int64_t Size); | void *getTgtPtrBegin(void *HstPtrBegin, int64_t Size); | ||||
TargetPointerResultTy getTgtPtrBegin(void *HstPtrBegin, int64_t Size, | TargetPointerResultTy getTgtPtrBegin(void *HstPtrBegin, void *HstPtrBase, | ||||
bool &IsLast, bool UpdateRefCount, | int64_t Size, bool &IsLast, | ||||
bool UpdateRefCount, | |||||
bool UseHoldRefCount, bool &IsHostPtr, | bool UseHoldRefCount, bool &IsHostPtr, | ||||
bool MustContain = false, | bool MustContain = false, | ||||
bool ForceDelete = false); | bool ForceDelete = false); | ||||
/// For the map entry for \p HstPtrBegin, decrement the reference count | /// For the map entry for \p HstPtrBegin, decrement the reference count | ||||
/// specified by \p HasHoldModifier and, if the the total reference count is | /// specified by \p HasHoldModifier and, if the the total reference count is | ||||
/// then zero, deallocate the corresponding device storage and remove the map | /// then zero, deallocate the corresponding device storage and remove the map | ||||
/// entry. Return \c OFFLOAD_SUCCESS if the map entry existed, and return | /// entry. Return \c OFFLOAD_SUCCESS if the map entry existed, and return | ||||
/// \c OFFLOAD_FAIL if not. It is the caller's responsibility to skip calling | /// \c OFFLOAD_FAIL if not. It is the caller's responsibility to skip calling | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |