Merge pull request #863 from aaronenyeshi/add-dot-instructions

Add Dot functions as amd_mixed_dot function
Tento commit je obsažen v:
Maneesh Gupta
2019-01-29 06:01:01 +05:30
odevzdal GitHub
6 změnil soubory, kde provedl 162 přidání a 1 odebrání
+9
Zobrazit soubor
@@ -1403,6 +1403,15 @@ THE SOFTWARE.
}
// Math functions
#if (__hcc_workweek__ >= 19015) || __HIP_CLANG_ONLY__
inline
__device__
float amd_mixed_dot(__half2 a, __half2 b, float c, bool saturate) {
return __ockl_fdot2(static_cast<__half2_raw>(a).data,
static_cast<__half2_raw>(b).data,
c, saturate);
}
#endif
inline
__device__
__half htrunc(__half x)
+5 -1
Zobrazit soubor
@@ -53,6 +53,10 @@ extern "C"
typedef _Float16 __2f16 __attribute__((ext_vector_type(2)));
typedef short __2i16 __attribute__((ext_vector_type(2)));
#if (__hcc_workweek__ >= 19015) || __HIP_CLANG_ONLY__
__device__ __attribute__((const)) float __ockl_fdot2(__2f16 a, __2f16 b, float c, bool s);
#endif
__device__ __attribute__((const)) __2f16 __ocml_ceil_2f16(__2f16);
__device__ __2f16 __ocml_cos_2f16(__2f16);
__device__ __attribute__((pure)) __2f16 __ocml_exp_2f16(__2f16);
@@ -75,4 +79,4 @@ extern "C"
__device__ __2f16 __ocml_sin_2f16(__2f16);
__device__ __attribute__((const)) __2f16 __ocml_sqrt_2f16(__2f16);
__device__ __attribute__((const)) __2f16 __ocml_trunc_2f16(__2f16);
}
}
+35
Zobrazit soubor
@@ -23,6 +23,7 @@ THE SOFTWARE.
#pragma once
#include "hip_fp16_math_fwd.h"
#include "hip_vector_types.h"
#include "math_fwd.h"
#include <hip/hcc_detail/host_defines.h>
@@ -119,6 +120,40 @@ uint64_t __make_mantissa(const char* tagp)
return __make_mantissa_base10(tagp);
}
// DOT FUNCTIONS
#if (__hcc_workweek__ >= 19015) || __HIP_CLANG_ONLY__
__DEVICE__
inline
int amd_mixed_dot(short2 a, short2 b, int c, bool saturate) {
return __ockl_sdot2(a.data, b.data, c, saturate);
}
__DEVICE__
inline
uint amd_mixed_dot(ushort2 a, ushort2 b, uint c, bool saturate) {
return __ockl_udot2(a.data, b.data, c, saturate);
}
__DEVICE__
inline
int amd_mixed_dot(char4 a, char4 b, int c, bool saturate) {
return __ockl_sdot4(a.data, b.data, c, saturate);
}
__DEVICE__
inline
uint amd_mixed_dot(uchar4 a, uchar4 b, uint c, bool saturate) {
return __ockl_udot4(a.data, b.data, c, saturate);
}
__DEVICE__
inline
int amd_mixed_dot(int a, int b, int c, bool saturate) {
return __ockl_sdot8(a, b, c, saturate);
}
__DEVICE__
inline
uint amd_mixed_dot(uint a, uint b, uint c, bool saturate) {
return __ockl_udot8(a, b, c, saturate);
}
#endif
// BEGIN FLOAT
__DEVICE__
inline
+39
Zobrazit soubor
@@ -28,6 +28,45 @@ THE SOFTWARE.
extern "C" {
#endif
// DOT FUNCTIONS
#if (__hcc_workweek__ >= 19015) || __HIP_CLANG_ONLY__
__device__
__attribute__((const))
int __ockl_sdot2(
HIP_vector_base<short, 2>::Native_vec_,
HIP_vector_base<short, 2>::Native_vec_,
int, bool);
__device__
__attribute__((const))
unsigned int __ockl_udot2(
HIP_vector_base<unsigned short, 2>::Native_vec_,
HIP_vector_base<unsigned short, 2>::Native_vec_,
unsigned int, bool);
__device__
__attribute__((const))
int __ockl_sdot4(
HIP_vector_base<char, 4>::Native_vec_,
HIP_vector_base<char, 4>::Native_vec_,
int, bool);
__device__
__attribute__((const))
unsigned int __ockl_udot4(
HIP_vector_base<unsigned char, 4>::Native_vec_,
HIP_vector_base<unsigned char, 4>::Native_vec_,
unsigned int, bool);
__device__
__attribute__((const))
int __ockl_sdot8(int, int, int, bool);
__device__
__attribute__((const))
unsigned int __ockl_udot8(unsigned int, unsigned int, unsigned int, bool);
#endif
// BEGIN FLOAT
__device__
__attribute__((const))