Skip to content

Commit

Permalink
fix complex abs( inf + inf*i ) in CUDA and HIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mgates3 committed Jul 7, 2024
1 parent 20d8dd2 commit b740a66
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/cuda/device_util.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ inline float abs(cuFloatComplex x)
b = fabsf(b);
w = max(a, b);
z = min(a, b);
if (z == 0) {
if (z == 0 || isinf( w )) {
t = w;
}
else {
Expand All @@ -194,7 +194,7 @@ inline double abs(cuDoubleComplex x)
// CUDA has a good implementation.
return cuCabs(x);
#else
// For HIP, use our implementation that scales per LAPACK.
// For HIP, use our implementation that scales per LAPACK lapy2.
double a = real( x );
double b = imag( x );
double z, w, t;
Expand All @@ -209,7 +209,7 @@ inline double abs(cuDoubleComplex x)
b = fabs(b);
w = max(a, b);
z = min(a, b);
if (z == 0) {
if (z == 0 || isinf( w )) {
t = w;
}
else {
Expand Down
6 changes: 3 additions & 3 deletions src/hip/device_util.hip.hh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ inline float abs(rocblas_float_complex x)
b = fabsf(b);
w = max(a, b);
z = min(a, b);
if (z == 0) {
if (z == 0 || isinf( w )) {
t = w;
}
else {
Expand All @@ -194,7 +194,7 @@ inline double abs(rocblas_double_complex x)
// CUDA has a good implementation.
return hipCabs(x);
#else
// For HIP, use our implementation that scales per LAPACK.
// For HIP, use our implementation that scales per LAPACK lapy2.
double a = real( x );
double b = imag( x );
double z, w, t;
Expand All @@ -209,7 +209,7 @@ inline double abs(rocblas_double_complex x)
b = fabs(b);
w = max(a, b);
z = min(a, b);
if (z == 0) {
if (z == 0 || isinf( w )) {
t = w;
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/hip/device_util.hip.hh.dep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a403f5b1c0195b503252fa643c722495 src/cuda/device_util.cuh
3a2509f9538de94f6212c4e678b236a6 src/cuda/device_util.cuh

0 comments on commit b740a66

Please sign in to comment.