-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tests] Fix for DEV builds. Fix testing on 16GB GPUs. #1729
Changes from all commits
a7110f4
1b966c5
ccecacb
dd59a7f
4b846d3
288384d
3520dad
c5e5c8d
93ac5e2
802b37c
6fdb01f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,21 +81,47 @@ std::size_t GetAvailableMemory() | |
|
||
void* default_allocator(void*, size_t sz) | ||
{ | ||
if(sz > GetAvailableMemory()) | ||
MIOPEN_THROW("Memory not available to allocate buffer: " + std::to_string(sz)); | ||
void* result; | ||
auto status = hipMalloc(&result, sz); | ||
if(status != hipSuccess) | ||
const auto available = GetAvailableMemory(); | ||
MIOPEN_LOG_I2("GetAvailableMemory " << available); | ||
if(sz > available) | ||
MIOPEN_LOG_I("GetAvailableMemory reports unsufficient memory to allocate " << sz); | ||
void* ptr; | ||
const auto status = hipMalloc(&ptr, sz); | ||
if(status == hipSuccess) | ||
{ | ||
status = hipHostMalloc(&result, sz); | ||
if(status != hipSuccess) | ||
MIOPEN_THROW_HIP_STATUS(status, | ||
"Hip error creating buffer " + std::to_string(sz) + ": "); | ||
MIOPEN_LOG_I2("hipMalloc " << sz << " at " << ptr << " Ok"); | ||
return ptr; | ||
} | ||
return result; | ||
const auto status_host = hipHostMalloc(&ptr, sz); | ||
if(status_host == hipSuccess) | ||
{ | ||
MIOPEN_LOG_I2("hipHostMalloc " << sz << " at " << ptr << " Ok"); | ||
return ptr; | ||
} | ||
MIOPEN_LOG_W("hipMalloc " << sz << " status: " << status); | ||
MIOPEN_THROW_HIP_STATUS(status_host, "hipHostMalloc " + std::to_string(sz)); | ||
} | ||
|
||
void default_deallocator(void*, void* mem) { hipFree(mem); } | ||
inline std::string to_string(void* const ptr) | ||
{ | ||
std::ostringstream oss; | ||
oss << ptr; | ||
return oss.str(); | ||
} | ||
|
||
void default_deallocator(void*, void* mem) | ||
{ | ||
size_t size = 0; | ||
auto status = hipMemPtrGetInfo(mem, &size); | ||
if(status != hipSuccess) | ||
MIOPEN_LOG_W("hipMemPtrGetInfo at " << mem << " status: " << status); | ||
status = hipFree(mem); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it ok to use hipFree for device and for host memory? |
||
if(status != hipSuccess) | ||
MIOPEN_THROW_HIP_STATUS(status, | ||
"hipFree " + std::to_string(size) + " at " + to_string(mem)); | ||
else | ||
MIOPEN_LOG_I2("hipFree " << size << " at " << mem << " Ok"); | ||
} | ||
|
||
int get_device_id() // Get random device | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ namespace miopen { | |
|
||
std::string HIPErrorMessage(int error, const std::string& msg) | ||
{ | ||
return msg + " " + hipGetErrorString(static_cast<hipError_t>(error)); | ||
return msg + ": " + hipGetErrorString(static_cast<hipError_t>(error)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is ":" change mandatory? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, if we want to automatically separate error message from the error code, see https://github.com/ROCmSoftwarePlatform/MIOpen/pull/1729/files#r962057473. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. |
||
} | ||
|
||
} // namespace miopen |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,6 +211,7 @@ void test_warnings(kernel_type_t kern_type) | |
if(kern_type == miopenOpenCLKernelType) | ||
EXPECT(throws([&] { | ||
h.AddKernel("GEMM", "", WriteNop(kern_type), "write", {1, 1, 1}, {1, 1, 1}, ""); | ||
MIOPEN_LOG_E("FAILED: Build of the OpenCL kernel should produce warnings"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is very good. |
||
})); | ||
else if(kern_type == miopenHIPKernelType) | ||
EXPECT(throws([&] { | ||
|
@@ -223,7 +224,8 @@ void test_warnings(kernel_type_t kern_type) | |
"", | ||
0, | ||
false, | ||
WriteNop(miopenHIPKernelType)); | ||
WriteNop(kern_type)); | ||
MIOPEN_LOG_E("FAILED: Build of the HIP kernel 'nop_hip.cpp' should produce warnings"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. This change is good. |
||
})); | ||
#else | ||
(void)kern_type; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muralinr I do not think we want to append
+ ": "
to eachMIOPEN_THROW_HIP_STATUS
.