Mapped hipDevice_t to int

Change-Id: I6cfa56c42b7cd04aa0e0bce510c0d72d34ea211a
This commit is contained in:
Rahul Garg
2016-12-17 16:53:03 +05:30
vanhempi 2665ad2762
commit 263a9614ff
4 muutettua tiedostoa jossa 20 lisäystä ja 41 poistoa
@@ -53,7 +53,7 @@ extern "C" {
typedef struct ihipCtx_t *hipCtx_t;
// Note many APIs also use integer deviceIds as an alternative to the device pointer:
typedef struct ihipDevice_t *hipDevice_t;
typedef int hipDevice_t;
typedef struct ihipStream_t *hipStream_t;
@@ -1904,18 +1904,6 @@ hipError_t hipIpcCloseMemHandle(void *devPtr);
} /* extern "c" */
#endif
#ifdef __cplusplus
/**
* @brief Returns a PCI Bus Id string for the device.
* @param [out] pciBusId
* @param [in] len
* @param [hipDevice_t] device
*
* @returns #hipSuccess, #hipErrorInavlidDevice
*/
hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device);
#endif
/**
*-------------------------------------------------------------------------------------------------
*-------------------------------------------------------------------------------------------------
+9 -5
Näytä tiedosto
@@ -57,8 +57,8 @@ hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device)
{
HIP_INIT_API(ctx, flags, device); // FIXME - review if we want to init
hipError_t e = hipSuccess;
*ctx = new ihipCtx_t(device, g_deviceCnt, flags);
auto deviceHandle = ihipGetDevice(device);
*ctx = new ihipCtx_t(deviceHandle, g_deviceCnt, flags);
ihipSetTlsDefaultCtx(*ctx);
tls_ctxStack.push(*ctx);
@@ -69,11 +69,13 @@ hipError_t hipDeviceGet(hipDevice_t *device, int deviceId)
{
HIP_INIT_API(device, deviceId); // FIXME - review if we want to init
*device = ihipGetDevice(deviceId);
auto deviceHandle = ihipGetDevice(deviceId);
hipError_t e = hipSuccess;
if (*device == NULL) {
if (deviceHandle == NULL) {
e = hipErrorInvalidDevice;
} else {
*device = deviceId;
}
return ihipLogStatus(e);
@@ -199,9 +201,11 @@ hipError_t hipCtxGetDevice(hipDevice_t *device)
if(ctx == nullptr) {
e = hipErrorInvalidContext;
// TODO *device = nullptr;
}
else {
*device = (ihipDevice_t*)ctx->getDevice();
auto deviceHandle = ctx->getDevice();
*device = deviceHandle->_deviceId;
}
return ihipLogStatus(e);
}
+8 -22
Näytä tiedosto
@@ -321,9 +321,8 @@ hipError_t hipDeviceComputeCapability(int *major, int *minor, hipDevice_t device
{
HIP_INIT_API(major,minor, device);
hipError_t e = hipSuccess;
int deviceId= device->_deviceId;
e = ihipDeviceGetAttribute(major, hipDeviceAttributeComputeCapabilityMajor, deviceId);
e = ihipDeviceGetAttribute(minor, hipDeviceAttributeComputeCapabilityMinor, deviceId);
e = ihipDeviceGetAttribute(major, hipDeviceAttributeComputeCapabilityMajor, device);
e = ihipDeviceGetAttribute(minor, hipDeviceAttributeComputeCapabilityMinor, device);
return ihipLogStatus(e);
}
@@ -331,28 +330,13 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device)
{
HIP_INIT_API(name,len, device);
hipError_t e = hipSuccess;
int nameLen = strlen(device->_props.name);
auto deviceHandle = ihipGetDevice(device);
int nameLen = strlen(deviceHandle->_props.name);
if(nameLen <= len)
memcpy(name,device->_props.name,nameLen);
memcpy(name,deviceHandle->_props.name,nameLen);
return ihipLogStatus(e);
}
#ifdef __cplusplus
hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device)
{
HIP_INIT_API(pciBusId, len, device);
hipError_t e = hipSuccess;
int deviceId= device->_deviceId;
int tempPciBusId = 0;
e = ihipDeviceGetAttribute( &tempPciBusId, hipDeviceAttributePciBusId, deviceId);
if( e == hipSuccess) {
std::string tempPciStr = std::to_string(tempPciBusId);
memcpy( pciBusId , tempPciStr.c_str() , tempPciStr.length() );
}
return ihipLogStatus(e);
}
#endif
hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device)
{
HIP_INIT_API(pciBusId, len, device);
@@ -365,11 +349,13 @@ hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device)
}
return ihipLogStatus(e);
}
hipError_t hipDeviceTotalMem (size_t *bytes,hipDevice_t device)
{
HIP_INIT_API(bytes, device);
hipError_t e = hipSuccess;
*bytes= device->_props.totalGlobalMem;
auto deviceHandle = ihipGetDevice(device);
*bytes= deviceHandle->_props.totalGlobalMem;
return ihipLogStatus(e);
}
+2 -1
Näytä tiedosto
@@ -27,7 +27,8 @@ int main(){
hipInit(0);
hipDevice_t device;
hipDeviceGet(&device, 0);
char pciBusId[100];
char pciBusId[10];
memset(pciBusId,0,10);
hipDeviceGetPCIBusId(pciBusId,100,device);
printf("PCI Bus ID= %s\n",pciBusId);
return 0;