| 1076 | /// \param y second operand |
| 1077 | /// \return Half-precision division remainder stored in single-precision |
| 1078 | MEGDNN_HOST MEGDNN_DEVICE static expr remainder(float x, float y) |
| 1079 | { |
| 1080 | #if defined(__CUDA_ARCH__) |
| 1081 | return expr(remainderf(x, y)); |
| 1082 | #elif HALF_ENABLE_CPP11_CMATH |
| 1083 | return expr(std::remainder(x, y)); |
| 1084 | #else |
| 1085 | if(builtin_isnan(x) || builtin_isnan(y)) |
| 1086 | return expr(std::numeric_limits<float>::quiet_NaN()); |
| 1087 | float ax = fabs(x), ay = fabs(y); |
| 1088 | if(ax >= 65536.0f || ay < ldexp(1.0f, -24)) |
| 1089 | return expr(std::numeric_limits<float>::quiet_NaN()); |
| 1090 | if(ay >= 65536.0f) |
| 1091 | return expr(x); |
| 1092 | if(ax == ay) |
| 1093 | return expr(builtin_signbit(x) ? -0.0f : 0.0f); |
| 1094 | ax = fmod(ax, ay+ay); |
| 1095 | float y2 = 0.5f * ay; |
| 1096 | if(ax > y2) |
| 1097 | { |
| 1098 | ax -= ay; |
| 1099 | if(ax >= y2) |
| 1100 | ax -= ay; |
| 1101 | } |
| 1102 | return expr(builtin_signbit(x) ? -ax : ax); |
| 1103 | #endif |
| 1104 | } |
| 1105 | |
| 1106 | /// Remainder implementation. |
| 1107 | /// \param x first operand |
nothing calls this directly
no test coverage detected