SWDEV-475382 - Add unit test for hipGetTextureAlignmentOffset
Change-Id: I6ec65522038ffc3761970542df4570cead3026fe
This commit is contained in:
committed by
Rakesh Roy
parent
eb894a8b8d
commit
d9162f9abe
@@ -35,6 +35,7 @@ set(TEST_SRC
|
||||
hipBindTex2DPitch.cc
|
||||
hipTex1DFetchCheckModes.cc
|
||||
hipGetChanDesc.cc
|
||||
hipGetTextureAlignmentOffset.cc
|
||||
hipTexObjPitch.cc
|
||||
hipTexRefSetArray.cc
|
||||
hipTexRefGetArray.cc
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Copyright (c) 2024 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
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
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>
|
||||
|
||||
#if defined(__HIP_PLATFORM_AMD__) || CUDA_VERSION < CUDA_12000
|
||||
|
||||
texture<float, 1, hipReadModeElementType> tex;
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Positive test for hipGetTextureAlignmentOffset
|
||||
* - Offset should always be 0
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/texture/hipGetTextureAlignmentOffset.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
TEST_CASE("Unit_hipGetTextureAlignmentOffset_Positive") {
|
||||
CHECK_IMAGE_SUPPORT
|
||||
|
||||
size_t offset = 0;
|
||||
size_t *tex_buf;
|
||||
hipChannelFormatDesc chanDesc = hipCreateChannelDesc(32, 0, 0, 0, hipChannelFormatKindFloat);
|
||||
|
||||
HIP_CHECK(hipMalloc(&tex_buf, 32));
|
||||
HIP_CHECK(hipBindTexture(&offset, tex, reinterpret_cast<void*>(tex_buf), chanDesc, 32));
|
||||
HIP_CHECK(hipGetTextureAlignmentOffset(&offset, &tex));
|
||||
REQUIRE(offset == 0);
|
||||
|
||||
HIP_CHECK(hipFree(tex_buf));
|
||||
HIP_CHECK(hipUnbindTexture(tex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Negative test for hipGetTextureAlignmentOffset
|
||||
* - Test should give invalid error if one of params is NULL
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/texture/hipGetTextureAlignmentOffset.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.7
|
||||
*/
|
||||
TEST_CASE("Unit_hipGetTextureAlignmentOffset_Negative") {
|
||||
CHECK_IMAGE_SUPPORT
|
||||
size_t offset = 0;
|
||||
size_t *tex_buf;
|
||||
hipChannelFormatDesc chanDesc = hipCreateChannelDesc(32, 0, 0, 0, hipChannelFormatKindFloat);
|
||||
|
||||
HIP_CHECK(hipMalloc(&tex_buf, 32));
|
||||
HIP_CHECK(hipBindTexture(&offset, tex, reinterpret_cast<void*>(tex_buf), chanDesc, 32));
|
||||
|
||||
SECTION("offset is nullptr") {
|
||||
HIP_CHECK_ERROR(hipGetTextureAlignmentOffset(nullptr, &tex), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("texture is nullptr") {
|
||||
#if HT_AMD
|
||||
HIP_CHECK_ERROR(hipGetTextureAlignmentOffset(&offset, nullptr), hipErrorInvalidValue);
|
||||
#else
|
||||
HIP_CHECK_ERROR(hipGetTextureAlignmentOffset(&offset, nullptr), hipErrorInvalidTexture);
|
||||
#endif
|
||||
}
|
||||
|
||||
HIP_CHECK(hipFree(tex_buf));
|
||||
HIP_CHECK(hipUnbindTexture(tex));
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user