Debian Codegraph @

tensilelite/Tensile/Source/KernelHeader.h

raw symbols SCIP
1 /*******************************************************************************
2 *
3 * MIT License
4 *
5 * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 *******************************************************************************/
26
27 #ifndef KERNEL_HEADER
28 #define KERNEL_HEADER
29
30 #if Tensile_RUNTIME_LANGUAGE_OCL
31 #include <string>
32 #else
33
34 #include "TensileTypes.h"
35 #include <hip/hip_runtime.h>
36
37 #include "ReductionTemplate.h"
38 #include "memory_gfx.h"
39
40
41 __device__ inline int GenDot4(int a, int b, int c)
42 {
43 #if(__hcc_workweek__ >= 19092) || __HIP_CLANG_ONLY__
44 union
45 {
46 int32_t i;
47 char4 z;
48 } va, vb;
49 #else
50 typedef struct
51 {
52 int c0 : 8, c1 : 8, c2 : 8, c3 : 8;
53 } C4I8;
54 union
55 {
56 int32_t i;
57 C4I8 z;
58 } va, vb;
59 #endif
60 va.i = a;
61 vb.i = b;
62
63 #if(__hcc_workweek__ >= 19092) || __HIP_CLANG_ONLY__
64 return amd_mixed_dot(va.z, vb.z, c, true);
65 }
66 #else
67 return c + (vb.z.c3 * va.z.c3 + vb.z.c2 * va.z.c2 + vb.z.c1 * va.z.c1 + vb.z.c0 * va.z.c0);
68 }
69 #endif
70
71 #endif // HIP
72
73 typedef _Float16 tensile_half2 __attribute__((ext_vector_type(2)));
74 typedef _Float16 tensile_half;
75
76 extern "C" __device__ tensile_half2 llvm_fma_v2f16(tensile_half2,
77 tensile_half2,
78 tensile_half2) __asm("llvm.fma.v2f16");
79
80 __device__ inline tensile_half2
81 tensile_fmadd_half2(tensile_half2 multiplier, tensile_half2 multiplicand, tensile_half2 addend)
82 {
83 tensile_half2 result;
84 result = llvm_fma_v2f16(multiplier, multiplicand, addend);
85 return result;
86 };
87
88 #endif