Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp
Show First 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void *__tgt_rtl_data_alloc(int32_t device_id, int64_t size, void *hst_ptr) { | void *__tgt_rtl_data_alloc(int32_t device_id, int64_t size, void *hst_ptr) { | ||||
void *ptr = malloc(size); | void *ptr = malloc(size); | ||||
return ptr; | return ptr; | ||||
} | } | ||||
int32_t __tgt_rtl_data_submit(int32_t device_id, void *tgt_ptr, void *hst_ptr, | int32_t __tgt_rtl_data_submit(int32_t device_id, void *tgt_ptr, void *hst_ptr, | ||||
int64_t size) { | int64_t size, __tgt_async_info *) { | ||||
memcpy(tgt_ptr, hst_ptr, size); | memcpy(tgt_ptr, hst_ptr, size); | ||||
return OFFLOAD_SUCCESS; | return OFFLOAD_SUCCESS; | ||||
} | } | ||||
int32_t __tgt_rtl_data_retrieve(int32_t device_id, void *hst_ptr, void *tgt_ptr, | int32_t __tgt_rtl_data_retrieve(int32_t device_id, void *hst_ptr, void *tgt_ptr, | ||||
int64_t size) { | int64_t size, __tgt_async_info *) { | ||||
memcpy(hst_ptr, tgt_ptr, size); | memcpy(hst_ptr, tgt_ptr, size); | ||||
return OFFLOAD_SUCCESS; | return OFFLOAD_SUCCESS; | ||||
} | } | ||||
int32_t __tgt_rtl_data_delete(int32_t device_id, void *tgt_ptr) { | int32_t __tgt_rtl_data_delete(int32_t device_id, void *tgt_ptr) { | ||||
free(tgt_ptr); | free(tgt_ptr); | ||||
return OFFLOAD_SUCCESS; | return OFFLOAD_SUCCESS; | ||||
} | } | ||||
int32_t __tgt_rtl_run_target_team_region(int32_t device_id, void *tgt_entry_ptr, | int32_t __tgt_rtl_run_target_team_region( | ||||
void **tgt_args, ptrdiff_t *tgt_offsets, int32_t arg_num, int32_t team_num, | int32_t device_id, void *tgt_entry_ptr, void **tgt_args, | ||||
int32_t thread_limit, uint64_t loop_tripcount /*not used*/) { | ptrdiff_t *tgt_offsets, int32_t arg_num, int32_t team_num, | ||||
int32_t thread_limit, uint64_t loop_tripcount /*not used*/, | |||||
__tgt_async_info *async_info /*not used*/) { | |||||
// ignore team num and thread limit. | // ignore team num and thread limit. | ||||
// Use libffi to launch execution. | // Use libffi to launch execution. | ||||
ffi_cif cif; | ffi_cif cif; | ||||
// All args are references. | // All args are references. | ||||
std::vector<ffi_type *> args_types(arg_num, &ffi_type_pointer); | std::vector<ffi_type *> args_types(arg_num, &ffi_type_pointer); | ||||
std::vector<void *> args(arg_num); | std::vector<void *> args(arg_num); | ||||
Show All 16 Lines | int32_t __tgt_rtl_run_target_team_region( | ||||
void (*entry)(void); | void (*entry)(void); | ||||
*((void**) &entry) = tgt_entry_ptr; | *((void**) &entry) = tgt_entry_ptr; | ||||
ffi_call(&cif, entry, NULL, &args[0]); | ffi_call(&cif, entry, NULL, &args[0]); | ||||
return OFFLOAD_SUCCESS; | return OFFLOAD_SUCCESS; | ||||
} | } | ||||
int32_t __tgt_rtl_run_target_region(int32_t device_id, void *tgt_entry_ptr, | int32_t __tgt_rtl_run_target_region(int32_t device_id, void *tgt_entry_ptr, | ||||
void **tgt_args, ptrdiff_t *tgt_offsets, int32_t arg_num) { | void **tgt_args, ptrdiff_t *tgt_offsets, | ||||
int32_t arg_num, | |||||
__tgt_async_info *async_info_ptr) { | |||||
// use one team and one thread. | // use one team and one thread. | ||||
return __tgt_rtl_run_target_team_region(device_id, tgt_entry_ptr, tgt_args, | return __tgt_rtl_run_target_team_region(device_id, tgt_entry_ptr, tgt_args, | ||||
tgt_offsets, arg_num, 1, 1, 0); | tgt_offsets, arg_num, 1, 1, 0, | ||||
async_info_ptr); | |||||
} | |||||
int32_t __tgt_rtl_synchronize(int32_t device_id, | |||||
__tgt_async_info *async_info_ptr) { | |||||
return OFFLOAD_SUCCESS; | |||||
} | } | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } | ||||
#endif | #endif |