libxsmm_spmdm_begin.h 2.36 KB
Newer Older
lisj's avatar
lisj committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/******************************************************************************
* Copyright (c) Intel Corporation - All rights reserved.                      *
* This file is part of the LIBXSMM library.                                   *
*                                                                             *
* For information on the license, see the LICENSE file.                       *
* Further information: https://github.com/hfp/libxsmm/                        *
* SPDX-License-Identifier: BSD-3-Clause                                       *
******************************************************************************/
/* Nadathur Satish, Hans Pabst (Intel Corp.)
******************************************************************************/

#define SIMD_WIDTH_FP32 (1)
#define SIMDTYPE_FP32 float
#define SIMDTYPE_INT32 int
#define SIMDMASKTYPE_FP32 int
#define _MM_SETZERO_FP32() (0)
#define _MM_SETZERO_INT32() (0)
#define _MM_SET1_FP32(x) (x)
#define _MM_SET1_INT32(x) (x)
#define _MM_SET1_INT16 (x)
#define _MM_LOAD_FP32(x) (*(x))
#define _MM_LOADU_FP32(x) (*(x))
#define _MM_LOAD_INT32(x) (*(x))
#define _MM_STORE_INT32(x,y) ((*(x)) = (y))
#define _MM_LOADU_INT32(x) (*(x))
#define _MM_GATHER_FP32(Addr, idx, scale) (*(Addr + (idx)))
#define _MM_CMPNEQ_FP32(v1,v2) (LIBXSMM_FEQ(v1, v2) ? 0 : 1)
#define _MM_STORE_FP32(x,y) ((*(x)) = (y))
#define _MM_STOREU_FP32(x,y) ((*(x)) = (y))
#define _MM_ADD_FP32(x,y) ((x) + (y))
#define _MM_FMADD_FP32(x,y,z) (((x)*(y))+(z))
#define _MM_MUL_FP32(x,y) ((x)*(y))
#define _MM_PREFETCH(x, y)
#define TRANSPOSE_SIMD_WIDTH_KERNEL(ptr_A, ldA, ptr_B, ldB) ((*(ptr_B)) = (*(ptr_A)))
#define TRANSPOSE_SIMD_WIDTH_KERNEL_BFLOAT16(ptr_A, ldA, ptr_B, ldB) { \
  uint16_t restmp = (*(ptr_A)); \
  union { int i; float f; } res; \
  res.i = restmp; \
  res.i <<= 16; \
  (*(ptr_B)) = res.f; \
}

#define COMPRESS_FP32(v, k, m, cnt) if (m) { \
  values_ptr[cnt] = v; \
  colidx_ptr[cnt] = (uint16_t)(k); \
  cnt++; \
}

#define EXPAND_BFLOAT16(v, vlo_final, vhi_final) { \
  union { int i; float f; } vlo_tmp, vhi_tmp; \
  vlo_tmp.i = (v) & 0xFFFF; vlo_tmp.i <<= 16; \
  vlo_final = vlo_tmp.f; \
  vhi_tmp.i = (v) & 0x0000FFFF; \
  vhi_final = vhi_tmp.f; \
}

#define COMPRESS_BFLOAT16(vlo, vhi, v) { \
  union { int i; float f; } vlo_tmp, vhi_tmp; \
  vlo_tmp.f = vlo; \
  v = (vlo_tmp.i >> 16); \
  vhi_tmp.f = vhi; \
  v = v | (vhi_tmp.i & 0xFFFF0000); \
}