Skip to content

Commit 485fb13

Browse files
committed
merge main into amd-staging
brings in [Libomptarget] Move API implementations into GenericPluginTy (llvm#86683) Change-Id: Id91192d0298a78e7fe80b824f4f28fb02186cd79
2 parents 31efa25 + ed68aac commit 485fb13

File tree

2 files changed

+597
-174
lines changed

2 files changed

+597
-174
lines changed

openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,177 @@ struct GenericPluginTy {
11791179
return (DeviceId >= 0 && DeviceId < getNumDevices());
11801180
}
11811181

1182+
public:
1183+
// TODO: This plugin interface needs to be cleaned up.
1184+
1185+
/// Returns non-zero if the provided \p Image can be executed by the runtime.
1186+
int32_t is_valid_binary(__tgt_device_image *Image);
1187+
1188+
/// Checks if the image is not supported.
1189+
void check_invalid_image(__tgt_device_image *InvalidImage);
1190+
1191+
/// Unused in current implementation.
1192+
int32_t supports_empty_images();
1193+
1194+
/// Initialize the device inside of the plugin.
1195+
int32_t init_device(int32_t DeviceId);
1196+
1197+
/// Return the number of devices this plugin can support.
1198+
int32_t number_of_devices();
1199+
1200+
/// Returns the number of processors available on the device.
1201+
int number_of_team_procs(int DeviceId);
1202+
1203+
/// Returns if this device is an APU.
1204+
bool has_apu_device(int32_t DeviceId);
1205+
1206+
/// Returns if this discrete GPU supports USM.
1207+
bool has_USM_capable_dGPU(int32_t DeviceId);
1208+
1209+
/// Returns if this device supports USM.
1210+
bool supports_unified_memory(int32_t DeviceId);
1211+
1212+
/// Returns if fine grained memory is supported.
1213+
bool is_fine_grained_memory_enabled(int32_t DeviceId);
1214+
1215+
/// Returns if managed memory is supported.
1216+
bool is_system_supporting_managed_memory(int32_t DeviceId);
1217+
1218+
/// Initializes the OpenMP register requires information.
1219+
int64_t init_requires(int64_t RequiresFlags);
1220+
1221+
/// Returns non-zero if the data can be exchanged between the two devices.
1222+
int32_t is_data_exchangable(int32_t SrcDeviceId, int32_t DstDeviceId);
1223+
1224+
/// Initializes the record and replay mechanism inside the plugin.
1225+
int32_t initialize_record_replay(int32_t DeviceId, int64_t MemorySize,
1226+
void *VAddr, bool isRecord, bool SaveOutput,
1227+
uint64_t &ReqPtrArgOffset);
1228+
1229+
/// Loads the associated binary into the plugin and returns a handle to it.
1230+
int32_t load_binary(int32_t DeviceId, __tgt_device_image *TgtImage,
1231+
__tgt_device_binary *Binary);
1232+
1233+
/// Allocates memory that is accessively to the given device.
1234+
void *data_alloc(int32_t DeviceId, int64_t Size, void *HostPtr, int32_t Kind);
1235+
1236+
/// Deallocates memory on the given device.
1237+
int32_t data_delete(int32_t DeviceId, void *TgtPtr, int32_t Kind);
1238+
1239+
/// Locks / pins host memory using the plugin runtime.
1240+
int32_t data_lock(int32_t DeviceId, void *Ptr, int64_t Size,
1241+
void **LockedPtr);
1242+
1243+
/// Unlocks / unpins host memory using the plugin runtime.
1244+
int32_t data_unlock(int32_t DeviceId, void *Ptr);
1245+
1246+
/// Notify the runtime about a new mapping that has been created outside.
1247+
int32_t data_notify_mapped(int32_t DeviceId, void *HstPtr, int64_t Size);
1248+
1249+
/// Notify t he runtime about a mapping that has been deleted.
1250+
int32_t data_notify_unmapped(int32_t DeviceId, void *HstPtr);
1251+
1252+
/// Copy data to the given device.
1253+
int32_t data_submit(int32_t DeviceId, void *TgtPtr, void *HstPtr,
1254+
int64_t Size);
1255+
1256+
/// Copy data to the given device asynchronously.
1257+
int32_t data_submit_async(int32_t DeviceId, void *TgtPtr, void *HstPtr,
1258+
int64_t Size, __tgt_async_info *AsyncInfoPtr);
1259+
1260+
/// Copy data from the given device.
1261+
int32_t data_retrieve(int32_t DeviceId, void *HstPtr, void *TgtPtr,
1262+
int64_t Size);
1263+
1264+
/// Copy data from the given device asynchornously.
1265+
int32_t data_retrieve_async(int32_t DeviceId, void *HstPtr, void *TgtPtr,
1266+
int64_t Size, __tgt_async_info *AsyncInfoPtr);
1267+
1268+
/// Exchange memory addresses between two devices.
1269+
int32_t data_exchange(int32_t SrcDeviceId, void *SrcPtr, int32_t DstDeviceId,
1270+
void *DstPtr, int64_t Size);
1271+
1272+
/// Exchange memory addresses between two devices asynchronously.
1273+
int32_t data_exchange_async(int32_t SrcDeviceId, void *SrcPtr,
1274+
int DstDeviceId, void *DstPtr, int64_t Size,
1275+
__tgt_async_info *AsyncInfo);
1276+
1277+
/// Begin executing a kernel on the given device.
1278+
int32_t launch_kernel_sync(int32_t DeviceId, void *TgtEntryPtr,
1279+
void **TgtArgs, ptrdiff_t *TgtOffsets,
1280+
KernelArgsTy *KernelArgs);
1281+
1282+
/// Begin executing a kernel on the given device.
1283+
int32_t launch_kernel(int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs,
1284+
ptrdiff_t *TgtOffsets, KernelArgsTy *KernelArgs,
1285+
__tgt_async_info *AsyncInfoPtr);
1286+
1287+
/// Synchronize an asyncrhonous queue with the plugin runtime.
1288+
int32_t synchronize(int32_t DeviceId, __tgt_async_info *AsyncInfoPtr);
1289+
1290+
/// Query the current state of an asynchronous queue.
1291+
int32_t query_async(int32_t DeviceId, __tgt_async_info *AsyncInfoPtr);
1292+
1293+
/// Prints information about the given devices supported by the plugin.
1294+
void print_device_info(int32_t DeviceId);
1295+
1296+
/// Creates an event in the given plugin if supported.
1297+
int32_t create_event(int32_t DeviceId, void **EventPtr);
1298+
1299+
/// Records an event that has occurred.
1300+
int32_t record_event(int32_t DeviceId, void *EventPtr,
1301+
__tgt_async_info *AsyncInfoPtr);
1302+
1303+
/// Wait until an event has occurred.
1304+
int32_t wait_event(int32_t DeviceId, void *EventPtr,
1305+
__tgt_async_info *AsyncInfoPtr);
1306+
1307+
/// Syncrhonize execution until an event is done.
1308+
int32_t sync_event(int32_t DeviceId, void *EventPtr);
1309+
1310+
/// Remove the event from the plugin.
1311+
int32_t destroy_event(int32_t DeviceId, void *EventPtr);
1312+
1313+
/// Creates an asynchronous queue for the given plugin.
1314+
int32_t init_async_info(int32_t DeviceId, __tgt_async_info **AsyncInfoPtr);
1315+
1316+
/// Creates device information to be used for diagnostics.
1317+
int32_t init_device_info(int32_t DeviceId, __tgt_device_info *DeviceInfo,
1318+
const char **ErrStr);
1319+
1320+
/// Sets the region of memory that is considered coarse grained.
1321+
int set_coarse_grain_mem_region(int32_t DeviceId, void *ptr, int64_t size);
1322+
1323+
/// Sets the offset into the devices for use by OMPT.
1324+
int32_t set_device_offset(int32_t DeviceIdOffset);
1325+
1326+
/// Populates the device page table.
1327+
int prepopulate_page_table(int32_t DeviceId, void *ptr, int64_t size);
1328+
1329+
/// Gets the coarse grained memory region.
1330+
int32_t query_coarse_grain_mem_region(int32_t DeviceId, const void *ptr,
1331+
int64_t size);
1332+
1333+
/// Look up a global symbol in the given binary.
1334+
int32_t get_global(__tgt_device_binary Binary, uint64_t Size,
1335+
const char *Name, void **DevicePtr);
1336+
1337+
/// Look up a kernel function in the given binary.
1338+
int32_t get_function(__tgt_device_binary Binary, const char *Name,
1339+
void **KernelPtr);
1340+
1341+
/// Returns if we can use automatic zero copy.
1342+
int32_t use_auto_zero_copy(int32_t DeviceId);
1343+
1344+
/// Make sure a pointer can be accessed by all agents.
1345+
int32_t enable_access_to_all_agents(int32_t DeviceId, void *ptr);
1346+
1347+
/// Perform some checks when using automatic zero copy.
1348+
int32_t zero_copy_sanity_checks_and_diag(int32_t DeviceId,
1349+
bool isUnifiedSharedMemory,
1350+
bool isAutoZeroCopy,
1351+
bool isEagerMaps);
1352+
11821353
private:
11831354
/// Number of devices available for the plugin.
11841355
int32_t NumDevices = 0;

0 commit comments

Comments
 (0)