Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/src/interface.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | EXTERN void __tgt_target_data_begin_mapper(ident_t *loc, int64_t device_id, | ||||
TIMESCOPE_WITH_IDENT(loc); | TIMESCOPE_WITH_IDENT(loc); | ||||
DP("Entering data begin region for device %" PRId64 " with %d mappings\n", | DP("Entering data begin region for device %" PRId64 " with %d mappings\n", | ||||
device_id, arg_num); | device_id, arg_num); | ||||
if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { | if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { | ||||
DP("Not offloading to device %" PRId64 "\n", device_id); | DP("Not offloading to device %" PRId64 "\n", device_id); | ||||
return; | return; | ||||
} | } | ||||
DeviceTy &Device = PM->Devices[device_id]; | DeviceTy &Device = *PM->Devices[device_id]; | ||||
if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) | if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) | ||||
printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, | printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, | ||||
arg_names, "Entering OpenMP data region"); | arg_names, "Entering OpenMP data region"); | ||||
#ifdef OMPTARGET_DEBUG | #ifdef OMPTARGET_DEBUG | ||||
for (int i = 0; i < arg_num; ++i) { | for (int i = 0; i < arg_num; ++i) { | ||||
DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | ||||
", Type=0x%" PRIx64 ", Name=%s\n", | ", Type=0x%" PRIx64 ", Name=%s\n", | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | EXTERN void __tgt_target_data_end_mapper(ident_t *loc, int64_t device_id, | ||||
void **arg_mappers) { | void **arg_mappers) { | ||||
TIMESCOPE_WITH_IDENT(loc); | TIMESCOPE_WITH_IDENT(loc); | ||||
DP("Entering data end region with %d mappings\n", arg_num); | DP("Entering data end region with %d mappings\n", arg_num); | ||||
if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { | if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { | ||||
DP("Not offloading to device %" PRId64 "\n", device_id); | DP("Not offloading to device %" PRId64 "\n", device_id); | ||||
return; | return; | ||||
} | } | ||||
DeviceTy &Device = PM->Devices[device_id]; | DeviceTy &Device = *PM->Devices[device_id]; | ||||
if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) | if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) | ||||
printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, | printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, | ||||
arg_names, "Exiting OpenMP data region"); | arg_names, "Exiting OpenMP data region"); | ||||
#ifdef OMPTARGET_DEBUG | #ifdef OMPTARGET_DEBUG | ||||
for (int i = 0; i < arg_num; ++i) { | for (int i = 0; i < arg_num; ++i) { | ||||
DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | ||||
", Type=0x%" PRIx64 ", Name=%s\n", | ", Type=0x%" PRIx64 ", Name=%s\n", | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { | ||||
DP("Not offloading to device %" PRId64 "\n", device_id); | DP("Not offloading to device %" PRId64 "\n", device_id); | ||||
return; | return; | ||||
} | } | ||||
if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) | if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) | ||||
printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, | printKernelArguments(loc, device_id, arg_num, arg_sizes, arg_types, | ||||
arg_names, "Updating OpenMP data"); | arg_names, "Updating OpenMP data"); | ||||
DeviceTy &Device = PM->Devices[device_id]; | DeviceTy &Device = *PM->Devices[device_id]; | ||||
AsyncInfoTy AsyncInfo(Device); | AsyncInfoTy AsyncInfo(Device); | ||||
int rc = targetDataUpdate(loc, Device, arg_num, args_base, args, arg_sizes, | int rc = targetDataUpdate(loc, Device, arg_num, args_base, args, arg_sizes, | ||||
arg_types, arg_names, arg_mappers, AsyncInfo); | arg_types, arg_names, arg_mappers, AsyncInfo); | ||||
if (rc == OFFLOAD_SUCCESS) | if (rc == OFFLOAD_SUCCESS) | ||||
rc = AsyncInfo.synchronize(); | rc = AsyncInfo.synchronize(); | ||||
handleTargetOutcome(rc == OFFLOAD_SUCCESS, loc); | handleTargetOutcome(rc == OFFLOAD_SUCCESS, loc); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | #ifdef OMPTARGET_DEBUG | ||||
for (int i = 0; i < arg_num; ++i) { | for (int i = 0; i < arg_num; ++i) { | ||||
DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | ||||
", Type=0x%" PRIx64 ", Name=%s\n", | ", Type=0x%" PRIx64 ", Name=%s\n", | ||||
i, DPxPTR(args_base[i]), DPxPTR(args[i]), arg_sizes[i], arg_types[i], | i, DPxPTR(args_base[i]), DPxPTR(args[i]), arg_sizes[i], arg_types[i], | ||||
(arg_names) ? getNameFromMapping(arg_names[i]).c_str() : "unknown"); | (arg_names) ? getNameFromMapping(arg_names[i]).c_str() : "unknown"); | ||||
} | } | ||||
#endif | #endif | ||||
DeviceTy &Device = PM->Devices[device_id]; | DeviceTy &Device = *PM->Devices[device_id]; | ||||
AsyncInfoTy AsyncInfo(Device); | AsyncInfoTy AsyncInfo(Device); | ||||
int rc = target(loc, Device, host_ptr, arg_num, args_base, args, arg_sizes, | int rc = target(loc, Device, host_ptr, arg_num, args_base, args, arg_sizes, | ||||
arg_types, arg_names, arg_mappers, 0, 0, false /*team*/, | arg_types, arg_names, arg_mappers, 0, 0, false /*team*/, | ||||
AsyncInfo); | AsyncInfo); | ||||
if (rc == OFFLOAD_SUCCESS) | if (rc == OFFLOAD_SUCCESS) | ||||
rc = AsyncInfo.synchronize(); | rc = AsyncInfo.synchronize(); | ||||
handleTargetOutcome(rc == OFFLOAD_SUCCESS, loc); | handleTargetOutcome(rc == OFFLOAD_SUCCESS, loc); | ||||
return rc; | return rc; | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | #ifdef OMPTARGET_DEBUG | ||||
for (int i = 0; i < arg_num; ++i) { | for (int i = 0; i < arg_num; ++i) { | ||||
DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | ||||
", Type=0x%" PRIx64 ", Name=%s\n", | ", Type=0x%" PRIx64 ", Name=%s\n", | ||||
i, DPxPTR(args_base[i]), DPxPTR(args[i]), arg_sizes[i], arg_types[i], | i, DPxPTR(args_base[i]), DPxPTR(args[i]), arg_sizes[i], arg_types[i], | ||||
(arg_names) ? getNameFromMapping(arg_names[i]).c_str() : "unknown"); | (arg_names) ? getNameFromMapping(arg_names[i]).c_str() : "unknown"); | ||||
} | } | ||||
#endif | #endif | ||||
DeviceTy &Device = PM->Devices[device_id]; | DeviceTy &Device = *PM->Devices[device_id]; | ||||
AsyncInfoTy AsyncInfo(Device); | AsyncInfoTy AsyncInfo(Device); | ||||
int rc = target(loc, Device, host_ptr, arg_num, args_base, args, arg_sizes, | int rc = target(loc, Device, host_ptr, arg_num, args_base, args, arg_sizes, | ||||
arg_types, arg_names, arg_mappers, team_num, thread_limit, | arg_types, arg_names, arg_mappers, team_num, thread_limit, | ||||
true /*team*/, AsyncInfo); | true /*team*/, AsyncInfo); | ||||
if (rc == OFFLOAD_SUCCESS) | if (rc == OFFLOAD_SUCCESS) | ||||
rc = AsyncInfo.synchronize(); | rc = AsyncInfo.synchronize(); | ||||
handleTargetOutcome(rc == OFFLOAD_SUCCESS, loc); | handleTargetOutcome(rc == OFFLOAD_SUCCESS, loc); | ||||
return rc; | return rc; | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | EXTERN void __kmpc_push_target_tripcount_mapper(ident_t *loc, int64_t device_id, | ||||
if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { | if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) { | ||||
DP("Not offloading to device %" PRId64 "\n", device_id); | DP("Not offloading to device %" PRId64 "\n", device_id); | ||||
return; | return; | ||||
} | } | ||||
DP("__kmpc_push_target_tripcount(%" PRId64 ", %" PRIu64 ")\n", device_id, | DP("__kmpc_push_target_tripcount(%" PRId64 ", %" PRIu64 ")\n", device_id, | ||||
loop_tripcount); | loop_tripcount); | ||||
PM->TblMapMtx.lock(); | PM->TblMapMtx.lock(); | ||||
PM->Devices[device_id].LoopTripCnt.emplace(__kmpc_global_thread_num(NULL), | PM->Devices[device_id]->LoopTripCnt.emplace(__kmpc_global_thread_num(NULL), | ||||
loop_tripcount); | loop_tripcount); | ||||
PM->TblMapMtx.unlock(); | PM->TblMapMtx.unlock(); | ||||
} | } | ||||
EXTERN void __tgt_set_info_flag(uint32_t NewInfoLevel) { | EXTERN void __tgt_set_info_flag(uint32_t NewInfoLevel) { | ||||
std::atomic<uint32_t> &InfoLevel = getInfoLevelInternal(); | std::atomic<uint32_t> &InfoLevel = getInfoLevelInternal(); | ||||
InfoLevel.store(NewInfoLevel); | InfoLevel.store(NewInfoLevel); | ||||
for (auto &R : PM->RTLs.AllRTLs) { | for (auto &R : PM->RTLs.AllRTLs) { | ||||
if (R.set_info_flag) | if (R.set_info_flag) | ||||
R.set_info_flag(NewInfoLevel); | R.set_info_flag(NewInfoLevel); | ||||
} | } | ||||
} | } | ||||
EXTERN int __tgt_print_device_info(int64_t device_id) { | EXTERN int __tgt_print_device_info(int64_t device_id) { | ||||
return PM->Devices[device_id].printDeviceInfo( | return PM->Devices[device_id]->printDeviceInfo( | ||||
PM->Devices[device_id].RTLDeviceID); | PM->Devices[device_id]->RTLDeviceID); | ||||
} | } |