1*c217d954SCole FaustR"( 2*c217d954SCole Faust 3*c217d954SCole Faust 4*c217d954SCole Faust#ifndef ARM_COMPUTE_HELPER_H 5*c217d954SCole Faust#define ARM_COMPUTE_HELPER_H 6*c217d954SCole Faust 7*c217d954SCole Faust 8*c217d954SCole Faust 9*c217d954SCole Faust 10*c217d954SCole Faust#define STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 11*c217d954SCole Faust VSTORE(N0) \ 12*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 13*c217d954SCole Faust 14*c217d954SCole Faust#define STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 15*c217d954SCole Faust STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 16*c217d954SCole Faust VSTORE(N0) \ 17*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 18*c217d954SCole Faust 19*c217d954SCole Faust#define STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 20*c217d954SCole Faust STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 21*c217d954SCole Faust VSTORE(N0) \ 22*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 23*c217d954SCole Faust 24*c217d954SCole Faust#define STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 25*c217d954SCole Faust STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 26*c217d954SCole Faust VSTORE(N0) \ 27*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 28*c217d954SCole Faust 29*c217d954SCole Faust#define STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 30*c217d954SCole Faust STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 31*c217d954SCole Faust VSTORE(N0) \ 32*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 33*c217d954SCole Faust 34*c217d954SCole Faust#define STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 35*c217d954SCole Faust STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 36*c217d954SCole Faust VSTORE(N0) \ 37*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 38*c217d954SCole Faust 39*c217d954SCole Faust#define STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 40*c217d954SCole Faust STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 41*c217d954SCole Faust VSTORE(N0) \ 42*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 43*c217d954SCole Faust 44*c217d954SCole Faust#define STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 45*c217d954SCole Faust STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 46*c217d954SCole Faust VSTORE(N0) \ 47*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 48*c217d954SCole Faust 49*c217d954SCole Faust#define STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 50*c217d954SCole Faust STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 51*c217d954SCole Faust VSTORE(N0) \ 52*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 53*c217d954SCole Faust 54*c217d954SCole Faust#define STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 55*c217d954SCole Faust STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 56*c217d954SCole Faust VSTORE(N0) \ 57*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 58*c217d954SCole Faust 59*c217d954SCole Faust#define STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 60*c217d954SCole Faust STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 61*c217d954SCole Faust VSTORE(N0) \ 62*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 63*c217d954SCole Faust 64*c217d954SCole Faust#define STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 65*c217d954SCole Faust STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 66*c217d954SCole Faust VSTORE(N0) \ 67*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 68*c217d954SCole Faust 69*c217d954SCole Faust#define STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 70*c217d954SCole Faust STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 71*c217d954SCole Faust VSTORE(N0) \ 72*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 73*c217d954SCole Faust 74*c217d954SCole Faust#define STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 75*c217d954SCole Faust STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 76*c217d954SCole Faust VSTORE(N0) \ 77*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 78*c217d954SCole Faust 79*c217d954SCole Faust#define STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 80*c217d954SCole Faust STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 81*c217d954SCole Faust VSTORE(N0) \ 82*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 83*c217d954SCole Faust 84*c217d954SCole Faust#define STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 85*c217d954SCole Faust STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 86*c217d954SCole Faust VSTORE(N0) \ 87*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 88*c217d954SCole Faust 89*c217d954SCole Faust 90*c217d954SCole Faust 91*c217d954SCole Faust#define CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 92*c217d954SCole Faust VSTORE(N0) \ 93*c217d954SCole Faust (CONVERT_SAT((BASENAME##0), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 94*c217d954SCole Faust 95*c217d954SCole Faust#define CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 96*c217d954SCole Faust CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 97*c217d954SCole Faust VSTORE(N0) \ 98*c217d954SCole Faust (CONVERT_SAT((BASENAME##1), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 99*c217d954SCole Faust 100*c217d954SCole Faust#define CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 101*c217d954SCole Faust CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 102*c217d954SCole Faust VSTORE(N0) \ 103*c217d954SCole Faust (CONVERT_SAT((BASENAME##2), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 104*c217d954SCole Faust 105*c217d954SCole Faust#define CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 106*c217d954SCole Faust CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 107*c217d954SCole Faust VSTORE(N0) \ 108*c217d954SCole Faust (CONVERT_SAT((BASENAME##3), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 109*c217d954SCole Faust 110*c217d954SCole Faust#define CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 111*c217d954SCole Faust CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 112*c217d954SCole Faust VSTORE(N0) \ 113*c217d954SCole Faust (CONVERT_SAT((BASENAME##4), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 114*c217d954SCole Faust 115*c217d954SCole Faust#define CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 116*c217d954SCole Faust CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 117*c217d954SCole Faust VSTORE(N0) \ 118*c217d954SCole Faust (CONVERT_SAT((BASENAME##5), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 119*c217d954SCole Faust 120*c217d954SCole Faust#define CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 121*c217d954SCole Faust CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 122*c217d954SCole Faust VSTORE(N0) \ 123*c217d954SCole Faust (CONVERT_SAT((BASENAME##6), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 124*c217d954SCole Faust 125*c217d954SCole Faust#define CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 126*c217d954SCole Faust CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 127*c217d954SCole Faust VSTORE(N0) \ 128*c217d954SCole Faust (CONVERT_SAT((BASENAME##7), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 129*c217d954SCole Faust 130*c217d954SCole Faust#define CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 131*c217d954SCole Faust CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 132*c217d954SCole Faust VSTORE(N0) \ 133*c217d954SCole Faust (CONVERT_SAT((BASENAME##8), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 134*c217d954SCole Faust 135*c217d954SCole Faust#define CONVERT_STORE_ROW_10(N0, DATA, BASENAME, PTR, STRIDE_Y, Z) \ 136*c217d954SCole Faust CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 137*c217d954SCole Faust VSTORE(N0) \ 138*c217d954SCole Faust (CONVERT_SAT((BASENAME##9), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 139*c217d954SCole Faust 140*c217d954SCole Faust#define CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 141*c217d954SCole Faust CONVERT_STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 142*c217d954SCole Faust VSTORE(N0) \ 143*c217d954SCole Faust (CONVERT_SAT((BASENAME##A), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 144*c217d954SCole Faust 145*c217d954SCole Faust#define CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 146*c217d954SCole Faust CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 147*c217d954SCole Faust VSTORE(N0) \ 148*c217d954SCole Faust (CONVERT_SAT((BASENAME##B), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 149*c217d954SCole Faust 150*c217d954SCole Faust#define CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 151*c217d954SCole Faust CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 152*c217d954SCole Faust VSTORE(N0) \ 153*c217d954SCole Faust (CONVERT_SAT((BASENAME##C), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 154*c217d954SCole Faust 155*c217d954SCole Faust#define CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 156*c217d954SCole Faust CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 157*c217d954SCole Faust VSTORE(N0) \ 158*c217d954SCole Faust (CONVERT_SAT((BASENAME##D), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 159*c217d954SCole Faust 160*c217d954SCole Faust#define CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 161*c217d954SCole Faust CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 162*c217d954SCole Faust VSTORE(N0) \ 163*c217d954SCole Faust (CONVERT_SAT((BASENAME##E), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 164*c217d954SCole Faust 165*c217d954SCole Faust#define CONVERT_STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 166*c217d954SCole Faust CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 167*c217d954SCole Faust VSTORE(N0) \ 168*c217d954SCole Faust (CONVERT_SAT((BASENAME##F), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 169*c217d954SCole Faust 170*c217d954SCole Faust 171*c217d954SCole Faust 172*c217d954SCole Faust 173*c217d954SCole Faust#define STORE_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) STORE_ROW_##M0(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 174*c217d954SCole Faust#define STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) STORE_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 175*c217d954SCole Faust 176*c217d954SCole Faust 177*c217d954SCole Faust 178*c217d954SCole Faust#define CONVERT_STORE_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) CONVERT_STORE_ROW_##M0(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 179*c217d954SCole Faust#define CONVERT_STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) CONVERT_STORE_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 180*c217d954SCole Faust 181*c217d954SCole Faust 182*c217d954SCole Faust 183*c217d954SCole Faust#define STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 184*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 185*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 186*c217d954SCole Faust 187*c217d954SCole Faust#define STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 188*c217d954SCole Faust STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 189*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 190*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 191*c217d954SCole Faust 192*c217d954SCole Faust#define STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 193*c217d954SCole Faust STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 194*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 195*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 196*c217d954SCole Faust 197*c217d954SCole Faust#define STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 198*c217d954SCole Faust STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 199*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 200*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 201*c217d954SCole Faust 202*c217d954SCole Faust#define STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 203*c217d954SCole Faust STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 204*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 205*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 206*c217d954SCole Faust 207*c217d954SCole Faust#define STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 208*c217d954SCole Faust STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 209*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 210*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 211*c217d954SCole Faust 212*c217d954SCole Faust#define STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 213*c217d954SCole Faust STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 214*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 215*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 216*c217d954SCole Faust 217*c217d954SCole Faust#define STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 218*c217d954SCole Faust STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 219*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 220*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 221*c217d954SCole Faust 222*c217d954SCole Faust#define STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 223*c217d954SCole Faust STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 224*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 225*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 226*c217d954SCole Faust 227*c217d954SCole Faust#define STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 228*c217d954SCole Faust STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 229*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 230*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 231*c217d954SCole Faust 232*c217d954SCole Faust#define STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 233*c217d954SCole Faust STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 234*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 235*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 236*c217d954SCole Faust 237*c217d954SCole Faust#define STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 238*c217d954SCole Faust STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 239*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 240*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 241*c217d954SCole Faust 242*c217d954SCole Faust#define STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 243*c217d954SCole Faust STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 244*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 245*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 246*c217d954SCole Faust 247*c217d954SCole Faust#define STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 248*c217d954SCole Faust STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 249*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 250*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 251*c217d954SCole Faust 252*c217d954SCole Faust#define STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 253*c217d954SCole Faust STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 254*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 255*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 256*c217d954SCole Faust 257*c217d954SCole Faust#define STORE_ROW_PARTIAL_16(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 258*c217d954SCole Faust STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 259*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 260*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 261*c217d954SCole Faust 262*c217d954SCole Faust 263*c217d954SCole Faust 264*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_STR(STORE_M0, STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) STORE_ROW_PARTIAL_##STORE_M0(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 265*c217d954SCole Faust#define STORE_BLOCK_PARTIAL(STORE_M0, STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) STORE_BLOCK_PARTIAL_STR(STORE_M0, STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 266*c217d954SCole Faust 267*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_X_AND_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 268*c217d954SCole Faust if(!(PARTIAL_COND_X) && !(PARTIAL_COND_Y)) \ 269*c217d954SCole Faust { \ 270*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 271*c217d954SCole Faust } \ 272*c217d954SCole Faust else if((PARTIAL_COND_Y) && !(PARTIAL_COND_X)) \ 273*c217d954SCole Faust { \ 274*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 275*c217d954SCole Faust } \ 276*c217d954SCole Faust else if(!(PARTIAL_COND_Y) && (PARTIAL_COND_X)) \ 277*c217d954SCole Faust { \ 278*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 279*c217d954SCole Faust } \ 280*c217d954SCole Faust else \ 281*c217d954SCole Faust { \ 282*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 283*c217d954SCole Faust } 284*c217d954SCole Faust 285*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) \ 286*c217d954SCole Faust if(!(PARTIAL_COND_X)) \ 287*c217d954SCole Faust { \ 288*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 289*c217d954SCole Faust } \ 290*c217d954SCole Faust else \ 291*c217d954SCole Faust { \ 292*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 293*c217d954SCole Faust } 294*c217d954SCole Faust 295*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) \ 296*c217d954SCole Faust if(!(PARTIAL_COND_Y)) \ 297*c217d954SCole Faust { \ 298*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 299*c217d954SCole Faust } \ 300*c217d954SCole Faust else \ 301*c217d954SCole Faust { \ 302*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 303*c217d954SCole Faust } 304*c217d954SCole Faust 305*c217d954SCole Faust 306*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) && defined(PARTIAL_STORE_N0) 307*c217d954SCole Faust 308*c217d954SCole Faust 309*c217d954SCole Faust#if PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 == 0 310*c217d954SCole Faust 311*c217d954SCole Faust#define STORE_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 312*c217d954SCole Faust STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 313*c217d954SCole Faust 314*c217d954SCole Faust#elif PARTIAL_STORE_M0 > 0 && PARTIAL_STORE_N0 == 0 315*c217d954SCole Faust 316*c217d954SCole Faust#define STORE_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 317*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) 318*c217d954SCole Faust 319*c217d954SCole Faust#elif PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 > 0 320*c217d954SCole Faust 321*c217d954SCole Faust#define STORE_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 322*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) 323*c217d954SCole Faust 324*c217d954SCole Faust#else 325*c217d954SCole Faust 326*c217d954SCole Faust#define STORE_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 327*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X_AND_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) 328*c217d954SCole Faust 329*c217d954SCole Faust#endif 330*c217d954SCole Faust 331*c217d954SCole Faust#endif 332*c217d954SCole Faust 333*c217d954SCole Faust 334*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) 335*c217d954SCole Faust 336*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 337*c217d954SCole Faust ((uint)(max(0, (int)(y * M0) - (int)((M0 - PARTIAL_STORE_M0) % M0)))) 338*c217d954SCole Faust#else 339*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 340*c217d954SCole Faust ((uint)(y * M0)) 341*c217d954SCole Faust#endif 342*c217d954SCole Faust 343*c217d954SCole Faust 344*c217d954SCole Faust 345*c217d954SCole Faust#define STORE_VECTOR_SELECT(basename, data_type, ptr, vec_size, leftover, cond) \ 346*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(1, vec_size, data_type, basename, ptr, 0, 0, leftover, cond) 347*c217d954SCole Faust 348*c217d954SCole Faust 349*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 350*c217d954SCole Faust#pragma OPENCL EXTENSION cl_khr_fp16 : enable 351*c217d954SCole Faust#endif 352*c217d954SCole Faust 353*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ENABLED) && defined(cl_arm_integer_dot_product_int8) 354*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable 355*c217d954SCole Faust#endif 356*c217d954SCole Faust 357*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED) && defined(cl_arm_integer_dot_product_accumulate_int8) 358*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable 359*c217d954SCole Faust#endif 360*c217d954SCole Faust 361*c217d954SCole Faust#if defined(ARM_COMPUTE_DEBUG_ENABLED) && defined(cl_arm_printf) 362*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_printf : enable 363*c217d954SCole Faust#endif 364*c217d954SCole Faust 365*c217d954SCole Faust#define GPU_ARCH_MIDGARD 0x100 366*c217d954SCole Faust#define GPU_ARCH_BIFROST 0x200 367*c217d954SCole Faust#define GPU_ARCH_VALHALL 0x300 368*c217d954SCole Faust 369*c217d954SCole Faust 370*c217d954SCole Faust#define CONCAT(a, b) a##b 371*c217d954SCole Faust 372*c217d954SCole Faust 373*c217d954SCole Faust#define EXPAND(x) x 374*c217d954SCole Faust 375*c217d954SCole Faust 376*c217d954SCole Faust#define CLAMP(x, min_val, max_val) min(max(x, min_val), max_val) 377*c217d954SCole Faust 378*c217d954SCole Faust 379*c217d954SCole Faust#define REV1(x) ((x)) 380*c217d954SCole Faust#define REV2(x) ((x).s10) 381*c217d954SCole Faust#define REV3(x) ((x).s210) 382*c217d954SCole Faust#define REV4(x) ((x).s3210) 383*c217d954SCole Faust#define REV8(x) ((x).s76543210) 384*c217d954SCole Faust#define REV16(x) ((x).sFEDCBA9876543210) 385*c217d954SCole Faust 386*c217d954SCole Faust 387*c217d954SCole Faust 388*c217d954SCole Faust#define REVERSE_STR(x, s) REV##s((x)) 389*c217d954SCole Faust#define REVERSE(x, s) REVERSE_STR(x, s) 390*c217d954SCole Faust 391*c217d954SCole Faust 392*c217d954SCole Faust 393*c217d954SCole Faust#define ROT1_0(x) ((x)) 394*c217d954SCole Faust#define ROT1_1(x) ((x)) 395*c217d954SCole Faust 396*c217d954SCole Faust#define ROT2_0(x) ((x)) 397*c217d954SCole Faust#define ROT2_1(x) ((x).s10) 398*c217d954SCole Faust#define ROT2_2(x) ((x)) 399*c217d954SCole Faust 400*c217d954SCole Faust#define ROT3_0(x) ((x)) 401*c217d954SCole Faust#define ROT3_1(x) ((x).s201) 402*c217d954SCole Faust#define ROT3_2(x) ((x).s120) 403*c217d954SCole Faust#define ROT3_3(x) ((x)) 404*c217d954SCole Faust 405*c217d954SCole Faust#define ROT4_0(x) ((x)) 406*c217d954SCole Faust#define ROT4_1(x) ((x).s3012) 407*c217d954SCole Faust#define ROT4_2(x) ((x).s2301) 408*c217d954SCole Faust#define ROT4_3(x) ((x).s1230) 409*c217d954SCole Faust#define ROT4_4(x) ((x)) 410*c217d954SCole Faust 411*c217d954SCole Faust#define ROT8_0(x) ((x)) 412*c217d954SCole Faust#define ROT8_1(x) ((x).s70123456) 413*c217d954SCole Faust#define ROT8_2(x) ((x).s67012345) 414*c217d954SCole Faust#define ROT8_3(x) ((x).s56701234) 415*c217d954SCole Faust#define ROT8_4(x) ((x).s45670123) 416*c217d954SCole Faust#define ROT8_5(x) ((x).s34567012) 417*c217d954SCole Faust#define ROT8_6(x) ((x).s23456701) 418*c217d954SCole Faust#define ROT8_7(x) ((x).s12345670) 419*c217d954SCole Faust#define ROT8_8(x) ((x)) 420*c217d954SCole Faust 421*c217d954SCole Faust#define ROT16_0(x) ((x)) 422*c217d954SCole Faust#define ROT16_1(x) ((x).sF0123456789ABCDE) 423*c217d954SCole Faust#define ROT16_2(x) ((x).sEF0123456789ABCD) 424*c217d954SCole Faust#define ROT16_3(x) ((x).sDEF0123456789ABC) 425*c217d954SCole Faust#define ROT16_4(x) ((x).sCDEF0123456789AB) 426*c217d954SCole Faust#define ROT16_5(x) ((x).sBCDEF0123456789A) 427*c217d954SCole Faust#define ROT16_6(x) ((x).sABCDEF0123456789) 428*c217d954SCole Faust#define ROT16_7(x) ((x).s9ABCDEF012345678) 429*c217d954SCole Faust#define ROT16_8(x) ((x).s89ABCDEF01234567) 430*c217d954SCole Faust#define ROT16_9(x) ((x).s789ABCDEF0123456) 431*c217d954SCole Faust#define ROT16_10(x) ((x).s6789ABCDEF012345) 432*c217d954SCole Faust#define ROT16_11(x) ((x).s56789ABCDEF01234) 433*c217d954SCole Faust#define ROT16_12(x) ((x).s456789ABCDEF0123) 434*c217d954SCole Faust#define ROT16_13(x) ((x).s3456789ABCDEF012) 435*c217d954SCole Faust#define ROT16_14(x) ((x).s23456789ABCDEF01) 436*c217d954SCole Faust#define ROT16_15(x) ((x).s123456789ABCDEF0) 437*c217d954SCole Faust#define ROT16_16(x) ((x)) 438*c217d954SCole Faust 439*c217d954SCole Faust 440*c217d954SCole Faust 441*c217d954SCole Faust#define ROTATE_STR(x, s, n) ROT##s##_##n(x) 442*c217d954SCole Faust#define ROTATE(x, s, n) ROTATE_STR(x, s, n) 443*c217d954SCole Faust 444*c217d954SCole Faust 445*c217d954SCole Faust 446*c217d954SCole Faust#define V_OFFS1(dt) (dt##1)(0) 447*c217d954SCole Faust#define V_OFFS2(dt) (dt##2)(0, 1) 448*c217d954SCole Faust#define V_OFFS3(dt) (dt##3)(0, 1, 2) 449*c217d954SCole Faust#define V_OFFS4(dt) (dt##4)(0, 1, 2, 3) 450*c217d954SCole Faust#define V_OFFS8(dt) (dt##8)(0, 1, 2, 3, 4, 5, 6, 7) 451*c217d954SCole Faust#define V_OFFS16(dt) (dt##16)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) 452*c217d954SCole Faust 453*c217d954SCole Faust 454*c217d954SCole Faust 455*c217d954SCole Faust#define VEC_OFFS_STR(dt, s) V_OFFS##s(dt) 456*c217d954SCole Faust#define VEC_OFFS(dt, s) VEC_OFFS_STR(dt, s) 457*c217d954SCole Faust 458*c217d954SCole Faust 459*c217d954SCole Faust#define VLOAD_STR(size) vload##size 460*c217d954SCole Faust#define VLOAD(size) VLOAD_STR(size) 461*c217d954SCole Faust 462*c217d954SCole Faust 463*c217d954SCole Faust#define VLOAD_PARTIAL_STR(size, load_size) vload_partial_##size##_##load_size 464*c217d954SCole Faust#define VLOAD_PARTIAL(size, load_size) VLOAD_PARTIAL_STR(size, load_size) 465*c217d954SCole Faust 466*c217d954SCole Faust#define NO_LOAD(data, offs, ptr) \ 467*c217d954SCole Faust { \ 468*c217d954SCole Faust } 469*c217d954SCole Faust 470*c217d954SCole Faust 471*c217d954SCole Faust#define vload_partial_1_0 NO_LOAD 472*c217d954SCole Faust#define vload_partial_1_1 vload1 473*c217d954SCole Faust#define vload_partial_1_2 NO_LOAD 474*c217d954SCole Faust#define vload_partial_1_3 NO_LOAD 475*c217d954SCole Faust#define vload_partial_1_4 NO_LOAD 476*c217d954SCole Faust#define vload_partial_1_5 NO_LOAD 477*c217d954SCole Faust#define vload_partial_1_6 NO_LOAD 478*c217d954SCole Faust#define vload_partial_1_7 NO_LOAD 479*c217d954SCole Faust#define vload_partial_1_8 NO_LOAD 480*c217d954SCole Faust#define vload_partial_1_9 NO_LOAD 481*c217d954SCole Faust#define vload_partial_1_10 NO_LOAD 482*c217d954SCole Faust#define vload_partial_1_11 NO_LOAD 483*c217d954SCole Faust#define vload_partial_1_12 NO_LOAD 484*c217d954SCole Faust#define vload_partial_1_13 NO_LOAD 485*c217d954SCole Faust#define vload_partial_1_14 NO_LOAD 486*c217d954SCole Faust#define vload_partial_1_15 NO_LOAD 487*c217d954SCole Faust#define vload_partial_1_16 NO_LOAD 488*c217d954SCole Faust 489*c217d954SCole Faust#define vload_partial_2_0 NO_LOAD 490*c217d954SCole Faust#define vload_partial_2_1 vload_partial_1 491*c217d954SCole Faust#define vload_partial_2_2 vload_partial_2 492*c217d954SCole Faust#define vload_partial_2_3 NO_LOAD 493*c217d954SCole Faust#define vload_partial_2_4 NO_LOAD 494*c217d954SCole Faust#define vload_partial_2_5 NO_LOAD 495*c217d954SCole Faust#define vload_partial_2_6 NO_LOAD 496*c217d954SCole Faust#define vload_partial_2_7 NO_LOAD 497*c217d954SCole Faust#define vload_partial_2_8 NO_LOAD 498*c217d954SCole Faust#define vload_partial_2_9 NO_LOAD 499*c217d954SCole Faust#define vload_partial_2_10 NO_LOAD 500*c217d954SCole Faust#define vload_partial_2_11 NO_LOAD 501*c217d954SCole Faust#define vload_partial_2_12 NO_LOAD 502*c217d954SCole Faust#define vload_partial_2_13 NO_LOAD 503*c217d954SCole Faust#define vload_partial_2_14 NO_LOAD 504*c217d954SCole Faust#define vload_partial_2_15 NO_LOAD 505*c217d954SCole Faust#define vload_partial_2_16 NO_LOAD 506*c217d954SCole Faust 507*c217d954SCole Faust#define vload_partial_3_0 NO_LOAD 508*c217d954SCole Faust#define vload_partial_3_1 vload_partial_1 509*c217d954SCole Faust#define vload_partial_3_2 vload_partial_2 510*c217d954SCole Faust#define vload_partial_3_3 vload_partial_3 511*c217d954SCole Faust#define vload_partial_3_4 NO_LOAD 512*c217d954SCole Faust#define vload_partial_3_5 NO_LOAD 513*c217d954SCole Faust#define vload_partial_3_6 NO_LOAD 514*c217d954SCole Faust#define vload_partial_3_7 NO_LOAD 515*c217d954SCole Faust#define vload_partial_3_8 NO_LOAD 516*c217d954SCole Faust#define vload_partial_3_9 NO_LOAD 517*c217d954SCole Faust#define vload_partial_3_10 NO_LOAD 518*c217d954SCole Faust#define vload_partial_3_11 NO_LOAD 519*c217d954SCole Faust#define vload_partial_3_12 NO_LOAD 520*c217d954SCole Faust#define vload_partial_3_13 NO_LOAD 521*c217d954SCole Faust#define vload_partial_3_14 NO_LOAD 522*c217d954SCole Faust#define vload_partial_3_15 NO_LOAD 523*c217d954SCole Faust#define vload_partial_3_16 NO_LOAD 524*c217d954SCole Faust 525*c217d954SCole Faust#define vload_partial_4_0 NO_LOAD 526*c217d954SCole Faust#define vload_partial_4_1 vload_partial_1 527*c217d954SCole Faust#define vload_partial_4_2 vload_partial_2 528*c217d954SCole Faust#define vload_partial_4_3 vload_partial_3 529*c217d954SCole Faust#define vload_partial_4_4 vload_partial_4 530*c217d954SCole Faust#define vload_partial_4_5 NO_LOAD 531*c217d954SCole Faust#define vload_partial_4_6 NO_LOAD 532*c217d954SCole Faust#define vload_partial_4_7 NO_LOAD 533*c217d954SCole Faust#define vload_partial_4_8 NO_LOAD 534*c217d954SCole Faust#define vload_partial_4_9 NO_LOAD 535*c217d954SCole Faust#define vload_partial_4_10 NO_LOAD 536*c217d954SCole Faust#define vload_partial_4_11 NO_LOAD 537*c217d954SCole Faust#define vload_partial_4_12 NO_LOAD 538*c217d954SCole Faust#define vload_partial_4_13 NO_LOAD 539*c217d954SCole Faust#define vload_partial_4_14 NO_LOAD 540*c217d954SCole Faust#define vload_partial_4_15 NO_LOAD 541*c217d954SCole Faust#define vload_partial_4_16 NO_LOAD 542*c217d954SCole Faust 543*c217d954SCole Faust#define vload_partial_8_0 NO_LOAD 544*c217d954SCole Faust#define vload_partial_8_1 vload_partial_1 545*c217d954SCole Faust#define vload_partial_8_2 vload_partial_2 546*c217d954SCole Faust#define vload_partial_8_3 vload_partial_3 547*c217d954SCole Faust#define vload_partial_8_4 vload_partial_4 548*c217d954SCole Faust#define vload_partial_8_5 vload_partial_5 549*c217d954SCole Faust#define vload_partial_8_6 vload_partial_6 550*c217d954SCole Faust#define vload_partial_8_7 vload_partial_7 551*c217d954SCole Faust#define vload_partial_8_8 vload_partial_8 552*c217d954SCole Faust#define vload_partial_8_9 NO_LOAD 553*c217d954SCole Faust#define vload_partial_8_10 NO_LOAD 554*c217d954SCole Faust#define vload_partial_8_11 NO_LOAD 555*c217d954SCole Faust#define vload_partial_8_12 NO_LOAD 556*c217d954SCole Faust#define vload_partial_8_13 NO_LOAD 557*c217d954SCole Faust#define vload_partial_8_14 NO_LOAD 558*c217d954SCole Faust#define vload_partial_8_15 NO_LOAD 559*c217d954SCole Faust#define vload_partial_8_16 NO_LOAD 560*c217d954SCole Faust 561*c217d954SCole Faust#define vload_partial_16_0 NO_LOAD 562*c217d954SCole Faust#define vload_partial_16_1 vload_partial_1 563*c217d954SCole Faust#define vload_partial_16_2 vload_partial_2 564*c217d954SCole Faust#define vload_partial_16_3 vload_partial_3 565*c217d954SCole Faust#define vload_partial_16_4 vload_partial_4 566*c217d954SCole Faust#define vload_partial_16_5 vload_partial_5 567*c217d954SCole Faust#define vload_partial_16_6 vload_partial_6 568*c217d954SCole Faust#define vload_partial_16_7 vload_partial_7 569*c217d954SCole Faust#define vload_partial_16_8 vload_partial_8 570*c217d954SCole Faust#define vload_partial_16_9 vload_partial_9 571*c217d954SCole Faust#define vload_partial_16_10 vload_partial_10 572*c217d954SCole Faust#define vload_partial_16_11 vload_partial_11 573*c217d954SCole Faust#define vload_partial_16_12 vload_partial_12 574*c217d954SCole Faust#define vload_partial_16_13 vload_partial_13 575*c217d954SCole Faust#define vload_partial_16_14 vload_partial_14 576*c217d954SCole Faust#define vload_partial_16_15 vload_partial_15 577*c217d954SCole Faust#define vload_partial_16_16 vload_partial_16 578*c217d954SCole Faust 579*c217d954SCole Faust 580*c217d954SCole Faust#define vload_partial_1(DATA, OFFSET, PTR) \ 581*c217d954SCole Faust DATA.s0 = vload1(OFFSET, PTR); 582*c217d954SCole Faust 583*c217d954SCole Faust#define vload_partial_2(DATA, OFFSET, PTR) \ 584*c217d954SCole Faust DATA.s01 = vload2(OFFSET, PTR); 585*c217d954SCole Faust 586*c217d954SCole Faust#define vload_partial_3(DATA, OFFSET, PTR) \ 587*c217d954SCole Faust DATA.s012 = vload3(OFFSET, PTR); 588*c217d954SCole Faust 589*c217d954SCole Faust#define vload_partial_4(DATA, OFFSET, PTR) \ 590*c217d954SCole Faust DATA.s0123 = vload4(OFFSET, PTR); 591*c217d954SCole Faust 592*c217d954SCole Faust#define vload_partial_5(DATA, OFFSET, PTR) \ 593*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 594*c217d954SCole Faust DATA.s4 = vload1(OFFSET, PTR + 4); 595*c217d954SCole Faust 596*c217d954SCole Faust#define vload_partial_6(DATA, OFFSET, PTR) \ 597*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 598*c217d954SCole Faust vload_partial_2(DATA.s45, OFFSET, PTR + 4); 599*c217d954SCole Faust 600*c217d954SCole Faust#define vload_partial_7(DATA, OFFSET, PTR) \ 601*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 602*c217d954SCole Faust vload_partial_3(DATA.s456, OFFSET, PTR + 4); 603*c217d954SCole Faust 604*c217d954SCole Faust#define vload_partial_8(DATA, OFFSET, PTR) \ 605*c217d954SCole Faust DATA.s01234567 = vload8(OFFSET, PTR); 606*c217d954SCole Faust 607*c217d954SCole Faust#define vload_partial_9(DATA, OFFSET, PTR) \ 608*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 609*c217d954SCole Faust DATA.s8 = vload1(OFFSET, PTR + 8); 610*c217d954SCole Faust 611*c217d954SCole Faust#define vload_partial_10(DATA, OFFSET, PTR) \ 612*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 613*c217d954SCole Faust vload_partial_2(DATA.s89, OFFSET, PTR + 8); 614*c217d954SCole Faust 615*c217d954SCole Faust#define vload_partial_11(DATA, OFFSET, PTR) \ 616*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 617*c217d954SCole Faust vload_partial_3(DATA.s89A, OFFSET, PTR + 8); 618*c217d954SCole Faust 619*c217d954SCole Faust#define vload_partial_12(DATA, OFFSET, PTR) \ 620*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 621*c217d954SCole Faust vload_partial_4(DATA.s89AB, OFFSET, PTR + 8); 622*c217d954SCole Faust 623*c217d954SCole Faust#define vload_partial_13(DATA, OFFSET, PTR) \ 624*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 625*c217d954SCole Faust vload_partial_5(DATA.s89ABCDEF, OFFSET, PTR + 8); 626*c217d954SCole Faust 627*c217d954SCole Faust#define vload_partial_14(DATA, OFFSET, PTR) \ 628*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 629*c217d954SCole Faust vload_partial_6(DATA.s89ABCDEF, OFFSET, PTR + 8); 630*c217d954SCole Faust 631*c217d954SCole Faust#define vload_partial_15(DATA, OFFSET, PTR) \ 632*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 633*c217d954SCole Faust vload_partial_7(DATA.s89ABCDEF, OFFSET, PTR + 8); 634*c217d954SCole Faust 635*c217d954SCole Faust#define vload_partial_16(DATA, OFFSET, PTR) \ 636*c217d954SCole Faust DATA = vload16(OFFSET, PTR); 637*c217d954SCole Faust 638*c217d954SCole Faust 639*c217d954SCole Faust 640*c217d954SCole Faust#define PIXEL_UNIT4 1 641*c217d954SCole Faust#define PIXEL_UNIT8 2 642*c217d954SCole Faust#define PIXEL_UNIT16 4 643*c217d954SCole Faust 644*c217d954SCole Faust 645*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) PIXEL_UNIT##vec_size 646*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT(vec_size) CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) 647*c217d954SCole Faust 648*c217d954SCole Faust 649*c217d954SCole Faust#define read_image2d_floatx1(img, x_coord, y_coord) (float4)(read_imagef(img, (int2)(x_coord, y_coord))); 650*c217d954SCole Faust#define read_image2d_floatx2(img, x_coord, y_coord) (float8)(read_imagef(img, (int2)(x_coord, y_coord)), read_imagef(img, (int2)(x_coord + 1, y_coord))); 651*c217d954SCole Faust#define read_image2d_floatx4(img, x_coord, y_coord) (float16)(read_imagef(img, (int2)(x_coord, y_coord)), read_imagef(img, (int2)(x_coord + 1, y_coord)), read_imagef(img, (int2)(x_coord + 2, y_coord)), read_imagef(img, (int2)(x_coord + 3, y_coord))); 652*c217d954SCole Faust 653*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 654*c217d954SCole Faust#define read_image2d_halfx1(img, x_coord, y_coord) (half4)(read_imageh(img, (int2)(x_coord, y_coord))); 655*c217d954SCole Faust#define read_image2d_halfx2(img, x_coord, y_coord) (half8)(read_imageh(img, (int2)(x_coord, y_coord)), read_imageh(img, (int2)(x_coord + 1, y_coord))); 656*c217d954SCole Faust#define read_image2d_halfx4(img, x_coord, y_coord) (half16)(read_imageh(img, (int2)(x_coord, y_coord)), read_imageh(img, (int2)(x_coord + 1, y_coord)), read_imageh(img, (int2)(x_coord + 2, y_coord)), read_imageh(img, (int2)(x_coord + 3, y_coord))); 657*c217d954SCole Faust#endif 658*c217d954SCole Faust 659*c217d954SCole Faust#define write_image2d_floatx1(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values)); 660*c217d954SCole Faust#define write_image2d_floatx2(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values.s0123), write_imagef(img, (int2)(x_coord + 1, y_coord), values.s4567)); 661*c217d954SCole Faust#define write_image2d_floatx4(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values.s0123), write_imagef(img, (int2)(x_coord + 1, y_coord), values.s4567), write_imagef(img, (int2)(x_coord + 2, y_coord), values.s89AB), write_imagef(img, (int2)(x_coord + 3, y_coord), values.sCDEF)); 662*c217d954SCole Faust 663*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 664*c217d954SCole Faust#define write_image2d_halfx1(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values)); 665*c217d954SCole Faust#define write_image2d_halfx2(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values.s0123), write_imageh(img, (int2)(x_coord + 1, y_coord), values.s4567)); 666*c217d954SCole Faust#define write_image2d_halfx4(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values.s0123), write_imageh(img, (int2)(x_coord + 1, y_coord), values.s4567), write_imageh(img, (int2)(x_coord + 2, y_coord), values.s89AB), write_imageh(img, (int2)(x_coord + 3, y_coord), values.sCDEF)); 667*c217d954SCole Faust#endif 668*c217d954SCole Faust 669*c217d954SCole Faust 670*c217d954SCole Faust#define READ_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord) read_image2d_##data_type##x##n0(img, x_coord, y_coord) 671*c217d954SCole Faust#define READ_IMAGE2D(data_type, n0, img, x_coord, y_coord) READ_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord) 672*c217d954SCole Faust 673*c217d954SCole Faust 674*c217d954SCole Faust#define WRITE_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord, values) write_image2d_##data_type##x##n0(img, x_coord, y_coord, values) 675*c217d954SCole Faust#define WRITE_IMAGE2D(data_type, n0, img, x_coord, y_coord, values) WRITE_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord, values) 676*c217d954SCole Faust 677*c217d954SCole Faust#define VSTORE_STR(size) vstore##size 678*c217d954SCole Faust#define VSTORE(size) VSTORE_STR(size) 679*c217d954SCole Faust 680*c217d954SCole Faust#define float1 float 681*c217d954SCole Faust#define half1 half 682*c217d954SCole Faust#define char1 char 683*c217d954SCole Faust#define uchar1 uchar 684*c217d954SCole Faust#define short1 short 685*c217d954SCole Faust#define ushort1 ushort 686*c217d954SCole Faust#define int1 int 687*c217d954SCole Faust#define uint1 uint 688*c217d954SCole Faust#define long1 long 689*c217d954SCole Faust#define ulong1 ulong 690*c217d954SCole Faust#define double1 double 691*c217d954SCole Faust 692*c217d954SCole Faust#define vload1(OFFSET, PTR) *(OFFSET + PTR) 693*c217d954SCole Faust#define vstore1(DATA, OFFSET, PTR) *(OFFSET + PTR) = DATA 694*c217d954SCole Faust 695*c217d954SCole Faust 696*c217d954SCole Faust#define VSTORE_PARTIAL_STR(size, store_size) vstore_partial_##size##_##store_size 697*c217d954SCole Faust#define VSTORE_PARTIAL(size, store_size) VSTORE_PARTIAL_STR(size, store_size) 698*c217d954SCole Faust 699*c217d954SCole Faust#define NO_STORE(data, offs, ptr) \ 700*c217d954SCole Faust { \ 701*c217d954SCole Faust } 702*c217d954SCole Faust 703*c217d954SCole Faust 704*c217d954SCole Faust#define vstore_partial_1_0 NO_STORE 705*c217d954SCole Faust#define vstore_partial_1_1 vstore1 706*c217d954SCole Faust#define vstore_partial_1_2 NO_STORE 707*c217d954SCole Faust#define vstore_partial_1_3 NO_STORE 708*c217d954SCole Faust#define vstore_partial_1_4 NO_STORE 709*c217d954SCole Faust#define vstore_partial_1_5 NO_STORE 710*c217d954SCole Faust#define vstore_partial_1_6 NO_STORE 711*c217d954SCole Faust#define vstore_partial_1_7 NO_STORE 712*c217d954SCole Faust#define vstore_partial_1_8 NO_STORE 713*c217d954SCole Faust#define vstore_partial_1_9 NO_STORE 714*c217d954SCole Faust#define vstore_partial_1_10 NO_STORE 715*c217d954SCole Faust#define vstore_partial_1_11 NO_STORE 716*c217d954SCole Faust#define vstore_partial_1_12 NO_STORE 717*c217d954SCole Faust#define vstore_partial_1_13 NO_STORE 718*c217d954SCole Faust#define vstore_partial_1_14 NO_STORE 719*c217d954SCole Faust#define vstore_partial_1_15 NO_STORE 720*c217d954SCole Faust#define vstore_partial_1_16 NO_STORE 721*c217d954SCole Faust 722*c217d954SCole Faust#define vstore_partial_2_0 NO_STORE 723*c217d954SCole Faust#define vstore_partial_2_1 vstore_partial_1 724*c217d954SCole Faust#define vstore_partial_2_2 vstore_partial_2 725*c217d954SCole Faust#define vstore_partial_2_3 NO_STORE 726*c217d954SCole Faust#define vstore_partial_2_4 NO_STORE 727*c217d954SCole Faust#define vstore_partial_2_5 NO_STORE 728*c217d954SCole Faust#define vstore_partial_2_6 NO_STORE 729*c217d954SCole Faust#define vstore_partial_2_7 NO_STORE 730*c217d954SCole Faust#define vstore_partial_2_8 NO_STORE 731*c217d954SCole Faust#define vstore_partial_2_9 NO_STORE 732*c217d954SCole Faust#define vstore_partial_2_10 NO_STORE 733*c217d954SCole Faust#define vstore_partial_2_11 NO_STORE 734*c217d954SCole Faust#define vstore_partial_2_12 NO_STORE 735*c217d954SCole Faust#define vstore_partial_2_13 NO_STORE 736*c217d954SCole Faust#define vstore_partial_2_14 NO_STORE 737*c217d954SCole Faust#define vstore_partial_2_15 NO_STORE 738*c217d954SCole Faust#define vstore_partial_2_16 NO_STORE 739*c217d954SCole Faust 740*c217d954SCole Faust#define vstore_partial_3_0 NO_STORE 741*c217d954SCole Faust#define vstore_partial_3_1 vstore_partial_1 742*c217d954SCole Faust#define vstore_partial_3_2 vstore_partial_2 743*c217d954SCole Faust#define vstore_partial_3_3 vstore_partial_3 744*c217d954SCole Faust#define vstore_partial_3_4 NO_STORE 745*c217d954SCole Faust#define vstore_partial_3_5 NO_STORE 746*c217d954SCole Faust#define vstore_partial_3_6 NO_STORE 747*c217d954SCole Faust#define vstore_partial_3_7 NO_STORE 748*c217d954SCole Faust#define vstore_partial_3_8 NO_STORE 749*c217d954SCole Faust#define vstore_partial_3_9 NO_STORE 750*c217d954SCole Faust#define vstore_partial_3_10 NO_STORE 751*c217d954SCole Faust#define vstore_partial_3_11 NO_STORE 752*c217d954SCole Faust#define vstore_partial_3_12 NO_STORE 753*c217d954SCole Faust#define vstore_partial_3_13 NO_STORE 754*c217d954SCole Faust#define vstore_partial_3_14 NO_STORE 755*c217d954SCole Faust#define vstore_partial_3_15 NO_STORE 756*c217d954SCole Faust#define vstore_partial_3_16 NO_STORE 757*c217d954SCole Faust 758*c217d954SCole Faust#define vstore_partial_4_0 NO_STORE 759*c217d954SCole Faust#define vstore_partial_4_1 vstore_partial_1 760*c217d954SCole Faust#define vstore_partial_4_2 vstore_partial_2 761*c217d954SCole Faust#define vstore_partial_4_3 vstore_partial_3 762*c217d954SCole Faust#define vstore_partial_4_4 vstore_partial_4 763*c217d954SCole Faust#define vstore_partial_4_5 NO_STORE 764*c217d954SCole Faust#define vstore_partial_4_6 NO_STORE 765*c217d954SCole Faust#define vstore_partial_4_7 NO_STORE 766*c217d954SCole Faust#define vstore_partial_4_8 NO_STORE 767*c217d954SCole Faust#define vstore_partial_4_9 NO_STORE 768*c217d954SCole Faust#define vstore_partial_4_10 NO_STORE 769*c217d954SCole Faust#define vstore_partial_4_11 NO_STORE 770*c217d954SCole Faust#define vstore_partial_4_12 NO_STORE 771*c217d954SCole Faust#define vstore_partial_4_13 NO_STORE 772*c217d954SCole Faust#define vstore_partial_4_14 NO_STORE 773*c217d954SCole Faust#define vstore_partial_4_15 NO_STORE 774*c217d954SCole Faust#define vstore_partial_4_16 NO_STORE 775*c217d954SCole Faust 776*c217d954SCole Faust#define vstore_partial_8_0 NO_STORE 777*c217d954SCole Faust#define vstore_partial_8_1 vstore_partial_1 778*c217d954SCole Faust#define vstore_partial_8_2 vstore_partial_2 779*c217d954SCole Faust#define vstore_partial_8_3 vstore_partial_3 780*c217d954SCole Faust#define vstore_partial_8_4 vstore_partial_4 781*c217d954SCole Faust#define vstore_partial_8_5 vstore_partial_5 782*c217d954SCole Faust#define vstore_partial_8_6 vstore_partial_6 783*c217d954SCole Faust#define vstore_partial_8_7 vstore_partial_7 784*c217d954SCole Faust#define vstore_partial_8_8 vstore_partial_8 785*c217d954SCole Faust#define vstore_partial_8_9 NO_STORE 786*c217d954SCole Faust#define vstore_partial_8_10 NO_STORE 787*c217d954SCole Faust#define vstore_partial_8_11 NO_STORE 788*c217d954SCole Faust#define vstore_partial_8_12 NO_STORE 789*c217d954SCole Faust#define vstore_partial_8_13 NO_STORE 790*c217d954SCole Faust#define vstore_partial_8_14 NO_STORE 791*c217d954SCole Faust#define vstore_partial_8_15 NO_STORE 792*c217d954SCole Faust#define vstore_partial_8_16 NO_STORE 793*c217d954SCole Faust 794*c217d954SCole Faust#define vstore_partial_16_0 NO_STORE 795*c217d954SCole Faust#define vstore_partial_16_1 vstore_partial_1 796*c217d954SCole Faust#define vstore_partial_16_2 vstore_partial_2 797*c217d954SCole Faust#define vstore_partial_16_3 vstore_partial_3 798*c217d954SCole Faust#define vstore_partial_16_4 vstore_partial_4 799*c217d954SCole Faust#define vstore_partial_16_5 vstore_partial_5 800*c217d954SCole Faust#define vstore_partial_16_6 vstore_partial_6 801*c217d954SCole Faust#define vstore_partial_16_7 vstore_partial_7 802*c217d954SCole Faust#define vstore_partial_16_8 vstore_partial_8 803*c217d954SCole Faust#define vstore_partial_16_9 vstore_partial_9 804*c217d954SCole Faust#define vstore_partial_16_10 vstore_partial_10 805*c217d954SCole Faust#define vstore_partial_16_11 vstore_partial_11 806*c217d954SCole Faust#define vstore_partial_16_12 vstore_partial_12 807*c217d954SCole Faust#define vstore_partial_16_13 vstore_partial_13 808*c217d954SCole Faust#define vstore_partial_16_14 vstore_partial_14 809*c217d954SCole Faust#define vstore_partial_16_15 vstore_partial_15 810*c217d954SCole Faust#define vstore_partial_16_16 vstore_partial_16 811*c217d954SCole Faust 812*c217d954SCole Faust 813*c217d954SCole Faust#define vstore_partial_1(DATA, OFFSET, PTR) \ 814*c217d954SCole Faust vstore1(DATA.s0, OFFSET, PTR); 815*c217d954SCole Faust 816*c217d954SCole Faust#define vstore_partial_2(DATA, OFFSET, PTR) \ 817*c217d954SCole Faust vstore2(DATA.s01, OFFSET, PTR); 818*c217d954SCole Faust 819*c217d954SCole Faust#define vstore_partial_3(DATA, OFFSET, PTR) \ 820*c217d954SCole Faust vstore3(DATA.s012, OFFSET, PTR); 821*c217d954SCole Faust 822*c217d954SCole Faust#define vstore_partial_4(DATA, OFFSET, PTR) \ 823*c217d954SCole Faust vstore4(DATA.s0123, OFFSET, PTR); 824*c217d954SCole Faust 825*c217d954SCole Faust#define vstore_partial_5(DATA, OFFSET, PTR) \ 826*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 827*c217d954SCole Faust vstore1(DATA.s4, OFFSET, PTR + 4); 828*c217d954SCole Faust 829*c217d954SCole Faust#define vstore_partial_6(DATA, OFFSET, PTR) \ 830*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 831*c217d954SCole Faust vstore_partial_2(DATA.s45, OFFSET, PTR + 4); 832*c217d954SCole Faust 833*c217d954SCole Faust#define vstore_partial_7(DATA, OFFSET, PTR) \ 834*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 835*c217d954SCole Faust vstore_partial_3(DATA.s456, OFFSET, PTR + 4); 836*c217d954SCole Faust 837*c217d954SCole Faust#define vstore_partial_8(DATA, OFFSET, PTR) \ 838*c217d954SCole Faust vstore8(DATA.s01234567, OFFSET, PTR); 839*c217d954SCole Faust 840*c217d954SCole Faust#define vstore_partial_9(DATA, OFFSET, PTR) \ 841*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 842*c217d954SCole Faust vstore1(DATA.s8, OFFSET, PTR + 8); 843*c217d954SCole Faust 844*c217d954SCole Faust#define vstore_partial_10(DATA, OFFSET, PTR) \ 845*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 846*c217d954SCole Faust vstore_partial_2(DATA.s89, OFFSET, PTR + 8); 847*c217d954SCole Faust 848*c217d954SCole Faust#define vstore_partial_11(DATA, OFFSET, PTR) \ 849*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 850*c217d954SCole Faust vstore_partial_3(DATA.s89a, OFFSET, PTR + 8); 851*c217d954SCole Faust 852*c217d954SCole Faust#define vstore_partial_12(DATA, OFFSET, PTR) \ 853*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 854*c217d954SCole Faust vstore_partial_4(DATA.s89ab, OFFSET, PTR + 8); 855*c217d954SCole Faust 856*c217d954SCole Faust#define vstore_partial_13(DATA, OFFSET, PTR) \ 857*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 858*c217d954SCole Faust vstore_partial_5(DATA.s89abcdef, OFFSET, PTR + 8); 859*c217d954SCole Faust 860*c217d954SCole Faust#define vstore_partial_14(DATA, OFFSET, PTR) \ 861*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 862*c217d954SCole Faust vstore_partial_6(DATA.s89abcdef, OFFSET, PTR + 8); 863*c217d954SCole Faust 864*c217d954SCole Faust#define vstore_partial_15(DATA, OFFSET, PTR) \ 865*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 866*c217d954SCole Faust vstore_partial_7(DATA.s89abcdef, OFFSET, PTR + 8); 867*c217d954SCole Faust 868*c217d954SCole Faust#define vstore_partial_16(DATA, OFFSET, PTR) \ 869*c217d954SCole Faust vstore16(DATA, OFFSET, PTR); 870*c217d954SCole Faust 871*c217d954SCole Faust 872*c217d954SCole Faust 873*c217d954SCole Faust 874*c217d954SCole Faust 875*c217d954SCole Faust#define convert_float_sat convert_float 876*c217d954SCole Faust#define convert_float1_sat convert_float 877*c217d954SCole Faust#define convert_float2_sat convert_float2 878*c217d954SCole Faust#define convert_float3_sat convert_float3 879*c217d954SCole Faust#define convert_float4_sat convert_float4 880*c217d954SCole Faust#define convert_float8_sat convert_float8 881*c217d954SCole Faust#define convert_float16_sat convert_float16 882*c217d954SCole Faust#define convert_half_sat convert_float 883*c217d954SCole Faust#define convert_half1_sat convert_half 884*c217d954SCole Faust#define convert_half2_sat convert_half2 885*c217d954SCole Faust#define convert_half3_sat convert_half3 886*c217d954SCole Faust#define convert_half4_sat convert_half4 887*c217d954SCole Faust#define convert_half8_sat convert_half8 888*c217d954SCole Faust#define convert_half16_sat convert_half16 889*c217d954SCole Faust 890*c217d954SCole Faust#define convert_float1 convert_float 891*c217d954SCole Faust#define convert_half1 convert_half 892*c217d954SCole Faust#define convert_char1 convert_char 893*c217d954SCole Faust#define convert_uchar1 convert_uchar 894*c217d954SCole Faust#define convert_short1 convert_short 895*c217d954SCole Faust#define convert_ushort1 convert_ushort 896*c217d954SCole Faust#define convert_int1 convert_int 897*c217d954SCole Faust#define convert_uint1 convert_uint 898*c217d954SCole Faust#define convert_long1 convert_long 899*c217d954SCole Faust#define convert_ulong1 convert_ulong 900*c217d954SCole Faust#define convert_double1 convert_double 901*c217d954SCole Faust 902*c217d954SCole Faust#define convert_char1_sat convert_char_sat 903*c217d954SCole Faust#define convert_uchar1_sat convert_uchar_sat 904*c217d954SCole Faust#define convert_uchar2_sat convert_uchar2_sat 905*c217d954SCole Faust#define convert_uchar3_sat convert_uchar3_sat 906*c217d954SCole Faust#define convert_uchar4_sat convert_uchar4_sat 907*c217d954SCole Faust#define convert_uchar8_sat convert_uchar8_sat 908*c217d954SCole Faust#define convert_uchar16_sat convert_uchar16_sat 909*c217d954SCole Faust#define convert_short1_sat convert_short_sat 910*c217d954SCole Faust#define convert_ushort1_sat convert_ushort_sat 911*c217d954SCole Faust#define convert_int1_sat convert_int_sat 912*c217d954SCole Faust#define convert_uint1_sat convert_uint_sat 913*c217d954SCole Faust#define convert_long1_sat convert_long_sat 914*c217d954SCole Faust#define convert_ulong1_sat convert_ulong_sat 915*c217d954SCole Faust#define convert_double1_sat convert_double_sat 916*c217d954SCole Faust 917*c217d954SCole Faust#define VEC_DATA_TYPE_STR(type, size) type##size 918*c217d954SCole Faust#define VEC_DATA_TYPE(type, size) VEC_DATA_TYPE_STR(type, size) 919*c217d954SCole Faust 920*c217d954SCole Faust#define CONVERT_STR(x, type) (convert_##type((x))) 921*c217d954SCole Faust#define CONVERT(x, type) CONVERT_STR(x, type) 922*c217d954SCole Faust 923*c217d954SCole Faust#define CONVERT_SAT_STR(x, type) (convert_##type##_sat((x))) 924*c217d954SCole Faust#define CONVERT_SAT(x, type) CONVERT_SAT_STR(x, type) 925*c217d954SCole Faust 926*c217d954SCole Faust#define CONVERT_SAT_ROUND_STR(x, type, round) (convert_##type##_sat_##round((x))) 927*c217d954SCole Faust#define CONVERT_SAT_ROUND(x, type, round) CONVERT_SAT_ROUND_STR(x, type, round) 928*c217d954SCole Faust 929*c217d954SCole Faust#define select_vec_dt_uchar(size) uchar##size 930*c217d954SCole Faust#define select_vec_dt_char(size) char##size 931*c217d954SCole Faust#define select_vec_dt_ushort(size) ushort##size 932*c217d954SCole Faust#define select_vec_dt_short(size) short##size 933*c217d954SCole Faust#define select_vec_dt_half(size) short##size 934*c217d954SCole Faust#define select_vec_dt_uint(size) uint##size 935*c217d954SCole Faust#define select_vec_dt_int(size) int##size 936*c217d954SCole Faust#define select_vec_dt_float(size) int##size 937*c217d954SCole Faust#define select_vec_dt_ulong(size) ulong##size 938*c217d954SCole Faust#define select_vec_dt_long(size) long##size 939*c217d954SCole Faust 940*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE_STR(type, size) select_vec_dt_##type(size) 941*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE(type, size) SELECT_VEC_DATA_TYPE_STR(type, size) 942*c217d954SCole Faust#define SELECT_DATA_TYPE(type) SELECT_VEC_DATA_TYPE_STR(type, 1) 943*c217d954SCole Faust 944*c217d954SCole Faust#define signed_int_vec_dt_uchar(size) char##size 945*c217d954SCole Faust#define signed_int_vec_dt_char(size) char##size 946*c217d954SCole Faust#define signed_int_vec_dt_ushort(size) short##size 947*c217d954SCole Faust#define signed_int_vec_dt_short(size) short##size 948*c217d954SCole Faust#define signed_int_vec_dt_half(size) short##size 949*c217d954SCole Faust#define signed_int_vec_dt_uint(size) int##size 950*c217d954SCole Faust#define signed_int_vec_dt_int(size) int##size 951*c217d954SCole Faust#define signed_int_vec_dt_float(size) int##size 952*c217d954SCole Faust#define signed_int_vec_dt_ulong(size) long##size 953*c217d954SCole Faust#define signed_int_vec_dt_long(size) long##size 954*c217d954SCole Faust 955*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE_STR(type, size) signed_int_vec_dt_##type(size) 956*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE(type, size) SIGNED_INT_VEC_DATA_TYPE_STR(type, size) 957*c217d954SCole Faust#define SIGNED_INT_DATA_TYPE(type) SIGNED_INT_VEC_DATA_TYPE_STR(type, 1) 958*c217d954SCole Faust 959*c217d954SCole Faust#define sum_reduce_1(x) (x) 960*c217d954SCole Faust#define sum_reduce_2(x) ((x).s0) + ((x).s1) 961*c217d954SCole Faust#define sum_reduce_3(x) sum_reduce_2((x).s01) + ((x).s2) 962*c217d954SCole Faust#define sum_reduce_4(x) sum_reduce_2((x).s01) + sum_reduce_2((x).s23) 963*c217d954SCole Faust#define sum_reduce_8(x) sum_reduce_4((x).s0123) + sum_reduce_4((x).s4567) 964*c217d954SCole Faust#define sum_reduce_16(x) sum_reduce_8((x).s01234567) + sum_reduce_8((x).s89ABCDEF) 965*c217d954SCole Faust 966*c217d954SCole Faust#define SUM_REDUCE_STR(x, size) sum_reduce_##size(x) 967*c217d954SCole Faust#define SUM_REDUCE(x, size) SUM_REDUCE_STR(x, size) 968*c217d954SCole Faust 969*c217d954SCole Faust#define prod_reduce_1(x) (x) 970*c217d954SCole Faust#define prod_reduce_2(x) ((x).s0) * ((x).s1) 971*c217d954SCole Faust#define prod_reduce_3(x) prod_reduce_2((x).s01) * ((x).s2) 972*c217d954SCole Faust#define prod_reduce_4(x) prod_reduce_2((x).s01) * prod_reduce_2((x).s23) 973*c217d954SCole Faust#define prod_reduce_8(x) prod_reduce_4((x).s0123) * prod_reduce_4((x).s4567) 974*c217d954SCole Faust#define prod_reduce_16(x) prod_reduce_8((x).s01234567) * prod_reduce_8((x).s89ABCDEF) 975*c217d954SCole Faust 976*c217d954SCole Faust#define PROD_REDUCE_STR(x, size) prod_reduce_##size(x) 977*c217d954SCole Faust#define PROD_REDUCE(x, size) PROD_REDUCE_STR(x, size) 978*c217d954SCole Faust 979*c217d954SCole Faust#define max_reduce_1(x) (x) 980*c217d954SCole Faust#define max_reduce_2(x) max(((x).s0), ((x).s1)) 981*c217d954SCole Faust#define max_reduce_3(x) max(max_reduce_2((x).s01), ((x).s2)) 982*c217d954SCole Faust#define max_reduce_4(x) max(max_reduce_2((x).s01), max_reduce_2((x).s23)) 983*c217d954SCole Faust#define max_reduce_8(x) max(max_reduce_4((x).s0123), max_reduce_4((x).s4567)) 984*c217d954SCole Faust#define max_reduce_16(x) max(max_reduce_8((x).s01234567), max_reduce_8((x).s89ABCDEF)) 985*c217d954SCole Faust 986*c217d954SCole Faust#define MAX_REDUCE_STR(x, size) max_reduce_##size(x) 987*c217d954SCole Faust#define MAX_REDUCE(x, size) MAX_REDUCE_STR(x, size) 988*c217d954SCole Faust 989*c217d954SCole Faust#define VECTOR_DECLARATION(name) \ 990*c217d954SCole Faust __global uchar *name##_ptr, \ 991*c217d954SCole Faust uint name##_stride_x, \ 992*c217d954SCole Faust uint name##_step_x, \ 993*c217d954SCole Faust uint name##_offset_first_element_in_bytes 994*c217d954SCole Faust 995*c217d954SCole Faust#define IMAGE_DECLARATION(name) \ 996*c217d954SCole Faust __global uchar *name##_ptr, \ 997*c217d954SCole Faust uint name##_stride_x, \ 998*c217d954SCole Faust uint name##_step_x, \ 999*c217d954SCole Faust uint name##_stride_y, \ 1000*c217d954SCole Faust uint name##_step_y, \ 1001*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1002*c217d954SCole Faust 1003*c217d954SCole Faust#define TENSOR3D_DECLARATION(name) \ 1004*c217d954SCole Faust __global uchar *name##_ptr, \ 1005*c217d954SCole Faust uint name##_stride_x, \ 1006*c217d954SCole Faust uint name##_step_x, \ 1007*c217d954SCole Faust uint name##_stride_y, \ 1008*c217d954SCole Faust uint name##_step_y, \ 1009*c217d954SCole Faust uint name##_stride_z, \ 1010*c217d954SCole Faust uint name##_step_z, \ 1011*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1012*c217d954SCole Faust 1013*c217d954SCole Faust#define TENSOR4D_DECLARATION(name) \ 1014*c217d954SCole Faust __global uchar *name##_ptr, \ 1015*c217d954SCole Faust uint name##_stride_x, \ 1016*c217d954SCole Faust uint name##_step_x, \ 1017*c217d954SCole Faust uint name##_stride_y, \ 1018*c217d954SCole Faust uint name##_step_y, \ 1019*c217d954SCole Faust uint name##_stride_z, \ 1020*c217d954SCole Faust uint name##_step_z, \ 1021*c217d954SCole Faust uint name##_stride_w, \ 1022*c217d954SCole Faust uint name##_step_w, \ 1023*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1024*c217d954SCole Faust 1025*c217d954SCole Faust#define TENSOR5D_DECLARATION(name) \ 1026*c217d954SCole Faust __global uchar *name##_ptr, \ 1027*c217d954SCole Faust uint name##_stride_x, \ 1028*c217d954SCole Faust uint name##_step_x, \ 1029*c217d954SCole Faust uint name##_stride_y, \ 1030*c217d954SCole Faust uint name##_step_y, \ 1031*c217d954SCole Faust uint name##_stride_z, \ 1032*c217d954SCole Faust uint name##_step_z, \ 1033*c217d954SCole Faust uint name##_stride_w, \ 1034*c217d954SCole Faust uint name##_step_w, \ 1035*c217d954SCole Faust uint name##_stride_v, \ 1036*c217d954SCole Faust uint name##_step_v, \ 1037*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1038*c217d954SCole Faust 1039*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT(name) \ 1040*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x) 1041*c217d954SCole Faust 1042*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT_NO_STEP(name) \ 1043*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0) 1044*c217d954SCole Faust 1045*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT(name) \ 1046*c217d954SCole Faust update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y) 1047*c217d954SCole Faust 1048*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name) \ 1049*c217d954SCole Faust update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0) 1050*c217d954SCole Faust 1051*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 1052*c217d954SCole Faust update_image_from_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, name##_stride_z, name##_step_z) 1053*c217d954SCole Faust 1054*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT_NO_STEP(name) \ 1055*c217d954SCole Faust update_image_from_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, name##_step_z) 1056*c217d954SCole Faust 1057*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 1058*c217d954SCole Faust update_image_from_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, name##_stride_z, name##_step_z) 1059*c217d954SCole Faust 1060*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT(name) \ 1061*c217d954SCole Faust update_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, \ 1062*c217d954SCole Faust name##_stride_z, name##_step_z) 1063*c217d954SCole Faust 1064*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name) \ 1065*c217d954SCole Faust update_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, 0) 1066*c217d954SCole Faust 1067*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT(name, mod_size) \ 1068*c217d954SCole Faust update_tensor4D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, \ 1069*c217d954SCole Faust name##_stride_z, name##_step_z, name##_stride_w, name##_step_w, mod_size) 1070*c217d954SCole Faust 1071*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(name, mod_size) \ 1072*c217d954SCole Faust update_tensor4D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, 0, name##_stride_w, 0, mod_size) 1073*c217d954SCole Faust 1074*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_UPDATE_PTR(name) \ 1075*c217d954SCole Faust tensor3D_ptr_no_update(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, \ 1076*c217d954SCole Faust name##_stride_z, name##_step_z) 1077*c217d954SCole Faust 1078*c217d954SCole Faust 1079*c217d954SCole Fausttypedef struct Vector 1080*c217d954SCole Faust{ 1081*c217d954SCole Faust __global uchar *ptr; 1082*c217d954SCole Faust int offset_first_element_in_bytes; 1083*c217d954SCole Faust int stride_x; 1084*c217d954SCole Faust} Vector; 1085*c217d954SCole Faust 1086*c217d954SCole Faust 1087*c217d954SCole Fausttypedef struct Image 1088*c217d954SCole Faust{ 1089*c217d954SCole Faust __global uchar *ptr; 1090*c217d954SCole Faust int offset_first_element_in_bytes; 1091*c217d954SCole Faust int stride_x; 1092*c217d954SCole Faust int stride_y; 1093*c217d954SCole Faust} Image; 1094*c217d954SCole Faust 1095*c217d954SCole Faust 1096*c217d954SCole Fausttypedef struct Tensor3D 1097*c217d954SCole Faust{ 1098*c217d954SCole Faust __global uchar *ptr; 1099*c217d954SCole Faust int offset_first_element_in_bytes; 1100*c217d954SCole Faust int stride_x; 1101*c217d954SCole Faust int stride_y; 1102*c217d954SCole Faust int stride_z; 1103*c217d954SCole Faust} Tensor3D; 1104*c217d954SCole Faust 1105*c217d954SCole Faust 1106*c217d954SCole Fausttypedef struct Tensor4D 1107*c217d954SCole Faust{ 1108*c217d954SCole Faust __global uchar *ptr; 1109*c217d954SCole Faust int offset_first_element_in_bytes; 1110*c217d954SCole Faust int stride_x; 1111*c217d954SCole Faust int stride_y; 1112*c217d954SCole Faust int stride_z; 1113*c217d954SCole Faust int stride_w; 1114*c217d954SCole Faust} Tensor4D; 1115*c217d954SCole Faust 1116*c217d954SCole Faust 1117*c217d954SCole Faustinline Vector update_vector_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x) 1118*c217d954SCole Faust{ 1119*c217d954SCole Faust Vector vector = 1120*c217d954SCole Faust { 1121*c217d954SCole Faust .ptr = ptr, 1122*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1123*c217d954SCole Faust .stride_x = stride_x, 1124*c217d954SCole Faust }; 1125*c217d954SCole Faust vector.ptr += vector.offset_first_element_in_bytes + get_global_id(0) * step_x; 1126*c217d954SCole Faust return vector; 1127*c217d954SCole Faust} 1128*c217d954SCole Faust 1129*c217d954SCole Faust 1130*c217d954SCole Faustinline Image update_image_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y) 1131*c217d954SCole Faust{ 1132*c217d954SCole Faust Image img = 1133*c217d954SCole Faust { 1134*c217d954SCole Faust .ptr = ptr, 1135*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1136*c217d954SCole Faust .stride_x = stride_x, 1137*c217d954SCole Faust .stride_y = stride_y 1138*c217d954SCole Faust }; 1139*c217d954SCole Faust img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y; 1140*c217d954SCole Faust return img; 1141*c217d954SCole Faust} 1142*c217d954SCole Faust 1143*c217d954SCole Faust 1144*c217d954SCole Faustinline Image update_image_from_tensor3D_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z) 1145*c217d954SCole Faust{ 1146*c217d954SCole Faust Image img = 1147*c217d954SCole Faust { 1148*c217d954SCole Faust .ptr = ptr, 1149*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1150*c217d954SCole Faust .stride_x = stride_x, 1151*c217d954SCole Faust .stride_y = stride_y 1152*c217d954SCole Faust }; 1153*c217d954SCole Faust img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + get_global_id(2) * step_z; 1154*c217d954SCole Faust return img; 1155*c217d954SCole Faust} 1156*c217d954SCole Faust 1157*c217d954SCole Faust 1158*c217d954SCole Faustinline Tensor3D update_tensor3D_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z) 1159*c217d954SCole Faust{ 1160*c217d954SCole Faust Tensor3D tensor = 1161*c217d954SCole Faust { 1162*c217d954SCole Faust .ptr = ptr, 1163*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1164*c217d954SCole Faust .stride_x = stride_x, 1165*c217d954SCole Faust .stride_y = stride_y, 1166*c217d954SCole Faust .stride_z = stride_z 1167*c217d954SCole Faust }; 1168*c217d954SCole Faust tensor.ptr += tensor.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + get_global_id(2) * step_z; 1169*c217d954SCole Faust return tensor; 1170*c217d954SCole Faust} 1171*c217d954SCole Faust 1172*c217d954SCole Faust 1173*c217d954SCole Faustinline Tensor3D tensor3D_ptr_no_update(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z) 1174*c217d954SCole Faust{ 1175*c217d954SCole Faust Tensor3D tensor = 1176*c217d954SCole Faust { 1177*c217d954SCole Faust .ptr = ptr, 1178*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1179*c217d954SCole Faust .stride_x = stride_x, 1180*c217d954SCole Faust .stride_y = stride_y, 1181*c217d954SCole Faust .stride_z = stride_z 1182*c217d954SCole Faust }; 1183*c217d954SCole Faust return tensor; 1184*c217d954SCole Faust} 1185*c217d954SCole Faust 1186*c217d954SCole Faustinline Tensor4D update_tensor4D_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z, uint stride_w, 1187*c217d954SCole Faust uint step_w, 1188*c217d954SCole Faust uint mod_size) 1189*c217d954SCole Faust{ 1190*c217d954SCole Faust Tensor4D tensor = 1191*c217d954SCole Faust { 1192*c217d954SCole Faust .ptr = ptr, 1193*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1194*c217d954SCole Faust .stride_x = stride_x, 1195*c217d954SCole Faust .stride_y = stride_y, 1196*c217d954SCole Faust .stride_z = stride_z, 1197*c217d954SCole Faust .stride_w = stride_w 1198*c217d954SCole Faust }; 1199*c217d954SCole Faust 1200*c217d954SCole Faust tensor.ptr += tensor.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + (get_global_id(2) % mod_size) * step_z + (get_global_id(2) / mod_size) * step_w; 1201*c217d954SCole Faust return tensor; 1202*c217d954SCole Faust} 1203*c217d954SCole Faust 1204*c217d954SCole Faust 1205*c217d954SCole Faustinline __global const uchar *vector_offset(const Vector *vec, int x) 1206*c217d954SCole Faust{ 1207*c217d954SCole Faust return vec->ptr + x * vec->stride_x; 1208*c217d954SCole Faust} 1209*c217d954SCole Faust 1210*c217d954SCole Faust 1211*c217d954SCole Faustinline __global uchar *offset(const Image *img, int x, int y) 1212*c217d954SCole Faust{ 1213*c217d954SCole Faust return img->ptr + x * img->stride_x + y * img->stride_y; 1214*c217d954SCole Faust} 1215*c217d954SCole Faust 1216*c217d954SCole Faust 1217*c217d954SCole Faustinline __global const uchar *tensor3D_offset(const Tensor3D *tensor, int x, int y, int z) 1218*c217d954SCole Faust{ 1219*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z; 1220*c217d954SCole Faust} 1221*c217d954SCole Faust 1222*c217d954SCole Faust 1223*c217d954SCole Faustinline __global const uchar *tensor4D_offset(const Tensor4D *tensor, int x, int y, int z, int w) 1224*c217d954SCole Faust{ 1225*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + w * tensor->stride_w; 1226*c217d954SCole Faust} 1227*c217d954SCole Faust 1228*c217d954SCole Faust 1229*c217d954SCole Faustinline __global const uchar *tensor3D_index2ptr(const Tensor3D *tensor, uint width, uint height, uint depth, uint index) 1230*c217d954SCole Faust{ 1231*c217d954SCole Faust uint num_elements = width * height; 1232*c217d954SCole Faust 1233*c217d954SCole Faust const uint z = index / num_elements; 1234*c217d954SCole Faust 1235*c217d954SCole Faust index %= num_elements; 1236*c217d954SCole Faust 1237*c217d954SCole Faust const uint y = index / width; 1238*c217d954SCole Faust 1239*c217d954SCole Faust index %= width; 1240*c217d954SCole Faust 1241*c217d954SCole Faust const uint x = index; 1242*c217d954SCole Faust 1243*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + tensor->offset_first_element_in_bytes; 1244*c217d954SCole Faust} 1245*c217d954SCole Faust 1246*c217d954SCole Faust#endif 1247*c217d954SCole Faust 1248*c217d954SCole Faust#ifndef SRC_CORE_CL_CL_KERNELS_TILE_HELPERS 1249*c217d954SCole Faust#define SRC_CORE_CL_CL_KERNELS_TILE_HELPERS 1250*c217d954SCole Faust 1251*c217d954SCole Faust 1252*c217d954SCole Faust 1253*c217d954SCole Faust 1254*c217d954SCole Faust#define TILE_VECTOR_SIZE1 1 1255*c217d954SCole Faust#define TILE_VECTOR_SIZE2 2 1256*c217d954SCole Faust#define TILE_VECTOR_SIZE3 3 1257*c217d954SCole Faust#define TILE_VECTOR_SIZE4 4 1258*c217d954SCole Faust#define TILE_VECTOR_SIZE5 8 1259*c217d954SCole Faust#define TILE_VECTOR_SIZE6 8 1260*c217d954SCole Faust#define TILE_VECTOR_SIZE7 8 1261*c217d954SCole Faust#define TILE_VECTOR_SIZE8 8 1262*c217d954SCole Faust#define TILE_VECTOR_SIZE9 16 1263*c217d954SCole Faust#define TILE_VECTOR_SIZE10 16 1264*c217d954SCole Faust#define TILE_VECTOR_SIZE11 16 1265*c217d954SCole Faust#define TILE_VECTOR_SIZE12 16 1266*c217d954SCole Faust#define TILE_VECTOR_SIZE13 16 1267*c217d954SCole Faust#define TILE_VECTOR_SIZE14 16 1268*c217d954SCole Faust#define TILE_VECTOR_SIZE15 16 1269*c217d954SCole Faust#define TILE_VECTOR_SIZE16 16 1270*c217d954SCole Faust 1271*c217d954SCole Faust#define TILE_VECTOR_TYPE1(DATA_TYPE) DATA_TYPE##1 1272*c217d954SCole Faust#define TILE_VECTOR_TYPE2(DATA_TYPE) DATA_TYPE##2 1273*c217d954SCole Faust#define TILE_VECTOR_TYPE3(DATA_TYPE) DATA_TYPE##3 1274*c217d954SCole Faust#define TILE_VECTOR_TYPE4(DATA_TYPE) DATA_TYPE##4 1275*c217d954SCole Faust#define TILE_VECTOR_TYPE5(DATA_TYPE) DATA_TYPE##8 1276*c217d954SCole Faust#define TILE_VECTOR_TYPE6(DATA_TYPE) DATA_TYPE##8 1277*c217d954SCole Faust#define TILE_VECTOR_TYPE7(DATA_TYPE) DATA_TYPE##8 1278*c217d954SCole Faust#define TILE_VECTOR_TYPE8(DATA_TYPE) DATA_TYPE##8 1279*c217d954SCole Faust#define TILE_VECTOR_TYPE9(DATA_TYPE) DATA_TYPE##16 1280*c217d954SCole Faust#define TILE_VECTOR_TYPE10(DATA_TYPE) DATA_TYPE##16 1281*c217d954SCole Faust#define TILE_VECTOR_TYPE11(DATA_TYPE) DATA_TYPE##16 1282*c217d954SCole Faust#define TILE_VECTOR_TYPE12(DATA_TYPE) DATA_TYPE##16 1283*c217d954SCole Faust#define TILE_VECTOR_TYPE13(DATA_TYPE) DATA_TYPE##16 1284*c217d954SCole Faust#define TILE_VECTOR_TYPE14(DATA_TYPE) DATA_TYPE##16 1285*c217d954SCole Faust#define TILE_VECTOR_TYPE15(DATA_TYPE) DATA_TYPE##16 1286*c217d954SCole Faust#define TILE_VECTOR_TYPE16(DATA_TYPE) DATA_TYPE##16 1287*c217d954SCole Faust 1288*c217d954SCole Faust 1289*c217d954SCole Faust#define TILE(DATA_TYPE, H, W, BASENAME) TILE_STR(DATA_TYPE, H, W, BASENAME) 1290*c217d954SCole Faust#define TILE_STR(DATA_TYPE, H, W, BASENAME) \ 1291*c217d954SCole Faust union { \ 1292*c217d954SCole Faust DATA_TYPE s[TILE_VECTOR_SIZE##W]; \ 1293*c217d954SCole Faust TILE_VECTOR_TYPE##W(DATA_TYPE) v; \ 1294*c217d954SCole Faust } BASENAME[H] 1295*c217d954SCole Faust 1296*c217d954SCole Faust#define TENSOR4D_IMAGE(name) \ 1297*c217d954SCole Faust __read_only image2d_t name##_img, \ 1298*c217d954SCole Faust __global uchar *name##_ptr, \ 1299*c217d954SCole Faust uint name##_stride_x, \ 1300*c217d954SCole Faust uint name##_step_x, \ 1301*c217d954SCole Faust uint name##_stride_y, \ 1302*c217d954SCole Faust uint name##_step_y, \ 1303*c217d954SCole Faust uint name##_stride_z, \ 1304*c217d954SCole Faust uint name##_step_z, \ 1305*c217d954SCole Faust uint name##_stride_w, \ 1306*c217d954SCole Faust uint name##_step_w, \ 1307*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1308*c217d954SCole Faust 1309*c217d954SCole Faust#define TENSOR4D_BUFFER(name) \ 1310*c217d954SCole Faust __global uchar *name##_ptr, \ 1311*c217d954SCole Faust uint name##_stride_x, \ 1312*c217d954SCole Faust uint name##_step_x, \ 1313*c217d954SCole Faust uint name##_stride_y, \ 1314*c217d954SCole Faust uint name##_step_y, \ 1315*c217d954SCole Faust uint name##_stride_z, \ 1316*c217d954SCole Faust uint name##_step_z, \ 1317*c217d954SCole Faust uint name##_stride_w, \ 1318*c217d954SCole Faust uint name##_step_w, \ 1319*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1320*c217d954SCole Faust 1321*c217d954SCole Faust#define TENSOR4D_STR(name, type) TENSOR4D_##type(name) 1322*c217d954SCole Faust#define TENSOR4D(name, type) TENSOR4D_STR(name, type) 1323*c217d954SCole Faust 1324*c217d954SCole Faust#define TENSOR4D_T_IMAGE(name) \ 1325*c217d954SCole Faust __read_only image2d_t name##_img, \ 1326*c217d954SCole Faust __global uchar *name##_ptr, \ 1327*c217d954SCole Faust uint name##_stride_y, \ 1328*c217d954SCole Faust uint name##_stride_z, \ 1329*c217d954SCole Faust uint name##_stride_w, \ 1330*c217d954SCole Faust uint name##_c, \ 1331*c217d954SCole Faust uint name##_w, \ 1332*c217d954SCole Faust uint name##_h, \ 1333*c217d954SCole Faust uint name##_n, \ 1334*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1335*c217d954SCole Faust 1336*c217d954SCole Faust#define TENSOR4D_T_BUFFER(name) \ 1337*c217d954SCole Faust __global uchar *name##_ptr, \ 1338*c217d954SCole Faust uint name##_stride_y, \ 1339*c217d954SCole Faust uint name##_stride_z, \ 1340*c217d954SCole Faust uint name##_stride_w, \ 1341*c217d954SCole Faust uint name##_c, \ 1342*c217d954SCole Faust uint name##_w, \ 1343*c217d954SCole Faust uint name##_h, \ 1344*c217d954SCole Faust uint name##_n, \ 1345*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1346*c217d954SCole Faust 1347*c217d954SCole Faust#define TENSOR4D_T_STR(name, type) TENSOR4D_T_##type(name) 1348*c217d954SCole Faust 1349*c217d954SCole Faust 1350*c217d954SCole Faust#define TENSOR4D_T(name, type) TENSOR4D_T_STR(name, type) 1351*c217d954SCole Faust 1352*c217d954SCole Faust#define TENSOR4D_RO_T_IMAGE(name) \ 1353*c217d954SCole Faust __read_only image2d_t name##_img, \ 1354*c217d954SCole Faust TENSOR4D_T_BUFFER(name) 1355*c217d954SCole Faust 1356*c217d954SCole Faust#define TENSOR4D_RO_T_BUFFER(name) TENSOR4D_T_BUFFER(name) 1357*c217d954SCole Faust 1358*c217d954SCole Faust#define TENSOR4D_RO_T_STR(name, type) TENSOR4D_RO_T_##type(name) 1359*c217d954SCole Faust 1360*c217d954SCole Faust 1361*c217d954SCole Faust#define TENSOR4D_RO_T(name, type) TENSOR4D_RO_T_STR(name, type) 1362*c217d954SCole Faust 1363*c217d954SCole Faust#define TENSOR4D_WO_T_IMAGE(name) \ 1364*c217d954SCole Faust __write_only image2d_t name##_img, \ 1365*c217d954SCole Faust TENSOR4D_T_BUFFER(name) 1366*c217d954SCole Faust 1367*c217d954SCole Faust#define TENSOR4D_WO_T_BUFFER(name) TENSOR4D_T_BUFFER(name) 1368*c217d954SCole Faust 1369*c217d954SCole Faust#define TENSOR4D_WO_T_STR(name, type) TENSOR4D_WO_T_##type(name) 1370*c217d954SCole Faust 1371*c217d954SCole Faust 1372*c217d954SCole Faust#define TENSOR4D_WO_T(name, type) TENSOR4D_WO_T_STR(name, type) 1373*c217d954SCole Faust 1374*c217d954SCole Faust#define TENSOR3D_T_IMAGE(name) \ 1375*c217d954SCole Faust __read_only image2d_t name##_img, \ 1376*c217d954SCole Faust __global uchar *name##_ptr, \ 1377*c217d954SCole Faust uint name##_stride_y, \ 1378*c217d954SCole Faust uint name##_stride_z, \ 1379*c217d954SCole Faust uint name##_w, \ 1380*c217d954SCole Faust uint name##_h, \ 1381*c217d954SCole Faust uint name##_n, \ 1382*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1383*c217d954SCole Faust 1384*c217d954SCole Faust#define TENSOR3D_T_BUFFER(name) \ 1385*c217d954SCole Faust __global uchar *name##_ptr, \ 1386*c217d954SCole Faust uint name##_stride_y, \ 1387*c217d954SCole Faust uint name##_stride_z, \ 1388*c217d954SCole Faust uint name##_w, \ 1389*c217d954SCole Faust uint name##_h, \ 1390*c217d954SCole Faust uint name##_n, \ 1391*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1392*c217d954SCole Faust 1393*c217d954SCole Faust#define TENSOR3D_T_STR(name, type) TENSOR3D_T_##type(name) 1394*c217d954SCole Faust#define TENSOR3D_T(name, type) TENSOR3D_T_STR(name, type) 1395*c217d954SCole Faust 1396*c217d954SCole Faust#if !defined(UNROLL_WITH_PRAGMA) 1397*c217d954SCole Faust#define UNROLL_INCR(idx, step, macro) idx += (step); (macro) 1398*c217d954SCole Faust 1399*c217d954SCole Faust#define LOOP_UNROLLING_1(idx, step, macro) (macro) 1400*c217d954SCole Faust#define LOOP_UNROLLING_2(idx, step, macro) LOOP_UNROLLING_1(idx, step, macro); UNROLL_INCR(idx, step, macro) 1401*c217d954SCole Faust#define LOOP_UNROLLING_3(idx, step, macro) LOOP_UNROLLING_2(idx, step, macro); UNROLL_INCR(idx, step, macro) 1402*c217d954SCole Faust#define LOOP_UNROLLING_4(idx, step, macro) LOOP_UNROLLING_3(idx, step, macro); UNROLL_INCR(idx, step, macro) 1403*c217d954SCole Faust#define LOOP_UNROLLING_5(idx, step, macro) LOOP_UNROLLING_4(idx, step, macro); UNROLL_INCR(idx, step, macro) 1404*c217d954SCole Faust#define LOOP_UNROLLING_6(idx, step, macro) LOOP_UNROLLING_5(idx, step, macro); UNROLL_INCR(idx, step, macro) 1405*c217d954SCole Faust#define LOOP_UNROLLING_7(idx, step, macro) LOOP_UNROLLING_6(idx, step, macro); UNROLL_INCR(idx, step, macro) 1406*c217d954SCole Faust#define LOOP_UNROLLING_8(idx, step, macro) LOOP_UNROLLING_7(idx, step, macro); UNROLL_INCR(idx, step, macro) 1407*c217d954SCole Faust#define LOOP_UNROLLING_9(idx, step, macro) LOOP_UNROLLING_8(idx, step, macro); UNROLL_INCR(idx, step, macro) 1408*c217d954SCole Faust#define LOOP_UNROLLING_10(idx, step, macro) LOOP_UNROLLING_9(idx, step, macro); UNROLL_INCR(idx, step, macro) 1409*c217d954SCole Faust#define LOOP_UNROLLING_11(idx, step, macro) LOOP_UNROLLING_10(idx, step, macro); UNROLL_INCR(idx, step, macro) 1410*c217d954SCole Faust#define LOOP_UNROLLING_12(idx, step, macro) LOOP_UNROLLING_11(idx, step, macro); UNROLL_INCR(idx, step, macro) 1411*c217d954SCole Faust#define LOOP_UNROLLING_13(idx, step, macro) LOOP_UNROLLING_12(idx, step, macro); UNROLL_INCR(idx, step, macro) 1412*c217d954SCole Faust#define LOOP_UNROLLING_14(idx, step, macro) LOOP_UNROLLING_13(idx, step, macro); UNROLL_INCR(idx, step, macro) 1413*c217d954SCole Faust#define LOOP_UNROLLING_15(idx, step, macro) LOOP_UNROLLING_14(idx, step, macro); UNROLL_INCR(idx, step, macro) 1414*c217d954SCole Faust#define LOOP_UNROLLING_16(idx, step, macro) LOOP_UNROLLING_15(idx, step, macro); UNROLL_INCR(idx, step, macro) 1415*c217d954SCole Faust#define LOOP_UNROLLING_17(idx, step, macro) LOOP_UNROLLING_16(idx, step, macro); UNROLL_INCR(idx, step, macro) 1416*c217d954SCole Faust#define LOOP_UNROLLING_18(idx, step, macro) LOOP_UNROLLING_17(idx, step, macro); UNROLL_INCR(idx, step, macro) 1417*c217d954SCole Faust#define LOOP_UNROLLING_19(idx, step, macro) LOOP_UNROLLING_18(idx, step, macro); UNROLL_INCR(idx, step, macro) 1418*c217d954SCole Faust#define LOOP_UNROLLING_20(idx, step, macro) LOOP_UNROLLING_19(idx, step, macro); UNROLL_INCR(idx, step, macro) 1419*c217d954SCole Faust#define LOOP_UNROLLING_21(idx, step, macro) LOOP_UNROLLING_20(idx, step, macro); UNROLL_INCR(idx, step, macro) 1420*c217d954SCole Faust#define LOOP_UNROLLING_22(idx, step, macro) LOOP_UNROLLING_21(idx, step, macro); UNROLL_INCR(idx, step, macro) 1421*c217d954SCole Faust#define LOOP_UNROLLING_23(idx, step, macro) LOOP_UNROLLING_22(idx, step, macro); UNROLL_INCR(idx, step, macro) 1422*c217d954SCole Faust#define LOOP_UNROLLING_24(idx, step, macro) LOOP_UNROLLING_23(idx, step, macro); UNROLL_INCR(idx, step, macro) 1423*c217d954SCole Faust#define LOOP_UNROLLING_25(idx, step, macro) LOOP_UNROLLING_24(idx, step, macro); UNROLL_INCR(idx, step, macro) 1424*c217d954SCole Faust#define LOOP_UNROLLING_26(idx, step, macro) LOOP_UNROLLING_25(idx, step, macro); UNROLL_INCR(idx, step, macro) 1425*c217d954SCole Faust#define LOOP_UNROLLING_27(idx, step, macro) LOOP_UNROLLING_26(idx, step, macro); UNROLL_INCR(idx, step, macro) 1426*c217d954SCole Faust#define LOOP_UNROLLING_28(idx, step, macro) LOOP_UNROLLING_27(idx, step, macro); UNROLL_INCR(idx, step, macro) 1427*c217d954SCole Faust#define LOOP_UNROLLING_29(idx, step, macro) LOOP_UNROLLING_28(idx, step, macro); UNROLL_INCR(idx, step, macro) 1428*c217d954SCole Faust#define LOOP_UNROLLING_30(idx, step, macro) LOOP_UNROLLING_29(idx, step, macro); UNROLL_INCR(idx, step, macro) 1429*c217d954SCole Faust#define LOOP_UNROLLING_31(idx, step, macro) LOOP_UNROLLING_30(idx, step, macro); UNROLL_INCR(idx, step, macro) 1430*c217d954SCole Faust#define LOOP_UNROLLING_32(idx, step, macro) LOOP_UNROLLING_31(idx, step, macro); UNROLL_INCR(idx, step, macro) 1431*c217d954SCole Faust#define LOOP_UNROLLING_33(idx, step, macro) LOOP_UNROLLING_32(idx, step, macro); UNROLL_INCR(idx, step, macro) 1432*c217d954SCole Faust#define LOOP_UNROLLING_34(idx, step, macro) LOOP_UNROLLING_33(idx, step, macro); UNROLL_INCR(idx, step, macro) 1433*c217d954SCole Faust#define LOOP_UNROLLING_35(idx, step, macro) LOOP_UNROLLING_34(idx, step, macro); UNROLL_INCR(idx, step, macro) 1434*c217d954SCole Faust#define LOOP_UNROLLING_36(idx, step, macro) LOOP_UNROLLING_35(idx, step, macro); UNROLL_INCR(idx, step, macro) 1435*c217d954SCole Faust#define LOOP_UNROLLING_37(idx, step, macro) LOOP_UNROLLING_36(idx, step, macro); UNROLL_INCR(idx, step, macro) 1436*c217d954SCole Faust#define LOOP_UNROLLING_38(idx, step, macro) LOOP_UNROLLING_37(idx, step, macro); UNROLL_INCR(idx, step, macro) 1437*c217d954SCole Faust#define LOOP_UNROLLING_39(idx, step, macro) LOOP_UNROLLING_38(idx, step, macro); UNROLL_INCR(idx, step, macro) 1438*c217d954SCole Faust#define LOOP_UNROLLING_40(idx, step, macro) LOOP_UNROLLING_39(idx, step, macro); UNROLL_INCR(idx, step, macro) 1439*c217d954SCole Faust#define LOOP_UNROLLING_41(idx, step, macro) LOOP_UNROLLING_40(idx, step, macro); UNROLL_INCR(idx, step, macro) 1440*c217d954SCole Faust#define LOOP_UNROLLING_42(idx, step, macro) LOOP_UNROLLING_41(idx, step, macro); UNROLL_INCR(idx, step, macro) 1441*c217d954SCole Faust#define LOOP_UNROLLING_43(idx, step, macro) LOOP_UNROLLING_42(idx, step, macro); UNROLL_INCR(idx, step, macro) 1442*c217d954SCole Faust#define LOOP_UNROLLING_44(idx, step, macro) LOOP_UNROLLING_43(idx, step, macro); UNROLL_INCR(idx, step, macro) 1443*c217d954SCole Faust#define LOOP_UNROLLING_45(idx, step, macro) LOOP_UNROLLING_44(idx, step, macro); UNROLL_INCR(idx, step, macro) 1444*c217d954SCole Faust#define LOOP_UNROLLING_46(idx, step, macro) LOOP_UNROLLING_45(idx, step, macro); UNROLL_INCR(idx, step, macro) 1445*c217d954SCole Faust#define LOOP_UNROLLING_47(idx, step, macro) LOOP_UNROLLING_46(idx, step, macro); UNROLL_INCR(idx, step, macro) 1446*c217d954SCole Faust#define LOOP_UNROLLING_48(idx, step, macro) LOOP_UNROLLING_47(idx, step, macro); UNROLL_INCR(idx, step, macro) 1447*c217d954SCole Faust#define LOOP_UNROLLING_49(idx, step, macro) LOOP_UNROLLING_48(idx, step, macro); UNROLL_INCR(idx, step, macro) 1448*c217d954SCole Faust#define LOOP_UNROLLING_50(idx, step, macro) LOOP_UNROLLING_49(idx, step, macro); UNROLL_INCR(idx, step, macro) 1449*c217d954SCole Faust#define LOOP_UNROLLING_51(idx, step, macro) LOOP_UNROLLING_50(idx, step, macro); UNROLL_INCR(idx, step, macro) 1450*c217d954SCole Faust#define LOOP_UNROLLING_52(idx, step, macro) LOOP_UNROLLING_51(idx, step, macro); UNROLL_INCR(idx, step, macro) 1451*c217d954SCole Faust#define LOOP_UNROLLING_53(idx, step, macro) LOOP_UNROLLING_52(idx, step, macro); UNROLL_INCR(idx, step, macro) 1452*c217d954SCole Faust#define LOOP_UNROLLING_54(idx, step, macro) LOOP_UNROLLING_53(idx, step, macro); UNROLL_INCR(idx, step, macro) 1453*c217d954SCole Faust#define LOOP_UNROLLING_55(idx, step, macro) LOOP_UNROLLING_54(idx, step, macro); UNROLL_INCR(idx, step, macro) 1454*c217d954SCole Faust#define LOOP_UNROLLING_56(idx, step, macro) LOOP_UNROLLING_55(idx, step, macro); UNROLL_INCR(idx, step, macro) 1455*c217d954SCole Faust#define LOOP_UNROLLING_57(idx, step, macro) LOOP_UNROLLING_56(idx, step, macro); UNROLL_INCR(idx, step, macro) 1456*c217d954SCole Faust#define LOOP_UNROLLING_58(idx, step, macro) LOOP_UNROLLING_57(idx, step, macro); UNROLL_INCR(idx, step, macro) 1457*c217d954SCole Faust#define LOOP_UNROLLING_59(idx, step, macro) LOOP_UNROLLING_58(idx, step, macro); UNROLL_INCR(idx, step, macro) 1458*c217d954SCole Faust#define LOOP_UNROLLING_60(idx, step, macro) LOOP_UNROLLING_59(idx, step, macro); UNROLL_INCR(idx, step, macro) 1459*c217d954SCole Faust#define LOOP_UNROLLING_61(idx, step, macro) LOOP_UNROLLING_60(idx, step, macro); UNROLL_INCR(idx, step, macro) 1460*c217d954SCole Faust#define LOOP_UNROLLING_62(idx, step, macro) LOOP_UNROLLING_61(idx, step, macro); UNROLL_INCR(idx, step, macro) 1461*c217d954SCole Faust#define LOOP_UNROLLING_63(idx, step, macro) LOOP_UNROLLING_62(idx, step, macro); UNROLL_INCR(idx, step, macro) 1462*c217d954SCole Faust#define LOOP_UNROLLING_64(idx, step, macro) LOOP_UNROLLING_63(idx, step, macro); UNROLL_INCR(idx, step, macro) 1463*c217d954SCole Faust#define LOOP_UNROLLING_65(idx, step, macro) LOOP_UNROLLING_64(idx, step, macro); UNROLL_INCR(idx, step, macro) 1464*c217d954SCole Faust#define LOOP_UNROLLING_66(idx, step, macro) LOOP_UNROLLING_65(idx, step, macro); UNROLL_INCR(idx, step, macro) 1465*c217d954SCole Faust#define LOOP_UNROLLING_67(idx, step, macro) LOOP_UNROLLING_66(idx, step, macro); UNROLL_INCR(idx, step, macro) 1466*c217d954SCole Faust#define LOOP_UNROLLING_68(idx, step, macro) LOOP_UNROLLING_67(idx, step, macro); UNROLL_INCR(idx, step, macro) 1467*c217d954SCole Faust#define LOOP_UNROLLING_69(idx, step, macro) LOOP_UNROLLING_68(idx, step, macro); UNROLL_INCR(idx, step, macro) 1468*c217d954SCole Faust#define LOOP_UNROLLING_70(idx, step, macro) LOOP_UNROLLING_69(idx, step, macro); UNROLL_INCR(idx, step, macro) 1469*c217d954SCole Faust#define LOOP_UNROLLING_71(idx, step, macro) LOOP_UNROLLING_70(idx, step, macro); UNROLL_INCR(idx, step, macro) 1470*c217d954SCole Faust#define LOOP_UNROLLING_72(idx, step, macro) LOOP_UNROLLING_71(idx, step, macro); UNROLL_INCR(idx, step, macro) 1471*c217d954SCole Faust#define LOOP_UNROLLING_73(idx, step, macro) LOOP_UNROLLING_72(idx, step, macro); UNROLL_INCR(idx, step, macro) 1472*c217d954SCole Faust#define LOOP_UNROLLING_74(idx, step, macro) LOOP_UNROLLING_73(idx, step, macro); UNROLL_INCR(idx, step, macro) 1473*c217d954SCole Faust#define LOOP_UNROLLING_75(idx, step, macro) LOOP_UNROLLING_74(idx, step, macro); UNROLL_INCR(idx, step, macro) 1474*c217d954SCole Faust#define LOOP_UNROLLING_76(idx, step, macro) LOOP_UNROLLING_75(idx, step, macro); UNROLL_INCR(idx, step, macro) 1475*c217d954SCole Faust#define LOOP_UNROLLING_77(idx, step, macro) LOOP_UNROLLING_76(idx, step, macro); UNROLL_INCR(idx, step, macro) 1476*c217d954SCole Faust#define LOOP_UNROLLING_78(idx, step, macro) LOOP_UNROLLING_77(idx, step, macro); UNROLL_INCR(idx, step, macro) 1477*c217d954SCole Faust#define LOOP_UNROLLING_79(idx, step, macro) LOOP_UNROLLING_78(idx, step, macro); UNROLL_INCR(idx, step, macro) 1478*c217d954SCole Faust#define LOOP_UNROLLING_80(idx, step, macro) LOOP_UNROLLING_79(idx, step, macro); UNROLL_INCR(idx, step, macro) 1479*c217d954SCole Faust#define LOOP_UNROLLING_81(idx, step, macro) LOOP_UNROLLING_80(idx, step, macro); UNROLL_INCR(idx, step, macro) 1480*c217d954SCole Faust#define LOOP_UNROLLING_82(idx, step, macro) LOOP_UNROLLING_81(idx, step, macro); UNROLL_INCR(idx, step, macro) 1481*c217d954SCole Faust#define LOOP_UNROLLING_83(idx, step, macro) LOOP_UNROLLING_82(idx, step, macro); UNROLL_INCR(idx, step, macro) 1482*c217d954SCole Faust#define LOOP_UNROLLING_84(idx, step, macro) LOOP_UNROLLING_83(idx, step, macro); UNROLL_INCR(idx, step, macro) 1483*c217d954SCole Faust#define LOOP_UNROLLING_85(idx, step, macro) LOOP_UNROLLING_84(idx, step, macro); UNROLL_INCR(idx, step, macro) 1484*c217d954SCole Faust#define LOOP_UNROLLING_86(idx, step, macro) LOOP_UNROLLING_85(idx, step, macro); UNROLL_INCR(idx, step, macro) 1485*c217d954SCole Faust#define LOOP_UNROLLING_87(idx, step, macro) LOOP_UNROLLING_86(idx, step, macro); UNROLL_INCR(idx, step, macro) 1486*c217d954SCole Faust#define LOOP_UNROLLING_88(idx, step, macro) LOOP_UNROLLING_87(idx, step, macro); UNROLL_INCR(idx, step, macro) 1487*c217d954SCole Faust#define LOOP_UNROLLING_89(idx, step, macro) LOOP_UNROLLING_88(idx, step, macro); UNROLL_INCR(idx, step, macro) 1488*c217d954SCole Faust#define LOOP_UNROLLING_90(idx, step, macro) LOOP_UNROLLING_89(idx, step, macro); UNROLL_INCR(idx, step, macro) 1489*c217d954SCole Faust#define LOOP_UNROLLING_91(idx, step, macro) LOOP_UNROLLING_90(idx, step, macro); UNROLL_INCR(idx, step, macro) 1490*c217d954SCole Faust#define LOOP_UNROLLING_92(idx, step, macro) LOOP_UNROLLING_91(idx, step, macro); UNROLL_INCR(idx, step, macro) 1491*c217d954SCole Faust#define LOOP_UNROLLING_93(idx, step, macro) LOOP_UNROLLING_92(idx, step, macro); UNROLL_INCR(idx, step, macro) 1492*c217d954SCole Faust#define LOOP_UNROLLING_94(idx, step, macro) LOOP_UNROLLING_93(idx, step, macro); UNROLL_INCR(idx, step, macro) 1493*c217d954SCole Faust#define LOOP_UNROLLING_95(idx, step, macro) LOOP_UNROLLING_94(idx, step, macro); UNROLL_INCR(idx, step, macro) 1494*c217d954SCole Faust#define LOOP_UNROLLING_96(idx, step, macro) LOOP_UNROLLING_95(idx, step, macro); UNROLL_INCR(idx, step, macro) 1495*c217d954SCole Faust#define LOOP_UNROLLING_97(idx, step, macro) LOOP_UNROLLING_96(idx, step, macro); UNROLL_INCR(idx, step, macro) 1496*c217d954SCole Faust#define LOOP_UNROLLING_98(idx, step, macro) LOOP_UNROLLING_97(idx, step, macro); UNROLL_INCR(idx, step, macro) 1497*c217d954SCole Faust#define LOOP_UNROLLING_99(idx, step, macro) LOOP_UNROLLING_98(idx, step, macro); UNROLL_INCR(idx, step, macro) 1498*c217d954SCole Faust#define LOOP_UNROLLING_100(idx, step, macro) LOOP_UNROLLING_99(idx, step, macro); UNROLL_INCR(idx, step, macro) 1499*c217d954SCole Faust#define LOOP_UNROLLING_101(idx, step, macro) LOOP_UNROLLING_100(idx, step, macro); UNROLL_INCR(idx, step, macro) 1500*c217d954SCole Faust#define LOOP_UNROLLING_102(idx, step, macro) LOOP_UNROLLING_101(idx, step, macro); UNROLL_INCR(idx, step, macro) 1501*c217d954SCole Faust#define LOOP_UNROLLING_103(idx, step, macro) LOOP_UNROLLING_102(idx, step, macro); UNROLL_INCR(idx, step, macro) 1502*c217d954SCole Faust#define LOOP_UNROLLING_104(idx, step, macro) LOOP_UNROLLING_103(idx, step, macro); UNROLL_INCR(idx, step, macro) 1503*c217d954SCole Faust#define LOOP_UNROLLING_105(idx, step, macro) LOOP_UNROLLING_104(idx, step, macro); UNROLL_INCR(idx, step, macro) 1504*c217d954SCole Faust#define LOOP_UNROLLING_106(idx, step, macro) LOOP_UNROLLING_105(idx, step, macro); UNROLL_INCR(idx, step, macro) 1505*c217d954SCole Faust#define LOOP_UNROLLING_107(idx, step, macro) LOOP_UNROLLING_106(idx, step, macro); UNROLL_INCR(idx, step, macro) 1506*c217d954SCole Faust#define LOOP_UNROLLING_108(idx, step, macro) LOOP_UNROLLING_107(idx, step, macro); UNROLL_INCR(idx, step, macro) 1507*c217d954SCole Faust#define LOOP_UNROLLING_109(idx, step, macro) LOOP_UNROLLING_108(idx, step, macro); UNROLL_INCR(idx, step, macro) 1508*c217d954SCole Faust#define LOOP_UNROLLING_110(idx, step, macro) LOOP_UNROLLING_109(idx, step, macro); UNROLL_INCR(idx, step, macro) 1509*c217d954SCole Faust#define LOOP_UNROLLING_111(idx, step, macro) LOOP_UNROLLING_110(idx, step, macro); UNROLL_INCR(idx, step, macro) 1510*c217d954SCole Faust#define LOOP_UNROLLING_112(idx, step, macro) LOOP_UNROLLING_111(idx, step, macro); UNROLL_INCR(idx, step, macro) 1511*c217d954SCole Faust#define LOOP_UNROLLING_113(idx, step, macro) LOOP_UNROLLING_112(idx, step, macro); UNROLL_INCR(idx, step, macro) 1512*c217d954SCole Faust#define LOOP_UNROLLING_114(idx, step, macro) LOOP_UNROLLING_113(idx, step, macro); UNROLL_INCR(idx, step, macro) 1513*c217d954SCole Faust#define LOOP_UNROLLING_115(idx, step, macro) LOOP_UNROLLING_114(idx, step, macro); UNROLL_INCR(idx, step, macro) 1514*c217d954SCole Faust#define LOOP_UNROLLING_116(idx, step, macro) LOOP_UNROLLING_115(idx, step, macro); UNROLL_INCR(idx, step, macro) 1515*c217d954SCole Faust#define LOOP_UNROLLING_117(idx, step, macro) LOOP_UNROLLING_116(idx, step, macro); UNROLL_INCR(idx, step, macro) 1516*c217d954SCole Faust#define LOOP_UNROLLING_118(idx, step, macro) LOOP_UNROLLING_117(idx, step, macro); UNROLL_INCR(idx, step, macro) 1517*c217d954SCole Faust#define LOOP_UNROLLING_119(idx, step, macro) LOOP_UNROLLING_118(idx, step, macro); UNROLL_INCR(idx, step, macro) 1518*c217d954SCole Faust#define LOOP_UNROLLING_120(idx, step, macro) LOOP_UNROLLING_119(idx, step, macro); UNROLL_INCR(idx, step, macro) 1519*c217d954SCole Faust#define LOOP_UNROLLING_121(idx, step, macro) LOOP_UNROLLING_120(idx, step, macro); UNROLL_INCR(idx, step, macro) 1520*c217d954SCole Faust#define LOOP_UNROLLING_122(idx, step, macro) LOOP_UNROLLING_121(idx, step, macro); UNROLL_INCR(idx, step, macro) 1521*c217d954SCole Faust#define LOOP_UNROLLING_123(idx, step, macro) LOOP_UNROLLING_122(idx, step, macro); UNROLL_INCR(idx, step, macro) 1522*c217d954SCole Faust#define LOOP_UNROLLING_124(idx, step, macro) LOOP_UNROLLING_123(idx, step, macro); UNROLL_INCR(idx, step, macro) 1523*c217d954SCole Faust#define LOOP_UNROLLING_125(idx, step, macro) LOOP_UNROLLING_124(idx, step, macro); UNROLL_INCR(idx, step, macro) 1524*c217d954SCole Faust#define LOOP_UNROLLING_126(idx, step, macro) LOOP_UNROLLING_125(idx, step, macro); UNROLL_INCR(idx, step, macro) 1525*c217d954SCole Faust#define LOOP_UNROLLING_127(idx, step, macro) LOOP_UNROLLING_126(idx, step, macro); UNROLL_INCR(idx, step, macro) 1526*c217d954SCole Faust#define LOOP_UNROLLING_128(idx, step, macro) LOOP_UNROLLING_127(idx, step, macro); UNROLL_INCR(idx, step, macro) 1527*c217d954SCole Faust 1528*c217d954SCole Faust#define LOOP_UNROLLING_STR(type, idx, start, step, num, macro) \ 1529*c217d954SCole Faust { \ 1530*c217d954SCole Faust type idx = start; \ 1531*c217d954SCole Faust LOOP_UNROLLING_##num(idx, step, macro); \ 1532*c217d954SCole Faust } 1533*c217d954SCole Faust#else 1534*c217d954SCole Faust#define LOOP_UNROLLING_STR(type, idx, start, step, num, macro) \ 1535*c217d954SCole Faust { \ 1536*c217d954SCole Faust _Pragma("unroll") \ 1537*c217d954SCole Faust for(type idx = start; idx < (num * step); idx += step) \ 1538*c217d954SCole Faust { \ 1539*c217d954SCole Faust (macro); \ 1540*c217d954SCole Faust } \ 1541*c217d954SCole Faust } 1542*c217d954SCole Faust#endif 1543*c217d954SCole Faust#define LOOP_UNROLLING(type, idx, start, step, num, macro) LOOP_UNROLLING_STR(type, idx, start, step, num, macro) 1544*c217d954SCole Faust 1545*c217d954SCole Faust 1546*c217d954SCole Faust#define GET_SPATIAL_IDX(IDX, N0, PARTIAL_N0) (max((int)(get_global_id(IDX) * N0 - (N0 - PARTIAL_N0) % N0), 0)) 1547*c217d954SCole Faust 1548*c217d954SCole Faust 1549*c217d954SCole Faust#define DOT_PRODUCT_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, K0, a, b, c) DOT_PRODUCT_INTEGER8_STR(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, K0, a, b, c) 1550*c217d954SCole Faust#define DOT_PRODUCT_INTEGER8_STR(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, K0, a, b, c) DOT_PRODUCT##K0##_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) 1551*c217d954SCole Faust#define DOT_PRODUCT1_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1552*c217d954SCole Faust ({ \ 1553*c217d954SCole Faust c += (C_DATA_TYPE)(a) * (C_DATA_TYPE)(b); \ 1554*c217d954SCole Faust }) 1555*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ENABLED) && defined(cl_khr_integer_dot_product) 1556*c217d954SCole Faust#define DOT_PRODUCT2_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c += dot((A_DATA_TYPE##4)((a).s01, (A_DATA_TYPE##2)(0)), (B_DATA_TYPE##4)(((b).s01), (B_DATA_TYPE##2)(0))); 1557*c217d954SCole Faust#define DOT_PRODUCT3_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c += dot((A_DATA_TYPE##4)((a).s012, (A_DATA_TYPE)0), (B_DATA_TYPE##4)(((b).s012), (B_DATA_TYPE)0)); 1558*c217d954SCole Faust#define DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c += dot((a), (b)); 1559*c217d954SCole Faust#elif defined(ARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED) && defined(cl_arm_integer_dot_product_accumulate_int8) 1560*c217d954SCole Faust#define DOT_PRODUCT2_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c = arm_dot_acc((A_DATA_TYPE##4)((a).s01, (A_DATA_TYPE##2)(0)), (B_DATA_TYPE##4)(((b).s01), (B_DATA_TYPE##2)(0)), (c)); 1561*c217d954SCole Faust#define DOT_PRODUCT3_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c = arm_dot_acc((A_DATA_TYPE##4)((a).s012, (A_DATA_TYPE)0), (B_DATA_TYPE##4)(((b).s012), (B_DATA_TYPE)0), (c)); 1562*c217d954SCole Faust#define DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c = arm_dot_acc((a), (b), (c)); 1563*c217d954SCole Faust#elif defined(ARM_COMPUTE_OPENCL_DOT8_ENABLED) && defined(cl_arm_integer_dot_product_int8) 1564*c217d954SCole Faust#define DOT_PRODUCT2_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c += arm_dot((A_DATA_TYPE##4)((a).s01, (A_DATA_TYPE##2)(0)), (B_DATA_TYPE##4)(((b).s01), (B_DATA_TYPE##2)(0))); 1565*c217d954SCole Faust#define DOT_PRODUCT3_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c += arm_dot((A_DATA_TYPE##4)((a).s012, (A_DATA_TYPE)0), (B_DATA_TYPE##4)(((b).s012), (B_DATA_TYPE)0)); 1566*c217d954SCole Faust#define DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) c += arm_dot((a), (b)); 1567*c217d954SCole Faust#else 1568*c217d954SCole Faust#define DOT_PRODUCT2_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1569*c217d954SCole Faust ({ \ 1570*c217d954SCole Faust c += (C_DATA_TYPE)(a).s0 * (C_DATA_TYPE)(b).s0; \ 1571*c217d954SCole Faust c += (C_DATA_TYPE)(a).s1 * (C_DATA_TYPE)(b).s1; \ 1572*c217d954SCole Faust }) 1573*c217d954SCole Faust#define DOT_PRODUCT3_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1574*c217d954SCole Faust ({ \ 1575*c217d954SCole Faust DOT_PRODUCT2_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c); \ 1576*c217d954SCole Faust c += (C_DATA_TYPE)(a).s2 * (C_DATA_TYPE)(b).s2; \ 1577*c217d954SCole Faust }) 1578*c217d954SCole Faust#define DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, x, y, val) \ 1579*c217d954SCole Faust ({ \ 1580*c217d954SCole Faust val += (C_DATA_TYPE)(x).s0 * (C_DATA_TYPE)(y).s0; \ 1581*c217d954SCole Faust val += (C_DATA_TYPE)(x).s1 * (C_DATA_TYPE)(y).s1; \ 1582*c217d954SCole Faust val += (C_DATA_TYPE)(x).s2 * (C_DATA_TYPE)(y).s2; \ 1583*c217d954SCole Faust val += (C_DATA_TYPE)(x).s3 * (C_DATA_TYPE)(y).s3; \ 1584*c217d954SCole Faust }) 1585*c217d954SCole Faust#endif 1586*c217d954SCole Faust#define DOT_PRODUCT5_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1587*c217d954SCole Faust ({ \ 1588*c217d954SCole Faust DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s0123), ((b).s0123), c); \ 1589*c217d954SCole Faust DOT_PRODUCT1_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s4), ((b).s4), c); \ 1590*c217d954SCole Faust }) 1591*c217d954SCole Faust#define DOT_PRODUCT6_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1592*c217d954SCole Faust ({ \ 1593*c217d954SCole Faust DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s0123), ((b).s0123), c); \ 1594*c217d954SCole Faust DOT_PRODUCT2_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s45), ((b).s45), c); \ 1595*c217d954SCole Faust }) 1596*c217d954SCole Faust#define DOT_PRODUCT7_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1597*c217d954SCole Faust ({ \ 1598*c217d954SCole Faust DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s0123), ((b).s0123), c); \ 1599*c217d954SCole Faust DOT_PRODUCT3_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s456), ((b).s456), c); \ 1600*c217d954SCole Faust }) 1601*c217d954SCole Faust#define DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1602*c217d954SCole Faust ({ \ 1603*c217d954SCole Faust DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).lo), ((b).lo), c); \ 1604*c217d954SCole Faust DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).hi), ((b).hi), c); \ 1605*c217d954SCole Faust }) 1606*c217d954SCole Faust#define DOT_PRODUCT9_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1607*c217d954SCole Faust ({ \ 1608*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s01234567), ((b).s01234567), c); \ 1609*c217d954SCole Faust DOT_PRODUCT1_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s8), ((b).s8), c); \ 1610*c217d954SCole Faust }) 1611*c217d954SCole Faust#define DOT_PRODUCT10_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1612*c217d954SCole Faust ({ \ 1613*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s01234567), ((b).s01234567), c); \ 1614*c217d954SCole Faust DOT_PRODUCT2_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s89), ((b).s89), c); \ 1615*c217d954SCole Faust }) 1616*c217d954SCole Faust#define DOT_PRODUCT11_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1617*c217d954SCole Faust ({ \ 1618*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s01234567), ((b).s01234567), c); \ 1619*c217d954SCole Faust DOT_PRODUCT3_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s89A), ((b).s89A), c); \ 1620*c217d954SCole Faust }) 1621*c217d954SCole Faust#define DOT_PRODUCT12_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1622*c217d954SCole Faust ({ \ 1623*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s01234567), ((b).s01234567), c); \ 1624*c217d954SCole Faust DOT_PRODUCT4_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s89AB), ((b).s89AB), c); \ 1625*c217d954SCole Faust }) 1626*c217d954SCole Faust#define DOT_PRODUCT13_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1627*c217d954SCole Faust ({ \ 1628*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s01234567), ((b).s01234567), c); \ 1629*c217d954SCole Faust DOT_PRODUCT5_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s89ABC), ((b).s89ABC), c); \ 1630*c217d954SCole Faust }) 1631*c217d954SCole Faust#define DOT_PRODUCT14_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1632*c217d954SCole Faust ({ \ 1633*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s01234567), ((b).s01234567), c); \ 1634*c217d954SCole Faust DOT_PRODUCT6_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s89ABCD), ((b).s89ABCD), c); \ 1635*c217d954SCole Faust }) 1636*c217d954SCole Faust#define DOT_PRODUCT15_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1637*c217d954SCole Faust ({ \ 1638*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s01234567), ((b).s01234567), c); \ 1639*c217d954SCole Faust DOT_PRODUCT7_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).s89ABCDE), ((b).s89ABCDE), c); \ 1640*c217d954SCole Faust }) 1641*c217d954SCole Faust#define DOT_PRODUCT16_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, a, b, c) \ 1642*c217d954SCole Faust ({ \ 1643*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).lo), ((b).lo), c); \ 1644*c217d954SCole Faust DOT_PRODUCT8_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, ((a).hi), ((b).hi), c); \ 1645*c217d954SCole Faust }) 1646*c217d954SCole Faust 1647*c217d954SCole Faust 1648*c217d954SCole Faust#define REDUCE_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, K0, a, c) REDUCE_INTEGER8_STR(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, K0, a, c) 1649*c217d954SCole Faust#define REDUCE_INTEGER8_STR(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, K0, a, c) DOT_PRODUCT_INTEGER8(A_DATA_TYPE, B_DATA_TYPE, C_DATA_TYPE, K0, a, (TILE_VECTOR_TYPE##K0(B_DATA_TYPE))1, c) 1650*c217d954SCole Faust 1651*c217d954SCole Faust 1652*c217d954SCole Faust#define V_LOAD(DATA_TYPE, WIDTH, TENSOR_TYPE, TENSOR, X, Y, STRIDE_Y) V_LOAD_STR(DATA_TYPE, WIDTH, TENSOR_TYPE, TENSOR, X, Y, STRIDE_Y) 1653*c217d954SCole Faust#define V_LOAD_STR(DATA_TYPE, WIDTH, TENSOR_TYPE, TENSOR, X, Y, STRIDE_Y) V_LOAD_##TENSOR_TYPE(DATA_TYPE, WIDTH, TENSOR, X, Y, STRIDE_Y) 1654*c217d954SCole Faust#define V_LOAD_BUFFER(DATA_TYPE, WIDTH, TENSOR, X, Y, STRIDE_Y) \ 1655*c217d954SCole Faust VLOAD(WIDTH) \ 1656*c217d954SCole Faust (0, (__global DATA_TYPE *)(TENSOR##_ptr + TENSOR##_offset_first_element_in_bytes + (X) * sizeof(DATA_TYPE) + (Y) * (STRIDE_Y))) 1657*c217d954SCole Faust#define V_LOAD_IMAGE(DATA_TYPE, WIDTH, TENSOR, X, Y, STRIDE_Y) READ_IMAGE2D(DATA_TYPE, CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT(WIDTH), TENSOR##_img, (X) / 4, (Y)) 1658*c217d954SCole Faust 1659*c217d954SCole Faust 1660*c217d954SCole Faust#define V_STORE(DATA_TYPE, WIDTH, TENSOR_TYPE, TENSOR, X, Y, STRIDE_Y, VALUES) V_STORE_STR(DATA_TYPE, WIDTH, TENSOR_TYPE, TENSOR, X, Y, STRIDE_Y, VALUES) 1661*c217d954SCole Faust#define V_STORE_STR(DATA_TYPE, WIDTH, TENSOR_TYPE, TENSOR, X, Y, STRIDE_Y, VALUES) V_STORE_##TENSOR_TYPE(DATA_TYPE, WIDTH, TENSOR, X, Y, STRIDE_Y, VALUES) 1662*c217d954SCole Faust#define V_STORE_BUFFER(DATA_TYPE, WIDTH, TENSOR, X, Y, STRIDE_Y, VALUES) \ 1663*c217d954SCole Faust VSTORE(WIDTH) \ 1664*c217d954SCole Faust (VALUES, 0, (__global DATA_TYPE *)(TENSOR##_ptr + TENSOR##_offset_first_element_in_bytes + (X) * sizeof(DATA_TYPE) + (Y) * (STRIDE_Y))) 1665*c217d954SCole Faust#define V_STORE_IMAGE(DATA_TYPE, WIDTH, TENSOR, X, Y, STRIDE_Y, VALUES) WRITE_IMAGE2D(DATA_TYPE, CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT(WIDTH), TENSOR##_img, (X) / 4, (Y), VALUES) 1666*c217d954SCole Faust 1667*c217d954SCole Faust 1668*c217d954SCole Faust#define T_LOAD(DATA_TYPE, HEIGHT, WIDTH, TENSOR_TYPE, TENSOR, X, Y, YI_MULTIPLIER, STRIDE_Y, dst) \ 1669*c217d954SCole Faust ({ \ 1670*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, HEIGHT, \ 1671*c217d954SCole Faust { \ 1672*c217d954SCole Faust dst[_i].v = V_LOAD(DATA_TYPE, WIDTH, TENSOR_TYPE, TENSOR, X, ((Y) + _i * (int)(YI_MULTIPLIER)), STRIDE_Y); \ 1673*c217d954SCole Faust }) \ 1674*c217d954SCole Faust }) 1675*c217d954SCole Faust 1676*c217d954SCole Faust 1677*c217d954SCole Faust#define T_LOAD_INDIRECT(DATA_TYPE, HEIGHT, WIDTH, TENSOR_TYPE, TENSOR, X, STRIDE_Y, indirect_y, dst) \ 1678*c217d954SCole Faust ({ \ 1679*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, HEIGHT, \ 1680*c217d954SCole Faust { \ 1681*c217d954SCole Faust dst[_i].v = V_LOAD(DATA_TYPE, WIDTH, TENSOR_TYPE, TENSOR, X, (indirect_y[_i].v), STRIDE_Y); \ 1682*c217d954SCole Faust }) \ 1683*c217d954SCole Faust }) 1684*c217d954SCole Faust 1685*c217d954SCole Faust 1686*c217d954SCole Faust#define T_LOAD_INDIRECT_WIDTH_SELECT(DATA_TYPE, HEIGHT, WIDTH0, WIDTH1, TENSOR_TYPE, TENSOR, X, STRIDE_Y, WIDTH1_CONDITION, dst, indirect_y) \ 1687*c217d954SCole Faust ({ \ 1688*c217d954SCole Faust if(WIDTH1_CONDITION) \ 1689*c217d954SCole Faust { \ 1690*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, HEIGHT, \ 1691*c217d954SCole Faust { \ 1692*c217d954SCole Faust VLOAD_PARTIAL(WIDTH0, WIDTH1) \ 1693*c217d954SCole Faust (dst[HEIGHT - 1 - _i].v, 0, (__global DATA_TYPE *)(TENSOR##_ptr + TENSOR##_offset_first_element_in_bytes + (X) * sizeof(DATA_TYPE) + (indirect_y[HEIGHT - 1 - _i].v) * STRIDE_Y)); \ 1694*c217d954SCole Faust }) \ 1695*c217d954SCole Faust } \ 1696*c217d954SCole Faust else \ 1697*c217d954SCole Faust { \ 1698*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, HEIGHT, \ 1699*c217d954SCole Faust { \ 1700*c217d954SCole Faust dst[HEIGHT - 1 - _i].v = V_LOAD(DATA_TYPE, WIDTH0, TENSOR_TYPE, TENSOR, X, (indirect_y[HEIGHT - 1 - _i].v), STRIDE_Y); \ 1701*c217d954SCole Faust }) \ 1702*c217d954SCole Faust } \ 1703*c217d954SCole Faust }) 1704*c217d954SCole Faust 1705*c217d954SCole Faust#define T_LOAD_NHWC(DATA_TYPE, TILE_HEIGHT, TILE_WIDTH, TILE_CHANNELS, TENSOR_TYPE, TENSOR, B, Y, X, C, TENSOR_WIDTH, TENSOR_HEIGHT, STRIDE_Y, dst) \ 1706*c217d954SCole Faust ({ \ 1707*c217d954SCole Faust LOOP_UNROLLING(int, _yk, 0, 1, TILE_HEIGHT, \ 1708*c217d954SCole Faust { \ 1709*c217d954SCole Faust LOOP_UNROLLING(int, _xk, 0, 1, TILE_WIDTH, \ 1710*c217d954SCole Faust { \ 1711*c217d954SCole Faust int _src_y = (X) + _xk + ((Y) + _yk) * (TENSOR_WIDTH); \ 1712*c217d954SCole Faust _src_y += (B) * (int)(TENSOR_WIDTH) * (int)(TENSOR_HEIGHT); \ 1713*c217d954SCole Faust int _src_valid_y = (((X) + _xk) >= 0 && ((X) + _xk) < (int)(TENSOR_WIDTH) && ((Y) + _yk) >= 0 && ((Y) + _yk) < (int)(TENSOR_HEIGHT)); \ 1714*c217d954SCole Faust if(_src_valid_y != 0) \ 1715*c217d954SCole Faust { \ 1716*c217d954SCole Faust dst[_xk + _yk * (TILE_WIDTH)].v = V_LOAD(DATA_TYPE, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, _src_y, STRIDE_Y); \ 1717*c217d954SCole Faust } \ 1718*c217d954SCole Faust }) \ 1719*c217d954SCole Faust }) \ 1720*c217d954SCole Faust }) 1721*c217d954SCole Faust 1722*c217d954SCole Faust 1723*c217d954SCole Faust#define T_LOAD_NHWC_WITH_DILATION(DATA_TYPE, TILE_HEIGHT, TILE_WIDTH, TILE_CHANNELS, TENSOR_TYPE, TENSOR, B, Y, X, C, TENSOR_WIDTH, TENSOR_HEIGHT, DILATION_X, DILATION_Y, BOUNDARY_CHECK, dst) \ 1724*c217d954SCole Faust ({ \ 1725*c217d954SCole Faust LOOP_UNROLLING(int, _yk, 0, 1, TILE_HEIGHT, \ 1726*c217d954SCole Faust { \ 1727*c217d954SCole Faust LOOP_UNROLLING(int, _xk, 0, 1, TILE_WIDTH, \ 1728*c217d954SCole Faust { \ 1729*c217d954SCole Faust int _src_y = (X) + _xk * (DILATION_X); \ 1730*c217d954SCole Faust int _src_z = ((Y) + _yk * (DILATION_Y)); \ 1731*c217d954SCole Faust int _src_w = (B); \ 1732*c217d954SCole Faust bool _src_valid_y = (((X) + _xk * (DILATION_X)) >= 0) && (((X) + _xk * (DILATION_X)) < (int)(TENSOR_WIDTH)) && (((Y) + _yk * (DILATION_Y)) >= 0) && (((Y) + _yk * (DILATION_Y)) < (int)(TENSOR_HEIGHT)); \ 1733*c217d954SCole Faust if(!(BOUNDARY_CHECK)) \ 1734*c217d954SCole Faust { \ 1735*c217d954SCole Faust dst[_xk + _yk * (TILE_WIDTH)].v = VLOAD(TILE_CHANNELS) \ 1736*c217d954SCole Faust (0, (__global DATA_TYPE *)(TENSOR##_ptr + TENSOR##_offset_first_element_in_bytes + (C) * sizeof(DATA_TYPE) + (_src_y) * (TENSOR##_stride_y) + (_src_z) * (TENSOR##_stride_z) + (_src_w) * (TENSOR##_stride_w))); \ 1737*c217d954SCole Faust } \ 1738*c217d954SCole Faust else \ 1739*c217d954SCole Faust { \ 1740*c217d954SCole Faust if(_src_valid_y) \ 1741*c217d954SCole Faust { \ 1742*c217d954SCole Faust dst[_xk + _yk * (TILE_WIDTH)].v = VLOAD(TILE_CHANNELS) \ 1743*c217d954SCole Faust (0, (__global DATA_TYPE *)(TENSOR##_ptr + TENSOR##_offset_first_element_in_bytes + (C) * sizeof(DATA_TYPE) + (_src_y) * (TENSOR##_stride_y) + (_src_z) * (TENSOR##_stride_z) + (_src_w) * (TENSOR##_stride_w))); \ 1744*c217d954SCole Faust } \ 1745*c217d954SCole Faust } \ 1746*c217d954SCole Faust }) \ 1747*c217d954SCole Faust }) \ 1748*c217d954SCole Faust }) 1749*c217d954SCole Faust 1750*c217d954SCole Faust 1751*c217d954SCole Faust#define T_LOAD_NHWC_INDIRECT(DATA_TYPE, TILE_AREA, TILE_CHANNELS, TENSOR_TYPE, TENSOR, B, Y, X, C, TENSOR_WIDTH, TENSOR_HEIGHT, STRIDE_Y, xi, yi, dst) \ 1752*c217d954SCole Faust ({ \ 1753*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, TILE_AREA, \ 1754*c217d954SCole Faust { \ 1755*c217d954SCole Faust int _src_y = (X) + xi[_i].v + ((Y) + yi[_i].v) * (TENSOR_WIDTH); \ 1756*c217d954SCole Faust _src_y += (B) * (int)(TENSOR_WIDTH) * (int)(TENSOR_HEIGHT); \ 1757*c217d954SCole Faust int _src_valid_y = (((X) + xi[_i].v) >= 0 && ((X) + xi[_i].v) < (int)(TENSOR_WIDTH) && ((Y) + yi[_i].v) >= 0 && ((Y) + yi[_i].v) < (int)(TENSOR_HEIGHT)); \ 1758*c217d954SCole Faust if(_src_valid_y != 0) \ 1759*c217d954SCole Faust { \ 1760*c217d954SCole Faust dst[_i].v = V_LOAD(DATA_TYPE, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, _src_y, STRIDE_Y); \ 1761*c217d954SCole Faust } \ 1762*c217d954SCole Faust }) \ 1763*c217d954SCole Faust }) 1764*c217d954SCole Faust 1765*c217d954SCole Faust 1766*c217d954SCole Faust#define T_LOAD2D_INDIRECT(DATA_TYPE, TILE_AREA, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, STRIDE_Y, yi, dst) T_LOAD2D_INDIRECT_STR(DATA_TYPE, TILE_AREA, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, STRIDE_Y, yi, dst) 1767*c217d954SCole Faust#define T_LOAD2D_INDIRECT_STR(DATA_TYPE, TILE_AREA, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, STRIDE_Y, yi, dst) T_LOAD2D_INDIRECT_##TENSOR_TYPE(DATA_TYPE, TILE_AREA, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, STRIDE_Y, yi, dst) 1768*c217d954SCole Faust#define T_LOAD2D_INDIRECT_BUFFER(DATA_TYPE, TILE_AREA, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, STRIDE_Y, yi, dst) \ 1769*c217d954SCole Faust ({ \ 1770*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, TILE_AREA, \ 1771*c217d954SCole Faust { \ 1772*c217d954SCole Faust if(yi[0].s[_i] >= 0) \ 1773*c217d954SCole Faust { \ 1774*c217d954SCole Faust dst[_i].v = V_LOAD(DATA_TYPE, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, yi[0].s[_i], STRIDE_Y); \ 1775*c217d954SCole Faust } \ 1776*c217d954SCole Faust }) \ 1777*c217d954SCole Faust }) 1778*c217d954SCole Faust 1779*c217d954SCole Faust#define T_LOAD2D_INDIRECT_IMAGE(DATA_TYPE, TILE_AREA, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, STRIDE_Y, yi, dst) \ 1780*c217d954SCole Faust ({ \ 1781*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, TILE_AREA, \ 1782*c217d954SCole Faust { \ 1783*c217d954SCole Faust dst[_i].v = V_LOAD(DATA_TYPE, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, yi[0].s[_i], STRIDE_Y); \ 1784*c217d954SCole Faust }) \ 1785*c217d954SCole Faust }) 1786*c217d954SCole Faust 1787*c217d954SCole Faust 1788*c217d954SCole Faust#define T_LOAD_NDHWC_INDIRECT(DATA_TYPE, TILE_AREA, TILE_CHANNELS, TENSOR_TYPE, TENSOR, B, Z, Y, X, C, TENSOR_WIDTH, TENSOR_HEIGHT, TENSOR_DEPTH, STRIDE_Y, xi, yi, zi, dst) \ 1789*c217d954SCole Faust ({ \ 1790*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, TILE_AREA, \ 1791*c217d954SCole Faust { \ 1792*c217d954SCole Faust int _src_y = (X) + xi[_i].v + ((Y) + yi[_i].v) * (TENSOR_WIDTH) + ((Z) + zi[_i].v) * (TENSOR_WIDTH * TENSOR_HEIGHT); \ 1793*c217d954SCole Faust _src_y += (B) * (int)(TENSOR_WIDTH) * (int)(TENSOR_HEIGHT) * (int)(TENSOR_DEPTH); \ 1794*c217d954SCole Faust int _src_valid_y = (((X) + xi[_i].v) >= 0 && ((X) + xi[_i].v) < (int)(TENSOR_WIDTH) && ((Y) + yi[_i].v) >= 0 && ((Y) + yi[_i].v) < (int)(TENSOR_HEIGHT) \ 1795*c217d954SCole Faust && ((Z) + zi[_i].v) >= 0 && ((Z) + zi[_i].v) < (int)(TENSOR_DEPTH)); \ 1796*c217d954SCole Faust if(_src_valid_y != 0) \ 1797*c217d954SCole Faust { \ 1798*c217d954SCole Faust dst[_i].v = V_LOAD(DATA_TYPE, TILE_CHANNELS, TENSOR_TYPE, TENSOR, C, _src_y, STRIDE_Y); \ 1799*c217d954SCole Faust } \ 1800*c217d954SCole Faust }) \ 1801*c217d954SCole Faust }) 1802*c217d954SCole Faust 1803*c217d954SCole Faust 1804*c217d954SCole Faust#define T_STORE_INDIRECT_WIDTH_SELECT(DATA_TYPE, HEIGHT, WIDTH0, WIDTH1, TENSOR_TYPE, TENSOR, X, STRIDE_Y, WIDTH1_CONDITION, src, indirect_y) \ 1805*c217d954SCole Faust ({ \ 1806*c217d954SCole Faust if(WIDTH1_CONDITION) \ 1807*c217d954SCole Faust { \ 1808*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, HEIGHT, \ 1809*c217d954SCole Faust { \ 1810*c217d954SCole Faust VSTORE_PARTIAL(WIDTH0, WIDTH1) \ 1811*c217d954SCole Faust (CONVERT(src[HEIGHT - 1 - _i].v, VEC_DATA_TYPE(DATA_TYPE, WIDTH0)), 0, (__global DATA_TYPE *)(TENSOR##_ptr + TENSOR##_offset_first_element_in_bytes + (X) * sizeof(DATA_TYPE) + (indirect_y[HEIGHT - 1 - _i].v) * STRIDE_Y)); \ 1812*c217d954SCole Faust }) \ 1813*c217d954SCole Faust } \ 1814*c217d954SCole Faust else \ 1815*c217d954SCole Faust { \ 1816*c217d954SCole Faust LOOP_UNROLLING(int, _i, 0, 1, HEIGHT, \ 1817*c217d954SCole Faust { \ 1818*c217d954SCole Faust VSTORE(WIDTH0) \ 1819*c217d954SCole Faust (CONVERT(src[HEIGHT - 1 - _i].v, VEC_DATA_TYPE(DATA_TYPE, WIDTH0)), 0, (__global DATA_TYPE *)(TENSOR##_ptr + TENSOR##_offset_first_element_in_bytes + (X) * sizeof(DATA_TYPE) + (indirect_y[HEIGHT - 1 - _i].v) * STRIDE_Y)); \ 1820*c217d954SCole Faust }) \ 1821*c217d954SCole Faust } \ 1822*c217d954SCole Faust }) 1823*c217d954SCole Faust 1824*c217d954SCole Faust 1825*c217d954SCole Faust#define T_OFFSET_CORRECTION(ACC_DATA_TYPE, M0, N0, K0, SRC_OFFSET, WEI_OFFSET, lhs, rhs, dst) \ 1826*c217d954SCole Faust ({ \ 1827*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 1828*c217d954SCole Faust { \ 1829*c217d954SCole Faust ACC_DATA_TYPE _tm = 0; \ 1830*c217d954SCole Faust LOOP_UNROLLING(int, _k0, 0, 1, K0, \ 1831*c217d954SCole Faust { \ 1832*c217d954SCole Faust _tm += ((ACC_DATA_TYPE)lhs[_m0].s[_k0] * (ACC_DATA_TYPE)WEI_OFFSET); \ 1833*c217d954SCole Faust }) \ 1834*c217d954SCole Faust LOOP_UNROLLING(int, _n0, 0, 1, N0, \ 1835*c217d954SCole Faust { \ 1836*c217d954SCole Faust dst[_m0].s[_n0] += _tm; \ 1837*c217d954SCole Faust LOOP_UNROLLING(int, _k0, 0, 1, K0, \ 1838*c217d954SCole Faust { \ 1839*c217d954SCole Faust dst[_m0].s[_n0] += ((ACC_DATA_TYPE)rhs[_n0].s[_k0] * (ACC_DATA_TYPE)SRC_OFFSET); \ 1840*c217d954SCole Faust }) \ 1841*c217d954SCole Faust }) \ 1842*c217d954SCole Faust }) \ 1843*c217d954SCole Faust }) 1844*c217d954SCole Faust 1845*c217d954SCole Faust 1846*c217d954SCole Faust#define T_QUANTIZE8(SRC_DATA_TYPE, DST_DATA_TYPE, QUANTIZATION_TYPE, M0, N0, DST_OFFSET, DST_SHIFT, DST_MULTIPLIER, src, dst_multipliers, dst_shifts, dst) T_QUANTIZE8_STR(SRC_DATA_TYPE, DST_DATA_TYPE, QUANTIZATION_TYPE, M0, N0, DST_OFFSET, DST_SHIFT, DST_MULTIPLIER, src, dst_multipliers, dst_shifts, dst) 1847*c217d954SCole Faust#define T_QUANTIZE8_STR(SRC_DATA_TYPE, DST_DATA_TYPE, QUANTIZATION_TYPE, M0, N0, DST_OFFSET, DST_SHIFT, DST_MULTIPLIER, src, dst_multipliers, dst_shifts, dst) T_QUANTIZE8_##QUANTIZATION_TYPE(SRC_DATA_TYPE, DST_DATA_TYPE, M0, N0, DST_OFFSET, DST_SHIFT, DST_MULTIPLIER, src, dst_multipliers, dst_shifts, dst) 1848*c217d954SCole Faust 1849*c217d954SCole Faust 1850*c217d954SCole Faust#define T_QUANTIZE8_PER_TENSOR(SRC_DATA_TYPE, DST_DATA_TYPE, M0, N0, DST_OFFSET, DST_SHIFT, DST_MULTIPLIER, src, dst_multipliers, dst_shifts, dst) \ 1851*c217d954SCole Faust ({ \ 1852*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 1853*c217d954SCole Faust { \ 1854*c217d954SCole Faust LOOP_UNROLLING(int, _n0, 0, 1, N0, \ 1855*c217d954SCole Faust { \ 1856*c217d954SCole Faust SRC_DATA_TYPE _tmp = 0; \ 1857*c217d954SCole Faust SRC_DATA_TYPE _src = src[_m0].s[_n0]; \ 1858*c217d954SCole Faust _src *= select((SRC_DATA_TYPE)1, ((SRC_DATA_TYPE)1 << (SRC_DATA_TYPE)(-DST_SHIFT)), ((SRC_DATA_TYPE)DST_SHIFT < (SRC_DATA_TYPE)0)); \ 1859*c217d954SCole Faust SRC_DATA_TYPE overflow = _src == DST_MULTIPLIER && _src == INT_MIN; \ 1860*c217d954SCole Faust long a_64 = (long)(_src); \ 1861*c217d954SCole Faust long b_64 = (long)(DST_MULTIPLIER); \ 1862*c217d954SCole Faust long ab_64 = a_64 * b_64; \ 1863*c217d954SCole Faust long mask1 = 1 << 30; \ 1864*c217d954SCole Faust long mask2 = 1 - (1 << 30); \ 1865*c217d954SCole Faust long is_positive_or_zero = ab_64 >= 0; \ 1866*c217d954SCole Faust long nudge = select(mask2, mask1, is_positive_or_zero); \ 1867*c217d954SCole Faust SRC_DATA_TYPE ab_x2_high32 = CONVERT((ab_64 + nudge) / (long)(1ll << 31), SRC_DATA_TYPE); \ 1868*c217d954SCole Faust _tmp = select(ab_x2_high32, (SRC_DATA_TYPE)INT_MAX, overflow); \ 1869*c217d954SCole Faust if(DST_SHIFT >= 0) \ 1870*c217d954SCole Faust { \ 1871*c217d954SCole Faust long mask = ((((int)1) << DST_SHIFT) - (long)1); \ 1872*c217d954SCole Faust long threshold = _tmp < (int)0 ? (mask >> 1) + (long)1 : (mask >> 1) + 0; \ 1873*c217d954SCole Faust _tmp = (_tmp & mask) > threshold ? (_tmp >> DST_SHIFT) + (int)1 : (_tmp >> DST_SHIFT); \ 1874*c217d954SCole Faust } \ 1875*c217d954SCole Faust _tmp += DST_OFFSET; \ 1876*c217d954SCole Faust dst[_m0].s[_n0] = CONVERT_SAT(_tmp, DST_DATA_TYPE); \ 1877*c217d954SCole Faust }) \ 1878*c217d954SCole Faust }) \ 1879*c217d954SCole Faust }) 1880*c217d954SCole Faust 1881*c217d954SCole Faust 1882*c217d954SCole Faust#define T_QUANTIZE8_PER_CHANNEL(SRC_DATA_TYPE, DST_DATA_TYPE, M0, N0, DST_OFFSET, DST_SHIFT, DST_MULTIPLIER, src, dst_multipliers, dst_shifts, dst) \ 1883*c217d954SCole Faust ({ \ 1884*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 1885*c217d954SCole Faust { \ 1886*c217d954SCole Faust LOOP_UNROLLING(int, _n0, 0, 1, N0, \ 1887*c217d954SCole Faust { \ 1888*c217d954SCole Faust SRC_DATA_TYPE _tmp = 0; \ 1889*c217d954SCole Faust SRC_DATA_TYPE _tmp2 = 0; \ 1890*c217d954SCole Faust SRC_DATA_TYPE _src = src[_m0].s[_n0]; \ 1891*c217d954SCole Faust SRC_DATA_TYPE _dst_multiplier = dst_multipliers[0].s[_n0]; \ 1892*c217d954SCole Faust SRC_DATA_TYPE _dst_shift = dst_shifts[0].s[_n0]; \ 1893*c217d954SCole Faust _src *= select((SRC_DATA_TYPE)1, ((SRC_DATA_TYPE)1 << (SRC_DATA_TYPE)(-_dst_shift)), ((SRC_DATA_TYPE)_dst_shift < (SRC_DATA_TYPE)0)); \ 1894*c217d954SCole Faust SRC_DATA_TYPE overflow = _src == _dst_multiplier && _src == INT_MIN; \ 1895*c217d954SCole Faust long a_64 = (long)(_src); \ 1896*c217d954SCole Faust long b_64 = (long)(_dst_multiplier); \ 1897*c217d954SCole Faust long ab_64 = a_64 * b_64; \ 1898*c217d954SCole Faust long mask1 = 1 << 30; \ 1899*c217d954SCole Faust long mask2 = 1 - (1 << 30); \ 1900*c217d954SCole Faust long is_positive_or_zero = ab_64 >= 0; \ 1901*c217d954SCole Faust long nudge = select(mask2, mask1, is_positive_or_zero); \ 1902*c217d954SCole Faust SRC_DATA_TYPE ab_x2_high32 = CONVERT((ab_64 + nudge) / (long)(1ll << 31), SRC_DATA_TYPE); \ 1903*c217d954SCole Faust _tmp = select(ab_x2_high32, (SRC_DATA_TYPE)INT_MAX, overflow); \ 1904*c217d954SCole Faust long mask = ((((int)1) << _dst_shift) - (int)1); \ 1905*c217d954SCole Faust long threshold = (mask >> 1) + any(_tmp); \ 1906*c217d954SCole Faust _tmp2 = _tmp >> _dst_shift; \ 1907*c217d954SCole Faust _tmp2 += select(0, 1, (_tmp & mask) > threshold); \ 1908*c217d954SCole Faust _tmp = select(_tmp, _tmp2, _dst_shift >= 0); \ 1909*c217d954SCole Faust _tmp += DST_OFFSET; \ 1910*c217d954SCole Faust dst[_m0].s[_n0] = CONVERT_SAT(_tmp, DST_DATA_TYPE); \ 1911*c217d954SCole Faust }) \ 1912*c217d954SCole Faust }) \ 1913*c217d954SCole Faust }) 1914*c217d954SCole Faust 1915*c217d954SCole Faust 1916*c217d954SCole Faust#define T_QUANTIZE8_ASYMMETRIC(SRC_DATA_TYPE, DST_DATA_TYPE, M0, N0, DST_OFFSET, DST_SHIFT, DST_MULTIPLIER, src, dst) \ 1917*c217d954SCole Faust ({ \ 1918*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 1919*c217d954SCole Faust { \ 1920*c217d954SCole Faust LOOP_UNROLLING(int, _n0, 0, 1, N0, \ 1921*c217d954SCole Faust { \ 1922*c217d954SCole Faust SRC_DATA_TYPE _tmp = 0; \ 1923*c217d954SCole Faust SRC_DATA_TYPE _src = src[_m0].s[_n0]; \ 1924*c217d954SCole Faust _src *= select((SRC_DATA_TYPE)1, ((SRC_DATA_TYPE)1 << (SRC_DATA_TYPE)(-DST_SHIFT)), ((SRC_DATA_TYPE)DST_SHIFT < (SRC_DATA_TYPE)0)); \ 1925*c217d954SCole Faust SRC_DATA_TYPE overflow = _src == DST_MULTIPLIER && _src == INT_MIN; \ 1926*c217d954SCole Faust long a_64 = (long)(_src); \ 1927*c217d954SCole Faust long b_64 = (long)(DST_MULTIPLIER); \ 1928*c217d954SCole Faust long ab_64 = a_64 * b_64; \ 1929*c217d954SCole Faust long mask1 = 1 << 30; \ 1930*c217d954SCole Faust long mask2 = 1 - (1 << 30); \ 1931*c217d954SCole Faust long is_positive_or_zero = ab_64 >= 0; \ 1932*c217d954SCole Faust long nudge = select(mask2, mask1, is_positive_or_zero); \ 1933*c217d954SCole Faust SRC_DATA_TYPE ab_x2_high32 = CONVERT((ab_64 + nudge) / (long)(1ll << 31), SRC_DATA_TYPE); \ 1934*c217d954SCole Faust _tmp = select(ab_x2_high32, (SRC_DATA_TYPE)INT_MAX, overflow); \ 1935*c217d954SCole Faust if(DST_SHIFT >= 0) \ 1936*c217d954SCole Faust { \ 1937*c217d954SCole Faust long mask = ((((int)1) << DST_SHIFT) - (int)1); \ 1938*c217d954SCole Faust long threshold = _tmp < (int)0 ? (mask >> 1) + (long)1 : (mask >> 1) + 0; \ 1939*c217d954SCole Faust _tmp = (_tmp & mask) > threshold ? (_tmp >> DST_SHIFT) + (int)1 : (_tmp >> DST_SHIFT); \ 1940*c217d954SCole Faust } \ 1941*c217d954SCole Faust _tmp += DST_OFFSET; \ 1942*c217d954SCole Faust dst[_m0].s[_n0] = CONVERT_SAT(_tmp, DST_DATA_TYPE); \ 1943*c217d954SCole Faust }) \ 1944*c217d954SCole Faust }) \ 1945*c217d954SCole Faust }) 1946*c217d954SCole Faust 1947*c217d954SCole Faust 1948*c217d954SCole Faust#define T_ROWSET_MASK(DATA_TYPE, M0, N0, VALUE_TO_SET, a, mask) \ 1949*c217d954SCole Faust ({ \ 1950*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 1951*c217d954SCole Faust { \ 1952*c217d954SCole Faust LOOP_UNROLLING(int, _n0, 0, 1, N0, \ 1953*c217d954SCole Faust { \ 1954*c217d954SCole Faust a[_m0].s[_n0] = select((DATA_TYPE)(a[_m0].s[_n0]), (DATA_TYPE)(VALUE_TO_SET), (SELECT_DATA_TYPE(DATA_TYPE))(mask[_m0].v == (DATA_TYPE)0)); \ 1955*c217d954SCole Faust }) \ 1956*c217d954SCole Faust }) \ 1957*c217d954SCole Faust }) 1958*c217d954SCole Faust 1959*c217d954SCole Faust 1960*c217d954SCole Faust#define T_ACTIVATION(DATA_TYPE, M0, N0, ACTIVATION_TYPE, A_VAL, B_VAL, src, dst) \ 1961*c217d954SCole Faust ({ \ 1962*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 1963*c217d954SCole Faust { \ 1964*c217d954SCole Faust dst[_m0].v = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, N0, src[_m0].v, A_VAL, B_VAL); \ 1965*c217d954SCole Faust }) \ 1966*c217d954SCole Faust }) 1967*c217d954SCole Faust 1968*c217d954SCole Faust 1969*c217d954SCole Faust#define relu_op_quantized(DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) (max((DATA_TYPE)ZERO_VALUE, x)) 1970*c217d954SCole Faust 1971*c217d954SCole Faust#define brelu_op_quantized(DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) (min((DATA_TYPE)A_VAL, max((DATA_TYPE)ZERO_VALUE, x))) 1972*c217d954SCole Faust 1973*c217d954SCole Faust#define lu_brelu_op_quantized(DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) (min(max(x, (DATA_TYPE)B_VAL), (DATA_TYPE)A_VAL)) 1974*c217d954SCole Faust 1975*c217d954SCole Faust#define hard_swish_op_quantized(DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) (x * ((min(max((DATA_TYPE)(x + (DATA_TYPE)3.f), (DATA_TYPE)0.f), (DATA_TYPE)6.f)) * (DATA_TYPE)0.166666667f)) 1976*c217d954SCole Faust 1977*c217d954SCole Faust#define identity_op_quantized(DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) (x) 1978*c217d954SCole Faust 1979*c217d954SCole Faust#define ACT_OP_QUANTIZED(op, DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) op##_op_quantized(DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) 1980*c217d954SCole Faust#define ACTIVATION_QUANTIZED(op, DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) ACT_OP_QUANTIZED(op, DATA_TYPE, VEC_SIZE, ZERO_VALUE, A_VAL, B_VAL, x) 1981*c217d954SCole Faust 1982*c217d954SCole Faust#define V_ADD(A_VAL, B_VAL) ((A_VAL) + (B_VAL)) 1983*c217d954SCole Faust#define V_SUB(A_VAL, B_VAL) ((A_VAL) - (B_VAL)) 1984*c217d954SCole Faust#define V_DIV(A_VAL, B_VAL) ((A_VAL) / (B_VAL)) 1985*c217d954SCole Faust#define V_MUL(A_VAL, B_VAL) ((A_VAL) * (B_VAL)) 1986*c217d954SCole Faust 1987*c217d954SCole Faust 1988*c217d954SCole Faust#define T_ACTIVATION_QUANTIZED(DATA_TYPE, M0, N0, ACTIVATION_TYPE, ZERO_VALUE, A_VAL, B_VAL, src, dst) \ 1989*c217d954SCole Faust ({ \ 1990*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 1991*c217d954SCole Faust { \ 1992*c217d954SCole Faust dst[_m0].v = ACTIVATION_QUANTIZED(ACTIVATION_TYPE, DATA_TYPE, N0, ZERO_VALUE, A_VAL, B_VAL, src[_m0].v); \ 1993*c217d954SCole Faust }) \ 1994*c217d954SCole Faust }) 1995*c217d954SCole Faust 1996*c217d954SCole Faust 1997*c217d954SCole Faust#define T_ADD(DATA_TYPE, M0, N0, lhs, rhs, dst) \ 1998*c217d954SCole Faust ({ \ 1999*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 2000*c217d954SCole Faust { \ 2001*c217d954SCole Faust dst[_m0].v = lhs[_m0].v + rhs[_m0].v; \ 2002*c217d954SCole Faust }) \ 2003*c217d954SCole Faust }) 2004*c217d954SCole Faust 2005*c217d954SCole Faust 2006*c217d954SCole Faust#define T_ADD_CONSTANT(DATA_TYPE, M0, N0, lhs, rhs_constant, dst) \ 2007*c217d954SCole Faust ({ \ 2008*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 2009*c217d954SCole Faust { \ 2010*c217d954SCole Faust dst[_m0].v = lhs[_m0].v + (DATA_TYPE)rhs_constant; \ 2011*c217d954SCole Faust }) \ 2012*c217d954SCole Faust }) 2013*c217d954SCole Faust 2014*c217d954SCole Faust#define T_ELTWISE_BROADCAST_ADD_X(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE_BROADCAST_X(V_ADD, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2015*c217d954SCole Faust#define T_ELTWISE_BROADCAST_LHS_X_ADD(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE_BROADCAST_LHS_X(V_ADD, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2016*c217d954SCole Faust#define T_ELTWISE_BROADCAST_RHS_X_ADD(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE_BROADCAST_X(V_ADD, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2017*c217d954SCole Faust 2018*c217d954SCole Faust#define T_ELTWISE_BROADCAST_LHS_X_SUB(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE_BROADCAST_LHS_X(V_SUB, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2019*c217d954SCole Faust#define T_ELTWISE_BROADCAST_RHS_X_SUB(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE_BROADCAST_X(V_SUB, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2020*c217d954SCole Faust 2021*c217d954SCole Faust#define T_ELTWISE_BROADCAST_DIV_X(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE_BROADCAST_X(V_DIV, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2022*c217d954SCole Faust 2023*c217d954SCole Faust#define T_ELTWISE_BROADCAST_LHS_X_MUL(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE_BROADCAST_LHS_X(V_MUL, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2024*c217d954SCole Faust#define T_ELTWISE_BROADCAST_RHS_X_MUL(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE_BROADCAST_X(V_MUL, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2025*c217d954SCole Faust 2026*c217d954SCole Faust 2027*c217d954SCole Faust#define T_SCALE_CONSTANT(DATA_TYPE, M0, N0, lhs, rhs_constant, dst) \ 2028*c217d954SCole Faust ({ \ 2029*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 2030*c217d954SCole Faust { \ 2031*c217d954SCole Faust dst[_m0].v = lhs[_m0].v * (DATA_TYPE)rhs_constant; \ 2032*c217d954SCole Faust }) \ 2033*c217d954SCole Faust }) 2034*c217d954SCole Faust 2035*c217d954SCole Faust 2036*c217d954SCole Faust#define T_ELTWISE_BROADCAST_X(T_ELWISE_OP, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) \ 2037*c217d954SCole Faust ({ \ 2038*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 2039*c217d954SCole Faust { \ 2040*c217d954SCole Faust dst[_m0].v = T_ELWISE_OP(CONVERT(lhs[_m0].v, VEC_DATA_TYPE(DST_DATA_TYPE, N0)), CONVERT(rhs[0].v, VEC_DATA_TYPE(DST_DATA_TYPE, N0))); \ 2041*c217d954SCole Faust }) \ 2042*c217d954SCole Faust }) 2043*c217d954SCole Faust 2044*c217d954SCole Faust 2045*c217d954SCole Faust#define T_ELTWISE_BROADCAST_LHS_X(T_ELWISE_OP, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) \ 2046*c217d954SCole Faust ({ \ 2047*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 2048*c217d954SCole Faust { \ 2049*c217d954SCole Faust dst[_m0].v = T_ELWISE_OP(CONVERT(lhs[0].v, VEC_DATA_TYPE(DST_DATA_TYPE, N0)), CONVERT(rhs[_m0].v, VEC_DATA_TYPE(DST_DATA_TYPE, N0))); \ 2050*c217d954SCole Faust }) \ 2051*c217d954SCole Faust }) 2052*c217d954SCole Faust 2053*c217d954SCole Faust#define T_ELTWISE_ADD(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE(V_ADD, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2054*c217d954SCole Faust#define T_ELTWISE_SUB(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE(V_SUB, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2055*c217d954SCole Faust#define T_ELTWISE_DIV(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE(V_DIV, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2056*c217d954SCole Faust#define T_ELTWISE_MUL(DST_DATA_TYPE, M0, N0, lhs, rhs, dst) T_ELTWISE(V_MUL, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) 2057*c217d954SCole Faust 2058*c217d954SCole Faust 2059*c217d954SCole Faust#define T_ELTWISE(T_ELWISE_OP, DST_DATA_TYPE, M0, N0, lhs, rhs, dst) \ 2060*c217d954SCole Faust ({ \ 2061*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 2062*c217d954SCole Faust { \ 2063*c217d954SCole Faust dst[_m0].v = T_ELWISE_OP(CONVERT(lhs[_m0].v, VEC_DATA_TYPE(DST_DATA_TYPE, N0)), CONVERT(rhs[_m0].v, VEC_DATA_TYPE(DST_DATA_TYPE, N0))); \ 2064*c217d954SCole Faust }) \ 2065*c217d954SCole Faust }) 2066*c217d954SCole Faust 2067*c217d954SCole Faust 2068*c217d954SCole Faust#define T_FLOOR(DST_DATA_TYPE, M0, N0, src, dst) \ 2069*c217d954SCole Faust ({ \ 2070*c217d954SCole Faust LOOP_UNROLLING(int, _m0, 0, 1, M0, \ 2071*c217d954SCole Faust { \ 2072*c217d954SCole Faust dst[_m0].v = floor(CONVERT(src[_m0].v, VEC_DATA_TYPE(DST_DATA_TYPE, N0))); \ 2073*c217d954SCole Faust }) \ 2074*c217d954SCole Faust }) 2075*c217d954SCole Faust 2076*c217d954SCole Faust 2077*c217d954SCole Faust#define T_MMUL(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, LHS_LAYOUT, RHS_LAYOUT, lhs, rhs, dst) T_MMUL_##LHS_LAYOUT##_##RHS_LAYOUT(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) 2078*c217d954SCole Faust#define T_MMUL_NT_T(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) T_MMUL_NT_T_##LHS_DATA_TYPE##_##RHS_DATA_TYPE##_##DST_DATA_TYPE(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) 2079*c217d954SCole Faust#define T_MMUL_NT_T_float_float_float(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) T_MMUL_NT_T_FLOAT(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) 2080*c217d954SCole Faust#define T_MMUL_NT_T_half_half_float(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) T_MMUL_NT_T_FLOAT(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) 2081*c217d954SCole Faust#define T_MMUL_NT_T_half_half_half(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) T_MMUL_NT_T_FLOAT(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) 2082*c217d954SCole Faust#define T_MMUL_NT_T_char_char_int(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) T_MMUL_NT_T_INTEGER8(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) 2083*c217d954SCole Faust#define T_MMUL_NT_T_uchar_uchar_uint(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) T_MMUL_NT_T_INTEGER8(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) 2084*c217d954SCole Faust#define T_MMUL_NT_T_uchar_uchar_int(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) T_MMUL_NT_T_INTEGER8(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) 2085*c217d954SCole Faust#define T_MMUL_NT_T_FLOAT(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) \ 2086*c217d954SCole Faust { \ 2087*c217d954SCole Faust LOOP_UNROLLING(int, _m, 0, 1, M0, \ 2088*c217d954SCole Faust { \ 2089*c217d954SCole Faust LOOP_UNROLLING(int, _n, 0, 1, N0, \ 2090*c217d954SCole Faust { \ 2091*c217d954SCole Faust LOOP_UNROLLING(int, _k, 0, 1, K0, \ 2092*c217d954SCole Faust { \ 2093*c217d954SCole Faust dst[_m].s[_n] = fma((DST_DATA_TYPE)(lhs[_m].s[_k]), (DST_DATA_TYPE)(rhs[_n].s[_k]), dst[_m].s[_n]); \ 2094*c217d954SCole Faust }) \ 2095*c217d954SCole Faust }) \ 2096*c217d954SCole Faust }) \ 2097*c217d954SCole Faust } 2098*c217d954SCole Faust 2099*c217d954SCole Faust#define T_MMUL_NT_T_INTEGER8(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, M0, N0, K0, lhs, rhs, dst) \ 2100*c217d954SCole Faust ({ \ 2101*c217d954SCole Faust LOOP_UNROLLING(int, _m, 0, 1, M0, \ 2102*c217d954SCole Faust { \ 2103*c217d954SCole Faust LOOP_UNROLLING(int, _n, 0, 1, N0, \ 2104*c217d954SCole Faust { \ 2105*c217d954SCole Faust DOT_PRODUCT_INTEGER8(LHS_DATA_TYPE, RHS_DATA_TYPE, DST_DATA_TYPE, K0, (lhs[_m].v), (rhs[_n].v), dst[_m].s[_n]); \ 2106*c217d954SCole Faust }) \ 2107*c217d954SCole Faust }) \ 2108*c217d954SCole Faust }) 2109*c217d954SCole Faust 2110*c217d954SCole Faust#endif 2111*c217d954SCole Faust 2112*c217d954SCole Faust 2113*c217d954SCole Faust 2114*c217d954SCole Faust 2115*c217d954SCole Faust__kernel void direct_convolution3d_ndhwc( 2116*c217d954SCole Faust TENSOR4D(src, BUFFER), 2117*c217d954SCole Faust TENSOR4D(dst, BUFFER), 2118*c217d954SCole Faust TENSOR4D(wei, BUFFER) 2119*c217d954SCole Faust#if defined(HAS_BIAS) 2120*c217d954SCole Faust , 2121*c217d954SCole Faust VECTOR_DECLARATION(bia) 2122*c217d954SCole Faust#endif 2123*c217d954SCole Faust) 2124*c217d954SCole Faust{ 2125*c217d954SCole Faust#define _IWEI_WIDTH WEI_WIDTH 2126*c217d954SCole Faust#define _IWEI_HEIGHT WEI_HEIGHT 2127*c217d954SCole Faust#define _IWEI_DEPTH WEI_DEPTH 2128*c217d954SCole Faust#define _ISRC_WIDTH SRC_WIDTH 2129*c217d954SCole Faust#define _ISRC_HEIGHT SRC_HEIGHT 2130*c217d954SCole Faust#define _ISRC_DEPTH SRC_DEPTH 2131*c217d954SCole Faust#define _ISRC_CHANNELS SRC_CHANNELS 2132*c217d954SCole Faust#define _IDST_WIDTH DST_WIDTH 2133*c217d954SCole Faust#define _IDST_HEIGHT DST_HEIGHT 2134*c217d954SCole Faust#define _IDST_DEPTH DST_DEPTH 2135*c217d954SCole Faust#define _IDST_CHANNELS DST_CHANNELS 2136*c217d954SCole Faust#define _IY_MULTIPLIER (_IWEI_WIDTH * _IWEI_HEIGHT * _IWEI_DEPTH) 2137*c217d954SCole Faust 2138*c217d954SCole Faust 2139*c217d954SCole Faust#if defined(IS_QUANTIZED) 2140*c217d954SCole Faust#define _IOUTPUT_TILE cq 2141*c217d954SCole Faust#else 2142*c217d954SCole Faust#define _IOUTPUT_TILE c 2143*c217d954SCole Faust#endif 2144*c217d954SCole Faust 2145*c217d954SCole Faust const int cout = GET_SPATIAL_IDX(0, N0, PARTIAL_N0); 2146*c217d954SCole Faust const int mout = GET_SPATIAL_IDX(1, M0, 0); 2147*c217d954SCole Faust const int bout = GET_SPATIAL_IDX(2, 1, 0); 2148*c217d954SCole Faust 2149*c217d954SCole Faust TILE(int, M0, 1, xi); 2150*c217d954SCole Faust TILE(int, M0, 1, yi); 2151*c217d954SCole Faust TILE(int, M0, 1, zi); 2152*c217d954SCole Faust 2153*c217d954SCole Faust 2154*c217d954SCole Faust LOOP_UNROLLING(int, i, 0, 1, M0, 2155*c217d954SCole Faust { 2156*c217d954SCole Faust xi[i].v = ((mout + i) % _IDST_WIDTH) * STRIDE_X; 2157*c217d954SCole Faust yi[i].v = (((mout + i) / _IDST_WIDTH) % _IDST_HEIGHT) * STRIDE_Y; 2158*c217d954SCole Faust zi[i].v = (((mout + i) / (_IDST_WIDTH * _IDST_HEIGHT)) % _IDST_DEPTH) * STRIDE_Z; 2159*c217d954SCole Faust 2160*c217d954SCole Faust xi[i].v -= PAD_LEFT; 2161*c217d954SCole Faust yi[i].v -= PAD_TOP; 2162*c217d954SCole Faust zi[i].v -= PAD_FRONT; 2163*c217d954SCole Faust }) 2164*c217d954SCole Faust 2165*c217d954SCole Faust 2166*c217d954SCole Faust TILE(ACC_DATA_TYPE, M0, N0, c); 2167*c217d954SCole Faust 2168*c217d954SCole Faust LOOP_UNROLLING(int, i, 0, 1, M0, 2169*c217d954SCole Faust { 2170*c217d954SCole Faust c[i].v = (ACC_DATA_TYPE)0; 2171*c217d954SCole Faust }) 2172*c217d954SCole Faust 2173*c217d954SCole Faust for(int i = 0; i < _IY_MULTIPLIER; ++i) 2174*c217d954SCole Faust { 2175*c217d954SCole Faust int ck = 0; 2176*c217d954SCole Faust int xk = i % _IWEI_WIDTH; 2177*c217d954SCole Faust int yk = (i / _IWEI_WIDTH) % _IWEI_HEIGHT; 2178*c217d954SCole Faust int zk = i / (_IWEI_WIDTH * _IWEI_HEIGHT); 2179*c217d954SCole Faust 2180*c217d954SCole Faust int k = 0; 2181*c217d954SCole Faust for(; k <= (_ISRC_CHANNELS - K0); k += K0) 2182*c217d954SCole Faust { 2183*c217d954SCole Faust TILE(DATA_TYPE, M0, K0, a); 2184*c217d954SCole Faust TILE(DATA_TYPE, N0, K0, b); 2185*c217d954SCole Faust 2186*c217d954SCole Faust LOOP_UNROLLING(int, i, 0, 1, M0, 2187*c217d954SCole Faust { 2188*c217d954SCole Faust a[i].v = ZERO_VALUE; 2189*c217d954SCole Faust }) 2190*c217d954SCole Faust 2191*c217d954SCole Faust 2192*c217d954SCole Faust T_LOAD_NDHWC_INDIRECT(DATA_TYPE, M0, K0, BUFFER, src, bout, zk, yk, xk, ck, _ISRC_WIDTH, _ISRC_HEIGHT, _ISRC_DEPTH, src_stride_y, xi, yi, zi, a); 2193*c217d954SCole Faust 2194*c217d954SCole Faust 2195*c217d954SCole Faust const int b_offs = k + (xk * _ISRC_CHANNELS) + (yk * _ISRC_CHANNELS * _IWEI_WIDTH) + (zk * _ISRC_CHANNELS * _IWEI_WIDTH * _IWEI_HEIGHT); 2196*c217d954SCole Faust LOOP_UNROLLING(int, i, 0, 1, N0, 2197*c217d954SCole Faust { 2198*c217d954SCole Faust if((cout + i) < _IDST_CHANNELS) 2199*c217d954SCole Faust { 2200*c217d954SCole Faust LOOP_UNROLLING(int, j, 0, 1, K0, 2201*c217d954SCole Faust { 2202*c217d954SCole Faust b[i].s[j] = *(__global DATA_TYPE *)(wei_ptr + wei_offset_first_element_in_bytes + (cout + i) * sizeof(DATA_TYPE) + j * wei_stride_y + b_offs * wei_stride_y); 2203*c217d954SCole Faust }) 2204*c217d954SCole Faust } 2205*c217d954SCole Faust }) 2206*c217d954SCole Faust 2207*c217d954SCole Faust 2208*c217d954SCole Faust T_MMUL(DATA_TYPE, DATA_TYPE, ACC_DATA_TYPE, M0, N0, K0, NT, T, a, b, c); 2209*c217d954SCole Faust 2210*c217d954SCole Faust 2211*c217d954SCole Faust 2212*c217d954SCole Faust T_OFFSET_CORRECTION(ACC_DATA_TYPE, M0, N0, K0, SRC_OFFSET, WEI_OFFSET, a, b, c); 2213*c217d954SCole Faust 2214*c217d954SCole Faust ck += K0; 2215*c217d954SCole Faust } 2216*c217d954SCole Faust 2217*c217d954SCole Faust#if((_ISRC_CHANNELS % K0) != 0) 2218*c217d954SCole Faust 2219*c217d954SCole Faust for(; k < _ISRC_CHANNELS; ++k) 2220*c217d954SCole Faust { 2221*c217d954SCole Faust TILE(DATA_TYPE, M0, 1, a); 2222*c217d954SCole Faust TILE(DATA_TYPE, N0, 1, b); 2223*c217d954SCole Faust 2224*c217d954SCole Faust LOOP_UNROLLING(int, i, 0, 1, M0, 2225*c217d954SCole Faust { 2226*c217d954SCole Faust a[i].v = ZERO_VALUE; 2227*c217d954SCole Faust }) 2228*c217d954SCole Faust 2229*c217d954SCole Faust 2230*c217d954SCole Faust T_LOAD_NDHWC_INDIRECT(DATA_TYPE, M0, 1, BUFFER, src, bout, zk, yk, xk, ck, _ISRC_WIDTH, _ISRC_HEIGHT, _ISRC_DEPTH, src_stride_y, xi, yi, zi, a); 2231*c217d954SCole Faust 2232*c217d954SCole Faust 2233*c217d954SCole Faust const int b_offs = k + (xk * _ISRC_CHANNELS) + (yk * _ISRC_CHANNELS * _IWEI_WIDTH) + (zk * _ISRC_CHANNELS * _IWEI_WIDTH * _IWEI_HEIGHT); 2234*c217d954SCole Faust LOOP_UNROLLING(int, i, 0, 1, N0, 2235*c217d954SCole Faust { 2236*c217d954SCole Faust if((cout + i) < _IDST_CHANNELS) 2237*c217d954SCole Faust { 2238*c217d954SCole Faust b[i].v = *(__global DATA_TYPE *)(wei_ptr + wei_offset_first_element_in_bytes + (cout + i) * sizeof(DATA_TYPE) + b_offs * wei_stride_y); 2239*c217d954SCole Faust } 2240*c217d954SCole Faust }) 2241*c217d954SCole Faust 2242*c217d954SCole Faust 2243*c217d954SCole Faust T_MMUL(DATA_TYPE, DATA_TYPE, ACC_DATA_TYPE, M0, N0, 1, NT, T, a, b, c); 2244*c217d954SCole Faust 2245*c217d954SCole Faust 2246*c217d954SCole Faust 2247*c217d954SCole Faust T_OFFSET_CORRECTION(ACC_DATA_TYPE, M0, N0, 1, SRC_OFFSET, WEI_OFFSET, a, b, c); 2248*c217d954SCole Faust 2249*c217d954SCole Faust ++ck; 2250*c217d954SCole Faust } 2251*c217d954SCole Faust#endif 2252*c217d954SCole Faust } 2253*c217d954SCole Faust 2254*c217d954SCole Faust 2255*c217d954SCole Faust 2256*c217d954SCole Faust T_ADD_CONSTANT(ACC_DATA_TYPE, M0, N0, c, (_IWEI_WIDTH * _IWEI_HEIGHT * _IWEI_DEPTH * _ISRC_CHANNELS * SRC_OFFSET * WEI_OFFSET), c); 2257*c217d954SCole Faust 2258*c217d954SCole Faust#if defined(HAS_BIAS) 2259*c217d954SCole Faust TILE(BIA_DATA_TYPE, 1, N0, bias0); 2260*c217d954SCole Faust 2261*c217d954SCole Faust if((cout + N0) <= _IDST_CHANNELS) 2262*c217d954SCole Faust { 2263*c217d954SCole Faust bias0[0].v = VLOAD(N0)(0, (__global BIA_DATA_TYPE *)(bia_ptr + bia_offset_first_element_in_bytes + cout * sizeof(BIA_DATA_TYPE))); 2264*c217d954SCole Faust } 2265*c217d954SCole Faust else 2266*c217d954SCole Faust { 2267*c217d954SCole Faust VLOAD_PARTIAL(N0, PARTIAL_N0) 2268*c217d954SCole Faust (bias0[0].v, 0, (__global BIA_DATA_TYPE *)(bia_ptr + bia_offset_first_element_in_bytes + cout * sizeof(BIA_DATA_TYPE))); 2269*c217d954SCole Faust } 2270*c217d954SCole Faust 2271*c217d954SCole Faust 2272*c217d954SCole Faust T_ELTWISE_BROADCAST_ADD_X(ACC_DATA_TYPE, M0, N0, c, bias0, c); 2273*c217d954SCole Faust 2274*c217d954SCole Faust#endif 2275*c217d954SCole Faust 2276*c217d954SCole Faust TILE(uint, M0, 1, dst_indirect_y); 2277*c217d954SCole Faust 2278*c217d954SCole Faust 2279*c217d954SCole Faust LOOP_UNROLLING(int, i, 0, 1, M0, 2280*c217d954SCole Faust { 2281*c217d954SCole Faust dst_indirect_y[i].v = (uint)min(mout + i, (int)(_IDST_WIDTH *_IDST_HEIGHT * _IDST_DEPTH) - 1); 2282*c217d954SCole Faust dst_indirect_y[i].v += bout * (int)(_IDST_WIDTH *_IDST_HEIGHT * _IDST_DEPTH); 2283*c217d954SCole Faust }) 2284*c217d954SCole Faust 2285*c217d954SCole Faust#if defined(IS_QUANTIZED) 2286*c217d954SCole Faust TILE(DATA_TYPE, M0, N0, cq); 2287*c217d954SCole Faust 2288*c217d954SCole Faust 2289*c217d954SCole Faust T_QUANTIZE8_ASYMMETRIC(ACC_DATA_TYPE, DATA_TYPE, M0, N0, DST_OFFSET, DST_SHIFT, DST_MULTIPLIER, c, cq); 2290*c217d954SCole Faust#endif 2291*c217d954SCole Faust 2292*c217d954SCole Faust bool x_cond = PARTIAL_N0 != 0 && get_global_id(0) == 0; 2293*c217d954SCole Faust 2294*c217d954SCole Faust 2295*c217d954SCole Faust T_STORE_INDIRECT_WIDTH_SELECT(DATA_TYPE, M0, N0, PARTIAL_N0, BUFFER, dst, cout, dst_stride_y, x_cond, _IOUTPUT_TILE, dst_indirect_y); 2296*c217d954SCole Faust})"