Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cea96af
SWDEV-355313 - Move catch tests and samples
gargrahul Oct 26, 2022
909e7e4
SWDEV-355313 - Add README
gargrahul Nov 7, 2022
094b9af
SWDEV-355313 - Update amd-staging branch
gargrahul Nov 28, 2022
070bb7c
EXSWHTEC-174 - Add Doxygen configuration and common header with group…
milos-mozetic Dec 1, 2022
2a205ed
EXSWHTEC-200 - Add support for TEMPLATE_TEST_CASE preprocessing
milos-mozetic Dec 5, 2022
25fa1f4
EXSWHTEC-20 - hipFreeAsync negative tests
marko-veniger Dec 8, 2022
bb6c9f7
EXSWHTEC-19 - hipMallocAsync negative tests
marko-veniger Dec 8, 2022
dc2e3a1
EXSWHTEC-35 - Implement negative tests for hipMallocFromPoolAsync
marko-veniger Dec 8, 2022
7e955da
EXSWHTEC-36 - Basic hip mem pool negative tests
marko-veniger Dec 8, 2022
7ef4d27
EXSWHTEC-57 - Hip mem pool import export tests
marko-veniger Dec 8, 2022
2db594f
Merge branch 'develop' of github.com:mirza-halilcevic/hip-tests into …
milos-mozetic Dec 13, 2022
1977515
EXSWHTEC-200 - Resolve conflicts in missed conflicted files
milos-mozetic Dec 13, 2022
259be27
EXSWHTEC-200 - Add newline at the end of the file
milos-mozetic Dec 14, 2022
e0daf30
EXSWHTEC-200 - Extend the PREDEFINED list to define all macro names t…
milos-mozetic Dec 14, 2022
2ac6a64
EXSWHTEC-224 - Test cases ID clean up and documentation for Stream Ma…
milos-mozetic Dec 15, 2022
057b8af
Merge branch 'develop' of github.com:mirza-halilcevic/hip-tests into …
milos-mozetic Dec 19, 2022
dd321b6
EXSWHTEC-224 - Resolve unresolved merge conflicts
milos-mozetic Dec 19, 2022
773156d
Merge branch 'doxygen_configuration' of github.com:mirza-halilcevic/h…
milos-mozetic Dec 19, 2022
6ea811c
Merge branch 'doxygen_configuration' of github.com:mirza-halilcevic/h…
milos-mozetic Dec 19, 2022
01ce39a
Merge branch 'doxygen_configuration' of github.com:mirza-halilcevic/h…
milos-mozetic Dec 19, 2022
eb551d4
Merge branch 'doxygen_configuration' of github.com:mirza-halilcevic/h…
milos-mozetic Dec 19, 2022
2c58a3d
Merge branch 'doxygen_configuration' of github.com:mirza-halilcevic/h…
milos-mozetic Dec 19, 2022
558bb21
Merge branch 'hipMallocAsync_tests' of github.com:mirza-halilcevic/hi…
milos-mozetic Dec 19, 2022
83ad0a4
Merge branch 'hipFreeAsync_tests' of github.com:mirza-halilcevic/hip-…
milos-mozetic Dec 19, 2022
e682295
Merge branch 'hipMallocFromPoolAsync_tests' of github.com:mirza-halil…
milos-mozetic Dec 19, 2022
6ba8130
Merge branch 'basic_hipMemPool_negative_tests' of github.com:mirza-ha…
milos-mozetic Dec 19, 2022
c5df959
Merge branch 'hipMemPoolImportExport_tests' of github.com:mirza-halil…
milos-mozetic Dec 19, 2022
943278f
EXSWHTEC-224 - Test cases ID clean up and documentation for Stream Or…
milos-mozetic Dec 19, 2022
53b356b
EXSWHTEC-224 - Fix faulty resolved merge conflict
milos-mozetic Dec 28, 2022
82a1cc5
EXSWHTEC-224 - Fix an error in hipMemPoolImportExport doxygen comment
milos-mozetic Jan 24, 2023
f8f988d
Merge branch 'develop' into doxygen_stream_management_documentation
milos-mozetic Jun 22, 2023
f980098
Merge branch 'develop' of github.com:mirza-halilcevic/hip-tests into …
milos-mozetic Jul 10, 2023
64bcc45
Merge remote-tracking branch 'origin/develop' into doxygen_stream_man…
nives-vukovic Feb 8, 2024
d4ee954
EXSWHTEC-224 - Fix merging issues
nives-vukovic Feb 8, 2024
83a305a
EXSWHTEC-224 - Modify doxygen comments
nives-vukovic Feb 8, 2024
e5ca6ce
Merge branch 'develop' into doxygen_stream_management_documentation
mirza-halilcevic Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions catch/include/hip_test_defgroups.hh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ THE SOFTWARE.
* @}
*/

/**
* @defgroup StreamOTest Ordered Memory Allocator
* @{
* This section describes the tests for Stream Ordered Memory Allocator functions of HIP runtime
* API.
*/

/**
* @defgroup StreamTest Stream Management
* @{
* This section describes tests for the stream management functions of HIP runtime API.
* @}
*/

/**
* @defgroup StreamMTest Stream Memory Operations
* @{
* This section describes tests for the Stream Memory Wait and Write functions of HIP runtime API.
*/

/**
* @defgroup ShflTest warp shuffle function Management
* @{
Expand Down
286 changes: 204 additions & 82 deletions catch/unit/memory/hipMemPoolApi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
THE SOFTWARE.
*/

/* Test Case Description:
1) This testcase verifies the basic scenario - supported on
all devices
*/

#include <hip_test_common.hh>
#include <hip_test_kernels.hh>
#include <hip_test_checkers.hh>
Expand All @@ -31,6 +26,12 @@
#include <thread>
#include <chrono>

/**
* @addtogroup hipMallocAsync hipMallocAsync
* @{
* @ingroup StreamOTest
*/

constexpr hipMemPoolProps kPoolProps = {
hipMemAllocationTypePinned,
hipMemHandleTypeNone,
Expand All @@ -42,10 +43,25 @@ constexpr hipMemPoolProps kPoolProps = {
{0}
};

/*
This testcase verifies HIP Mem Pool API basic scenario - supported on all devices
/**
* @addtogroup hipMallocAsync hipMallocAsync
* @{
* @ingroup StreamOTest
*/

/**
* Test Description
* ------------------------
* - Allocates memory for the array.
* - Checks basic functionalities.
* Test source
* ------------------------
* - unit/memory/hipMemPoolApi.cc
* Test requirements
* ------------------------
* - Runtime supports Memory Pools
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipMemPoolApi_Basic") {
int mem_pool_support = 0;
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
Expand Down Expand Up @@ -108,6 +124,100 @@ TEST_CASE("Unit_hipMemPoolApi_Basic") {
HIP_CHECK(hipStreamDestroy(stream));
}

/**
* Test Description
* ------------------------
* - Checks that the freed memory is used for allocation again.
* - Launches kernel to create a realistic test case.
* Test source
* ------------------------
* - unit/memory/hipMemPoolApi.cc
* Test requirements
* ------------------------
* - Runtime supports Memory Pools
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipMemPoolApi_Default") {
int mem_pool_support = 0;
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
if (!mem_pool_support) {
SUCCEED("Runtime doesn't support Memory Pool. Skip the test case.");
return;
}

hipMemPool_t mem_pool;
HIP_CHECK(hipDeviceGetDefaultMemPool(&mem_pool, 0));

float *A, *B, *C;
hipStream_t stream;
HIP_CHECK(hipStreamCreate(&stream));

size_t numElements = 8 * 1024 * 1024;
HIP_CHECK(hipMallocAsync(reinterpret_cast<void**>(&A), numElements * sizeof(float), stream));

numElements = 1024;
HIP_CHECK(hipMallocAsync(reinterpret_cast<void**>(&C), numElements * sizeof(float), stream));

int blocks = 2;
int clkRate;

if (IsGfx11()) {
HIP_CHECK(hipDeviceGetAttribute(&clkRate, hipDeviceAttributeWallClockRate, 0));
kernel500ms_gfx11<<<32, blocks, 0, stream>>>(A, clkRate);
} else {
HIP_CHECK(hipDeviceGetAttribute(&clkRate, hipDeviceAttributeClockRate, 0));

kernel500ms<<<32, blocks, 0, stream>>>(A, clkRate);
}

hipMemPoolAttr attr;
// Not a real free, since kernel isn't done
HIP_CHECK(hipFreeAsync(reinterpret_cast<void*>(A), stream));

numElements = 8 * 1024 * 1024;
HIP_CHECK(hipMallocAsync(reinterpret_cast<void**>(&B), numElements * sizeof(float), stream));
// Runtime must reuse the pointer
REQUIRE(A == B);

// Make a sync before the second kernel launch to make sure memory B isn't gone
HIP_CHECK(hipStreamSynchronize(stream));

// Second kernel launch with new memory
if (IsGfx11()) {
kernel500ms_gfx11<<<32, blocks, 0, stream>>>(B, clkRate);
} else {
kernel500ms<<<32, blocks, 0, stream>>>(B, clkRate);
}

HIP_CHECK(hipFreeAsync(reinterpret_cast<void*>(B), stream));

HIP_CHECK(hipStreamSynchronize(stream));

std::uint64_t value64 = 0;
attr = hipMemPoolAttrReservedMemCurrent;
HIP_CHECK(hipMemPoolGetAttribute(mem_pool, attr, &value64));
// Make sure the current reserved is at least allocation size of buffer C (4KB)
REQUIRE(sizeof(float) * 1024 <= value64);

attr = hipMemPoolAttrUsedMemHigh;
HIP_CHECK(hipMemPoolGetAttribute(mem_pool, attr, &value64));
// Make sure the high watermark usage works - the both buffers must be reported
REQUIRE(sizeof(float) * (8 * 1024 * 1024 + 1024) == value64);

attr = hipMemPoolAttrUsedMemCurrent;
HIP_CHECK(hipMemPoolGetAttribute(mem_pool, attr, &value64));
// Make sure the current usage reports just one buffer, because the above free doesn't hold memory
REQUIRE(sizeof(float) * 1024 == value64);

HIP_CHECK(hipFreeAsync(reinterpret_cast<void*>(C), stream));
HIP_CHECK(hipStreamDestroy(stream));
}

/**
* End doxygen group hipMallocAsync.
* @}
*/

constexpr auto wait_ms = 500;

__global__ void kernel500ms(float* hostRes, int clkRate) {
Expand Down Expand Up @@ -138,6 +248,25 @@ __global__ void kernel500ms_gfx11(float* hostRes, int clkRate) {
#endif
}

/**
* @addtogroup hipFreeAsync hipFreeAsync
* @{
* @ingroup StreamOTest
*/

/**
* Test Description
* ------------------------
* - Checks if memory usage is different before and after synchronization.
* - Synchronization will force free to execute.
* Test source
* ------------------------
* - unit/memory/hipMemPoolApi.cc
* Test requirements
* ------------------------
* - Runtime supports Memory Pools
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipMemPoolApi_BasicAlloc") {
int mem_pool_support = 0;
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
Expand Down Expand Up @@ -226,6 +355,30 @@ TEST_CASE("Unit_hipMemPoolApi_BasicAlloc") {
HIP_CHECK(hipStreamDestroy(stream));
}

/**
* End doxygen group hipFreeAsync.
* @}
*/

/**
* @addtogroup hipMemPoolTrimTo hipMemPoolTrimTo
* @{
* @ingroup StreamOTest
*/

/**
* Test Description
* ------------------------
* - Check if a trim operation is no-op when memory is still in use.
* - Check that trim works correctly once the memory is not in use.
* Test source
* ------------------------
* - unit/memory/hipMemPoolApi.cc
* Test requirements
* ------------------------
* - Runtime supports Memory Pools
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipMemPoolApi_BasicTrim") {
int mem_pool_support = 0;
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
Expand Down Expand Up @@ -314,6 +467,31 @@ TEST_CASE("Unit_hipMemPoolApi_BasicTrim") {
HIP_CHECK(hipStreamDestroy(stream));
}

/**
* End doxygen group hipMemPoolTrimTo.
* @}
*/

/**
* @addtogroup hipMallocFromPoolAsync hipMallocFromPoolAsync
* @{
* @ingroup StreamOTest
*/

/**
* Test Description
* ------------------------
* - Checks that memory from pool is reused when freed.
* - Allocate the same array after the memory is freed.
* - Verify that the old and new pointers are the same.
* Test source
* ------------------------
* - unit/memory/hipMemPoolApi.cc
* Test requirements
* ------------------------
* - Runtime supports Memory Pools
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipMemPoolApi_BasicReuse") {
int mem_pool_support = 0;
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
Expand Down Expand Up @@ -390,6 +568,21 @@ TEST_CASE("Unit_hipMemPoolApi_BasicReuse") {
HIP_CHECK(hipStreamDestroy(stream));
}

/**
* Test Description
* ------------------------
* - Verifies that an oportunistic flag behaves correctly with allocations.
* -# When oportunistic is disallowed and no reuse
* -# When oportunistic is allowed and reuse
* -# When oportunistic is allowed and no reuse
* Test source
* ------------------------
* - unit/memory/hipMemPoolApi.cc
* Test requirements
* ------------------------
* - Runtime supports Memory Pools
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipMemPoolApi_Opportunistic") {
int mem_pool_support = 0;
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
Expand Down Expand Up @@ -553,78 +746,7 @@ TEST_CASE("Unit_hipMemPoolApi_Opportunistic") {
HIP_CHECK(hipStreamDestroy(stream2));
}

TEST_CASE("Unit_hipMemPoolApi_Default") {
int mem_pool_support = 0;
HIP_CHECK(hipDeviceGetAttribute(&mem_pool_support, hipDeviceAttributeMemoryPoolsSupported, 0));
if (!mem_pool_support) {
SUCCEED("Runtime doesn't support Memory Pool. Skip the test case.");
return;
}

hipMemPool_t mem_pool;
HIP_CHECK(hipDeviceGetDefaultMemPool(&mem_pool, 0));

float *A, *B, *C;
hipStream_t stream;
HIP_CHECK(hipStreamCreate(&stream));

size_t numElements = 8 * 1024 * 1024;
HIP_CHECK(hipMallocAsync(reinterpret_cast<void**>(&A), numElements * sizeof(float), stream));

numElements = 1024;
HIP_CHECK(hipMallocAsync(reinterpret_cast<void**>(&C), numElements * sizeof(float), stream));

int blocks = 2;
int clkRate;

if (IsGfx11()) {
HIP_CHECK(hipDeviceGetAttribute(&clkRate, hipDeviceAttributeWallClockRate, 0));
kernel500ms_gfx11<<<32, blocks, 0, stream>>>(A, clkRate);
} else {
HIP_CHECK(hipDeviceGetAttribute(&clkRate, hipDeviceAttributeClockRate, 0));

kernel500ms<<<32, blocks, 0, stream>>>(A, clkRate);
}

hipMemPoolAttr attr;
// Not a real free, since kernel isn't done
HIP_CHECK(hipFreeAsync(reinterpret_cast<void*>(A), stream));

numElements = 8 * 1024 * 1024;
HIP_CHECK(hipMallocAsync(reinterpret_cast<void**>(&B), numElements * sizeof(float), stream));
// Runtime must reuse the pointer
REQUIRE(A == B);

// Make a sync before the second kernel launch to make sure memory B isn't gone
HIP_CHECK(hipStreamSynchronize(stream));

// Second kernel launch with new memory
if (IsGfx11()) {
kernel500ms_gfx11<<<32, blocks, 0, stream>>>(B, clkRate);
} else {
kernel500ms<<<32, blocks, 0, stream>>>(B, clkRate);
}

HIP_CHECK(hipFreeAsync(reinterpret_cast<void*>(B), stream));

HIP_CHECK(hipStreamSynchronize(stream));

std::uint64_t value64 = 0;
attr = hipMemPoolAttrReservedMemCurrent;
HIP_CHECK(hipMemPoolGetAttribute(mem_pool, attr, &value64));
// Make sure the current reserved is at least allocation size of buffer C (4KB)
REQUIRE(sizeof(float) * 1024 <= value64);

attr = hipMemPoolAttrUsedMemHigh;
HIP_CHECK(hipMemPoolGetAttribute(mem_pool, attr, &value64));
// Make sure the high watermark usage works - the both buffers must be reported
REQUIRE(sizeof(float) * (8 * 1024 * 1024 + 1024) == value64);

attr = hipMemPoolAttrUsedMemCurrent;
HIP_CHECK(hipMemPoolGetAttribute(mem_pool, attr, &value64));
// Make sure the current usage reports just one buffer, because the above free doesn't hold memory
REQUIRE(sizeof(float) * 1024 == value64);

HIP_CHECK(hipFreeAsync(reinterpret_cast<void*>(C), stream));
HIP_CHECK(hipStreamDestroy(stream));
}
/**
* End doxygen group hipMallocFromPoolAsync.
* @}
*/
Loading