Updated negative tests for hipStreamGetPriority (#2517)
Este commit está contenido en:
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"DisabledTests":
|
||||
[
|
||||
"# Following test is related to ticket EXSWCPHIPT-41",
|
||||
"Unit_hipStreamGetPriority_happy",
|
||||
"Unit_hipStreamPerThread_DeviceReset_1"
|
||||
]
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@
|
||||
"Unit_hipGraphAddEventRecordNode_Functional_WithFlags",
|
||||
"Unit_hipGraphAddEventRecordNode_MultipleRun",
|
||||
"Unit_hipMalloc3D_Negative",
|
||||
"Unit_hipPointerGetAttribute_MappedMem"
|
||||
"Unit_hipPointerGetAttribute_MappedMem",
|
||||
"# Following test is related to ticket EXSWCPHIPT-41",
|
||||
"Unit_hipStreamGetPriority_happy"
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ THE SOFTWARE.
|
||||
|
||||
#define HIP_PRINT_STATUS(status) INFO(hipGetErrorName(status) << " at line: " << __LINE__);
|
||||
|
||||
// Not thread-safe
|
||||
#define HIP_CHECK(error) \
|
||||
{ \
|
||||
hipError_t localError = error; \
|
||||
@@ -37,6 +38,20 @@ THE SOFTWARE.
|
||||
} \
|
||||
}
|
||||
|
||||
// Check that an expression, errorExpr, evaluates to the expected error_t, expectedError.
|
||||
#define HIP_CHECK_ERROR(errorExpr, expectedError) \
|
||||
{ \
|
||||
hipError_t localError = errorExpr; \
|
||||
INFO("Matching Errors: " \
|
||||
<< " Expected Error: " << hipGetErrorString(expectedError) \
|
||||
<< " Expected Code: " << expectedError << '\n' \
|
||||
<< " Actual Error: " << hipGetErrorString(localError) \
|
||||
<< " Actual Code: " << localError << "\nStr: " << #errorExpr \
|
||||
<< "\nIn File: " << __FILE__ << " At line: " << __LINE__); \
|
||||
REQUIRE(localError == expectedError); \
|
||||
}
|
||||
|
||||
// Not thread-safe
|
||||
#define HIPRTC_CHECK(error) \
|
||||
{ \
|
||||
auto localError = error; \
|
||||
@@ -46,25 +61,26 @@ THE SOFTWARE.
|
||||
REQUIRE(false); \
|
||||
} \
|
||||
}
|
||||
|
||||
// Although its assert, it will be evaluated at runtime
|
||||
#define HIP_ASSERT(x) \
|
||||
{ REQUIRE((x)); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
#endif
|
||||
|
||||
#define HIPCHECK(error) \
|
||||
{ \
|
||||
hipError_t localError = error; \
|
||||
if ((localError != hipSuccess) && (localError != hipErrorPeerAccessAlreadyEnabled)) { \
|
||||
printf("error: '%s'(%d) from %s at %s:%d\n", hipGetErrorString(localError), \
|
||||
localError, #error, __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
{ \
|
||||
hipError_t localError = error; \
|
||||
if ((localError != hipSuccess) && (localError != hipErrorPeerAccessAlreadyEnabled)) { \
|
||||
printf("error: '%s'(%d) from %s at %s:%d\n", hipGetErrorString(localError), localError, \
|
||||
#error, __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define HIPASSERT(condition) \
|
||||
if (!(condition)) { \
|
||||
@@ -104,8 +120,8 @@ static inline int getDeviceCount() {
|
||||
|
||||
// Returns the current system time in microseconds
|
||||
static inline long long get_time() {
|
||||
return std::chrono::high_resolution_clock::now().time_since_epoch()
|
||||
/std::chrono::microseconds(1);
|
||||
return std::chrono::high_resolution_clock::now().time_since_epoch() /
|
||||
std::chrono::microseconds(1);
|
||||
}
|
||||
|
||||
static inline double elapsed_time(long long startTimeUs, long long stopTimeUs) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved.
|
||||
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
|
||||
@@ -16,59 +16,77 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
/**
|
||||
|
||||
/*
|
||||
Testcase Scenarios :
|
||||
1) Negative tests for hipStreamGetPriority api.
|
||||
2) Create stream and check default priority of stream is within range.
|
||||
3) Create stream with high or low priority and check priority is set as expected.
|
||||
4) Create stream with higher priority or lower priority for the priority range returned.
|
||||
4) Create stream with higher priority or lower priority for the priority range returned, the stream
|
||||
priority should be clamped to the priority range.
|
||||
5) Create stream with CUMask and check priority is returned as expected.
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
/**
|
||||
* Negative tests for hipStreamGetPriority api.
|
||||
* Check the error returned when an invalid pointer to a priority is used.
|
||||
*/
|
||||
TEST_CASE("Unit_hipStreamGetPriority_Negative") {
|
||||
hipStream_t stream = 0;
|
||||
REQUIRE(hipStreamGetPriority(stream, nullptr) == hipErrorInvalidValue);
|
||||
TEST_CASE("Unit_hipStreamGetPriority_InvalidPriorityPointer") {
|
||||
hipStream_t stream{};
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
HIP_CHECK_ERROR(hipStreamGetPriority(stream, nullptr), hipErrorInvalidValue);
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stream with higher priority for the priority range returned.
|
||||
* Create stream and check priority.
|
||||
*/
|
||||
TEST_CASE("Unit_hipStreamGetPriority_higher") {
|
||||
TEST_CASE("Unit_hipStreamGetPriority_happy") {
|
||||
int priority_low = 0;
|
||||
int priority_high = 0;
|
||||
int devID = GENERATE(range(0, HipTest::getDeviceCount()));
|
||||
HIP_CHECK(hipSetDevice(devID));
|
||||
HIP_CHECK(hipDeviceGetStreamPriorityRange(&priority_low, &priority_high));
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamNonBlocking,
|
||||
priority_high-1));
|
||||
hipStream_t stream{};
|
||||
int priority = 0;
|
||||
HIP_CHECK(hipStreamGetPriority(stream, &priority));
|
||||
REQUIRE(priority == priority_high);
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stream with lower priority for the priority range returned.
|
||||
*/
|
||||
TEST_CASE("Unit_hipStreamGetPriority_lower") {
|
||||
int priority_low = 0;
|
||||
int priority_high = 0;
|
||||
int devID = GENERATE(range(0, HipTest::getDeviceCount()));
|
||||
HIP_CHECK(hipSetDevice(devID));
|
||||
HIP_CHECK(hipDeviceGetStreamPriorityRange(&priority_low, &priority_high));
|
||||
hipStream_t stream;
|
||||
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamNonBlocking,
|
||||
priority_low+1));
|
||||
int priority = 0;
|
||||
HIP_CHECK(hipStreamGetPriority(stream, &priority));
|
||||
REQUIRE(priority_low == priority);
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
SECTION("Null Stream") {
|
||||
HIP_CHECK(hipStreamGetPriority(nullptr, &priority));
|
||||
// valid priority
|
||||
REQUIRE(priority_low >= priority);
|
||||
REQUIRE(priority >= priority_high);
|
||||
}
|
||||
SECTION("Created Stream") {
|
||||
SECTION("Default Priority") {
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
HIP_CHECK(hipStreamGetPriority(stream, &priority));
|
||||
// valid priority
|
||||
// Lower the value higher the priority, higher the value lower the priority
|
||||
REQUIRE(priority_low >= priority);
|
||||
REQUIRE(priority >= priority_high);
|
||||
}
|
||||
SECTION("High Priority") {
|
||||
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamDefault, priority_high));
|
||||
HIP_CHECK(hipStreamGetPriority(stream, &priority));
|
||||
REQUIRE(priority == priority_high);
|
||||
}
|
||||
SECTION("Higher Priority") {
|
||||
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamNonBlocking, priority_high - 1));
|
||||
HIP_CHECK(hipStreamGetPriority(stream, &priority));
|
||||
REQUIRE(priority == priority_high);
|
||||
}
|
||||
SECTION("Low Priority") {
|
||||
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamDefault, priority_low));
|
||||
HIP_CHECK(hipStreamGetPriority(stream, &priority));
|
||||
REQUIRE(priority_low == priority);
|
||||
}
|
||||
SECTION("Lower Priority") {
|
||||
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamNonBlocking, priority_low + 1));
|
||||
HIP_CHECK(hipStreamGetPriority(stream, &priority));
|
||||
REQUIRE(priority_low == priority);
|
||||
}
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
}
|
||||
|
||||
#if HT_AMD
|
||||
@@ -76,7 +94,7 @@ TEST_CASE("Unit_hipStreamGetPriority_lower") {
|
||||
* Create stream with CUMask and check priority is returned as expected.
|
||||
*/
|
||||
TEST_CASE("Unit_hipStreamGetPriority_StreamsWithCUMask") {
|
||||
hipStream_t stream;
|
||||
hipStream_t stream{};
|
||||
int priority = 0;
|
||||
int priority_normal = 0;
|
||||
int priority_low = 0;
|
||||
|
||||
Referencia en una nueva incidencia
Block a user