Add and restructure tests for hipStreamCreate (#2560)

* Add and restructure tests for hipStreamCreate
* Add streamCreate to CMakeLists file

[ROCm/hip commit: f81d477ee7]
This commit is contained in:
Jatin Chaudhary
2022-04-01 04:32:45 +01:00
committed by GitHub
parent e06d8f5681
commit 09d43a6ba4
6 changed files with 268 additions and 106 deletions
@@ -16,36 +16,20 @@ 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.
*/
#include <hip_test_common.hh>
TEST_CASE("Unit_hipStreamCreate_default") {
hipStream_t stream;
HIP_CHECK(hipStreamCreate(&stream));
}
TEST_CASE("Unit_hipStreamCreateWithFlags_Negative") {
hipStream_t stream;
auto status = hipStreamCreateWithFlags(&stream, 0xFF);
REQUIRE(status == hipErrorInvalidValue);
status = hipStreamCreateWithFlags(nullptr, hipStreamDefault);
REQUIRE(status == hipErrorInvalidValue);
}
TEST_CASE("Unit_hipStreamCreateWithFlags") {
hipStream_t stream;
HIP_CHECK(hipStreamCreateWithFlags(&stream, hipStreamDefault));
HIP_CHECK(hipStreamDestroy(stream));
HIP_CHECK(hipStreamCreateWithFlags(&stream, hipStreamNonBlocking));
HIP_CHECK(hipStreamDestroy(stream));
}
TEST_CASE("Unit_hipStreamCreateWithPriority") {
int priority_low = 0;
int priority_high = 0;
HIP_CHECK(hipDeviceGetStreamPriorityRange(&priority_low, &priority_high));
hipStream_t stream;
SECTION("Setting high prirority") {
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamDefault, priority_high));
}
SECTION("Setting low priority") {
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamDefault, priority_low));
}
#include "streamCommon.hh"
TEST_CASE("Unit_hipStreamCreate_default") {
int id = GENERATE(range(0, HipTest::getDeviceCount()));
HIP_CHECK(hipSetDevice(id));
hipStream_t stream{nullptr};
HIP_CHECK(hipStreamCreate(&stream));
REQUIRE(stream != nullptr); // Check if stream has a valid ptr
REQUIRE(hip::checkStream(stream)); // check its flags and priority
HIP_CHECK(hipStreamDestroy(stream));
}
TEST_CASE("Unit_hipStreamCreate_Negative") {
REQUIRE(hipErrorInvalidValue == hipStreamCreate(nullptr));
}