added comparision device functions for fp16
1. Added comparision device functions 2. Added test to check correct isa getting generated Change-Id: I16732f5a1438bdce145f7bfcecd28198e3cc4b79
This commit is contained in:
@@ -36,6 +36,17 @@ typedef struct __attribute__((aligned(4))){
|
||||
};
|
||||
} __half2;
|
||||
|
||||
struct holder{
|
||||
union {
|
||||
__half h;
|
||||
unsigned short s;
|
||||
};
|
||||
};
|
||||
|
||||
#define HINF 65504
|
||||
|
||||
static struct holder hInf = {HINF};
|
||||
|
||||
extern "C" __half __hip_hc_ir_hadd_half(__half, __half);
|
||||
extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half);
|
||||
extern "C" __half __hip_hc_ir_hmul_half(__half, __half);
|
||||
@@ -152,6 +163,70 @@ __device__ static inline __half2 h2div(__half2 a, __half2 b) {
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
Half comparision Functions
|
||||
*/
|
||||
|
||||
__device__ static inline bool __heq(__half a, __half b) {
|
||||
return a == b ? true : false;
|
||||
}
|
||||
|
||||
__device__ static inline bool __hge(__half a, __half b) {
|
||||
return a >= b ? true : false;
|
||||
}
|
||||
|
||||
__device__ static inline bool __hgt(__half a, __half b) {
|
||||
return a > b ? true : false;
|
||||
}
|
||||
|
||||
__device__ static inline bool __hisinf(__half a) {
|
||||
return a == hInf.s ? true : false;
|
||||
}
|
||||
|
||||
__device__ static inline bool __hisnan(__half a) {
|
||||
return a > hInf.s ? true : false;
|
||||
}
|
||||
|
||||
__device__ static inline bool __hle(__half a, __half b) {
|
||||
return a <= b ? true : false;
|
||||
}
|
||||
|
||||
__device__ static inline bool __hlt(__half a, __half b) {
|
||||
return a < b ? true : false;
|
||||
}
|
||||
|
||||
__device__ static inline bool __hne(__half a, __half b) {
|
||||
return a != b ? true : false;
|
||||
}
|
||||
|
||||
/*
|
||||
Half2 Comparision Functions
|
||||
*/
|
||||
|
||||
__device__ static inline bool __hbeq2(__half2 a, __half2 b) {
|
||||
return (a.p[0] == b.p[0] ? true : false) && (a.p[1] == b.p[1] ? true : false);
|
||||
}
|
||||
|
||||
__device__ static inline bool __hbge2(__half2 a, __half2 b) {
|
||||
return (a.p[0] >= b.p[0] ? true : false) && (a.p[1] >= b.p[1] ? true : false);
|
||||
}
|
||||
|
||||
__device__ static inline bool __hbgt2(__half2 a, __half2 b) {
|
||||
return (a.p[0] > b.p[0] ? true : false) && (a.p[1] > b.p[1] ? true : false);
|
||||
}
|
||||
|
||||
__device__ static inline bool __hble2(__half2 a, __half2 b) {
|
||||
return (a.p[0] <= b.p[0] ? true : false) && (a.p[1] <= b.p[1] ? true : false);
|
||||
}
|
||||
|
||||
__device__ static inline bool __hblt2(__half2 a, __half2 b) {
|
||||
return (a.p[0] < b.p[0] ? true : false) && (a.p[1] < b.p[1] ? true : false);
|
||||
}
|
||||
|
||||
__device__ static inline bool __hbne2(__half2 a, __half2 b) {
|
||||
return (a.p[0] != b.p[0] ? true : false) && (a.p[1] != b.p[1] ? true : false);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if __clang_major__ == 3
|
||||
|
||||
@@ -49,13 +49,6 @@ THE SOFTWARE.
|
||||
#define hNeg1 0xBC00
|
||||
#define hNeg1PK 0xBC00BC00
|
||||
|
||||
struct holder{
|
||||
union{
|
||||
__half a;
|
||||
unsigned short b;
|
||||
};
|
||||
};
|
||||
|
||||
__global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In3, __half* Out){
|
||||
Out[0] = __hadd(In1[0], In2[0]);
|
||||
Out[1] = __hadd_sat(In1[1], In2[1]);
|
||||
@@ -82,6 +75,17 @@ __global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2
|
||||
Out[9] = h2div(In1[9], In2[9]);
|
||||
}
|
||||
|
||||
__global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* Out) {
|
||||
Out[0] = __heq(In1[0], In2[0]);
|
||||
Out[1] = __hge(In1[1], In2[1]);
|
||||
Out[2] = __hgt(In1[2], In2[2]);
|
||||
Out[3] = __hisinf(In1[3]);
|
||||
Out[4] = __hisnan(In1[4]);
|
||||
Out[5] = __hle(In1[5], In2[5]);
|
||||
Out[6] = __hlt(In1[6], In2[6]);
|
||||
Out[7] = __hne(In1[7], In2[7]);
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
}
|
||||
|
||||
Referens i nytt ärende
Block a user