коммит произвёл
GitHub
родитель
b71a2dbaab
Коммит
db400a1ccb
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
#include <memory>
|
||||
|
||||
// Stress allocation tests
|
||||
// Try to allocate as much memory as possible
|
||||
// But since max allocation can fail, we need to be happy with atleast 1/4th of memory
|
||||
TEST_CASE("Stress_hipMalloc_HighSizeAlloc") {
|
||||
size_t devMemTotal{0}, devMemFree{0};
|
||||
HIP_CHECK(hipMemGetInfo(&devMemFree, &devMemTotal));
|
||||
REQUIRE(devMemFree > 0);
|
||||
REQUIRE(devMemTotal > 0);
|
||||
|
||||
char* d_ptr{nullptr};
|
||||
size_t counter{0};
|
||||
|
||||
INFO("Free Mem Available: " << devMemFree << " bytes out of " << devMemTotal << " bytes!");
|
||||
while (hipMalloc(&d_ptr, devMemFree) != hipSuccess && devMemFree > 1) {
|
||||
counter++;
|
||||
devMemFree >>= 1; // reduce the memory to be allocated by half
|
||||
INFO("Attempt to allocate " << devMemFree << " bytes out of " << devMemTotal
|
||||
<< " bytes failed!");
|
||||
REQUIRE(counter <= 2); // Make sure that we are atleast able to allocate 1/4th of max memory
|
||||
}
|
||||
|
||||
HIP_CHECK(hipMemset(d_ptr, 1, devMemFree));
|
||||
auto ptr = std::unique_ptr<unsigned char[]>{new unsigned char[devMemFree]};
|
||||
HIP_CHECK(hipMemcpy(ptr.get(), d_ptr, devMemFree, hipMemcpyDeviceToHost));
|
||||
HIP_CHECK(hipFree(d_ptr));
|
||||
REQUIRE(std::all_of(ptr.get(), ptr.get() + devMemFree, [](unsigned char n) { return n == 1; }));
|
||||
}
|
||||
@@ -150,7 +150,7 @@ static int HmmAttrPrint() {
|
||||
// The following test case allocation, host access, device access of HMM
|
||||
// memory from size 1 to 10KB
|
||||
|
||||
TEST_CASE("Unit_hipMallocManaged_MultiSize") {
|
||||
TEST_CASE("Stress_hipMallocManaged_MultiSize") {
|
||||
IfTestPassed = true;
|
||||
int managed = HmmAttrPrint();
|
||||
if (managed == 1) {
|
||||
@@ -196,7 +196,7 @@ TEST_CASE("Unit_hipMallocManaged_MultiSize") {
|
||||
// The following test case tests the behavior of kernel with a HMM memory and
|
||||
// hipMalloc memory
|
||||
|
||||
TEST_CASE("Unit_hipMallocManaged_KrnlWth2MemTypes") {
|
||||
TEST_CASE("Stress_hipMallocManaged_KrnlWth2MemTypes") {
|
||||
IfTestPassed = true;
|
||||
int *Hmm = NULL, *Dptr = NULL, InitVal = 123;
|
||||
size_t NumElms = (1024 * 1024);
|
||||
@@ -241,7 +241,7 @@ TEST_CASE("Unit_hipMallocManaged_KrnlWth2MemTypes") {
|
||||
|
||||
// The following test case tests when the same Hmm memory is used for
|
||||
// launching multiple different kernels will results in any issue
|
||||
TEST_CASE("Unit_hipMallocManaged_MultiKrnlHmmAccess") {
|
||||
TEST_CASE("Stress_hipMallocManaged_MultiKrnlHmmAccess") {
|
||||
int managed = HmmAttrPrint();
|
||||
if (managed) {
|
||||
int InitVal = 123, NumElms = (1024 * 1024);
|
||||
@@ -253,7 +253,7 @@ TEST_CASE("Unit_hipMallocManaged_MultiKrnlHmmAccess") {
|
||||
}
|
||||
|
||||
// Testing the allocation of/scenarios around max possible memory
|
||||
TEST_CASE("Unit_hipMallocManaged_ExtremeSizes") {
|
||||
TEST_CASE("Stress_hipMallocManaged_ExtremeSizes") {
|
||||
int managed = HmmAttrPrint();
|
||||
if (managed == 1) {
|
||||
bool IfTestPassed = true;
|
||||
|
||||
Ссылка в новой задаче
Block a user