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
405 lines
14 KiB
C++
405 lines
14 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "complex_function_common.hh"
|
|
#include "complex_cast_negative_kernels_rtc.hh"
|
|
#include "complex_make_negative_kernels_rtc.hh"
|
|
#include "complex_negative_kernels_1Arg_rtc.hh"
|
|
#include "complex_negative_kernels_2Arg_rtc.hh"
|
|
#include "complex_negative_kernels_3Arg_rtc.hh"
|
|
|
|
/**
|
|
* @addtogroup complex complex
|
|
* @{
|
|
* @ingroup ComplexTest
|
|
* Contains unit tests for complex type functions
|
|
*/
|
|
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks unary complex functions on device for reduced set of input values. The
|
|
* results are compared against manually calculated ones:
|
|
* -# hipConj, hipConjf
|
|
* -# hipCreal, hipCrealf
|
|
* -# hipCimag, hipCimagf
|
|
* -# hipCabs, hipCabsf
|
|
* -# hipCsqabs, hipCsqabsf
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_Unary_Device_Sanity_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input_i = GENERATE(-4.75, 0, 1.75);
|
|
|
|
TestType input_val = MakeComplexType<TestType>(input_r, input_i);
|
|
for (const auto function :
|
|
{ComplexFunction::kConj, ComplexFunction::kReal, ComplexFunction::kImag,
|
|
ComplexFunction::kAbs, ComplexFunction::kSqabs}) {
|
|
DYNAMIC_SECTION("function: " << to_string(function)) {
|
|
ComplexFunctionUnaryDeviceTest(function, input_val);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks unary complex functions on host for reduced set of input values. The
|
|
* results are compared against manually calculated ones:
|
|
* -# hipConj, hipConjf
|
|
* -# hipCreal, hipCrealf
|
|
* -# hipCimag, hipCimagf
|
|
* -# hipCabs, hipCabsf
|
|
* -# hipCsqabs, hipCsqabsf
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_Unary_Host_Sanity_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input_i = GENERATE(-4.75, 0, 1.75);
|
|
|
|
TestType input_val = MakeComplexType<TestType>(input_r, input_i);
|
|
for (const auto function :
|
|
{ComplexFunction::kConj, ComplexFunction::kReal, ComplexFunction::kImag,
|
|
ComplexFunction::kAbs, ComplexFunction::kSqabs}) {
|
|
DYNAMIC_SECTION("function: " << to_string(function)) {
|
|
ComplexFunctionUnaryHostTest(function, input_val);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks binary complex functions on device for reduced set of input values. The
|
|
* results are compared against manually calculated ones:
|
|
* -# hipCadd, hipCaddf
|
|
* -# hipCsub, hipCsubf
|
|
* -# hipCmul, hipCmulf
|
|
* -# hipCdiv, hipCdivf
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_Binary_Device_Sanity_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input1_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input1_i = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input2_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input2_i = GENERATE(-4.75, 0, 1.75);
|
|
|
|
TestType input_val1 = MakeComplexType<TestType>(input1_r, input1_i);
|
|
TestType input_val2 = MakeComplexType<TestType>(input2_r, input2_i);
|
|
for (const auto function : {ComplexFunction::kAdd, ComplexFunction::kSub, ComplexFunction::kMul,
|
|
ComplexFunction::kDiv}) {
|
|
DYNAMIC_SECTION("function: " << to_string(function)) {
|
|
ComplexFunctionBinaryDeviceTest(function, input_val1, input_val2);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks binary complex functions on host for reduced set of input values. The
|
|
* results are compared against manually calculated ones:
|
|
* -# hipCadd, hipCaddf
|
|
* -# hipCsub, hipCsubf
|
|
* -# hipCmul, hipCmulf
|
|
* -# hipCdiv, hipCdivf
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_Binary_Host_Sanity_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input1_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input1_i = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input2_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input2_i = GENERATE(-4.75, 0, 1.75);
|
|
|
|
TestType input_val1 = MakeComplexType<TestType>(input1_r, input1_i);
|
|
TestType input_val2 = MakeComplexType<TestType>(input2_r, input2_i);
|
|
for (const auto function : {ComplexFunction::kAdd, ComplexFunction::kSub, ComplexFunction::kMul,
|
|
ComplexFunction::kDiv}) {
|
|
DYNAMIC_SECTION("function: " << to_string(function)) {
|
|
ComplexFunctionBinaryHostTest(function, input_val1, input_val2);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks hipCfma/hipCfmaf complex functions on device for reduced set of input
|
|
* values. The results are compared against manually calculated ones.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_hipCfma_Device_Sanity_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input1_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input1_i = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input2_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input2_i = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input3_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input3_i = GENERATE(-4.75, 0, 1.75);
|
|
|
|
TestType input_val1 = MakeComplexType<TestType>(input1_r, input1_i);
|
|
TestType input_val2 = MakeComplexType<TestType>(input2_r, input2_i);
|
|
TestType input_val3 = MakeComplexType<TestType>(input3_r, input3_i);
|
|
|
|
ComplexFunctionTernaryDeviceTest(ComplexFunction::kFma, input_val1, input_val2, input_val3);
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks hipCfma/hipCfmaf complex functions on host for reduced set of input
|
|
* values. The results are compared against manually calculated ones.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_hipCfma_Host_Sanity_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input1_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input1_i = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input2_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input2_i = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input3_r = GENERATE(-4.75, 0, 1.75);
|
|
decltype(TestType().x) input3_i = GENERATE(-4.75, 0, 1.75);
|
|
|
|
TestType input_val1 = MakeComplexType<TestType>(input1_r, input1_i);
|
|
TestType input_val2 = MakeComplexType<TestType>(input2_r, input2_i);
|
|
TestType input_val3 = MakeComplexType<TestType>(input3_r, input3_i);
|
|
|
|
ComplexFunctionTernaryHostTest(ComplexFunction::kFma, input_val1, input_val2, input_val3);
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks make_hipFloatComplex/make_hipDoubleComplex functions on device for reduced
|
|
* set of input values. The results are compared against manually calculated ones.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_make_Complex_Device_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input_r = GENERATE(-0.25, 0, 0.25);
|
|
decltype(TestType().x) input_i = GENERATE(-1.75, 0, 1.75);
|
|
|
|
LinearAllocGuard<TestType> result_d(LinearAllocs::hipMalloc, sizeof(TestType));
|
|
LinearAllocGuard<TestType> result_h(LinearAllocs::hipHostMalloc, sizeof(TestType));
|
|
|
|
MakeComplexTypeKernel<TestType><<<1, 1>>>(result_d.ptr(), input_r, input_i);
|
|
HIP_CHECK(hipMemcpy(result_h.ptr(), result_d.ptr(), sizeof(TestType), hipMemcpyDeviceToHost));
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
REQUIRE(result_h.ptr()[0].x == input_r);
|
|
REQUIRE(result_h.ptr()[0].y == input_i);
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks make_hipFloatComplex/make_hipDoubleComplex functions on device for reduced
|
|
* set of input values. The results are compared against manually calculated ones.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_make_Complex_Host_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input_r = GENERATE(-0.25, 0, 0.25);
|
|
decltype(TestType().x) input_i = GENERATE(-1.75, 0, 1.75);
|
|
|
|
TestType result = MakeComplexType<TestType>(input_r, input_i);
|
|
|
|
REQUIRE(result.x == input_r);
|
|
REQUIRE(result.y == input_i);
|
|
}
|
|
|
|
#if HT_AMD // EXSWHTEC-321
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks make_hipComplex functions on device for reduced set of input values. The
|
|
* results are compared against manually calculated ones.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_make_hipComplex_Device_Positive) {
|
|
float input_r = GENERATE(-0.25, 0, 0.25);
|
|
float input_i = GENERATE(-1.75, 0, 1.75);
|
|
|
|
LinearAllocGuard<hipComplex> result_d(LinearAllocs::hipMalloc, sizeof(hipComplex));
|
|
LinearAllocGuard<hipComplex> result_h(LinearAllocs::hipHostMalloc, sizeof(hipComplex));
|
|
|
|
MakeHipComplexTypeKernel<<<1, 1>>>(result_d.ptr(), input_r, input_i);
|
|
HIP_CHECK(hipMemcpy(result_h.ptr(), result_d.ptr(), sizeof(hipComplex), hipMemcpyDeviceToHost));
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
REQUIRE(result_h.ptr()[0].x == input_r);
|
|
REQUIRE(result_h.ptr()[0].y == input_i);
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks make_hipComplex functions on host for reduced set of input values. The
|
|
* results are compared against manually calculated ones.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_make_hipComplex_Host_Positive) {
|
|
float input_r = GENERATE(-0.25, 0, 0.25);
|
|
float input_i = GENERATE(-1.75, 0, 1.75);
|
|
|
|
hipComplex result = make_hipComplex(input_r, input_i);
|
|
|
|
REQUIRE(result.x == input_r);
|
|
REQUIRE(result.y == input_i);
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks hipComplexDoubleToFloat/hipComplexFloatToDouble functions on device for
|
|
* reduced set of input values. The results are compared against manually calculated ones.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_Cast_Device_Sanity_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input_r = GENERATE(-0.25, 0, 0.25);
|
|
decltype(TestType().x) input_i = GENERATE(-1.75, 0, 1.75);
|
|
TestType input = MakeComplexType<TestType>(input_r, input_i);
|
|
|
|
LinearAllocGuard<CastType_t<TestType>> result_d{LinearAllocs::hipMalloc,
|
|
sizeof(CastType_t<TestType>)};
|
|
LinearAllocGuard<CastType_t<TestType>> result_h{LinearAllocs::hipHostMalloc,
|
|
sizeof(CastType_t<TestType>)};
|
|
|
|
CastComplexTypeKernel<<<1, 1>>>(result_d.ptr(), input);
|
|
HIP_CHECK(hipMemcpy(result_h.ptr(), result_d.ptr(), sizeof(CastType_t<TestType>),
|
|
hipMemcpyDeviceToHost));
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
REQUIRE(result_h.ptr()[0].x == static_cast<decltype(CastType_t<TestType>().x)>(input_r));
|
|
REQUIRE(result_h.ptr()[0].y == static_cast<decltype(CastType_t<TestType>().x)>(input_i));
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks hipComplexDoubleToFloat/hipComplexFloatToDouble functions on host for
|
|
* reduced set of input values. The results are compared against manually calculated ones.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_Cast_Host_Sanity_Positive, hipFloatComplex,
|
|
hipDoubleComplex) {
|
|
decltype(TestType().x) input_r = GENERATE(-0.25, 0, 0.25);
|
|
decltype(TestType().x) input_i = GENERATE(-1.75, 0, 1.75);
|
|
TestType input = MakeComplexType<TestType>(input_r, input_i);
|
|
|
|
CastType_t<TestType> result = CastComplexType<CastType_t<TestType>>(input);
|
|
|
|
REQUIRE(result.x == static_cast<decltype(CastType_t<TestType>().x)>(input_r));
|
|
REQUIRE(result.y == static_cast<decltype(CastType_t<TestType>().x)>(input_i));
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Test that checks hipComplexDoubleToFloat/hipComplexFloatToDouble single value
|
|
* constructor only initializes the real component.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/complex/complex.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEMPLATE_TEST_CASE(Unit_Device_Complex_Constructor_Host, hipFloatComplex, hipDoubleComplex) {
|
|
decltype(TestType().x) input_r = GENERATE(-0.25, 0.25);
|
|
TestType input{input_r};
|
|
|
|
CastType_t<TestType> result = CastComplexType<CastType_t<TestType>>(input);
|
|
|
|
REQUIRE(result.x == static_cast<decltype(CastType_t<TestType>().x)>(input_r));
|
|
REQUIRE(result.y != static_cast<decltype(CastType_t<TestType>().x)>(input_r));
|
|
}
|
|
|
|
/**
|
|
* End doxygen group ComplexTest.
|
|
* @}
|
|
*/
|