Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/src/device.cpp
Show All 13 Lines | |||||
#include "private.h" | #include "private.h" | ||||
#include "rtl.h" | #include "rtl.h" | ||||
#include <cassert> | #include <cassert> | ||||
#include <climits> | #include <climits> | ||||
#include <cstdio> | #include <cstdio> | ||||
#include <string> | #include <string> | ||||
DeviceTy::DeviceTy(const DeviceTy &D) | |||||
: DeviceID(D.DeviceID), RTL(D.RTL), RTLDeviceID(D.RTLDeviceID), | |||||
IsInit(D.IsInit), InitFlag(), HasPendingGlobals(D.HasPendingGlobals), | |||||
HostDataToTargetMap(D.HostDataToTargetMap), | |||||
PendingCtorsDtors(D.PendingCtorsDtors), ShadowPtrMap(D.ShadowPtrMap), | |||||
DataMapMtx(), PendingGlobalsMtx(), ShadowMtx(), | |||||
LoopTripCnt(D.LoopTripCnt) {} | |||||
DeviceTy &DeviceTy::operator=(const DeviceTy &D) { | |||||
DeviceID = D.DeviceID; | |||||
RTL = D.RTL; | |||||
RTLDeviceID = D.RTLDeviceID; | |||||
IsInit = D.IsInit; | |||||
HasPendingGlobals = D.HasPendingGlobals; | |||||
HostDataToTargetMap = D.HostDataToTargetMap; | |||||
PendingCtorsDtors = D.PendingCtorsDtors; | |||||
ShadowPtrMap = D.ShadowPtrMap; | |||||
LoopTripCnt = D.LoopTripCnt; | |||||
return *this; | |||||
} | |||||
DeviceTy::DeviceTy(RTLInfoTy *RTL) | DeviceTy::DeviceTy(RTLInfoTy *RTL) | ||||
: DeviceID(-1), RTL(RTL), RTLDeviceID(-1), IsInit(false), InitFlag(), | : DeviceID(-1), RTL(RTL), RTLDeviceID(-1), IsInit(false), InitFlag(), | ||||
HasPendingGlobals(false), HostDataToTargetMap(), PendingCtorsDtors(), | HasPendingGlobals(false), HostDataToTargetMap(), PendingCtorsDtors(), | ||||
ShadowPtrMap(), DataMapMtx(), PendingGlobalsMtx(), ShadowMtx() {} | ShadowPtrMap(), DataMapMtx(), PendingGlobalsMtx(), ShadowMtx() {} | ||||
DeviceTy::~DeviceTy() { | DeviceTy::~DeviceTy() { | ||||
if (DeviceID == -1 || !(getInfoLevel() & OMP_INFOTYPE_DUMP_TABLE)) | if (DeviceID == -1 || !(getInfoLevel() & OMP_INFOTYPE_DUMP_TABLE)) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 562 Lines • ▼ Show 20 Lines | bool device_is_ready(int device_num) { | ||||
size_t DevicesSize = PM->Devices.size(); | size_t DevicesSize = PM->Devices.size(); | ||||
PM->RTLsMtx.unlock(); | PM->RTLsMtx.unlock(); | ||||
if (DevicesSize <= (size_t)device_num) { | if (DevicesSize <= (size_t)device_num) { | ||||
DP("Device ID %d does not have a matching RTL\n", device_num); | DP("Device ID %d does not have a matching RTL\n", device_num); | ||||
return false; | return false; | ||||
} | } | ||||
// Get device info | // Get device info | ||||
DeviceTy &Device = PM->Devices[device_num]; | DeviceTy &Device = *PM->Devices[device_num]; | ||||
DP("Is the device %d (local ID %d) initialized? %d\n", device_num, | DP("Is the device %d (local ID %d) initialized? %d\n", device_num, | ||||
Device.RTLDeviceID, Device.IsInit); | Device.RTLDeviceID, Device.IsInit); | ||||
// Init the device if not done before | // Init the device if not done before | ||||
if (!Device.IsInit && Device.initOnce() != OFFLOAD_SUCCESS) { | if (!Device.IsInit && Device.initOnce() != OFFLOAD_SUCCESS) { | ||||
DP("Failed to init device %d\n", device_num); | DP("Failed to init device %d\n", device_num); | ||||
return false; | return false; | ||||
} | } | ||||
DP("Device %d is ready to use.\n", device_num); | DP("Device %d is ready to use.\n", device_num); | ||||
return true; | return true; | ||||
} | } |