Modify hipMalloc to take size of 0 and return NULL pointer for it.
Modify hipMemoryAllocate test for this change. Change-Id: I884aee0cd5fe0c60aebb4cb37cdbb4833c5bd0c7
Cette révision appartient à :
@@ -119,7 +119,13 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes)
|
||||
HIP_INIT_API(ptr, sizeBytes);
|
||||
|
||||
hipError_t hip_status = hipSuccess;
|
||||
|
||||
// return NULL pointer when malloc size is 0
|
||||
if (sizeBytes == 0)
|
||||
{
|
||||
*ptr = NULL;
|
||||
return ihipLogStatus(hip_status);
|
||||
}
|
||||
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
|
||||
if (ctx) {
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
#define SIZE 1024*1024*256
|
||||
|
||||
int main(){
|
||||
float *Ad, *B, *Bd, *Bm, *C, *Cd;
|
||||
float *Ad, *B, *Bd, *Bm, *C, *Cd, *ptr_0;
|
||||
B = (float*)malloc(SIZE);
|
||||
hipMalloc((void**)&Ad, SIZE);
|
||||
hipHostMalloc((void**)&B, SIZE);
|
||||
@@ -31,12 +31,15 @@ int main(){
|
||||
|
||||
hipHostGetDevicePointer((void**)&Cd, C, 0/*flags*/);
|
||||
|
||||
HIPCHECK_API(hipMalloc((void**)&ptr_0,0), hipSuccess);
|
||||
|
||||
HIPCHECK_API(hipFree(Ad) , hipSuccess);
|
||||
HIPCHECK_API(hipHostFree(Ad) , hipErrorInvalidValue);
|
||||
|
||||
HIPCHECK_API(hipFree(B) , hipErrorInvalidDevicePointer); // try to hipFree on malloced memory
|
||||
HIPCHECK_API(hipFree(Bd) , hipErrorInvalidDevicePointer);
|
||||
HIPCHECK_API(hipFree(Bm) , hipErrorInvalidDevicePointer);
|
||||
HIPCHECK_API(hipFree(ptr_0) , hipSuccess);
|
||||
HIPCHECK_API(hipHostFree(Bd) , hipSuccess);
|
||||
HIPCHECK_API(hipHostFree(Bm) , hipSuccess);
|
||||
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur