SWDEV-561337 Additional Tests for hipStreamCopyAttributes API (#1607)
* SWDEV-548797 Additional Tests for hipStreamCopyAttributes API * SWDEV-548797 : Added sanity check section for negative test case
Cette révision appartient à :
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
* @{
|
||||
* @ingroup StreamTest
|
||||
* `hipStreamCopyAttributes (hipStream_t dst, hipStream_t src)` -
|
||||
* copies attributes from one stream to other
|
||||
* copies attributes from one stream to other
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
@@ -43,18 +43,20 @@ TEST_CASE("Unit_hipStreamCopyAttributes_Basic") {
|
||||
hipStreamAttrValue val1, val2;
|
||||
HIP_CHECK(hipStreamCreate(&stream1));
|
||||
HIP_CHECK(hipStreamCreate(&stream2));
|
||||
|
||||
|
||||
SECTION("Two Non Default Streams") {
|
||||
val1.syncPolicy = hipSyncPolicySpin;
|
||||
|
||||
// Set the sync policy attribute of stream1 to hipSyncPolicySpin
|
||||
HIP_CHECK(hipStreamSetAttribute(stream1, hipStreamAttributeSynchronizationPolicy, &val1));
|
||||
HIP_CHECK(hipStreamSetAttribute(
|
||||
stream1, hipStreamAttributeSynchronizationPolicy, &val1));
|
||||
|
||||
// Copy attributes from stream1 to stream2
|
||||
HIP_CHECK(hipStreamCopyAttributes(stream2, stream1));
|
||||
|
||||
// Query stream2 to verify the copied sync policy
|
||||
HIP_CHECK(hipStreamGetAttribute(stream2, hipStreamAttributeSynchronizationPolicy, &val2));
|
||||
HIP_CHECK(hipStreamGetAttribute(
|
||||
stream2, hipStreamAttributeSynchronizationPolicy, &val2));
|
||||
|
||||
REQUIRE(val2.syncPolicy == hipSyncPolicySpin);
|
||||
}
|
||||
@@ -65,13 +67,15 @@ TEST_CASE("Unit_hipStreamCopyAttributes_Basic") {
|
||||
val1.syncPolicy = hipSyncPolicyYield;
|
||||
|
||||
// Set the sync policy attribute of stream1 to hipSyncPolicySpin
|
||||
HIP_CHECK(hipStreamSetAttribute(stream3, hipStreamAttributeSynchronizationPolicy, &val1));
|
||||
HIP_CHECK(hipStreamSetAttribute(
|
||||
stream3, hipStreamAttributeSynchronizationPolicy, &val1));
|
||||
|
||||
// Copy attributes from null stream to legacy stream
|
||||
HIP_CHECK(hipStreamCopyAttributes(stream4, stream3));
|
||||
|
||||
// Query stream2 to verify the copied sync policy
|
||||
HIP_CHECK(hipStreamGetAttribute(stream4, hipStreamAttributeSynchronizationPolicy, &val2));
|
||||
HIP_CHECK(hipStreamGetAttribute(
|
||||
stream4, hipStreamAttributeSynchronizationPolicy, &val2));
|
||||
|
||||
REQUIRE(val2.syncPolicy == hipSyncPolicyYield);
|
||||
}
|
||||
@@ -81,17 +85,106 @@ TEST_CASE("Unit_hipStreamCopyAttributes_Basic") {
|
||||
val1.syncPolicy = hipSyncPolicyBlockingSync;
|
||||
|
||||
// Set the sync policy attribute of stream1 to hipSyncPolicySpin
|
||||
HIP_CHECK(hipStreamSetAttribute(stream3, hipStreamAttributeSynchronizationPolicy, &val1));
|
||||
HIP_CHECK(hipStreamSetAttribute(
|
||||
stream3, hipStreamAttributeSynchronizationPolicy, &val1));
|
||||
|
||||
// Copy attributes from streamperthread to non default stream
|
||||
HIP_CHECK(hipStreamCopyAttributes(stream2, stream3));
|
||||
|
||||
// Query stream2 to verify the copied sync policy
|
||||
HIP_CHECK(hipStreamGetAttribute(stream2, hipStreamAttributeSynchronizationPolicy, &val2));
|
||||
HIP_CHECK(hipStreamGetAttribute(
|
||||
stream2, hipStreamAttributeSynchronizationPolicy, &val2));
|
||||
|
||||
REQUIRE(val2.syncPolicy == hipSyncPolicyBlockingSync);
|
||||
}
|
||||
|
||||
|
||||
HIP_CHECK(hipStreamDestroy(stream1));
|
||||
HIP_CHECK(hipStreamDestroy(stream2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - This test case checks the following negative scenarios
|
||||
* - 1) With Invalid source Stream
|
||||
* - 2) With Invalid destination Stream
|
||||
* - 3) With Invalid source and destination Streams
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/stream/hipStreamCopyAttributes.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 7.2
|
||||
*/
|
||||
TEST_CASE("Unit_hipStreamCopyAttributes_Negative") {
|
||||
hipStream_t srcStream = nullptr;
|
||||
HIP_CHECK(hipStreamCreate(&srcStream));
|
||||
hipStream_t dstStream = nullptr;
|
||||
HIP_CHECK(hipStreamCreate(&dstStream));
|
||||
|
||||
hipStream_t invalidStream = reinterpret_cast<hipStream_t>(-1);
|
||||
|
||||
SECTION("Sanity - Should pass") {
|
||||
HIP_CHECK(hipStreamCopyAttributes(srcStream, dstStream));
|
||||
}
|
||||
|
||||
SECTION("With Invalid Source Stream") {
|
||||
HIP_CHECK_ERROR(hipStreamCopyAttributes(dstStream, invalidStream),
|
||||
hipErrorInvalidResourceHandle);
|
||||
}
|
||||
|
||||
SECTION("With Invalid Destination Stream") {
|
||||
HIP_CHECK_ERROR(hipStreamCopyAttributes(invalidStream, srcStream),
|
||||
hipErrorInvalidResourceHandle);
|
||||
}
|
||||
|
||||
SECTION("With Invalid Source & Destination Streams") {
|
||||
HIP_CHECK_ERROR(hipStreamCopyAttributes(invalidStream, invalidStream),
|
||||
hipErrorInvalidResourceHandle);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipStreamDestroy(srcStream));
|
||||
HIP_CHECK(hipStreamDestroy(dstStream));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - This test case checks behavior of hipStreamCopyAttributes
|
||||
* - with SynchronizationPolicy attribute and with all possible values
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/stream/hipStreamCopyAttributes.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 7.2
|
||||
*/
|
||||
TEST_CASE("Unit_hipStreamCopyAttributes_WithAllSyncPolicyValues") {
|
||||
hipStream_t srcStream = nullptr;
|
||||
HIP_CHECK(hipStreamCreate(&srcStream));
|
||||
hipStream_t dstStream = nullptr;
|
||||
HIP_CHECK(hipStreamCreate(&dstStream));
|
||||
|
||||
hipStreamAttrID attr = hipStreamAttributeSynchronizationPolicy;
|
||||
hipStreamAttrValue valueToSetForSrc;
|
||||
hipSynchronizationPolicy syncPolicy =
|
||||
GENERATE(hipSynchronizationPolicy::hipSyncPolicyAuto,
|
||||
hipSynchronizationPolicy::hipSyncPolicySpin,
|
||||
hipSynchronizationPolicy::hipSyncPolicyYield,
|
||||
hipSynchronizationPolicy::hipSyncPolicyBlockingSync);
|
||||
valueToSetForSrc.syncPolicy = syncPolicy;
|
||||
HIP_CHECK(hipStreamSetAttribute(srcStream, attr, &valueToSetForSrc));
|
||||
|
||||
hipStreamAttrValue valueToSetForDst;
|
||||
valueToSetForDst.syncPolicy = hipSynchronizationPolicy::hipSyncPolicySpin;
|
||||
HIP_CHECK(hipStreamSetAttribute(dstStream, attr, &valueToSetForDst));
|
||||
|
||||
HIP_CHECK(hipStreamCopyAttributes(dstStream, srcStream));
|
||||
|
||||
hipStreamAttrValue valueOut;
|
||||
HIP_CHECK(hipStreamGetAttribute(dstStream, attr, &valueOut));
|
||||
REQUIRE(valueOut.syncPolicy == syncPolicy);
|
||||
|
||||
HIP_CHECK(hipStreamDestroy(srcStream));
|
||||
HIP_CHECK(hipStreamDestroy(dstStream));
|
||||
}
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur