CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
171 lines
5.4 KiB
C++
171 lines
5.4 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <hip_test_common.hh>
|
|
|
|
/**
|
|
* Kernel to double each element in the given array
|
|
*/
|
|
static __global__ void doubleKernel(int *arr) {
|
|
size_t i = threadIdx.x;
|
|
arr[i] += arr[i];
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - This test case checks the following scenario,
|
|
* - 1) Using hipStreamGetAttribute, get the default value of attribute
|
|
* - hipStreamAttributeSynchronizationPolicy
|
|
* - 2) Using hipStreamSetAttribute, set the possible values of
|
|
hipStreamAttributeSynchronizationPolicy attribute
|
|
* - 3) And validate it by getting value using hipStreamGetAttribute
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/stream/hipStreamSetGetAttributes.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 7.1
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipStreamSetAttribute_hipStreamGetAttribute_Basic) {
|
|
constexpr int N = 1024;
|
|
int hostMem[N];
|
|
for (int i = 0; i < N; i++) {
|
|
hostMem[i] = 5;
|
|
}
|
|
|
|
int *devMem = nullptr;
|
|
HIP_CHECK(hipMalloc(&devMem, N * sizeof(int)));
|
|
REQUIRE(devMem != nullptr);
|
|
|
|
hipStream_t stream = nullptr;
|
|
HIP_CHECK(hipStreamCreate(&stream));
|
|
|
|
hipStreamAttrID attr = hipStreamAttributeSynchronizationPolicy;
|
|
hipStreamAttrValue valueToSet;
|
|
hipSynchronizationPolicy syncPolicy =
|
|
GENERATE(hipSynchronizationPolicy::hipSyncPolicyAuto,
|
|
hipSynchronizationPolicy::hipSyncPolicySpin,
|
|
hipSynchronizationPolicy::hipSyncPolicyYield,
|
|
hipSynchronizationPolicy::hipSyncPolicyBlockingSync);
|
|
valueToSet.syncPolicy = syncPolicy;
|
|
HIP_CHECK(hipStreamSetAttribute(stream, attr, &valueToSet));
|
|
|
|
hipStreamAttrValue valueOut;
|
|
HIP_CHECK(hipStreamGetAttribute(stream, attr, &valueOut));
|
|
REQUIRE(valueOut.syncPolicy == syncPolicy);
|
|
|
|
HIP_CHECK(hipMemcpyAsync(devMem, hostMem, N * sizeof(int),
|
|
hipMemcpyHostToDevice, stream));
|
|
doubleKernel<<<1, N, 0, stream>>>(devMem);
|
|
HIP_CHECK(hipMemcpyAsync(hostMem, devMem, N * sizeof(int),
|
|
hipMemcpyDeviceToHost, stream));
|
|
HIP_CHECK(hipStreamSynchronize(stream));
|
|
|
|
for (int i = 0; i < N; i++) {
|
|
INFO("At index " << i << " Expected value = 10 "
|
|
<< " Got value = " << hostMem[i]);
|
|
REQUIRE(hostMem[i] == 10);
|
|
}
|
|
|
|
HIP_CHECK(hipStreamDestroy(stream));
|
|
HIP_CHECK(hipFree(devMem));
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - This test case checks the following Negative scenarios
|
|
* - for the hipStreamGetAttribute,
|
|
* - 1) With Invalid stream
|
|
* - 2) With Invalid attribute
|
|
* - 3) With Invalid Attribute value
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/stream/hipStreamSetGetAttributes.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 7.1
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipStreamGetAttribute_Negative) {
|
|
hipStream_t stream = nullptr;
|
|
HIP_CHECK(hipStreamCreate(&stream));
|
|
|
|
hipStreamAttrID attr = hipStreamAttributeSynchronizationPolicy;
|
|
hipStreamAttrValue valueOut;
|
|
|
|
SECTION("With Invalid stream") {
|
|
hipStream_t invalidStream = reinterpret_cast<hipStream_t>(-1);
|
|
HIP_CHECK_ERROR(hipStreamGetAttribute(invalidStream, attr, &valueOut),
|
|
hipErrorInvalidResourceHandle);
|
|
}
|
|
|
|
SECTION("With invalid attribute") {
|
|
attr = static_cast<hipStreamAttrID>(-1);
|
|
HIP_CHECK_ERROR(hipStreamGetAttribute(stream, attr, &valueOut),
|
|
hipErrorInvalidValue);
|
|
}
|
|
#if HT_AMD
|
|
// Facing segmentation fault issue in CUDA
|
|
SECTION("With invalid attribute value") {
|
|
HIP_CHECK_ERROR(hipStreamGetAttribute(stream, attr, nullptr),
|
|
hipErrorInvalidValue);
|
|
}
|
|
#endif
|
|
HIP_CHECK(hipStreamDestroy(stream));
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - This test case checks the following Negative scenarios
|
|
* - for the hipStreamSetAttribute,
|
|
* - 1) With Invalid stream
|
|
* - 2) With Invalid attribute
|
|
* - 3) With Invalid Attribute value
|
|
* - 4) With Invalid hipSynchronizationPolicy
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/stream/hipStreamSetGetAttributes.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 7.1
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipStreamSetAttribute_Negative) {
|
|
hipStream_t stream = nullptr;
|
|
HIP_CHECK(hipStreamCreate(&stream));
|
|
|
|
hipStreamAttrID attr = hipStreamAttributeSynchronizationPolicy;
|
|
hipStreamAttrValue valueToSet;
|
|
|
|
SECTION("With Invalid stream") {
|
|
hipStream_t invalidStream = reinterpret_cast<hipStream_t>(-1);
|
|
valueToSet.syncPolicy = hipSynchronizationPolicy::hipSyncPolicyAuto;
|
|
HIP_CHECK_ERROR(hipStreamSetAttribute(invalidStream, attr, &valueToSet),
|
|
hipErrorInvalidResourceHandle);
|
|
}
|
|
|
|
SECTION("With invalid attribute") {
|
|
attr = static_cast<hipStreamAttrID>(-1);
|
|
HIP_CHECK_ERROR(hipStreamSetAttribute(stream, attr, &valueToSet),
|
|
hipErrorInvalidValue);
|
|
}
|
|
#if HT_AMD
|
|
// Facing segmentation fault issue in CUDA
|
|
SECTION("With invalid attribute value") {
|
|
HIP_CHECK_ERROR(hipStreamSetAttribute(stream, attr, nullptr),
|
|
hipErrorInvalidValue);
|
|
}
|
|
#endif
|
|
SECTION("With Invalid hipSynchronizationPolicy") {
|
|
valueToSet.syncPolicy = static_cast<hipSynchronizationPolicy>(-1);
|
|
HIP_CHECK_ERROR(hipStreamSetAttribute(stream, attr, &valueToSet),
|
|
hipErrorInvalidValue);
|
|
}
|
|
|
|
HIP_CHECK(hipStreamDestroy(stream));
|
|
}
|