Skip to content

Commit a48534c

Browse files
committed
opal/accelerator: implement additional stub APIs
This change implements stub APIs introduced in open-mpi#10959 Signed-off-by: Wenduo Wang <[email protected]>
1 parent cb8de8b commit a48534c

File tree

4 files changed

+337
-0
lines changed

4 files changed

+337
-0
lines changed

opal/mca/accelerator/cuda/accelerator_cuda.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@
2525
/* Accelerator API's */
2626
static int accelerator_cuda_check_addr(const void *addr, int *dev_id, uint64_t *flags);
2727
static int accelerator_cuda_create_stream(int dev_id, opal_accelerator_stream_t **stream);
28+
static int accelerator_cuda_destroy_stream(opal_accelerator_stream_t *stream);
29+
static int accelerator_cuda_synchronize_stream(opal_accelerator_stream_t *stream);
30+
static int accelerator_cuda_stream_wait_event(opal_accelerator_stream_t *stream,
31+
opal_accelerator_event_t *event);
2832

2933
static int accelerator_cuda_create_event(int dev_id, opal_accelerator_event_t **event);
34+
static int accelerator_cuda_destroy_event(opal_accelerator_event_t *event);
3035
static int accelerator_cuda_record_event(int dev_id, opal_accelerator_event_t *event, opal_accelerator_stream_t *stream);
3136
static int accelerator_cuda_query_event(int dev_id, opal_accelerator_event_t *event);
3237

@@ -41,6 +46,17 @@ static int accelerator_cuda_mem_release(int dev_id, void *ptr);
4146
static int accelerator_cuda_get_address_range(int dev_id, const void *ptr, void **base,
4247
size_t *size);
4348

49+
static bool accelerator_cuda_is_ipc_enabled(void);
50+
static int accelerator_cuda_get_ipc_handle(int dev_id, void *dev_ptr,
51+
opal_accelerator_ipc_handle_t *handle);
52+
static int accelerator_cuda_open_ipc_handle(int dev_id, opal_accelerator_ipc_handle_t *handle,
53+
void **dev_ptr);
54+
static int accelerator_cuda_get_ipc_event_handle(opal_accelerator_event_t *event,
55+
opal_accelerator_ipc_event_handle_t *handle);
56+
static int accelerator_cuda_open_ipc_event_handle(opal_accelerator_ipc_event_handle_t *handle,
57+
opal_accelerator_event_t *event);
58+
static int accelerator_cuda_close_ipc_handle(int dev_id, void *dev_ptr);
59+
4460
static int accelerator_cuda_host_register(int dev_id, void *ptr, size_t size);
4561
static int accelerator_cuda_host_unregister(int dev_id, void *ptr);
4662

@@ -55,8 +71,12 @@ opal_accelerator_base_module_t opal_accelerator_cuda_module =
5571
accelerator_cuda_check_addr,
5672

5773
accelerator_cuda_create_stream,
74+
accelerator_cuda_destroy_stream,
75+
accelerator_cuda_synchronize_stream,
76+
accelerator_cuda_stream_wait_event,
5877

5978
accelerator_cuda_create_event,
79+
accelerator_cuda_destroy_event,
6080
accelerator_cuda_record_event,
6181
accelerator_cuda_query_event,
6282

@@ -67,6 +87,13 @@ opal_accelerator_base_module_t opal_accelerator_cuda_module =
6787
accelerator_cuda_mem_release,
6888
accelerator_cuda_get_address_range,
6989

90+
accelerator_cuda_is_ipc_enabled,
91+
accelerator_cuda_get_ipc_handle,
92+
accelerator_cuda_open_ipc_handle,
93+
accelerator_cuda_get_ipc_event_handle,
94+
accelerator_cuda_open_ipc_event_handle,
95+
accelerator_cuda_close_ipc_handle,
96+
7097
accelerator_cuda_host_register,
7198
accelerator_cuda_host_unregister,
7299

@@ -254,6 +281,23 @@ static void opal_accelerator_cuda_stream_destruct(opal_accelerator_cuda_stream_t
254281
}
255282
}
256283

284+
static int accelerator_cuda_destroy_stream(opal_accelerator_stream_t *stream)
285+
{
286+
opal_accelerator_cuda_stream_destruct(stream);
287+
return OPAL_SUCCESS;
288+
}
289+
290+
static int accelerator_cuda_synchronize_stream(opal_accelerator_stream_t *stream)
291+
{
292+
return OPAL_ERR_NOT_IMPLEMENTED;
293+
}
294+
295+
static int accelerator_cuda_stream_wait_event(opal_accelerator_stream_t *stream,
296+
opal_accelerator_event_t *event)
297+
{
298+
return OPAL_ERR_NOT_IMPLEMENTED;
299+
}
300+
257301
OBJ_CLASS_INSTANCE(
258302
opal_accelerator_cuda_stream_t,
259303
opal_accelerator_stream_t,
@@ -302,6 +346,12 @@ static void opal_accelerator_cuda_event_destruct(opal_accelerator_cuda_event_t *
302346
}
303347
}
304348

349+
static int accelerator_cuda_destroy_event(opal_accelerator_event_t *event)
350+
{
351+
opal_accelerator_cuda_event_destruct(event);
352+
return OPAL_SUCCESS;
353+
}
354+
305355
OBJ_CLASS_INSTANCE(
306356
opal_accelerator_cuda_event_t,
307357
opal_accelerator_event_t,
@@ -520,6 +570,40 @@ static int accelerator_cuda_get_address_range(int dev_id, const void *ptr, void
520570
return 0;
521571
}
522572

573+
static bool accelerator_null_is_ipc_enabled(void)
574+
{
575+
return false;
576+
}
577+
578+
static int accelerator_cuda_get_ipc_handle(int dev_id, void *dev_ptr,
579+
opal_accelerator_ipc_handle_t *handle)
580+
{
581+
return OPAL_ERR_NOT_IMPLEMENTED;
582+
}
583+
584+
static int accelerator_cuda_open_ipc_handle(int dev_id, opal_accelerator_ipc_handle_t *handle,
585+
void **dev_ptr)
586+
{
587+
return OPAL_ERR_NOT_IMPLEMENTED;
588+
}
589+
590+
static int accelerator_cuda_get_ipc_event_handle(opal_accelerator_event_t *event,
591+
opal_accelerator_ipc_event_handle_t *handle)
592+
{
593+
return OPAL_ERR_NOT_IMPLEMENTED;
594+
}
595+
596+
static int accelerator_cuda_open_ipc_event_handle(opal_accelerator_ipc_event_handle_t *handle,
597+
opal_accelerator_event_t *event)
598+
{
599+
return OPAL_ERR_NOT_IMPLEMENTED;
600+
}
601+
602+
static int accelerator_cuda_close_ipc_handle(int dev_id, void *dev_ptr)
603+
{
604+
return OPAL_ERR_NOT_IMPLEMENTED;
605+
}
606+
523607
static int accelerator_cuda_host_register(int dev_id, void *ptr, size_t size)
524608
{
525609
CUresult result;

opal/mca/accelerator/null/accelerator_null_component.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ static void accelerator_null_finalize(opal_accelerator_base_module_t* module);
4040
static int accelerator_null_check_addr(const void *addr, int *dev_id, uint64_t *flags);
4141

4242
static int accelerator_null_create_stream(int dev_id, opal_accelerator_stream_t **stream);
43+
static int accelerator_null_destroy_stream(opal_accelerator_stream_t *stream);
44+
static int accelerator_null_synchronize_stream(opal_accelerator_stream_t *stream);
45+
static int accelerator_null_stream_wait_event(opal_accelerator_stream_t *stream,
46+
opal_accelerator_event_t *event);
4347
static int accelerator_null_create_event(int dev_id, opal_accelerator_event_t **event);
48+
static int accelerator_null_destroy_event(opal_accelerator_event_t *event);
4449
static int accelerator_null_record_event(int dev_id, opal_accelerator_event_t *event, opal_accelerator_stream_t *stream);
4550
static int accelerator_null_query_event(int dev_id, opal_accelerator_event_t *event);
4651

@@ -55,6 +60,17 @@ static int accelerator_null_mem_alloc(int dev_id, void **ptr, size_t size);
5560
static int accelerator_null_mem_release(int dev_id, void *ptr);
5661
static int accelerator_null_get_address_range(int dev_id, const void *ptr, void **base, size_t *size);
5762

63+
static bool accelerator_null_is_ipc_enabled(void);
64+
static int accelerator_null_get_ipc_handle(int dev_id, void *dev_ptr,
65+
opal_accelerator_ipc_handle_t *handle);
66+
static int accelerator_null_open_ipc_handle(int dev_id, opal_accelerator_ipc_handle_t *handle,
67+
void **dev_ptr);
68+
static int accelerator_null_get_ipc_event_handle(opal_accelerator_event_t *event,
69+
opal_accelerator_ipc_event_handle_t *handle);
70+
static int accelerator_null_open_ipc_event_handle(opal_accelerator_ipc_event_handle_t *handle,
71+
opal_accelerator_event_t *event);
72+
static int accelerator_null_close_ipc_handle(int dev_id, void *dev_ptr);
73+
5874
static int accelerator_null_host_register(int dev_id, void *ptr, size_t size);
5975
static int accelerator_null_host_unregister(int dev_id, void *ptr);
6076

@@ -107,8 +123,12 @@ opal_accelerator_base_module_t opal_accelerator_null_module =
107123
accelerator_null_check_addr,
108124

109125
accelerator_null_create_stream,
126+
accelerator_null_destroy_stream,
127+
accelerator_null_synchronize_stream,
128+
accelerator_null_stream_wait_event,
110129

111130
accelerator_null_create_event,
131+
accelerator_null_destroy_event,
112132
accelerator_null_record_event,
113133
accelerator_null_query_event,
114134

@@ -119,6 +139,13 @@ opal_accelerator_base_module_t opal_accelerator_null_module =
119139
accelerator_null_mem_release,
120140
accelerator_null_get_address_range,
121141

142+
accelerator_null_is_ipc_enabled,
143+
accelerator_null_get_ipc_handle,
144+
accelerator_null_open_ipc_handle,
145+
accelerator_null_get_ipc_event_handle,
146+
accelerator_null_open_ipc_event_handle,
147+
accelerator_null_close_ipc_handle,
148+
122149
accelerator_null_host_register,
123150
accelerator_null_host_unregister,
124151

@@ -167,12 +194,35 @@ static int accelerator_null_create_stream(int dev_id, opal_accelerator_stream_t
167194
return OPAL_SUCCESS;
168195
}
169196

197+
static int accelerator_null_destroy_stream(opal_accelerator_stream_t *stream)
198+
{
199+
OBJ_RELEASE(stream);
200+
return OPAL_SUCCESS;
201+
}
202+
203+
static int accelerator_null_synchronize_stream(opal_accelerator_stream_t *stream)
204+
{
205+
return OPAL_SUCCESS;
206+
}
207+
208+
static int accelerator_null_stream_wait_event(opal_accelerator_stream_t *stream,
209+
opal_accelerator_event_t *event)
210+
{
211+
return OPAL_SUCCESS;
212+
}
213+
170214
static int accelerator_null_create_event(int dev_id, opal_accelerator_event_t **event)
171215
{
172216
*event = OBJ_NEW(opal_accelerator_event_t);
173217
return OPAL_SUCCESS;
174218
}
175219

220+
static int accelerator_null_destroy_event(opal_accelerator_event_t *event)
221+
{
222+
OBJ_RELEASE(event);
223+
return OPAL_SUCCESS;
224+
}
225+
176226
static int accelerator_null_record_event(int dev_id, opal_accelerator_event_t *event, opal_accelerator_stream_t *stream)
177227
{
178228
return OPAL_SUCCESS;
@@ -222,6 +272,40 @@ static int accelerator_null_get_address_range(int dev_id, const void *ptr, void
222272
return OPAL_ERR_NOT_IMPLEMENTED;
223273
}
224274

275+
static bool accelerator_null_is_ipc_enabled(void)
276+
{
277+
return false;
278+
}
279+
280+
static int accelerator_null_get_ipc_handle(int dev_id, void *dev_ptr,
281+
opal_accelerator_ipc_handle_t *handle)
282+
{
283+
return OPAL_ERR_NOT_IMPLEMENTED;
284+
}
285+
286+
static int accelerator_null_open_ipc_handle(int dev_id, opal_accelerator_ipc_handle_t *handle,
287+
void **dev_ptr)
288+
{
289+
return OPAL_ERR_NOT_IMPLEMENTED;
290+
}
291+
292+
static int accelerator_null_get_ipc_event_handle(opal_accelerator_event_t *event,
293+
opal_accelerator_ipc_event_handle_t *handle)
294+
{
295+
return OPAL_ERR_NOT_IMPLEMENTED;
296+
}
297+
298+
static int accelerator_null_open_ipc_event_handle(opal_accelerator_ipc_event_handle_t *handle,
299+
opal_accelerator_event_t *event)
300+
{
301+
return OPAL_ERR_NOT_IMPLEMENTED;
302+
}
303+
304+
static int accelerator_null_close_ipc_handle(int dev_id, void *dev_ptr)
305+
{
306+
return OPAL_ERR_NOT_IMPLEMENTED;
307+
}
308+
225309
static int accelerator_null_host_register(int dev_id, void *ptr, size_t size)
226310
{
227311
return OPAL_ERR_NOT_IMPLEMENTED;

0 commit comments

Comments
 (0)