14
14
#define OMPTARGET_PLUGIN_MANAGER_H
15
15
16
16
#include " Shared/APITypes.h"
17
+ #include " Shared/PluginAPI.h"
17
18
18
19
#include " device.h"
19
20
25
26
#include < mutex>
26
27
27
28
struct PluginAdaptorTy {
28
- typedef int32_t (init_plugin_ty)();
29
- typedef int32_t (is_valid_binary_ty)(void *);
30
- typedef int32_t (is_valid_binary_info_ty)(void *, void *);
31
- typedef int32_t (is_data_exchangable_ty)(int32_t , int32_t );
32
- typedef int32_t (number_of_devices_ty)();
33
- typedef int32_t (init_device_ty)(int32_t );
34
- typedef __tgt_target_table *(load_binary_ty)(int32_t , void *);
35
- typedef void *(data_alloc_ty)(int32_t , int64_t , void *, int32_t );
36
- typedef int32_t (data_submit_ty)(int32_t , void *, void *, int64_t );
37
- typedef int32_t (data_submit_async_ty)(int32_t , void *, void *, int64_t ,
38
- __tgt_async_info *);
39
- typedef int32_t (data_retrieve_ty)(int32_t , void *, void *, int64_t );
40
- typedef int32_t (data_retrieve_async_ty)(int32_t , void *, void *, int64_t ,
41
- __tgt_async_info *);
42
- typedef int32_t (data_exchange_ty)(int32_t , void *, int32_t , void *, int64_t );
43
- typedef int32_t (data_exchange_async_ty)(int32_t , void *, int32_t , void *,
44
- int64_t , __tgt_async_info *);
45
- typedef int32_t (data_delete_ty)(int32_t , void *, int32_t );
46
- typedef int32_t (launch_kernel_ty)(int32_t , void *, void **, ptrdiff_t *,
47
- const KernelArgsTy *, __tgt_async_info *);
48
- typedef int64_t (init_requires_ty)(int64_t );
49
- typedef int32_t (synchronize_ty)(int32_t , __tgt_async_info *);
50
- typedef int32_t (query_async_ty)(int32_t , __tgt_async_info *);
51
- typedef int32_t (supports_empty_images_ty)();
52
- typedef void (print_device_info_ty)(int32_t );
53
- typedef void (set_info_flag_ty)(uint32_t );
54
- typedef int32_t (create_event_ty)(int32_t , void **);
55
- typedef int32_t (record_event_ty)(int32_t , void *, __tgt_async_info *);
56
- typedef int32_t (wait_event_ty)(int32_t , void *, __tgt_async_info *);
57
- typedef int32_t (sync_event_ty)(int32_t , void *);
58
- typedef int32_t (destroy_event_ty)(int32_t , void *);
59
- typedef int32_t (release_async_info_ty)(int32_t , __tgt_async_info *);
60
- typedef int32_t (init_async_info_ty)(int32_t , __tgt_async_info **);
61
- typedef int64_t (init_device_into_ty)(int64_t , __tgt_device_info *,
62
- const char **);
63
- typedef int32_t (data_lock_ty)(int32_t , void *, int64_t , void **);
64
- typedef int32_t (data_unlock_ty)(int32_t , void *);
65
- typedef int32_t (data_notify_mapped_ty)(int32_t , void *, int64_t );
66
- typedef int32_t (data_notify_unmapped_ty)(int32_t , void *);
67
- typedef int32_t (set_device_offset_ty)(int32_t );
68
- typedef int32_t (activate_record_replay_ty)(int32_t , uint64_t , void *, bool ,
69
- bool , uint64_t &);
70
-
71
29
int32_t Idx = -1 ; // RTL index, index is the number of devices
72
30
// of other RTLs that were registered before,
73
31
// i.e. the OpenMP index of the first device
@@ -80,43 +38,48 @@ struct PluginAdaptorTy {
80
38
std::string RTLName;
81
39
#endif
82
40
41
+ #define DEFINE_PLUGIN_API_HANDLE (NAME ) \
42
+ using NAME##_ty = decltype (__tgt_rtl_##NAME); \
43
+ NAME##_ty *NAME = nullptr ;
44
+
83
45
// Functions implemented in the RTL.
84
- init_plugin_ty *init_plugin = nullptr ;
85
- is_valid_binary_ty *is_valid_binary = nullptr ;
86
- is_valid_binary_info_ty *is_valid_binary_info = nullptr ;
87
- is_data_exchangable_ty *is_data_exchangable = nullptr ;
88
- number_of_devices_ty *number_of_devices = nullptr ;
89
- init_device_ty *init_device = nullptr ;
90
- load_binary_ty *load_binary = nullptr ;
91
- data_alloc_ty *data_alloc = nullptr ;
92
- data_submit_ty *data_submit = nullptr ;
93
- data_submit_async_ty *data_submit_async = nullptr ;
94
- data_retrieve_ty *data_retrieve = nullptr ;
95
- data_retrieve_async_ty *data_retrieve_async = nullptr ;
96
- data_exchange_ty *data_exchange = nullptr ;
97
- data_exchange_async_ty *data_exchange_async = nullptr ;
98
- data_delete_ty *data_delete = nullptr ;
99
- launch_kernel_ty *launch_kernel = nullptr ;
100
- init_requires_ty *init_requires = nullptr ;
101
- synchronize_ty *synchronize = nullptr ;
102
- query_async_ty *query_async = nullptr ;
103
- supports_empty_images_ty *supports_empty_images = nullptr ;
104
- set_info_flag_ty *set_info_flag = nullptr ;
105
- print_device_info_ty *print_device_info = nullptr ;
106
- create_event_ty *create_event = nullptr ;
107
- record_event_ty *record_event = nullptr ;
108
- wait_event_ty *wait_event = nullptr ;
109
- sync_event_ty *sync_event = nullptr ;
110
- destroy_event_ty *destroy_event = nullptr ;
111
- init_async_info_ty *init_async_info = nullptr ;
112
- init_device_into_ty *init_device_info = nullptr ;
113
- release_async_info_ty *release_async_info = nullptr ;
114
- data_lock_ty *data_lock = nullptr ;
115
- data_unlock_ty *data_unlock = nullptr ;
116
- data_notify_mapped_ty *data_notify_mapped = nullptr ;
117
- data_notify_unmapped_ty *data_notify_unmapped = nullptr ;
118
- set_device_offset_ty *set_device_offset = nullptr ;
119
- activate_record_replay_ty *activate_record_replay = nullptr ;
46
+ DEFINE_PLUGIN_API_HANDLE (init_plugin);
47
+ DEFINE_PLUGIN_API_HANDLE (is_valid_binary);
48
+ DEFINE_PLUGIN_API_HANDLE (is_valid_binary_info);
49
+ DEFINE_PLUGIN_API_HANDLE (is_data_exchangable);
50
+ DEFINE_PLUGIN_API_HANDLE (number_of_devices);
51
+ DEFINE_PLUGIN_API_HANDLE (init_device);
52
+ DEFINE_PLUGIN_API_HANDLE (load_binary);
53
+ DEFINE_PLUGIN_API_HANDLE (data_alloc);
54
+ DEFINE_PLUGIN_API_HANDLE (data_submit);
55
+ DEFINE_PLUGIN_API_HANDLE (data_submit_async);
56
+ DEFINE_PLUGIN_API_HANDLE (data_retrieve);
57
+ DEFINE_PLUGIN_API_HANDLE (data_retrieve_async);
58
+ DEFINE_PLUGIN_API_HANDLE (data_exchange);
59
+ DEFINE_PLUGIN_API_HANDLE (data_exchange_async);
60
+ DEFINE_PLUGIN_API_HANDLE (data_delete);
61
+ DEFINE_PLUGIN_API_HANDLE (launch_kernel);
62
+ DEFINE_PLUGIN_API_HANDLE (init_requires);
63
+ DEFINE_PLUGIN_API_HANDLE (synchronize);
64
+ DEFINE_PLUGIN_API_HANDLE (query_async);
65
+ DEFINE_PLUGIN_API_HANDLE (supports_empty_images);
66
+ DEFINE_PLUGIN_API_HANDLE (set_info_flag);
67
+ DEFINE_PLUGIN_API_HANDLE (print_device_info);
68
+ DEFINE_PLUGIN_API_HANDLE (create_event);
69
+ DEFINE_PLUGIN_API_HANDLE (record_event);
70
+ DEFINE_PLUGIN_API_HANDLE (wait_event);
71
+ DEFINE_PLUGIN_API_HANDLE (sync_event);
72
+ DEFINE_PLUGIN_API_HANDLE (destroy_event);
73
+ DEFINE_PLUGIN_API_HANDLE (init_async_info);
74
+ DEFINE_PLUGIN_API_HANDLE (init_device_info);
75
+ DEFINE_PLUGIN_API_HANDLE (data_lock);
76
+ DEFINE_PLUGIN_API_HANDLE (data_unlock);
77
+ DEFINE_PLUGIN_API_HANDLE (data_notify_mapped);
78
+ DEFINE_PLUGIN_API_HANDLE (data_notify_unmapped);
79
+ DEFINE_PLUGIN_API_HANDLE (set_device_offset);
80
+ DEFINE_PLUGIN_API_HANDLE (initialize_record_replay);
81
+
82
+ #undef DEFINE_PLUGIN_API_HANDLE
120
83
121
84
// Are there images associated with this RTL.
122
85
bool IsUsed = false ;
0 commit comments