This repository was archived by the owner on Jan 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -1250,6 +1250,38 @@ THE SOFTWARE.
12501250 inline
12511251 __HOST_DEVICE__
12521252 bool __hbgtu2 (__half2 x, __half2 y) { return __hbgt2 (x, y); }
1253+ inline
1254+ __device__
1255+ __half __hmax (const __half x, const __half y) {
1256+ return __half_raw{__ocml_fmax_f16 (static_cast <__half_raw>(x).data ,
1257+ static_cast <__half_raw>(y).data )};
1258+ }
1259+ inline
1260+ __device__
1261+ __half __hmax_nan (const __half x, const __half y) {
1262+ if (__ocml_isnan_f16 (x)) {
1263+ return x;
1264+ } else if (__ocml_isnan_f16 (y)) {
1265+ return y;
1266+ }
1267+ return __hmax (x, y);
1268+ }
1269+ inline
1270+ __device__
1271+ __half __hmin (const __half x, const __half y) {
1272+ return __half_raw{__ocml_fmin_f16 (static_cast <__half_raw>(x).data ,
1273+ static_cast <__half_raw>(y).data )};
1274+ }
1275+ inline
1276+ __device__
1277+ __half __hmin_nan (const __half x, const __half y) {
1278+ if (__ocml_isnan_f16 (x)) {
1279+ return x;
1280+ } else if (__ocml_isnan_f16 (y)) {
1281+ return y;
1282+ }
1283+ return __hmin (x, y);
1284+ }
12531285
12541286 // Arithmetic
12551287 inline
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ THE SOFTWARE.
2525// /*
2626// Half Math Functions
2727// */
28-
2928#include "host_defines.h"
3029#if !__CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__
3130extern "C"
@@ -51,6 +50,8 @@ extern "C"
5150 __device__ _Float16 __ocml_sin_f16 (_Float16 );
5251 __device__ __attribute__((const )) _Float16 __ocml_sqrt_f16 (_Float16 );
5352 __device__ __attribute__((const )) _Float16 __ocml_trunc_f16 (_Float16 );
53+ __device__ __attribute__((const )) _Float16 __ocml_fmax_f16 (_Float16 , _Float16 );
54+ __device__ __attribute__((const )) _Float16 __ocml_fmin_f16 (_Float16 , _Float16 );
5455
5556 typedef _Float16 __2f16 __attribute__((ext_vector_type (2 )));
5657 typedef short __2i16 __attribute__((ext_vector_type (2 )));
@@ -84,3 +85,8 @@ extern "C"
8485 __device__ __attribute__((const )) __2f16 __ocml_trunc_2f16 (__2f16 );
8586}
8687#endif // !__CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__
88+ //TODO: remove these after they get into clang header __clang_hip_libdevice_declares.h'
89+ extern "C" {
90+ __device__ __attribute__((const )) _Float16 __ocml_fmax_f16 (_Float16 , _Float16 );
91+ __device__ __attribute__((const )) _Float16 __ocml_fmin_f16 (_Float16 , _Float16 );
92+ }
You can’t perform that action at this time.
0 commit comments