added more device negative testing
1. Added fallback for nullptr to hipGetDeviceProperties and hipGetDeviceCount
2. Added negative tests for hipGetDeviceProperties and hipGetDeviceCount
Change-Id: Iac93fd53d7d4794fb10546ddadf6ca802b047c87
[ROCm/clr commit: 4299316039]
Tento commit je obsažen v:
@@ -52,13 +52,20 @@ hipError_t hipGetDeviceCount(int *count)
|
||||
{
|
||||
HIP_INIT_API(count);
|
||||
|
||||
*count = g_deviceCnt;
|
||||
hipError_t e = hipSuccess;
|
||||
|
||||
if (*count > 0) {
|
||||
return ihipLogStatus(hipSuccess);
|
||||
if(count != nullptr) {
|
||||
*count = g_deviceCnt;
|
||||
|
||||
if (*count > 0) {
|
||||
e = ihipLogStatus(hipSuccess);
|
||||
} else {
|
||||
e = ihipLogStatus(hipErrorNoDevice);
|
||||
}
|
||||
} else {
|
||||
return ihipLogStatus(hipErrorNoDevice);
|
||||
e = ihipLogStatus(hipErrorNoDevice);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
hipError_t hipDeviceSetCacheConfig ( hipFuncCache cacheConfig )
|
||||
@@ -217,12 +224,16 @@ hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device)
|
||||
|
||||
hipError_t e;
|
||||
|
||||
auto * hipDevice = ihipGetDevice(device);
|
||||
if (hipDevice) {
|
||||
if(props != nullptr){
|
||||
auto * hipDevice = ihipGetDevice(device);
|
||||
if (hipDevice) {
|
||||
// copy saved props
|
||||
*props = hipDevice->_props;
|
||||
e = hipSuccess;
|
||||
} else {
|
||||
*props = hipDevice->_props;
|
||||
e = hipSuccess;
|
||||
} else {
|
||||
e = hipErrorInvalidDevice;
|
||||
}
|
||||
}else{
|
||||
e = hipErrorInvalidDevice;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include<hip/hip_runtime.h>
|
||||
#include<hip/hip_runtime_api.h>
|
||||
#include"hipDeviceUtil.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int deviceCnt;
|
||||
HIP_CHECK(hipGetDeviceCount(&deviceCnt), hipGetDeviceCount);
|
||||
HIP_CHECK(hipGetDeviceCount(0), hipGetDeviceCount);
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#include<hip/hip_runtime.h>
|
||||
#include<hip/hip_runtime_api.h>
|
||||
#include"hipDeviceUtil.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
hipDeviceProp_t props;
|
||||
HIP_CHECK(hipGetDeviceProperties(&props, 0), hipGetDeviceProperties);
|
||||
HIP_CHECK(hipGetDeviceProperties(NULL, 0), hipGetDeviceProperties);
|
||||
HIP_CHECK(hipGetDeviceProperties(NULL, -1), hipGetDeviceProperties);
|
||||
HIP_CHECK(hipGetDeviceProperties(&props, -1), hipGetDeviceProperties);
|
||||
HIP_CHECK(hipGetDeviceProperties(NULL, 1024), hipGetDeviceProperties);
|
||||
HIP_CHECK(hipGetDeviceProperties(&props, 1024), hipGetDeviceProperties);
|
||||
}
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele