1*c217d954SCole FaustR"( 2*c217d954SCole Faust#define PARTIAL_STORE_M0 VEC_SIZE_LEFTOVER_X 3*c217d954SCole Faust#define PARTIAL_STORE_N0 VEC_SIZE_LEFTOVER_Y 4*c217d954SCole Faust 5*c217d954SCole Faust 6*c217d954SCole Faust#ifndef ARM_COMPUTE_HELPER_H 7*c217d954SCole Faust#define ARM_COMPUTE_HELPER_H 8*c217d954SCole Faust 9*c217d954SCole Faust 10*c217d954SCole Faust 11*c217d954SCole Faust 12*c217d954SCole Faust#define STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 13*c217d954SCole Faust VSTORE(N0) \ 14*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 15*c217d954SCole Faust 16*c217d954SCole Faust#define STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 17*c217d954SCole Faust STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 18*c217d954SCole Faust VSTORE(N0) \ 19*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 20*c217d954SCole Faust 21*c217d954SCole Faust#define STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 22*c217d954SCole Faust STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 23*c217d954SCole Faust VSTORE(N0) \ 24*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 25*c217d954SCole Faust 26*c217d954SCole Faust#define STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 27*c217d954SCole Faust STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 28*c217d954SCole Faust VSTORE(N0) \ 29*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 30*c217d954SCole Faust 31*c217d954SCole Faust#define STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 32*c217d954SCole Faust STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 33*c217d954SCole Faust VSTORE(N0) \ 34*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 35*c217d954SCole Faust 36*c217d954SCole Faust#define STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 37*c217d954SCole Faust STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 38*c217d954SCole Faust VSTORE(N0) \ 39*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 40*c217d954SCole Faust 41*c217d954SCole Faust#define STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 42*c217d954SCole Faust STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 43*c217d954SCole Faust VSTORE(N0) \ 44*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 45*c217d954SCole Faust 46*c217d954SCole Faust#define STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 47*c217d954SCole Faust STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 48*c217d954SCole Faust VSTORE(N0) \ 49*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 50*c217d954SCole Faust 51*c217d954SCole Faust#define STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 52*c217d954SCole Faust STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 53*c217d954SCole Faust VSTORE(N0) \ 54*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 55*c217d954SCole Faust 56*c217d954SCole Faust#define STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 57*c217d954SCole Faust STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 58*c217d954SCole Faust VSTORE(N0) \ 59*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 60*c217d954SCole Faust 61*c217d954SCole Faust#define STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 62*c217d954SCole Faust STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 63*c217d954SCole Faust VSTORE(N0) \ 64*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 65*c217d954SCole Faust 66*c217d954SCole Faust#define STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 67*c217d954SCole Faust STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 68*c217d954SCole Faust VSTORE(N0) \ 69*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 70*c217d954SCole Faust 71*c217d954SCole Faust#define STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 72*c217d954SCole Faust STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 73*c217d954SCole Faust VSTORE(N0) \ 74*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 75*c217d954SCole Faust 76*c217d954SCole Faust#define STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 77*c217d954SCole Faust STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 78*c217d954SCole Faust VSTORE(N0) \ 79*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 80*c217d954SCole Faust 81*c217d954SCole Faust#define STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 82*c217d954SCole Faust STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 83*c217d954SCole Faust VSTORE(N0) \ 84*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 85*c217d954SCole Faust 86*c217d954SCole Faust#define STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 87*c217d954SCole Faust STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 88*c217d954SCole Faust VSTORE(N0) \ 89*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 90*c217d954SCole Faust 91*c217d954SCole Faust 92*c217d954SCole Faust 93*c217d954SCole Faust#define CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 94*c217d954SCole Faust VSTORE(N0) \ 95*c217d954SCole Faust (CONVERT_SAT((BASENAME##0), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 96*c217d954SCole Faust 97*c217d954SCole Faust#define CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 98*c217d954SCole Faust CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 99*c217d954SCole Faust VSTORE(N0) \ 100*c217d954SCole Faust (CONVERT_SAT((BASENAME##1), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 101*c217d954SCole Faust 102*c217d954SCole Faust#define CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 103*c217d954SCole Faust CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 104*c217d954SCole Faust VSTORE(N0) \ 105*c217d954SCole Faust (CONVERT_SAT((BASENAME##2), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 106*c217d954SCole Faust 107*c217d954SCole Faust#define CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 108*c217d954SCole Faust CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 109*c217d954SCole Faust VSTORE(N0) \ 110*c217d954SCole Faust (CONVERT_SAT((BASENAME##3), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 111*c217d954SCole Faust 112*c217d954SCole Faust#define CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 113*c217d954SCole Faust CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 114*c217d954SCole Faust VSTORE(N0) \ 115*c217d954SCole Faust (CONVERT_SAT((BASENAME##4), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 116*c217d954SCole Faust 117*c217d954SCole Faust#define CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 118*c217d954SCole Faust CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 119*c217d954SCole Faust VSTORE(N0) \ 120*c217d954SCole Faust (CONVERT_SAT((BASENAME##5), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 121*c217d954SCole Faust 122*c217d954SCole Faust#define CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 123*c217d954SCole Faust CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 124*c217d954SCole Faust VSTORE(N0) \ 125*c217d954SCole Faust (CONVERT_SAT((BASENAME##6), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 126*c217d954SCole Faust 127*c217d954SCole Faust#define CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 128*c217d954SCole Faust CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 129*c217d954SCole Faust VSTORE(N0) \ 130*c217d954SCole Faust (CONVERT_SAT((BASENAME##7), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 131*c217d954SCole Faust 132*c217d954SCole Faust#define CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 133*c217d954SCole Faust CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 134*c217d954SCole Faust VSTORE(N0) \ 135*c217d954SCole Faust (CONVERT_SAT((BASENAME##8), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 136*c217d954SCole Faust 137*c217d954SCole Faust#define CONVERT_STORE_ROW_10(N0, DATA, BASENAME, PTR, STRIDE_Y, Z) \ 138*c217d954SCole Faust CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 139*c217d954SCole Faust VSTORE(N0) \ 140*c217d954SCole Faust (CONVERT_SAT((BASENAME##9), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 141*c217d954SCole Faust 142*c217d954SCole Faust#define CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 143*c217d954SCole Faust CONVERT_STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 144*c217d954SCole Faust VSTORE(N0) \ 145*c217d954SCole Faust (CONVERT_SAT((BASENAME##A), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 146*c217d954SCole Faust 147*c217d954SCole Faust#define CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 148*c217d954SCole Faust CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 149*c217d954SCole Faust VSTORE(N0) \ 150*c217d954SCole Faust (CONVERT_SAT((BASENAME##B), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 151*c217d954SCole Faust 152*c217d954SCole Faust#define CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 153*c217d954SCole Faust CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 154*c217d954SCole Faust VSTORE(N0) \ 155*c217d954SCole Faust (CONVERT_SAT((BASENAME##C), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 156*c217d954SCole Faust 157*c217d954SCole Faust#define CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 158*c217d954SCole Faust CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 159*c217d954SCole Faust VSTORE(N0) \ 160*c217d954SCole Faust (CONVERT_SAT((BASENAME##D), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 161*c217d954SCole Faust 162*c217d954SCole Faust#define CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 163*c217d954SCole Faust CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 164*c217d954SCole Faust VSTORE(N0) \ 165*c217d954SCole Faust (CONVERT_SAT((BASENAME##E), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 166*c217d954SCole Faust 167*c217d954SCole Faust#define CONVERT_STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 168*c217d954SCole Faust CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 169*c217d954SCole Faust VSTORE(N0) \ 170*c217d954SCole Faust (CONVERT_SAT((BASENAME##F), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 171*c217d954SCole Faust 172*c217d954SCole Faust 173*c217d954SCole Faust 174*c217d954SCole Faust 175*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) 176*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) 177*c217d954SCole Faust 178*c217d954SCole Faust 179*c217d954SCole Faust 180*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) 181*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) 182*c217d954SCole Faust 183*c217d954SCole Faust 184*c217d954SCole Faust 185*c217d954SCole Faust#define STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 186*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 187*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 188*c217d954SCole Faust 189*c217d954SCole Faust#define STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 190*c217d954SCole Faust STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 191*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 192*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 193*c217d954SCole Faust 194*c217d954SCole Faust#define STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 195*c217d954SCole Faust STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 196*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 197*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 198*c217d954SCole Faust 199*c217d954SCole Faust#define STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 200*c217d954SCole Faust STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 201*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 202*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 203*c217d954SCole Faust 204*c217d954SCole Faust#define STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 205*c217d954SCole Faust STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 206*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 207*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 208*c217d954SCole Faust 209*c217d954SCole Faust#define STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 210*c217d954SCole Faust STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 211*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 212*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 213*c217d954SCole Faust 214*c217d954SCole Faust#define STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 215*c217d954SCole Faust STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 216*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 217*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 218*c217d954SCole Faust 219*c217d954SCole Faust#define STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 220*c217d954SCole Faust STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 221*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 222*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 223*c217d954SCole Faust 224*c217d954SCole Faust#define STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 225*c217d954SCole Faust STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 226*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 227*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 228*c217d954SCole Faust 229*c217d954SCole Faust#define STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 230*c217d954SCole Faust STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 231*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 232*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 233*c217d954SCole Faust 234*c217d954SCole Faust#define STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 235*c217d954SCole Faust STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 236*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 237*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 238*c217d954SCole Faust 239*c217d954SCole Faust#define STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 240*c217d954SCole Faust STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 241*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 242*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 243*c217d954SCole Faust 244*c217d954SCole Faust#define STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 245*c217d954SCole Faust STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 246*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 247*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 248*c217d954SCole Faust 249*c217d954SCole Faust#define STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 250*c217d954SCole Faust STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 251*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 252*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 253*c217d954SCole Faust 254*c217d954SCole Faust#define STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 255*c217d954SCole Faust STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 256*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 257*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 258*c217d954SCole Faust 259*c217d954SCole Faust#define STORE_ROW_PARTIAL_16(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 260*c217d954SCole Faust STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 261*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 262*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 263*c217d954SCole Faust 264*c217d954SCole Faust 265*c217d954SCole Faust 266*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) 267*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) 268*c217d954SCole Faust 269*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) \ 270*c217d954SCole Faust if(!(PARTIAL_COND_X) && !(PARTIAL_COND_Y)) \ 271*c217d954SCole Faust { \ 272*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 273*c217d954SCole Faust } \ 274*c217d954SCole Faust else if((PARTIAL_COND_Y) && !(PARTIAL_COND_X)) \ 275*c217d954SCole Faust { \ 276*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 277*c217d954SCole Faust } \ 278*c217d954SCole Faust else if(!(PARTIAL_COND_Y) && (PARTIAL_COND_X)) \ 279*c217d954SCole Faust { \ 280*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 281*c217d954SCole Faust } \ 282*c217d954SCole Faust else \ 283*c217d954SCole Faust { \ 284*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 285*c217d954SCole Faust } 286*c217d954SCole Faust 287*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) \ 288*c217d954SCole Faust if(!(PARTIAL_COND_X)) \ 289*c217d954SCole Faust { \ 290*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 291*c217d954SCole Faust } \ 292*c217d954SCole Faust else \ 293*c217d954SCole Faust { \ 294*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 295*c217d954SCole Faust } 296*c217d954SCole Faust 297*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) \ 298*c217d954SCole Faust if(!(PARTIAL_COND_Y)) \ 299*c217d954SCole Faust { \ 300*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 301*c217d954SCole Faust } \ 302*c217d954SCole Faust else \ 303*c217d954SCole Faust { \ 304*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 305*c217d954SCole Faust } 306*c217d954SCole Faust 307*c217d954SCole Faust 308*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) && defined(PARTIAL_STORE_N0) 309*c217d954SCole Faust 310*c217d954SCole Faust 311*c217d954SCole Faust#if PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 == 0 312*c217d954SCole Faust 313*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) \ 314*c217d954SCole Faust STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 315*c217d954SCole Faust 316*c217d954SCole Faust#elif PARTIAL_STORE_M0 > 0 && PARTIAL_STORE_N0 == 0 317*c217d954SCole Faust 318*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) \ 319*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) 320*c217d954SCole Faust 321*c217d954SCole Faust#elif PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 > 0 322*c217d954SCole Faust 323*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) \ 324*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) 325*c217d954SCole Faust 326*c217d954SCole Faust#else 327*c217d954SCole Faust 328*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) \ 329*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) 330*c217d954SCole Faust 331*c217d954SCole Faust#endif 332*c217d954SCole Faust 333*c217d954SCole Faust#endif 334*c217d954SCole Faust 335*c217d954SCole Faust 336*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) 337*c217d954SCole Faust 338*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 339*c217d954SCole Faust ((uint)(max(0, (int)(y * M0) - (int)((M0 - PARTIAL_STORE_M0) % M0)))) 340*c217d954SCole Faust#else 341*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 342*c217d954SCole Faust ((uint)(y * M0)) 343*c217d954SCole Faust#endif 344*c217d954SCole Faust 345*c217d954SCole Faust 346*c217d954SCole Faust 347*c217d954SCole Faust#define STORE_VECTOR_SELECT(basename, data_type, ptr, vec_size, leftover, cond) \ 348*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(1, vec_size, data_type, basename, ptr, 0, 0, leftover, cond) 349*c217d954SCole Faust 350*c217d954SCole Faust 351*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 352*c217d954SCole Faust#pragma OPENCL EXTENSION cl_khr_fp16 : enable 353*c217d954SCole Faust#endif 354*c217d954SCole Faust 355*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ENABLED) && defined(cl_arm_integer_dot_product_int8) 356*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable 357*c217d954SCole Faust#endif 358*c217d954SCole Faust 359*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED) && defined(cl_arm_integer_dot_product_accumulate_int8) 360*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable 361*c217d954SCole Faust#endif 362*c217d954SCole Faust 363*c217d954SCole Faust#if defined(ARM_COMPUTE_DEBUG_ENABLED) && defined(cl_arm_printf) 364*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_printf : enable 365*c217d954SCole Faust#endif 366*c217d954SCole Faust 367*c217d954SCole Faust#define GPU_ARCH_MIDGARD 0x100 368*c217d954SCole Faust#define GPU_ARCH_BIFROST 0x200 369*c217d954SCole Faust#define GPU_ARCH_VALHALL 0x300 370*c217d954SCole Faust 371*c217d954SCole Faust 372*c217d954SCole Faust#define CONCAT(a, b) a##b 373*c217d954SCole Faust 374*c217d954SCole Faust 375*c217d954SCole Faust#define EXPAND(x) x 376*c217d954SCole Faust 377*c217d954SCole Faust 378*c217d954SCole Faust#define CLAMP(x, min_val, max_val) min(max(x, min_val), max_val) 379*c217d954SCole Faust 380*c217d954SCole Faust 381*c217d954SCole Faust#define REV1(x) ((x)) 382*c217d954SCole Faust#define REV2(x) ((x).s10) 383*c217d954SCole Faust#define REV3(x) ((x).s210) 384*c217d954SCole Faust#define REV4(x) ((x).s3210) 385*c217d954SCole Faust#define REV8(x) ((x).s76543210) 386*c217d954SCole Faust#define REV16(x) ((x).sFEDCBA9876543210) 387*c217d954SCole Faust 388*c217d954SCole Faust 389*c217d954SCole Faust 390*c217d954SCole Faust#define REVERSE_STR(x, s) REV##s((x)) 391*c217d954SCole Faust#define REVERSE(x, s) REVERSE_STR(x, s) 392*c217d954SCole Faust 393*c217d954SCole Faust 394*c217d954SCole Faust 395*c217d954SCole Faust#define ROT1_0(x) ((x)) 396*c217d954SCole Faust#define ROT1_1(x) ((x)) 397*c217d954SCole Faust 398*c217d954SCole Faust#define ROT2_0(x) ((x)) 399*c217d954SCole Faust#define ROT2_1(x) ((x).s10) 400*c217d954SCole Faust#define ROT2_2(x) ((x)) 401*c217d954SCole Faust 402*c217d954SCole Faust#define ROT3_0(x) ((x)) 403*c217d954SCole Faust#define ROT3_1(x) ((x).s201) 404*c217d954SCole Faust#define ROT3_2(x) ((x).s120) 405*c217d954SCole Faust#define ROT3_3(x) ((x)) 406*c217d954SCole Faust 407*c217d954SCole Faust#define ROT4_0(x) ((x)) 408*c217d954SCole Faust#define ROT4_1(x) ((x).s3012) 409*c217d954SCole Faust#define ROT4_2(x) ((x).s2301) 410*c217d954SCole Faust#define ROT4_3(x) ((x).s1230) 411*c217d954SCole Faust#define ROT4_4(x) ((x)) 412*c217d954SCole Faust 413*c217d954SCole Faust#define ROT8_0(x) ((x)) 414*c217d954SCole Faust#define ROT8_1(x) ((x).s70123456) 415*c217d954SCole Faust#define ROT8_2(x) ((x).s67012345) 416*c217d954SCole Faust#define ROT8_3(x) ((x).s56701234) 417*c217d954SCole Faust#define ROT8_4(x) ((x).s45670123) 418*c217d954SCole Faust#define ROT8_5(x) ((x).s34567012) 419*c217d954SCole Faust#define ROT8_6(x) ((x).s23456701) 420*c217d954SCole Faust#define ROT8_7(x) ((x).s12345670) 421*c217d954SCole Faust#define ROT8_8(x) ((x)) 422*c217d954SCole Faust 423*c217d954SCole Faust#define ROT16_0(x) ((x)) 424*c217d954SCole Faust#define ROT16_1(x) ((x).sF0123456789ABCDE) 425*c217d954SCole Faust#define ROT16_2(x) ((x).sEF0123456789ABCD) 426*c217d954SCole Faust#define ROT16_3(x) ((x).sDEF0123456789ABC) 427*c217d954SCole Faust#define ROT16_4(x) ((x).sCDEF0123456789AB) 428*c217d954SCole Faust#define ROT16_5(x) ((x).sBCDEF0123456789A) 429*c217d954SCole Faust#define ROT16_6(x) ((x).sABCDEF0123456789) 430*c217d954SCole Faust#define ROT16_7(x) ((x).s9ABCDEF012345678) 431*c217d954SCole Faust#define ROT16_8(x) ((x).s89ABCDEF01234567) 432*c217d954SCole Faust#define ROT16_9(x) ((x).s789ABCDEF0123456) 433*c217d954SCole Faust#define ROT16_10(x) ((x).s6789ABCDEF012345) 434*c217d954SCole Faust#define ROT16_11(x) ((x).s56789ABCDEF01234) 435*c217d954SCole Faust#define ROT16_12(x) ((x).s456789ABCDEF0123) 436*c217d954SCole Faust#define ROT16_13(x) ((x).s3456789ABCDEF012) 437*c217d954SCole Faust#define ROT16_14(x) ((x).s23456789ABCDEF01) 438*c217d954SCole Faust#define ROT16_15(x) ((x).s123456789ABCDEF0) 439*c217d954SCole Faust#define ROT16_16(x) ((x)) 440*c217d954SCole Faust 441*c217d954SCole Faust 442*c217d954SCole Faust 443*c217d954SCole Faust#define ROTATE_STR(x, s, n) ROT##s##_##n(x) 444*c217d954SCole Faust#define ROTATE(x, s, n) ROTATE_STR(x, s, n) 445*c217d954SCole Faust 446*c217d954SCole Faust 447*c217d954SCole Faust 448*c217d954SCole Faust#define V_OFFS1(dt) (dt##1)(0) 449*c217d954SCole Faust#define V_OFFS2(dt) (dt##2)(0, 1) 450*c217d954SCole Faust#define V_OFFS3(dt) (dt##3)(0, 1, 2) 451*c217d954SCole Faust#define V_OFFS4(dt) (dt##4)(0, 1, 2, 3) 452*c217d954SCole Faust#define V_OFFS8(dt) (dt##8)(0, 1, 2, 3, 4, 5, 6, 7) 453*c217d954SCole Faust#define V_OFFS16(dt) (dt##16)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) 454*c217d954SCole Faust 455*c217d954SCole Faust 456*c217d954SCole Faust 457*c217d954SCole Faust#define VEC_OFFS_STR(dt, s) V_OFFS##s(dt) 458*c217d954SCole Faust#define VEC_OFFS(dt, s) VEC_OFFS_STR(dt, s) 459*c217d954SCole Faust 460*c217d954SCole Faust 461*c217d954SCole Faust#define VLOAD_STR(size) vload##size 462*c217d954SCole Faust#define VLOAD(size) VLOAD_STR(size) 463*c217d954SCole Faust 464*c217d954SCole Faust 465*c217d954SCole Faust#define VLOAD_PARTIAL_STR(size, load_size) vload_partial_##size##_##load_size 466*c217d954SCole Faust#define VLOAD_PARTIAL(size, load_size) VLOAD_PARTIAL_STR(size, load_size) 467*c217d954SCole Faust 468*c217d954SCole Faust#define NO_LOAD(data, offs, ptr) \ 469*c217d954SCole Faust { \ 470*c217d954SCole Faust } 471*c217d954SCole Faust 472*c217d954SCole Faust 473*c217d954SCole Faust#define vload_partial_1_0 NO_LOAD 474*c217d954SCole Faust#define vload_partial_1_1 vload1 475*c217d954SCole Faust#define vload_partial_1_2 NO_LOAD 476*c217d954SCole Faust#define vload_partial_1_3 NO_LOAD 477*c217d954SCole Faust#define vload_partial_1_4 NO_LOAD 478*c217d954SCole Faust#define vload_partial_1_5 NO_LOAD 479*c217d954SCole Faust#define vload_partial_1_6 NO_LOAD 480*c217d954SCole Faust#define vload_partial_1_7 NO_LOAD 481*c217d954SCole Faust#define vload_partial_1_8 NO_LOAD 482*c217d954SCole Faust#define vload_partial_1_9 NO_LOAD 483*c217d954SCole Faust#define vload_partial_1_10 NO_LOAD 484*c217d954SCole Faust#define vload_partial_1_11 NO_LOAD 485*c217d954SCole Faust#define vload_partial_1_12 NO_LOAD 486*c217d954SCole Faust#define vload_partial_1_13 NO_LOAD 487*c217d954SCole Faust#define vload_partial_1_14 NO_LOAD 488*c217d954SCole Faust#define vload_partial_1_15 NO_LOAD 489*c217d954SCole Faust#define vload_partial_1_16 NO_LOAD 490*c217d954SCole Faust 491*c217d954SCole Faust#define vload_partial_2_0 NO_LOAD 492*c217d954SCole Faust#define vload_partial_2_1 vload_partial_1 493*c217d954SCole Faust#define vload_partial_2_2 vload_partial_2 494*c217d954SCole Faust#define vload_partial_2_3 NO_LOAD 495*c217d954SCole Faust#define vload_partial_2_4 NO_LOAD 496*c217d954SCole Faust#define vload_partial_2_5 NO_LOAD 497*c217d954SCole Faust#define vload_partial_2_6 NO_LOAD 498*c217d954SCole Faust#define vload_partial_2_7 NO_LOAD 499*c217d954SCole Faust#define vload_partial_2_8 NO_LOAD 500*c217d954SCole Faust#define vload_partial_2_9 NO_LOAD 501*c217d954SCole Faust#define vload_partial_2_10 NO_LOAD 502*c217d954SCole Faust#define vload_partial_2_11 NO_LOAD 503*c217d954SCole Faust#define vload_partial_2_12 NO_LOAD 504*c217d954SCole Faust#define vload_partial_2_13 NO_LOAD 505*c217d954SCole Faust#define vload_partial_2_14 NO_LOAD 506*c217d954SCole Faust#define vload_partial_2_15 NO_LOAD 507*c217d954SCole Faust#define vload_partial_2_16 NO_LOAD 508*c217d954SCole Faust 509*c217d954SCole Faust#define vload_partial_3_0 NO_LOAD 510*c217d954SCole Faust#define vload_partial_3_1 vload_partial_1 511*c217d954SCole Faust#define vload_partial_3_2 vload_partial_2 512*c217d954SCole Faust#define vload_partial_3_3 vload_partial_3 513*c217d954SCole Faust#define vload_partial_3_4 NO_LOAD 514*c217d954SCole Faust#define vload_partial_3_5 NO_LOAD 515*c217d954SCole Faust#define vload_partial_3_6 NO_LOAD 516*c217d954SCole Faust#define vload_partial_3_7 NO_LOAD 517*c217d954SCole Faust#define vload_partial_3_8 NO_LOAD 518*c217d954SCole Faust#define vload_partial_3_9 NO_LOAD 519*c217d954SCole Faust#define vload_partial_3_10 NO_LOAD 520*c217d954SCole Faust#define vload_partial_3_11 NO_LOAD 521*c217d954SCole Faust#define vload_partial_3_12 NO_LOAD 522*c217d954SCole Faust#define vload_partial_3_13 NO_LOAD 523*c217d954SCole Faust#define vload_partial_3_14 NO_LOAD 524*c217d954SCole Faust#define vload_partial_3_15 NO_LOAD 525*c217d954SCole Faust#define vload_partial_3_16 NO_LOAD 526*c217d954SCole Faust 527*c217d954SCole Faust#define vload_partial_4_0 NO_LOAD 528*c217d954SCole Faust#define vload_partial_4_1 vload_partial_1 529*c217d954SCole Faust#define vload_partial_4_2 vload_partial_2 530*c217d954SCole Faust#define vload_partial_4_3 vload_partial_3 531*c217d954SCole Faust#define vload_partial_4_4 vload_partial_4 532*c217d954SCole Faust#define vload_partial_4_5 NO_LOAD 533*c217d954SCole Faust#define vload_partial_4_6 NO_LOAD 534*c217d954SCole Faust#define vload_partial_4_7 NO_LOAD 535*c217d954SCole Faust#define vload_partial_4_8 NO_LOAD 536*c217d954SCole Faust#define vload_partial_4_9 NO_LOAD 537*c217d954SCole Faust#define vload_partial_4_10 NO_LOAD 538*c217d954SCole Faust#define vload_partial_4_11 NO_LOAD 539*c217d954SCole Faust#define vload_partial_4_12 NO_LOAD 540*c217d954SCole Faust#define vload_partial_4_13 NO_LOAD 541*c217d954SCole Faust#define vload_partial_4_14 NO_LOAD 542*c217d954SCole Faust#define vload_partial_4_15 NO_LOAD 543*c217d954SCole Faust#define vload_partial_4_16 NO_LOAD 544*c217d954SCole Faust 545*c217d954SCole Faust#define vload_partial_8_0 NO_LOAD 546*c217d954SCole Faust#define vload_partial_8_1 vload_partial_1 547*c217d954SCole Faust#define vload_partial_8_2 vload_partial_2 548*c217d954SCole Faust#define vload_partial_8_3 vload_partial_3 549*c217d954SCole Faust#define vload_partial_8_4 vload_partial_4 550*c217d954SCole Faust#define vload_partial_8_5 vload_partial_5 551*c217d954SCole Faust#define vload_partial_8_6 vload_partial_6 552*c217d954SCole Faust#define vload_partial_8_7 vload_partial_7 553*c217d954SCole Faust#define vload_partial_8_8 vload_partial_8 554*c217d954SCole Faust#define vload_partial_8_9 NO_LOAD 555*c217d954SCole Faust#define vload_partial_8_10 NO_LOAD 556*c217d954SCole Faust#define vload_partial_8_11 NO_LOAD 557*c217d954SCole Faust#define vload_partial_8_12 NO_LOAD 558*c217d954SCole Faust#define vload_partial_8_13 NO_LOAD 559*c217d954SCole Faust#define vload_partial_8_14 NO_LOAD 560*c217d954SCole Faust#define vload_partial_8_15 NO_LOAD 561*c217d954SCole Faust#define vload_partial_8_16 NO_LOAD 562*c217d954SCole Faust 563*c217d954SCole Faust#define vload_partial_16_0 NO_LOAD 564*c217d954SCole Faust#define vload_partial_16_1 vload_partial_1 565*c217d954SCole Faust#define vload_partial_16_2 vload_partial_2 566*c217d954SCole Faust#define vload_partial_16_3 vload_partial_3 567*c217d954SCole Faust#define vload_partial_16_4 vload_partial_4 568*c217d954SCole Faust#define vload_partial_16_5 vload_partial_5 569*c217d954SCole Faust#define vload_partial_16_6 vload_partial_6 570*c217d954SCole Faust#define vload_partial_16_7 vload_partial_7 571*c217d954SCole Faust#define vload_partial_16_8 vload_partial_8 572*c217d954SCole Faust#define vload_partial_16_9 vload_partial_9 573*c217d954SCole Faust#define vload_partial_16_10 vload_partial_10 574*c217d954SCole Faust#define vload_partial_16_11 vload_partial_11 575*c217d954SCole Faust#define vload_partial_16_12 vload_partial_12 576*c217d954SCole Faust#define vload_partial_16_13 vload_partial_13 577*c217d954SCole Faust#define vload_partial_16_14 vload_partial_14 578*c217d954SCole Faust#define vload_partial_16_15 vload_partial_15 579*c217d954SCole Faust#define vload_partial_16_16 vload_partial_16 580*c217d954SCole Faust 581*c217d954SCole Faust 582*c217d954SCole Faust#define vload_partial_1(DATA, OFFSET, PTR) \ 583*c217d954SCole Faust DATA.s0 = vload1(OFFSET, PTR); 584*c217d954SCole Faust 585*c217d954SCole Faust#define vload_partial_2(DATA, OFFSET, PTR) \ 586*c217d954SCole Faust DATA.s01 = vload2(OFFSET, PTR); 587*c217d954SCole Faust 588*c217d954SCole Faust#define vload_partial_3(DATA, OFFSET, PTR) \ 589*c217d954SCole Faust DATA.s012 = vload3(OFFSET, PTR); 590*c217d954SCole Faust 591*c217d954SCole Faust#define vload_partial_4(DATA, OFFSET, PTR) \ 592*c217d954SCole Faust DATA.s0123 = vload4(OFFSET, PTR); 593*c217d954SCole Faust 594*c217d954SCole Faust#define vload_partial_5(DATA, OFFSET, PTR) \ 595*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 596*c217d954SCole Faust DATA.s4 = vload1(OFFSET, PTR + 4); 597*c217d954SCole Faust 598*c217d954SCole Faust#define vload_partial_6(DATA, OFFSET, PTR) \ 599*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 600*c217d954SCole Faust vload_partial_2(DATA.s45, OFFSET, PTR + 4); 601*c217d954SCole Faust 602*c217d954SCole Faust#define vload_partial_7(DATA, OFFSET, PTR) \ 603*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 604*c217d954SCole Faust vload_partial_3(DATA.s456, OFFSET, PTR + 4); 605*c217d954SCole Faust 606*c217d954SCole Faust#define vload_partial_8(DATA, OFFSET, PTR) \ 607*c217d954SCole Faust DATA.s01234567 = vload8(OFFSET, PTR); 608*c217d954SCole Faust 609*c217d954SCole Faust#define vload_partial_9(DATA, OFFSET, PTR) \ 610*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 611*c217d954SCole Faust DATA.s8 = vload1(OFFSET, PTR + 8); 612*c217d954SCole Faust 613*c217d954SCole Faust#define vload_partial_10(DATA, OFFSET, PTR) \ 614*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 615*c217d954SCole Faust vload_partial_2(DATA.s89, OFFSET, PTR + 8); 616*c217d954SCole Faust 617*c217d954SCole Faust#define vload_partial_11(DATA, OFFSET, PTR) \ 618*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 619*c217d954SCole Faust vload_partial_3(DATA.s89A, OFFSET, PTR + 8); 620*c217d954SCole Faust 621*c217d954SCole Faust#define vload_partial_12(DATA, OFFSET, PTR) \ 622*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 623*c217d954SCole Faust vload_partial_4(DATA.s89AB, OFFSET, PTR + 8); 624*c217d954SCole Faust 625*c217d954SCole Faust#define vload_partial_13(DATA, OFFSET, PTR) \ 626*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 627*c217d954SCole Faust vload_partial_5(DATA.s89ABCDEF, OFFSET, PTR + 8); 628*c217d954SCole Faust 629*c217d954SCole Faust#define vload_partial_14(DATA, OFFSET, PTR) \ 630*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 631*c217d954SCole Faust vload_partial_6(DATA.s89ABCDEF, OFFSET, PTR + 8); 632*c217d954SCole Faust 633*c217d954SCole Faust#define vload_partial_15(DATA, OFFSET, PTR) \ 634*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 635*c217d954SCole Faust vload_partial_7(DATA.s89ABCDEF, OFFSET, PTR + 8); 636*c217d954SCole Faust 637*c217d954SCole Faust#define vload_partial_16(DATA, OFFSET, PTR) \ 638*c217d954SCole Faust DATA = vload16(OFFSET, PTR); 639*c217d954SCole Faust 640*c217d954SCole Faust 641*c217d954SCole Faust 642*c217d954SCole Faust#define PIXEL_UNIT4 1 643*c217d954SCole Faust#define PIXEL_UNIT8 2 644*c217d954SCole Faust#define PIXEL_UNIT16 4 645*c217d954SCole Faust 646*c217d954SCole Faust 647*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) PIXEL_UNIT##vec_size 648*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT(vec_size) CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) 649*c217d954SCole Faust 650*c217d954SCole Faust 651*c217d954SCole Faust#define read_image2d_floatx1(img, x_coord, y_coord) (float4)(read_imagef(img, (int2)(x_coord, y_coord))); 652*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))); 653*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))); 654*c217d954SCole Faust 655*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 656*c217d954SCole Faust#define read_image2d_halfx1(img, x_coord, y_coord) (half4)(read_imageh(img, (int2)(x_coord, y_coord))); 657*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))); 658*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))); 659*c217d954SCole Faust#endif 660*c217d954SCole Faust 661*c217d954SCole Faust#define write_image2d_floatx1(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values)); 662*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)); 663*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)); 664*c217d954SCole Faust 665*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 666*c217d954SCole Faust#define write_image2d_halfx1(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values)); 667*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)); 668*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)); 669*c217d954SCole Faust#endif 670*c217d954SCole Faust 671*c217d954SCole Faust 672*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) 673*c217d954SCole Faust#define READ_IMAGE2D(data_type, n0, img, x_coord, y_coord) READ_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord) 674*c217d954SCole Faust 675*c217d954SCole Faust 676*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) 677*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) 678*c217d954SCole Faust 679*c217d954SCole Faust#define VSTORE_STR(size) vstore##size 680*c217d954SCole Faust#define VSTORE(size) VSTORE_STR(size) 681*c217d954SCole Faust 682*c217d954SCole Faust#define float1 float 683*c217d954SCole Faust#define half1 half 684*c217d954SCole Faust#define char1 char 685*c217d954SCole Faust#define uchar1 uchar 686*c217d954SCole Faust#define short1 short 687*c217d954SCole Faust#define ushort1 ushort 688*c217d954SCole Faust#define int1 int 689*c217d954SCole Faust#define uint1 uint 690*c217d954SCole Faust#define long1 long 691*c217d954SCole Faust#define ulong1 ulong 692*c217d954SCole Faust#define double1 double 693*c217d954SCole Faust 694*c217d954SCole Faust#define vload1(OFFSET, PTR) *(OFFSET + PTR) 695*c217d954SCole Faust#define vstore1(DATA, OFFSET, PTR) *(OFFSET + PTR) = DATA 696*c217d954SCole Faust 697*c217d954SCole Faust 698*c217d954SCole Faust#define VSTORE_PARTIAL_STR(size, store_size) vstore_partial_##size##_##store_size 699*c217d954SCole Faust#define VSTORE_PARTIAL(size, store_size) VSTORE_PARTIAL_STR(size, store_size) 700*c217d954SCole Faust 701*c217d954SCole Faust#define NO_STORE(data, offs, ptr) \ 702*c217d954SCole Faust { \ 703*c217d954SCole Faust } 704*c217d954SCole Faust 705*c217d954SCole Faust 706*c217d954SCole Faust#define vstore_partial_1_0 NO_STORE 707*c217d954SCole Faust#define vstore_partial_1_1 vstore1 708*c217d954SCole Faust#define vstore_partial_1_2 NO_STORE 709*c217d954SCole Faust#define vstore_partial_1_3 NO_STORE 710*c217d954SCole Faust#define vstore_partial_1_4 NO_STORE 711*c217d954SCole Faust#define vstore_partial_1_5 NO_STORE 712*c217d954SCole Faust#define vstore_partial_1_6 NO_STORE 713*c217d954SCole Faust#define vstore_partial_1_7 NO_STORE 714*c217d954SCole Faust#define vstore_partial_1_8 NO_STORE 715*c217d954SCole Faust#define vstore_partial_1_9 NO_STORE 716*c217d954SCole Faust#define vstore_partial_1_10 NO_STORE 717*c217d954SCole Faust#define vstore_partial_1_11 NO_STORE 718*c217d954SCole Faust#define vstore_partial_1_12 NO_STORE 719*c217d954SCole Faust#define vstore_partial_1_13 NO_STORE 720*c217d954SCole Faust#define vstore_partial_1_14 NO_STORE 721*c217d954SCole Faust#define vstore_partial_1_15 NO_STORE 722*c217d954SCole Faust#define vstore_partial_1_16 NO_STORE 723*c217d954SCole Faust 724*c217d954SCole Faust#define vstore_partial_2_0 NO_STORE 725*c217d954SCole Faust#define vstore_partial_2_1 vstore_partial_1 726*c217d954SCole Faust#define vstore_partial_2_2 vstore_partial_2 727*c217d954SCole Faust#define vstore_partial_2_3 NO_STORE 728*c217d954SCole Faust#define vstore_partial_2_4 NO_STORE 729*c217d954SCole Faust#define vstore_partial_2_5 NO_STORE 730*c217d954SCole Faust#define vstore_partial_2_6 NO_STORE 731*c217d954SCole Faust#define vstore_partial_2_7 NO_STORE 732*c217d954SCole Faust#define vstore_partial_2_8 NO_STORE 733*c217d954SCole Faust#define vstore_partial_2_9 NO_STORE 734*c217d954SCole Faust#define vstore_partial_2_10 NO_STORE 735*c217d954SCole Faust#define vstore_partial_2_11 NO_STORE 736*c217d954SCole Faust#define vstore_partial_2_12 NO_STORE 737*c217d954SCole Faust#define vstore_partial_2_13 NO_STORE 738*c217d954SCole Faust#define vstore_partial_2_14 NO_STORE 739*c217d954SCole Faust#define vstore_partial_2_15 NO_STORE 740*c217d954SCole Faust#define vstore_partial_2_16 NO_STORE 741*c217d954SCole Faust 742*c217d954SCole Faust#define vstore_partial_3_0 NO_STORE 743*c217d954SCole Faust#define vstore_partial_3_1 vstore_partial_1 744*c217d954SCole Faust#define vstore_partial_3_2 vstore_partial_2 745*c217d954SCole Faust#define vstore_partial_3_3 vstore_partial_3 746*c217d954SCole Faust#define vstore_partial_3_4 NO_STORE 747*c217d954SCole Faust#define vstore_partial_3_5 NO_STORE 748*c217d954SCole Faust#define vstore_partial_3_6 NO_STORE 749*c217d954SCole Faust#define vstore_partial_3_7 NO_STORE 750*c217d954SCole Faust#define vstore_partial_3_8 NO_STORE 751*c217d954SCole Faust#define vstore_partial_3_9 NO_STORE 752*c217d954SCole Faust#define vstore_partial_3_10 NO_STORE 753*c217d954SCole Faust#define vstore_partial_3_11 NO_STORE 754*c217d954SCole Faust#define vstore_partial_3_12 NO_STORE 755*c217d954SCole Faust#define vstore_partial_3_13 NO_STORE 756*c217d954SCole Faust#define vstore_partial_3_14 NO_STORE 757*c217d954SCole Faust#define vstore_partial_3_15 NO_STORE 758*c217d954SCole Faust#define vstore_partial_3_16 NO_STORE 759*c217d954SCole Faust 760*c217d954SCole Faust#define vstore_partial_4_0 NO_STORE 761*c217d954SCole Faust#define vstore_partial_4_1 vstore_partial_1 762*c217d954SCole Faust#define vstore_partial_4_2 vstore_partial_2 763*c217d954SCole Faust#define vstore_partial_4_3 vstore_partial_3 764*c217d954SCole Faust#define vstore_partial_4_4 vstore_partial_4 765*c217d954SCole Faust#define vstore_partial_4_5 NO_STORE 766*c217d954SCole Faust#define vstore_partial_4_6 NO_STORE 767*c217d954SCole Faust#define vstore_partial_4_7 NO_STORE 768*c217d954SCole Faust#define vstore_partial_4_8 NO_STORE 769*c217d954SCole Faust#define vstore_partial_4_9 NO_STORE 770*c217d954SCole Faust#define vstore_partial_4_10 NO_STORE 771*c217d954SCole Faust#define vstore_partial_4_11 NO_STORE 772*c217d954SCole Faust#define vstore_partial_4_12 NO_STORE 773*c217d954SCole Faust#define vstore_partial_4_13 NO_STORE 774*c217d954SCole Faust#define vstore_partial_4_14 NO_STORE 775*c217d954SCole Faust#define vstore_partial_4_15 NO_STORE 776*c217d954SCole Faust#define vstore_partial_4_16 NO_STORE 777*c217d954SCole Faust 778*c217d954SCole Faust#define vstore_partial_8_0 NO_STORE 779*c217d954SCole Faust#define vstore_partial_8_1 vstore_partial_1 780*c217d954SCole Faust#define vstore_partial_8_2 vstore_partial_2 781*c217d954SCole Faust#define vstore_partial_8_3 vstore_partial_3 782*c217d954SCole Faust#define vstore_partial_8_4 vstore_partial_4 783*c217d954SCole Faust#define vstore_partial_8_5 vstore_partial_5 784*c217d954SCole Faust#define vstore_partial_8_6 vstore_partial_6 785*c217d954SCole Faust#define vstore_partial_8_7 vstore_partial_7 786*c217d954SCole Faust#define vstore_partial_8_8 vstore_partial_8 787*c217d954SCole Faust#define vstore_partial_8_9 NO_STORE 788*c217d954SCole Faust#define vstore_partial_8_10 NO_STORE 789*c217d954SCole Faust#define vstore_partial_8_11 NO_STORE 790*c217d954SCole Faust#define vstore_partial_8_12 NO_STORE 791*c217d954SCole Faust#define vstore_partial_8_13 NO_STORE 792*c217d954SCole Faust#define vstore_partial_8_14 NO_STORE 793*c217d954SCole Faust#define vstore_partial_8_15 NO_STORE 794*c217d954SCole Faust#define vstore_partial_8_16 NO_STORE 795*c217d954SCole Faust 796*c217d954SCole Faust#define vstore_partial_16_0 NO_STORE 797*c217d954SCole Faust#define vstore_partial_16_1 vstore_partial_1 798*c217d954SCole Faust#define vstore_partial_16_2 vstore_partial_2 799*c217d954SCole Faust#define vstore_partial_16_3 vstore_partial_3 800*c217d954SCole Faust#define vstore_partial_16_4 vstore_partial_4 801*c217d954SCole Faust#define vstore_partial_16_5 vstore_partial_5 802*c217d954SCole Faust#define vstore_partial_16_6 vstore_partial_6 803*c217d954SCole Faust#define vstore_partial_16_7 vstore_partial_7 804*c217d954SCole Faust#define vstore_partial_16_8 vstore_partial_8 805*c217d954SCole Faust#define vstore_partial_16_9 vstore_partial_9 806*c217d954SCole Faust#define vstore_partial_16_10 vstore_partial_10 807*c217d954SCole Faust#define vstore_partial_16_11 vstore_partial_11 808*c217d954SCole Faust#define vstore_partial_16_12 vstore_partial_12 809*c217d954SCole Faust#define vstore_partial_16_13 vstore_partial_13 810*c217d954SCole Faust#define vstore_partial_16_14 vstore_partial_14 811*c217d954SCole Faust#define vstore_partial_16_15 vstore_partial_15 812*c217d954SCole Faust#define vstore_partial_16_16 vstore_partial_16 813*c217d954SCole Faust 814*c217d954SCole Faust 815*c217d954SCole Faust#define vstore_partial_1(DATA, OFFSET, PTR) \ 816*c217d954SCole Faust vstore1(DATA.s0, OFFSET, PTR); 817*c217d954SCole Faust 818*c217d954SCole Faust#define vstore_partial_2(DATA, OFFSET, PTR) \ 819*c217d954SCole Faust vstore2(DATA.s01, OFFSET, PTR); 820*c217d954SCole Faust 821*c217d954SCole Faust#define vstore_partial_3(DATA, OFFSET, PTR) \ 822*c217d954SCole Faust vstore3(DATA.s012, OFFSET, PTR); 823*c217d954SCole Faust 824*c217d954SCole Faust#define vstore_partial_4(DATA, OFFSET, PTR) \ 825*c217d954SCole Faust vstore4(DATA.s0123, OFFSET, PTR); 826*c217d954SCole Faust 827*c217d954SCole Faust#define vstore_partial_5(DATA, OFFSET, PTR) \ 828*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 829*c217d954SCole Faust vstore1(DATA.s4, OFFSET, PTR + 4); 830*c217d954SCole Faust 831*c217d954SCole Faust#define vstore_partial_6(DATA, OFFSET, PTR) \ 832*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 833*c217d954SCole Faust vstore_partial_2(DATA.s45, OFFSET, PTR + 4); 834*c217d954SCole Faust 835*c217d954SCole Faust#define vstore_partial_7(DATA, OFFSET, PTR) \ 836*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 837*c217d954SCole Faust vstore_partial_3(DATA.s456, OFFSET, PTR + 4); 838*c217d954SCole Faust 839*c217d954SCole Faust#define vstore_partial_8(DATA, OFFSET, PTR) \ 840*c217d954SCole Faust vstore8(DATA.s01234567, OFFSET, PTR); 841*c217d954SCole Faust 842*c217d954SCole Faust#define vstore_partial_9(DATA, OFFSET, PTR) \ 843*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 844*c217d954SCole Faust vstore1(DATA.s8, OFFSET, PTR + 8); 845*c217d954SCole Faust 846*c217d954SCole Faust#define vstore_partial_10(DATA, OFFSET, PTR) \ 847*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 848*c217d954SCole Faust vstore_partial_2(DATA.s89, OFFSET, PTR + 8); 849*c217d954SCole Faust 850*c217d954SCole Faust#define vstore_partial_11(DATA, OFFSET, PTR) \ 851*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 852*c217d954SCole Faust vstore_partial_3(DATA.s89a, OFFSET, PTR + 8); 853*c217d954SCole Faust 854*c217d954SCole Faust#define vstore_partial_12(DATA, OFFSET, PTR) \ 855*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 856*c217d954SCole Faust vstore_partial_4(DATA.s89ab, OFFSET, PTR + 8); 857*c217d954SCole Faust 858*c217d954SCole Faust#define vstore_partial_13(DATA, OFFSET, PTR) \ 859*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 860*c217d954SCole Faust vstore_partial_5(DATA.s89abcdef, OFFSET, PTR + 8); 861*c217d954SCole Faust 862*c217d954SCole Faust#define vstore_partial_14(DATA, OFFSET, PTR) \ 863*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 864*c217d954SCole Faust vstore_partial_6(DATA.s89abcdef, OFFSET, PTR + 8); 865*c217d954SCole Faust 866*c217d954SCole Faust#define vstore_partial_15(DATA, OFFSET, PTR) \ 867*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 868*c217d954SCole Faust vstore_partial_7(DATA.s89abcdef, OFFSET, PTR + 8); 869*c217d954SCole Faust 870*c217d954SCole Faust#define vstore_partial_16(DATA, OFFSET, PTR) \ 871*c217d954SCole Faust vstore16(DATA, OFFSET, PTR); 872*c217d954SCole Faust 873*c217d954SCole Faust 874*c217d954SCole Faust 875*c217d954SCole Faust 876*c217d954SCole Faust 877*c217d954SCole Faust#define convert_float_sat convert_float 878*c217d954SCole Faust#define convert_float1_sat convert_float 879*c217d954SCole Faust#define convert_float2_sat convert_float2 880*c217d954SCole Faust#define convert_float3_sat convert_float3 881*c217d954SCole Faust#define convert_float4_sat convert_float4 882*c217d954SCole Faust#define convert_float8_sat convert_float8 883*c217d954SCole Faust#define convert_float16_sat convert_float16 884*c217d954SCole Faust#define convert_half_sat convert_float 885*c217d954SCole Faust#define convert_half1_sat convert_half 886*c217d954SCole Faust#define convert_half2_sat convert_half2 887*c217d954SCole Faust#define convert_half3_sat convert_half3 888*c217d954SCole Faust#define convert_half4_sat convert_half4 889*c217d954SCole Faust#define convert_half8_sat convert_half8 890*c217d954SCole Faust#define convert_half16_sat convert_half16 891*c217d954SCole Faust 892*c217d954SCole Faust#define convert_float1 convert_float 893*c217d954SCole Faust#define convert_half1 convert_half 894*c217d954SCole Faust#define convert_char1 convert_char 895*c217d954SCole Faust#define convert_uchar1 convert_uchar 896*c217d954SCole Faust#define convert_short1 convert_short 897*c217d954SCole Faust#define convert_ushort1 convert_ushort 898*c217d954SCole Faust#define convert_int1 convert_int 899*c217d954SCole Faust#define convert_uint1 convert_uint 900*c217d954SCole Faust#define convert_long1 convert_long 901*c217d954SCole Faust#define convert_ulong1 convert_ulong 902*c217d954SCole Faust#define convert_double1 convert_double 903*c217d954SCole Faust 904*c217d954SCole Faust#define convert_char1_sat convert_char_sat 905*c217d954SCole Faust#define convert_uchar1_sat convert_uchar_sat 906*c217d954SCole Faust#define convert_uchar2_sat convert_uchar2_sat 907*c217d954SCole Faust#define convert_uchar3_sat convert_uchar3_sat 908*c217d954SCole Faust#define convert_uchar4_sat convert_uchar4_sat 909*c217d954SCole Faust#define convert_uchar8_sat convert_uchar8_sat 910*c217d954SCole Faust#define convert_uchar16_sat convert_uchar16_sat 911*c217d954SCole Faust#define convert_short1_sat convert_short_sat 912*c217d954SCole Faust#define convert_ushort1_sat convert_ushort_sat 913*c217d954SCole Faust#define convert_int1_sat convert_int_sat 914*c217d954SCole Faust#define convert_uint1_sat convert_uint_sat 915*c217d954SCole Faust#define convert_long1_sat convert_long_sat 916*c217d954SCole Faust#define convert_ulong1_sat convert_ulong_sat 917*c217d954SCole Faust#define convert_double1_sat convert_double_sat 918*c217d954SCole Faust 919*c217d954SCole Faust#define VEC_DATA_TYPE_STR(type, size) type##size 920*c217d954SCole Faust#define VEC_DATA_TYPE(type, size) VEC_DATA_TYPE_STR(type, size) 921*c217d954SCole Faust 922*c217d954SCole Faust#define CONVERT_STR(x, type) (convert_##type((x))) 923*c217d954SCole Faust#define CONVERT(x, type) CONVERT_STR(x, type) 924*c217d954SCole Faust 925*c217d954SCole Faust#define CONVERT_SAT_STR(x, type) (convert_##type##_sat((x))) 926*c217d954SCole Faust#define CONVERT_SAT(x, type) CONVERT_SAT_STR(x, type) 927*c217d954SCole Faust 928*c217d954SCole Faust#define CONVERT_SAT_ROUND_STR(x, type, round) (convert_##type##_sat_##round((x))) 929*c217d954SCole Faust#define CONVERT_SAT_ROUND(x, type, round) CONVERT_SAT_ROUND_STR(x, type, round) 930*c217d954SCole Faust 931*c217d954SCole Faust#define select_vec_dt_uchar(size) uchar##size 932*c217d954SCole Faust#define select_vec_dt_char(size) char##size 933*c217d954SCole Faust#define select_vec_dt_ushort(size) ushort##size 934*c217d954SCole Faust#define select_vec_dt_short(size) short##size 935*c217d954SCole Faust#define select_vec_dt_half(size) short##size 936*c217d954SCole Faust#define select_vec_dt_uint(size) uint##size 937*c217d954SCole Faust#define select_vec_dt_int(size) int##size 938*c217d954SCole Faust#define select_vec_dt_float(size) int##size 939*c217d954SCole Faust#define select_vec_dt_ulong(size) ulong##size 940*c217d954SCole Faust#define select_vec_dt_long(size) long##size 941*c217d954SCole Faust 942*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE_STR(type, size) select_vec_dt_##type(size) 943*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE(type, size) SELECT_VEC_DATA_TYPE_STR(type, size) 944*c217d954SCole Faust#define SELECT_DATA_TYPE(type) SELECT_VEC_DATA_TYPE_STR(type, 1) 945*c217d954SCole Faust 946*c217d954SCole Faust#define signed_int_vec_dt_uchar(size) char##size 947*c217d954SCole Faust#define signed_int_vec_dt_char(size) char##size 948*c217d954SCole Faust#define signed_int_vec_dt_ushort(size) short##size 949*c217d954SCole Faust#define signed_int_vec_dt_short(size) short##size 950*c217d954SCole Faust#define signed_int_vec_dt_half(size) short##size 951*c217d954SCole Faust#define signed_int_vec_dt_uint(size) int##size 952*c217d954SCole Faust#define signed_int_vec_dt_int(size) int##size 953*c217d954SCole Faust#define signed_int_vec_dt_float(size) int##size 954*c217d954SCole Faust#define signed_int_vec_dt_ulong(size) long##size 955*c217d954SCole Faust#define signed_int_vec_dt_long(size) long##size 956*c217d954SCole Faust 957*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE_STR(type, size) signed_int_vec_dt_##type(size) 958*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE(type, size) SIGNED_INT_VEC_DATA_TYPE_STR(type, size) 959*c217d954SCole Faust#define SIGNED_INT_DATA_TYPE(type) SIGNED_INT_VEC_DATA_TYPE_STR(type, 1) 960*c217d954SCole Faust 961*c217d954SCole Faust#define sum_reduce_1(x) (x) 962*c217d954SCole Faust#define sum_reduce_2(x) ((x).s0) + ((x).s1) 963*c217d954SCole Faust#define sum_reduce_3(x) sum_reduce_2((x).s01) + ((x).s2) 964*c217d954SCole Faust#define sum_reduce_4(x) sum_reduce_2((x).s01) + sum_reduce_2((x).s23) 965*c217d954SCole Faust#define sum_reduce_8(x) sum_reduce_4((x).s0123) + sum_reduce_4((x).s4567) 966*c217d954SCole Faust#define sum_reduce_16(x) sum_reduce_8((x).s01234567) + sum_reduce_8((x).s89ABCDEF) 967*c217d954SCole Faust 968*c217d954SCole Faust#define SUM_REDUCE_STR(x, size) sum_reduce_##size(x) 969*c217d954SCole Faust#define SUM_REDUCE(x, size) SUM_REDUCE_STR(x, size) 970*c217d954SCole Faust 971*c217d954SCole Faust#define prod_reduce_1(x) (x) 972*c217d954SCole Faust#define prod_reduce_2(x) ((x).s0) * ((x).s1) 973*c217d954SCole Faust#define prod_reduce_3(x) prod_reduce_2((x).s01) * ((x).s2) 974*c217d954SCole Faust#define prod_reduce_4(x) prod_reduce_2((x).s01) * prod_reduce_2((x).s23) 975*c217d954SCole Faust#define prod_reduce_8(x) prod_reduce_4((x).s0123) * prod_reduce_4((x).s4567) 976*c217d954SCole Faust#define prod_reduce_16(x) prod_reduce_8((x).s01234567) * prod_reduce_8((x).s89ABCDEF) 977*c217d954SCole Faust 978*c217d954SCole Faust#define PROD_REDUCE_STR(x, size) prod_reduce_##size(x) 979*c217d954SCole Faust#define PROD_REDUCE(x, size) PROD_REDUCE_STR(x, size) 980*c217d954SCole Faust 981*c217d954SCole Faust#define max_reduce_1(x) (x) 982*c217d954SCole Faust#define max_reduce_2(x) max(((x).s0), ((x).s1)) 983*c217d954SCole Faust#define max_reduce_3(x) max(max_reduce_2((x).s01), ((x).s2)) 984*c217d954SCole Faust#define max_reduce_4(x) max(max_reduce_2((x).s01), max_reduce_2((x).s23)) 985*c217d954SCole Faust#define max_reduce_8(x) max(max_reduce_4((x).s0123), max_reduce_4((x).s4567)) 986*c217d954SCole Faust#define max_reduce_16(x) max(max_reduce_8((x).s01234567), max_reduce_8((x).s89ABCDEF)) 987*c217d954SCole Faust 988*c217d954SCole Faust#define MAX_REDUCE_STR(x, size) max_reduce_##size(x) 989*c217d954SCole Faust#define MAX_REDUCE(x, size) MAX_REDUCE_STR(x, size) 990*c217d954SCole Faust 991*c217d954SCole Faust#define VECTOR_DECLARATION(name) \ 992*c217d954SCole Faust __global uchar *name##_ptr, \ 993*c217d954SCole Faust uint name##_stride_x, \ 994*c217d954SCole Faust uint name##_step_x, \ 995*c217d954SCole Faust uint name##_offset_first_element_in_bytes 996*c217d954SCole Faust 997*c217d954SCole Faust#define IMAGE_DECLARATION(name) \ 998*c217d954SCole Faust __global uchar *name##_ptr, \ 999*c217d954SCole Faust uint name##_stride_x, \ 1000*c217d954SCole Faust uint name##_step_x, \ 1001*c217d954SCole Faust uint name##_stride_y, \ 1002*c217d954SCole Faust uint name##_step_y, \ 1003*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1004*c217d954SCole Faust 1005*c217d954SCole Faust#define TENSOR3D_DECLARATION(name) \ 1006*c217d954SCole Faust __global uchar *name##_ptr, \ 1007*c217d954SCole Faust uint name##_stride_x, \ 1008*c217d954SCole Faust uint name##_step_x, \ 1009*c217d954SCole Faust uint name##_stride_y, \ 1010*c217d954SCole Faust uint name##_step_y, \ 1011*c217d954SCole Faust uint name##_stride_z, \ 1012*c217d954SCole Faust uint name##_step_z, \ 1013*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1014*c217d954SCole Faust 1015*c217d954SCole Faust#define TENSOR4D_DECLARATION(name) \ 1016*c217d954SCole Faust __global uchar *name##_ptr, \ 1017*c217d954SCole Faust uint name##_stride_x, \ 1018*c217d954SCole Faust uint name##_step_x, \ 1019*c217d954SCole Faust uint name##_stride_y, \ 1020*c217d954SCole Faust uint name##_step_y, \ 1021*c217d954SCole Faust uint name##_stride_z, \ 1022*c217d954SCole Faust uint name##_step_z, \ 1023*c217d954SCole Faust uint name##_stride_w, \ 1024*c217d954SCole Faust uint name##_step_w, \ 1025*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1026*c217d954SCole Faust 1027*c217d954SCole Faust#define TENSOR5D_DECLARATION(name) \ 1028*c217d954SCole Faust __global uchar *name##_ptr, \ 1029*c217d954SCole Faust uint name##_stride_x, \ 1030*c217d954SCole Faust uint name##_step_x, \ 1031*c217d954SCole Faust uint name##_stride_y, \ 1032*c217d954SCole Faust uint name##_step_y, \ 1033*c217d954SCole Faust uint name##_stride_z, \ 1034*c217d954SCole Faust uint name##_step_z, \ 1035*c217d954SCole Faust uint name##_stride_w, \ 1036*c217d954SCole Faust uint name##_step_w, \ 1037*c217d954SCole Faust uint name##_stride_v, \ 1038*c217d954SCole Faust uint name##_step_v, \ 1039*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1040*c217d954SCole Faust 1041*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT(name) \ 1042*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x) 1043*c217d954SCole Faust 1044*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT_NO_STEP(name) \ 1045*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0) 1046*c217d954SCole Faust 1047*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT(name) \ 1048*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) 1049*c217d954SCole Faust 1050*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name) \ 1051*c217d954SCole Faust update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0) 1052*c217d954SCole Faust 1053*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 1054*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) 1055*c217d954SCole Faust 1056*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT_NO_STEP(name) \ 1057*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) 1058*c217d954SCole Faust 1059*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 1060*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) 1061*c217d954SCole Faust 1062*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT(name) \ 1063*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, \ 1064*c217d954SCole Faust name##_stride_z, name##_step_z) 1065*c217d954SCole Faust 1066*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name) \ 1067*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) 1068*c217d954SCole Faust 1069*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT(name, mod_size) \ 1070*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, \ 1071*c217d954SCole Faust name##_stride_z, name##_step_z, name##_stride_w, name##_step_w, mod_size) 1072*c217d954SCole Faust 1073*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(name, mod_size) \ 1074*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) 1075*c217d954SCole Faust 1076*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_UPDATE_PTR(name) \ 1077*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, \ 1078*c217d954SCole Faust name##_stride_z, name##_step_z) 1079*c217d954SCole Faust 1080*c217d954SCole Faust 1081*c217d954SCole Fausttypedef struct Vector 1082*c217d954SCole Faust{ 1083*c217d954SCole Faust __global uchar *ptr; 1084*c217d954SCole Faust int offset_first_element_in_bytes; 1085*c217d954SCole Faust int stride_x; 1086*c217d954SCole Faust} Vector; 1087*c217d954SCole Faust 1088*c217d954SCole Faust 1089*c217d954SCole Fausttypedef struct Image 1090*c217d954SCole Faust{ 1091*c217d954SCole Faust __global uchar *ptr; 1092*c217d954SCole Faust int offset_first_element_in_bytes; 1093*c217d954SCole Faust int stride_x; 1094*c217d954SCole Faust int stride_y; 1095*c217d954SCole Faust} Image; 1096*c217d954SCole Faust 1097*c217d954SCole Faust 1098*c217d954SCole Fausttypedef struct Tensor3D 1099*c217d954SCole Faust{ 1100*c217d954SCole Faust __global uchar *ptr; 1101*c217d954SCole Faust int offset_first_element_in_bytes; 1102*c217d954SCole Faust int stride_x; 1103*c217d954SCole Faust int stride_y; 1104*c217d954SCole Faust int stride_z; 1105*c217d954SCole Faust} Tensor3D; 1106*c217d954SCole Faust 1107*c217d954SCole Faust 1108*c217d954SCole Fausttypedef struct Tensor4D 1109*c217d954SCole Faust{ 1110*c217d954SCole Faust __global uchar *ptr; 1111*c217d954SCole Faust int offset_first_element_in_bytes; 1112*c217d954SCole Faust int stride_x; 1113*c217d954SCole Faust int stride_y; 1114*c217d954SCole Faust int stride_z; 1115*c217d954SCole Faust int stride_w; 1116*c217d954SCole Faust} Tensor4D; 1117*c217d954SCole Faust 1118*c217d954SCole Faust 1119*c217d954SCole Faustinline Vector update_vector_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x) 1120*c217d954SCole Faust{ 1121*c217d954SCole Faust Vector vector = 1122*c217d954SCole Faust { 1123*c217d954SCole Faust .ptr = ptr, 1124*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1125*c217d954SCole Faust .stride_x = stride_x, 1126*c217d954SCole Faust }; 1127*c217d954SCole Faust vector.ptr += vector.offset_first_element_in_bytes + get_global_id(0) * step_x; 1128*c217d954SCole Faust return vector; 1129*c217d954SCole Faust} 1130*c217d954SCole Faust 1131*c217d954SCole Faust 1132*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) 1133*c217d954SCole Faust{ 1134*c217d954SCole Faust Image img = 1135*c217d954SCole Faust { 1136*c217d954SCole Faust .ptr = ptr, 1137*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1138*c217d954SCole Faust .stride_x = stride_x, 1139*c217d954SCole Faust .stride_y = stride_y 1140*c217d954SCole Faust }; 1141*c217d954SCole Faust img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y; 1142*c217d954SCole Faust return img; 1143*c217d954SCole Faust} 1144*c217d954SCole Faust 1145*c217d954SCole Faust 1146*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) 1147*c217d954SCole Faust{ 1148*c217d954SCole Faust Image img = 1149*c217d954SCole Faust { 1150*c217d954SCole Faust .ptr = ptr, 1151*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1152*c217d954SCole Faust .stride_x = stride_x, 1153*c217d954SCole Faust .stride_y = stride_y 1154*c217d954SCole Faust }; 1155*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; 1156*c217d954SCole Faust return img; 1157*c217d954SCole Faust} 1158*c217d954SCole Faust 1159*c217d954SCole Faust 1160*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) 1161*c217d954SCole Faust{ 1162*c217d954SCole Faust Tensor3D tensor = 1163*c217d954SCole Faust { 1164*c217d954SCole Faust .ptr = ptr, 1165*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1166*c217d954SCole Faust .stride_x = stride_x, 1167*c217d954SCole Faust .stride_y = stride_y, 1168*c217d954SCole Faust .stride_z = stride_z 1169*c217d954SCole Faust }; 1170*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; 1171*c217d954SCole Faust return tensor; 1172*c217d954SCole Faust} 1173*c217d954SCole Faust 1174*c217d954SCole Faust 1175*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) 1176*c217d954SCole Faust{ 1177*c217d954SCole Faust Tensor3D tensor = 1178*c217d954SCole Faust { 1179*c217d954SCole Faust .ptr = ptr, 1180*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1181*c217d954SCole Faust .stride_x = stride_x, 1182*c217d954SCole Faust .stride_y = stride_y, 1183*c217d954SCole Faust .stride_z = stride_z 1184*c217d954SCole Faust }; 1185*c217d954SCole Faust return tensor; 1186*c217d954SCole Faust} 1187*c217d954SCole Faust 1188*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, 1189*c217d954SCole Faust uint step_w, 1190*c217d954SCole Faust uint mod_size) 1191*c217d954SCole Faust{ 1192*c217d954SCole Faust Tensor4D tensor = 1193*c217d954SCole Faust { 1194*c217d954SCole Faust .ptr = ptr, 1195*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1196*c217d954SCole Faust .stride_x = stride_x, 1197*c217d954SCole Faust .stride_y = stride_y, 1198*c217d954SCole Faust .stride_z = stride_z, 1199*c217d954SCole Faust .stride_w = stride_w 1200*c217d954SCole Faust }; 1201*c217d954SCole Faust 1202*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; 1203*c217d954SCole Faust return tensor; 1204*c217d954SCole Faust} 1205*c217d954SCole Faust 1206*c217d954SCole Faust 1207*c217d954SCole Faustinline __global const uchar *vector_offset(const Vector *vec, int x) 1208*c217d954SCole Faust{ 1209*c217d954SCole Faust return vec->ptr + x * vec->stride_x; 1210*c217d954SCole Faust} 1211*c217d954SCole Faust 1212*c217d954SCole Faust 1213*c217d954SCole Faustinline __global uchar *offset(const Image *img, int x, int y) 1214*c217d954SCole Faust{ 1215*c217d954SCole Faust return img->ptr + x * img->stride_x + y * img->stride_y; 1216*c217d954SCole Faust} 1217*c217d954SCole Faust 1218*c217d954SCole Faust 1219*c217d954SCole Faustinline __global const uchar *tensor3D_offset(const Tensor3D *tensor, int x, int y, int z) 1220*c217d954SCole Faust{ 1221*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z; 1222*c217d954SCole Faust} 1223*c217d954SCole Faust 1224*c217d954SCole Faust 1225*c217d954SCole Faustinline __global const uchar *tensor4D_offset(const Tensor4D *tensor, int x, int y, int z, int w) 1226*c217d954SCole Faust{ 1227*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + w * tensor->stride_w; 1228*c217d954SCole Faust} 1229*c217d954SCole Faust 1230*c217d954SCole Faust 1231*c217d954SCole Faustinline __global const uchar *tensor3D_index2ptr(const Tensor3D *tensor, uint width, uint height, uint depth, uint index) 1232*c217d954SCole Faust{ 1233*c217d954SCole Faust uint num_elements = width * height; 1234*c217d954SCole Faust 1235*c217d954SCole Faust const uint z = index / num_elements; 1236*c217d954SCole Faust 1237*c217d954SCole Faust index %= num_elements; 1238*c217d954SCole Faust 1239*c217d954SCole Faust const uint y = index / width; 1240*c217d954SCole Faust 1241*c217d954SCole Faust index %= width; 1242*c217d954SCole Faust 1243*c217d954SCole Faust const uint x = index; 1244*c217d954SCole Faust 1245*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + tensor->offset_first_element_in_bytes; 1246*c217d954SCole Faust} 1247*c217d954SCole Faust 1248*c217d954SCole Faust#endif 1249*c217d954SCole Faust 1250*c217d954SCole Faust#ifndef ARM_COMPUTE_REPEAT_H 1251*c217d954SCole Faust#define ARM_COMPUTE_REPEAT_H 1252*c217d954SCole Faust 1253*c217d954SCole Faust 1254*c217d954SCole Faust#ifndef ARM_COMPUTE_HELPER_H 1255*c217d954SCole Faust#define ARM_COMPUTE_HELPER_H 1256*c217d954SCole Faust 1257*c217d954SCole Faust 1258*c217d954SCole Faust 1259*c217d954SCole Faust 1260*c217d954SCole Faust#define STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1261*c217d954SCole Faust VSTORE(N0) \ 1262*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 1263*c217d954SCole Faust 1264*c217d954SCole Faust#define STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1265*c217d954SCole Faust STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1266*c217d954SCole Faust VSTORE(N0) \ 1267*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 1268*c217d954SCole Faust 1269*c217d954SCole Faust#define STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1270*c217d954SCole Faust STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1271*c217d954SCole Faust VSTORE(N0) \ 1272*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 1273*c217d954SCole Faust 1274*c217d954SCole Faust#define STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1275*c217d954SCole Faust STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1276*c217d954SCole Faust VSTORE(N0) \ 1277*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 1278*c217d954SCole Faust 1279*c217d954SCole Faust#define STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1280*c217d954SCole Faust STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1281*c217d954SCole Faust VSTORE(N0) \ 1282*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 1283*c217d954SCole Faust 1284*c217d954SCole Faust#define STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1285*c217d954SCole Faust STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1286*c217d954SCole Faust VSTORE(N0) \ 1287*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 1288*c217d954SCole Faust 1289*c217d954SCole Faust#define STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1290*c217d954SCole Faust STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1291*c217d954SCole Faust VSTORE(N0) \ 1292*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 1293*c217d954SCole Faust 1294*c217d954SCole Faust#define STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1295*c217d954SCole Faust STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1296*c217d954SCole Faust VSTORE(N0) \ 1297*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 1298*c217d954SCole Faust 1299*c217d954SCole Faust#define STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1300*c217d954SCole Faust STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1301*c217d954SCole Faust VSTORE(N0) \ 1302*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 1303*c217d954SCole Faust 1304*c217d954SCole Faust#define STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1305*c217d954SCole Faust STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1306*c217d954SCole Faust VSTORE(N0) \ 1307*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 1308*c217d954SCole Faust 1309*c217d954SCole Faust#define STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1310*c217d954SCole Faust STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1311*c217d954SCole Faust VSTORE(N0) \ 1312*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 1313*c217d954SCole Faust 1314*c217d954SCole Faust#define STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1315*c217d954SCole Faust STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1316*c217d954SCole Faust VSTORE(N0) \ 1317*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 1318*c217d954SCole Faust 1319*c217d954SCole Faust#define STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1320*c217d954SCole Faust STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1321*c217d954SCole Faust VSTORE(N0) \ 1322*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 1323*c217d954SCole Faust 1324*c217d954SCole Faust#define STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1325*c217d954SCole Faust STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1326*c217d954SCole Faust VSTORE(N0) \ 1327*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 1328*c217d954SCole Faust 1329*c217d954SCole Faust#define STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1330*c217d954SCole Faust STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1331*c217d954SCole Faust VSTORE(N0) \ 1332*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 1333*c217d954SCole Faust 1334*c217d954SCole Faust#define STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1335*c217d954SCole Faust STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1336*c217d954SCole Faust VSTORE(N0) \ 1337*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 1338*c217d954SCole Faust 1339*c217d954SCole Faust 1340*c217d954SCole Faust 1341*c217d954SCole Faust#define CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1342*c217d954SCole Faust VSTORE(N0) \ 1343*c217d954SCole Faust (CONVERT_SAT((BASENAME##0), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 1344*c217d954SCole Faust 1345*c217d954SCole Faust#define CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1346*c217d954SCole Faust CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1347*c217d954SCole Faust VSTORE(N0) \ 1348*c217d954SCole Faust (CONVERT_SAT((BASENAME##1), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 1349*c217d954SCole Faust 1350*c217d954SCole Faust#define CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1351*c217d954SCole Faust CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1352*c217d954SCole Faust VSTORE(N0) \ 1353*c217d954SCole Faust (CONVERT_SAT((BASENAME##2), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 1354*c217d954SCole Faust 1355*c217d954SCole Faust#define CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1356*c217d954SCole Faust CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1357*c217d954SCole Faust VSTORE(N0) \ 1358*c217d954SCole Faust (CONVERT_SAT((BASENAME##3), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 1359*c217d954SCole Faust 1360*c217d954SCole Faust#define CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1361*c217d954SCole Faust CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1362*c217d954SCole Faust VSTORE(N0) \ 1363*c217d954SCole Faust (CONVERT_SAT((BASENAME##4), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 1364*c217d954SCole Faust 1365*c217d954SCole Faust#define CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1366*c217d954SCole Faust CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1367*c217d954SCole Faust VSTORE(N0) \ 1368*c217d954SCole Faust (CONVERT_SAT((BASENAME##5), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 1369*c217d954SCole Faust 1370*c217d954SCole Faust#define CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1371*c217d954SCole Faust CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1372*c217d954SCole Faust VSTORE(N0) \ 1373*c217d954SCole Faust (CONVERT_SAT((BASENAME##6), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 1374*c217d954SCole Faust 1375*c217d954SCole Faust#define CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1376*c217d954SCole Faust CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1377*c217d954SCole Faust VSTORE(N0) \ 1378*c217d954SCole Faust (CONVERT_SAT((BASENAME##7), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 1379*c217d954SCole Faust 1380*c217d954SCole Faust#define CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1381*c217d954SCole Faust CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1382*c217d954SCole Faust VSTORE(N0) \ 1383*c217d954SCole Faust (CONVERT_SAT((BASENAME##8), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 1384*c217d954SCole Faust 1385*c217d954SCole Faust#define CONVERT_STORE_ROW_10(N0, DATA, BASENAME, PTR, STRIDE_Y, Z) \ 1386*c217d954SCole Faust CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1387*c217d954SCole Faust VSTORE(N0) \ 1388*c217d954SCole Faust (CONVERT_SAT((BASENAME##9), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 1389*c217d954SCole Faust 1390*c217d954SCole Faust#define CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1391*c217d954SCole Faust CONVERT_STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1392*c217d954SCole Faust VSTORE(N0) \ 1393*c217d954SCole Faust (CONVERT_SAT((BASENAME##A), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 1394*c217d954SCole Faust 1395*c217d954SCole Faust#define CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1396*c217d954SCole Faust CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1397*c217d954SCole Faust VSTORE(N0) \ 1398*c217d954SCole Faust (CONVERT_SAT((BASENAME##B), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 1399*c217d954SCole Faust 1400*c217d954SCole Faust#define CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1401*c217d954SCole Faust CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1402*c217d954SCole Faust VSTORE(N0) \ 1403*c217d954SCole Faust (CONVERT_SAT((BASENAME##C), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 1404*c217d954SCole Faust 1405*c217d954SCole Faust#define CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1406*c217d954SCole Faust CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1407*c217d954SCole Faust VSTORE(N0) \ 1408*c217d954SCole Faust (CONVERT_SAT((BASENAME##D), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 1409*c217d954SCole Faust 1410*c217d954SCole Faust#define CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1411*c217d954SCole Faust CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1412*c217d954SCole Faust VSTORE(N0) \ 1413*c217d954SCole Faust (CONVERT_SAT((BASENAME##E), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 1414*c217d954SCole Faust 1415*c217d954SCole Faust#define CONVERT_STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1416*c217d954SCole Faust CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1417*c217d954SCole Faust VSTORE(N0) \ 1418*c217d954SCole Faust (CONVERT_SAT((BASENAME##F), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 1419*c217d954SCole Faust 1420*c217d954SCole Faust 1421*c217d954SCole Faust 1422*c217d954SCole Faust 1423*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) 1424*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) 1425*c217d954SCole Faust 1426*c217d954SCole Faust 1427*c217d954SCole Faust 1428*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) 1429*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) 1430*c217d954SCole Faust 1431*c217d954SCole Faust 1432*c217d954SCole Faust 1433*c217d954SCole Faust#define STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1434*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1435*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 1436*c217d954SCole Faust 1437*c217d954SCole Faust#define STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1438*c217d954SCole Faust STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1439*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1440*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 1441*c217d954SCole Faust 1442*c217d954SCole Faust#define STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1443*c217d954SCole Faust STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1444*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1445*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 1446*c217d954SCole Faust 1447*c217d954SCole Faust#define STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1448*c217d954SCole Faust STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1449*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1450*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 1451*c217d954SCole Faust 1452*c217d954SCole Faust#define STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1453*c217d954SCole Faust STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1454*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1455*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 1456*c217d954SCole Faust 1457*c217d954SCole Faust#define STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1458*c217d954SCole Faust STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1459*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1460*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 1461*c217d954SCole Faust 1462*c217d954SCole Faust#define STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1463*c217d954SCole Faust STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1464*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1465*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 1466*c217d954SCole Faust 1467*c217d954SCole Faust#define STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1468*c217d954SCole Faust STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1469*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1470*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 1471*c217d954SCole Faust 1472*c217d954SCole Faust#define STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1473*c217d954SCole Faust STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1474*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1475*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 1476*c217d954SCole Faust 1477*c217d954SCole Faust#define STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1478*c217d954SCole Faust STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1479*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1480*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 1481*c217d954SCole Faust 1482*c217d954SCole Faust#define STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1483*c217d954SCole Faust STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1484*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1485*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 1486*c217d954SCole Faust 1487*c217d954SCole Faust#define STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1488*c217d954SCole Faust STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1489*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1490*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 1491*c217d954SCole Faust 1492*c217d954SCole Faust#define STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1493*c217d954SCole Faust STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1494*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1495*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 1496*c217d954SCole Faust 1497*c217d954SCole Faust#define STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1498*c217d954SCole Faust STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1499*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1500*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 1501*c217d954SCole Faust 1502*c217d954SCole Faust#define STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1503*c217d954SCole Faust STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1504*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1505*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 1506*c217d954SCole Faust 1507*c217d954SCole Faust#define STORE_ROW_PARTIAL_16(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1508*c217d954SCole Faust STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1509*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1510*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 1511*c217d954SCole Faust 1512*c217d954SCole Faust 1513*c217d954SCole Faust 1514*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) 1515*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) 1516*c217d954SCole Faust 1517*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) \ 1518*c217d954SCole Faust if(!(PARTIAL_COND_X) && !(PARTIAL_COND_Y)) \ 1519*c217d954SCole Faust { \ 1520*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1521*c217d954SCole Faust } \ 1522*c217d954SCole Faust else if((PARTIAL_COND_Y) && !(PARTIAL_COND_X)) \ 1523*c217d954SCole Faust { \ 1524*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1525*c217d954SCole Faust } \ 1526*c217d954SCole Faust else if(!(PARTIAL_COND_Y) && (PARTIAL_COND_X)) \ 1527*c217d954SCole Faust { \ 1528*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1529*c217d954SCole Faust } \ 1530*c217d954SCole Faust else \ 1531*c217d954SCole Faust { \ 1532*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1533*c217d954SCole Faust } 1534*c217d954SCole Faust 1535*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) \ 1536*c217d954SCole Faust if(!(PARTIAL_COND_X)) \ 1537*c217d954SCole Faust { \ 1538*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1539*c217d954SCole Faust } \ 1540*c217d954SCole Faust else \ 1541*c217d954SCole Faust { \ 1542*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1543*c217d954SCole Faust } 1544*c217d954SCole Faust 1545*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) \ 1546*c217d954SCole Faust if(!(PARTIAL_COND_Y)) \ 1547*c217d954SCole Faust { \ 1548*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1549*c217d954SCole Faust } \ 1550*c217d954SCole Faust else \ 1551*c217d954SCole Faust { \ 1552*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1553*c217d954SCole Faust } 1554*c217d954SCole Faust 1555*c217d954SCole Faust 1556*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) && defined(PARTIAL_STORE_N0) 1557*c217d954SCole Faust 1558*c217d954SCole Faust 1559*c217d954SCole Faust#if PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 == 0 1560*c217d954SCole Faust 1561*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) \ 1562*c217d954SCole Faust STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 1563*c217d954SCole Faust 1564*c217d954SCole Faust#elif PARTIAL_STORE_M0 > 0 && PARTIAL_STORE_N0 == 0 1565*c217d954SCole Faust 1566*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) \ 1567*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) 1568*c217d954SCole Faust 1569*c217d954SCole Faust#elif PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 > 0 1570*c217d954SCole Faust 1571*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) \ 1572*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) 1573*c217d954SCole Faust 1574*c217d954SCole Faust#else 1575*c217d954SCole Faust 1576*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) \ 1577*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) 1578*c217d954SCole Faust 1579*c217d954SCole Faust#endif 1580*c217d954SCole Faust 1581*c217d954SCole Faust#endif 1582*c217d954SCole Faust 1583*c217d954SCole Faust 1584*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) 1585*c217d954SCole Faust 1586*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 1587*c217d954SCole Faust ((uint)(max(0, (int)(y * M0) - (int)((M0 - PARTIAL_STORE_M0) % M0)))) 1588*c217d954SCole Faust#else 1589*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 1590*c217d954SCole Faust ((uint)(y * M0)) 1591*c217d954SCole Faust#endif 1592*c217d954SCole Faust 1593*c217d954SCole Faust 1594*c217d954SCole Faust 1595*c217d954SCole Faust#define STORE_VECTOR_SELECT(basename, data_type, ptr, vec_size, leftover, cond) \ 1596*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(1, vec_size, data_type, basename, ptr, 0, 0, leftover, cond) 1597*c217d954SCole Faust 1598*c217d954SCole Faust 1599*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 1600*c217d954SCole Faust#pragma OPENCL EXTENSION cl_khr_fp16 : enable 1601*c217d954SCole Faust#endif 1602*c217d954SCole Faust 1603*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ENABLED) && defined(cl_arm_integer_dot_product_int8) 1604*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable 1605*c217d954SCole Faust#endif 1606*c217d954SCole Faust 1607*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED) && defined(cl_arm_integer_dot_product_accumulate_int8) 1608*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable 1609*c217d954SCole Faust#endif 1610*c217d954SCole Faust 1611*c217d954SCole Faust#if defined(ARM_COMPUTE_DEBUG_ENABLED) && defined(cl_arm_printf) 1612*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_printf : enable 1613*c217d954SCole Faust#endif 1614*c217d954SCole Faust 1615*c217d954SCole Faust#define GPU_ARCH_MIDGARD 0x100 1616*c217d954SCole Faust#define GPU_ARCH_BIFROST 0x200 1617*c217d954SCole Faust#define GPU_ARCH_VALHALL 0x300 1618*c217d954SCole Faust 1619*c217d954SCole Faust 1620*c217d954SCole Faust#define CONCAT(a, b) a##b 1621*c217d954SCole Faust 1622*c217d954SCole Faust 1623*c217d954SCole Faust#define EXPAND(x) x 1624*c217d954SCole Faust 1625*c217d954SCole Faust 1626*c217d954SCole Faust#define CLAMP(x, min_val, max_val) min(max(x, min_val), max_val) 1627*c217d954SCole Faust 1628*c217d954SCole Faust 1629*c217d954SCole Faust#define REV1(x) ((x)) 1630*c217d954SCole Faust#define REV2(x) ((x).s10) 1631*c217d954SCole Faust#define REV3(x) ((x).s210) 1632*c217d954SCole Faust#define REV4(x) ((x).s3210) 1633*c217d954SCole Faust#define REV8(x) ((x).s76543210) 1634*c217d954SCole Faust#define REV16(x) ((x).sFEDCBA9876543210) 1635*c217d954SCole Faust 1636*c217d954SCole Faust 1637*c217d954SCole Faust 1638*c217d954SCole Faust#define REVERSE_STR(x, s) REV##s((x)) 1639*c217d954SCole Faust#define REVERSE(x, s) REVERSE_STR(x, s) 1640*c217d954SCole Faust 1641*c217d954SCole Faust 1642*c217d954SCole Faust 1643*c217d954SCole Faust#define ROT1_0(x) ((x)) 1644*c217d954SCole Faust#define ROT1_1(x) ((x)) 1645*c217d954SCole Faust 1646*c217d954SCole Faust#define ROT2_0(x) ((x)) 1647*c217d954SCole Faust#define ROT2_1(x) ((x).s10) 1648*c217d954SCole Faust#define ROT2_2(x) ((x)) 1649*c217d954SCole Faust 1650*c217d954SCole Faust#define ROT3_0(x) ((x)) 1651*c217d954SCole Faust#define ROT3_1(x) ((x).s201) 1652*c217d954SCole Faust#define ROT3_2(x) ((x).s120) 1653*c217d954SCole Faust#define ROT3_3(x) ((x)) 1654*c217d954SCole Faust 1655*c217d954SCole Faust#define ROT4_0(x) ((x)) 1656*c217d954SCole Faust#define ROT4_1(x) ((x).s3012) 1657*c217d954SCole Faust#define ROT4_2(x) ((x).s2301) 1658*c217d954SCole Faust#define ROT4_3(x) ((x).s1230) 1659*c217d954SCole Faust#define ROT4_4(x) ((x)) 1660*c217d954SCole Faust 1661*c217d954SCole Faust#define ROT8_0(x) ((x)) 1662*c217d954SCole Faust#define ROT8_1(x) ((x).s70123456) 1663*c217d954SCole Faust#define ROT8_2(x) ((x).s67012345) 1664*c217d954SCole Faust#define ROT8_3(x) ((x).s56701234) 1665*c217d954SCole Faust#define ROT8_4(x) ((x).s45670123) 1666*c217d954SCole Faust#define ROT8_5(x) ((x).s34567012) 1667*c217d954SCole Faust#define ROT8_6(x) ((x).s23456701) 1668*c217d954SCole Faust#define ROT8_7(x) ((x).s12345670) 1669*c217d954SCole Faust#define ROT8_8(x) ((x)) 1670*c217d954SCole Faust 1671*c217d954SCole Faust#define ROT16_0(x) ((x)) 1672*c217d954SCole Faust#define ROT16_1(x) ((x).sF0123456789ABCDE) 1673*c217d954SCole Faust#define ROT16_2(x) ((x).sEF0123456789ABCD) 1674*c217d954SCole Faust#define ROT16_3(x) ((x).sDEF0123456789ABC) 1675*c217d954SCole Faust#define ROT16_4(x) ((x).sCDEF0123456789AB) 1676*c217d954SCole Faust#define ROT16_5(x) ((x).sBCDEF0123456789A) 1677*c217d954SCole Faust#define ROT16_6(x) ((x).sABCDEF0123456789) 1678*c217d954SCole Faust#define ROT16_7(x) ((x).s9ABCDEF012345678) 1679*c217d954SCole Faust#define ROT16_8(x) ((x).s89ABCDEF01234567) 1680*c217d954SCole Faust#define ROT16_9(x) ((x).s789ABCDEF0123456) 1681*c217d954SCole Faust#define ROT16_10(x) ((x).s6789ABCDEF012345) 1682*c217d954SCole Faust#define ROT16_11(x) ((x).s56789ABCDEF01234) 1683*c217d954SCole Faust#define ROT16_12(x) ((x).s456789ABCDEF0123) 1684*c217d954SCole Faust#define ROT16_13(x) ((x).s3456789ABCDEF012) 1685*c217d954SCole Faust#define ROT16_14(x) ((x).s23456789ABCDEF01) 1686*c217d954SCole Faust#define ROT16_15(x) ((x).s123456789ABCDEF0) 1687*c217d954SCole Faust#define ROT16_16(x) ((x)) 1688*c217d954SCole Faust 1689*c217d954SCole Faust 1690*c217d954SCole Faust 1691*c217d954SCole Faust#define ROTATE_STR(x, s, n) ROT##s##_##n(x) 1692*c217d954SCole Faust#define ROTATE(x, s, n) ROTATE_STR(x, s, n) 1693*c217d954SCole Faust 1694*c217d954SCole Faust 1695*c217d954SCole Faust 1696*c217d954SCole Faust#define V_OFFS1(dt) (dt##1)(0) 1697*c217d954SCole Faust#define V_OFFS2(dt) (dt##2)(0, 1) 1698*c217d954SCole Faust#define V_OFFS3(dt) (dt##3)(0, 1, 2) 1699*c217d954SCole Faust#define V_OFFS4(dt) (dt##4)(0, 1, 2, 3) 1700*c217d954SCole Faust#define V_OFFS8(dt) (dt##8)(0, 1, 2, 3, 4, 5, 6, 7) 1701*c217d954SCole Faust#define V_OFFS16(dt) (dt##16)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) 1702*c217d954SCole Faust 1703*c217d954SCole Faust 1704*c217d954SCole Faust 1705*c217d954SCole Faust#define VEC_OFFS_STR(dt, s) V_OFFS##s(dt) 1706*c217d954SCole Faust#define VEC_OFFS(dt, s) VEC_OFFS_STR(dt, s) 1707*c217d954SCole Faust 1708*c217d954SCole Faust 1709*c217d954SCole Faust#define VLOAD_STR(size) vload##size 1710*c217d954SCole Faust#define VLOAD(size) VLOAD_STR(size) 1711*c217d954SCole Faust 1712*c217d954SCole Faust 1713*c217d954SCole Faust#define VLOAD_PARTIAL_STR(size, load_size) vload_partial_##size##_##load_size 1714*c217d954SCole Faust#define VLOAD_PARTIAL(size, load_size) VLOAD_PARTIAL_STR(size, load_size) 1715*c217d954SCole Faust 1716*c217d954SCole Faust#define NO_LOAD(data, offs, ptr) \ 1717*c217d954SCole Faust { \ 1718*c217d954SCole Faust } 1719*c217d954SCole Faust 1720*c217d954SCole Faust 1721*c217d954SCole Faust#define vload_partial_1_0 NO_LOAD 1722*c217d954SCole Faust#define vload_partial_1_1 vload1 1723*c217d954SCole Faust#define vload_partial_1_2 NO_LOAD 1724*c217d954SCole Faust#define vload_partial_1_3 NO_LOAD 1725*c217d954SCole Faust#define vload_partial_1_4 NO_LOAD 1726*c217d954SCole Faust#define vload_partial_1_5 NO_LOAD 1727*c217d954SCole Faust#define vload_partial_1_6 NO_LOAD 1728*c217d954SCole Faust#define vload_partial_1_7 NO_LOAD 1729*c217d954SCole Faust#define vload_partial_1_8 NO_LOAD 1730*c217d954SCole Faust#define vload_partial_1_9 NO_LOAD 1731*c217d954SCole Faust#define vload_partial_1_10 NO_LOAD 1732*c217d954SCole Faust#define vload_partial_1_11 NO_LOAD 1733*c217d954SCole Faust#define vload_partial_1_12 NO_LOAD 1734*c217d954SCole Faust#define vload_partial_1_13 NO_LOAD 1735*c217d954SCole Faust#define vload_partial_1_14 NO_LOAD 1736*c217d954SCole Faust#define vload_partial_1_15 NO_LOAD 1737*c217d954SCole Faust#define vload_partial_1_16 NO_LOAD 1738*c217d954SCole Faust 1739*c217d954SCole Faust#define vload_partial_2_0 NO_LOAD 1740*c217d954SCole Faust#define vload_partial_2_1 vload_partial_1 1741*c217d954SCole Faust#define vload_partial_2_2 vload_partial_2 1742*c217d954SCole Faust#define vload_partial_2_3 NO_LOAD 1743*c217d954SCole Faust#define vload_partial_2_4 NO_LOAD 1744*c217d954SCole Faust#define vload_partial_2_5 NO_LOAD 1745*c217d954SCole Faust#define vload_partial_2_6 NO_LOAD 1746*c217d954SCole Faust#define vload_partial_2_7 NO_LOAD 1747*c217d954SCole Faust#define vload_partial_2_8 NO_LOAD 1748*c217d954SCole Faust#define vload_partial_2_9 NO_LOAD 1749*c217d954SCole Faust#define vload_partial_2_10 NO_LOAD 1750*c217d954SCole Faust#define vload_partial_2_11 NO_LOAD 1751*c217d954SCole Faust#define vload_partial_2_12 NO_LOAD 1752*c217d954SCole Faust#define vload_partial_2_13 NO_LOAD 1753*c217d954SCole Faust#define vload_partial_2_14 NO_LOAD 1754*c217d954SCole Faust#define vload_partial_2_15 NO_LOAD 1755*c217d954SCole Faust#define vload_partial_2_16 NO_LOAD 1756*c217d954SCole Faust 1757*c217d954SCole Faust#define vload_partial_3_0 NO_LOAD 1758*c217d954SCole Faust#define vload_partial_3_1 vload_partial_1 1759*c217d954SCole Faust#define vload_partial_3_2 vload_partial_2 1760*c217d954SCole Faust#define vload_partial_3_3 vload_partial_3 1761*c217d954SCole Faust#define vload_partial_3_4 NO_LOAD 1762*c217d954SCole Faust#define vload_partial_3_5 NO_LOAD 1763*c217d954SCole Faust#define vload_partial_3_6 NO_LOAD 1764*c217d954SCole Faust#define vload_partial_3_7 NO_LOAD 1765*c217d954SCole Faust#define vload_partial_3_8 NO_LOAD 1766*c217d954SCole Faust#define vload_partial_3_9 NO_LOAD 1767*c217d954SCole Faust#define vload_partial_3_10 NO_LOAD 1768*c217d954SCole Faust#define vload_partial_3_11 NO_LOAD 1769*c217d954SCole Faust#define vload_partial_3_12 NO_LOAD 1770*c217d954SCole Faust#define vload_partial_3_13 NO_LOAD 1771*c217d954SCole Faust#define vload_partial_3_14 NO_LOAD 1772*c217d954SCole Faust#define vload_partial_3_15 NO_LOAD 1773*c217d954SCole Faust#define vload_partial_3_16 NO_LOAD 1774*c217d954SCole Faust 1775*c217d954SCole Faust#define vload_partial_4_0 NO_LOAD 1776*c217d954SCole Faust#define vload_partial_4_1 vload_partial_1 1777*c217d954SCole Faust#define vload_partial_4_2 vload_partial_2 1778*c217d954SCole Faust#define vload_partial_4_3 vload_partial_3 1779*c217d954SCole Faust#define vload_partial_4_4 vload_partial_4 1780*c217d954SCole Faust#define vload_partial_4_5 NO_LOAD 1781*c217d954SCole Faust#define vload_partial_4_6 NO_LOAD 1782*c217d954SCole Faust#define vload_partial_4_7 NO_LOAD 1783*c217d954SCole Faust#define vload_partial_4_8 NO_LOAD 1784*c217d954SCole Faust#define vload_partial_4_9 NO_LOAD 1785*c217d954SCole Faust#define vload_partial_4_10 NO_LOAD 1786*c217d954SCole Faust#define vload_partial_4_11 NO_LOAD 1787*c217d954SCole Faust#define vload_partial_4_12 NO_LOAD 1788*c217d954SCole Faust#define vload_partial_4_13 NO_LOAD 1789*c217d954SCole Faust#define vload_partial_4_14 NO_LOAD 1790*c217d954SCole Faust#define vload_partial_4_15 NO_LOAD 1791*c217d954SCole Faust#define vload_partial_4_16 NO_LOAD 1792*c217d954SCole Faust 1793*c217d954SCole Faust#define vload_partial_8_0 NO_LOAD 1794*c217d954SCole Faust#define vload_partial_8_1 vload_partial_1 1795*c217d954SCole Faust#define vload_partial_8_2 vload_partial_2 1796*c217d954SCole Faust#define vload_partial_8_3 vload_partial_3 1797*c217d954SCole Faust#define vload_partial_8_4 vload_partial_4 1798*c217d954SCole Faust#define vload_partial_8_5 vload_partial_5 1799*c217d954SCole Faust#define vload_partial_8_6 vload_partial_6 1800*c217d954SCole Faust#define vload_partial_8_7 vload_partial_7 1801*c217d954SCole Faust#define vload_partial_8_8 vload_partial_8 1802*c217d954SCole Faust#define vload_partial_8_9 NO_LOAD 1803*c217d954SCole Faust#define vload_partial_8_10 NO_LOAD 1804*c217d954SCole Faust#define vload_partial_8_11 NO_LOAD 1805*c217d954SCole Faust#define vload_partial_8_12 NO_LOAD 1806*c217d954SCole Faust#define vload_partial_8_13 NO_LOAD 1807*c217d954SCole Faust#define vload_partial_8_14 NO_LOAD 1808*c217d954SCole Faust#define vload_partial_8_15 NO_LOAD 1809*c217d954SCole Faust#define vload_partial_8_16 NO_LOAD 1810*c217d954SCole Faust 1811*c217d954SCole Faust#define vload_partial_16_0 NO_LOAD 1812*c217d954SCole Faust#define vload_partial_16_1 vload_partial_1 1813*c217d954SCole Faust#define vload_partial_16_2 vload_partial_2 1814*c217d954SCole Faust#define vload_partial_16_3 vload_partial_3 1815*c217d954SCole Faust#define vload_partial_16_4 vload_partial_4 1816*c217d954SCole Faust#define vload_partial_16_5 vload_partial_5 1817*c217d954SCole Faust#define vload_partial_16_6 vload_partial_6 1818*c217d954SCole Faust#define vload_partial_16_7 vload_partial_7 1819*c217d954SCole Faust#define vload_partial_16_8 vload_partial_8 1820*c217d954SCole Faust#define vload_partial_16_9 vload_partial_9 1821*c217d954SCole Faust#define vload_partial_16_10 vload_partial_10 1822*c217d954SCole Faust#define vload_partial_16_11 vload_partial_11 1823*c217d954SCole Faust#define vload_partial_16_12 vload_partial_12 1824*c217d954SCole Faust#define vload_partial_16_13 vload_partial_13 1825*c217d954SCole Faust#define vload_partial_16_14 vload_partial_14 1826*c217d954SCole Faust#define vload_partial_16_15 vload_partial_15 1827*c217d954SCole Faust#define vload_partial_16_16 vload_partial_16 1828*c217d954SCole Faust 1829*c217d954SCole Faust 1830*c217d954SCole Faust#define vload_partial_1(DATA, OFFSET, PTR) \ 1831*c217d954SCole Faust DATA.s0 = vload1(OFFSET, PTR); 1832*c217d954SCole Faust 1833*c217d954SCole Faust#define vload_partial_2(DATA, OFFSET, PTR) \ 1834*c217d954SCole Faust DATA.s01 = vload2(OFFSET, PTR); 1835*c217d954SCole Faust 1836*c217d954SCole Faust#define vload_partial_3(DATA, OFFSET, PTR) \ 1837*c217d954SCole Faust DATA.s012 = vload3(OFFSET, PTR); 1838*c217d954SCole Faust 1839*c217d954SCole Faust#define vload_partial_4(DATA, OFFSET, PTR) \ 1840*c217d954SCole Faust DATA.s0123 = vload4(OFFSET, PTR); 1841*c217d954SCole Faust 1842*c217d954SCole Faust#define vload_partial_5(DATA, OFFSET, PTR) \ 1843*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 1844*c217d954SCole Faust DATA.s4 = vload1(OFFSET, PTR + 4); 1845*c217d954SCole Faust 1846*c217d954SCole Faust#define vload_partial_6(DATA, OFFSET, PTR) \ 1847*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 1848*c217d954SCole Faust vload_partial_2(DATA.s45, OFFSET, PTR + 4); 1849*c217d954SCole Faust 1850*c217d954SCole Faust#define vload_partial_7(DATA, OFFSET, PTR) \ 1851*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 1852*c217d954SCole Faust vload_partial_3(DATA.s456, OFFSET, PTR + 4); 1853*c217d954SCole Faust 1854*c217d954SCole Faust#define vload_partial_8(DATA, OFFSET, PTR) \ 1855*c217d954SCole Faust DATA.s01234567 = vload8(OFFSET, PTR); 1856*c217d954SCole Faust 1857*c217d954SCole Faust#define vload_partial_9(DATA, OFFSET, PTR) \ 1858*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1859*c217d954SCole Faust DATA.s8 = vload1(OFFSET, PTR + 8); 1860*c217d954SCole Faust 1861*c217d954SCole Faust#define vload_partial_10(DATA, OFFSET, PTR) \ 1862*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1863*c217d954SCole Faust vload_partial_2(DATA.s89, OFFSET, PTR + 8); 1864*c217d954SCole Faust 1865*c217d954SCole Faust#define vload_partial_11(DATA, OFFSET, PTR) \ 1866*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1867*c217d954SCole Faust vload_partial_3(DATA.s89A, OFFSET, PTR + 8); 1868*c217d954SCole Faust 1869*c217d954SCole Faust#define vload_partial_12(DATA, OFFSET, PTR) \ 1870*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1871*c217d954SCole Faust vload_partial_4(DATA.s89AB, OFFSET, PTR + 8); 1872*c217d954SCole Faust 1873*c217d954SCole Faust#define vload_partial_13(DATA, OFFSET, PTR) \ 1874*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1875*c217d954SCole Faust vload_partial_5(DATA.s89ABCDEF, OFFSET, PTR + 8); 1876*c217d954SCole Faust 1877*c217d954SCole Faust#define vload_partial_14(DATA, OFFSET, PTR) \ 1878*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1879*c217d954SCole Faust vload_partial_6(DATA.s89ABCDEF, OFFSET, PTR + 8); 1880*c217d954SCole Faust 1881*c217d954SCole Faust#define vload_partial_15(DATA, OFFSET, PTR) \ 1882*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1883*c217d954SCole Faust vload_partial_7(DATA.s89ABCDEF, OFFSET, PTR + 8); 1884*c217d954SCole Faust 1885*c217d954SCole Faust#define vload_partial_16(DATA, OFFSET, PTR) \ 1886*c217d954SCole Faust DATA = vload16(OFFSET, PTR); 1887*c217d954SCole Faust 1888*c217d954SCole Faust 1889*c217d954SCole Faust 1890*c217d954SCole Faust#define PIXEL_UNIT4 1 1891*c217d954SCole Faust#define PIXEL_UNIT8 2 1892*c217d954SCole Faust#define PIXEL_UNIT16 4 1893*c217d954SCole Faust 1894*c217d954SCole Faust 1895*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) PIXEL_UNIT##vec_size 1896*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT(vec_size) CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) 1897*c217d954SCole Faust 1898*c217d954SCole Faust 1899*c217d954SCole Faust#define read_image2d_floatx1(img, x_coord, y_coord) (float4)(read_imagef(img, (int2)(x_coord, y_coord))); 1900*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))); 1901*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))); 1902*c217d954SCole Faust 1903*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 1904*c217d954SCole Faust#define read_image2d_halfx1(img, x_coord, y_coord) (half4)(read_imageh(img, (int2)(x_coord, y_coord))); 1905*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))); 1906*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))); 1907*c217d954SCole Faust#endif 1908*c217d954SCole Faust 1909*c217d954SCole Faust#define write_image2d_floatx1(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values)); 1910*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)); 1911*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)); 1912*c217d954SCole Faust 1913*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 1914*c217d954SCole Faust#define write_image2d_halfx1(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values)); 1915*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)); 1916*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)); 1917*c217d954SCole Faust#endif 1918*c217d954SCole Faust 1919*c217d954SCole Faust 1920*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) 1921*c217d954SCole Faust#define READ_IMAGE2D(data_type, n0, img, x_coord, y_coord) READ_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord) 1922*c217d954SCole Faust 1923*c217d954SCole Faust 1924*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) 1925*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) 1926*c217d954SCole Faust 1927*c217d954SCole Faust#define VSTORE_STR(size) vstore##size 1928*c217d954SCole Faust#define VSTORE(size) VSTORE_STR(size) 1929*c217d954SCole Faust 1930*c217d954SCole Faust#define float1 float 1931*c217d954SCole Faust#define half1 half 1932*c217d954SCole Faust#define char1 char 1933*c217d954SCole Faust#define uchar1 uchar 1934*c217d954SCole Faust#define short1 short 1935*c217d954SCole Faust#define ushort1 ushort 1936*c217d954SCole Faust#define int1 int 1937*c217d954SCole Faust#define uint1 uint 1938*c217d954SCole Faust#define long1 long 1939*c217d954SCole Faust#define ulong1 ulong 1940*c217d954SCole Faust#define double1 double 1941*c217d954SCole Faust 1942*c217d954SCole Faust#define vload1(OFFSET, PTR) *(OFFSET + PTR) 1943*c217d954SCole Faust#define vstore1(DATA, OFFSET, PTR) *(OFFSET + PTR) = DATA 1944*c217d954SCole Faust 1945*c217d954SCole Faust 1946*c217d954SCole Faust#define VSTORE_PARTIAL_STR(size, store_size) vstore_partial_##size##_##store_size 1947*c217d954SCole Faust#define VSTORE_PARTIAL(size, store_size) VSTORE_PARTIAL_STR(size, store_size) 1948*c217d954SCole Faust 1949*c217d954SCole Faust#define NO_STORE(data, offs, ptr) \ 1950*c217d954SCole Faust { \ 1951*c217d954SCole Faust } 1952*c217d954SCole Faust 1953*c217d954SCole Faust 1954*c217d954SCole Faust#define vstore_partial_1_0 NO_STORE 1955*c217d954SCole Faust#define vstore_partial_1_1 vstore1 1956*c217d954SCole Faust#define vstore_partial_1_2 NO_STORE 1957*c217d954SCole Faust#define vstore_partial_1_3 NO_STORE 1958*c217d954SCole Faust#define vstore_partial_1_4 NO_STORE 1959*c217d954SCole Faust#define vstore_partial_1_5 NO_STORE 1960*c217d954SCole Faust#define vstore_partial_1_6 NO_STORE 1961*c217d954SCole Faust#define vstore_partial_1_7 NO_STORE 1962*c217d954SCole Faust#define vstore_partial_1_8 NO_STORE 1963*c217d954SCole Faust#define vstore_partial_1_9 NO_STORE 1964*c217d954SCole Faust#define vstore_partial_1_10 NO_STORE 1965*c217d954SCole Faust#define vstore_partial_1_11 NO_STORE 1966*c217d954SCole Faust#define vstore_partial_1_12 NO_STORE 1967*c217d954SCole Faust#define vstore_partial_1_13 NO_STORE 1968*c217d954SCole Faust#define vstore_partial_1_14 NO_STORE 1969*c217d954SCole Faust#define vstore_partial_1_15 NO_STORE 1970*c217d954SCole Faust#define vstore_partial_1_16 NO_STORE 1971*c217d954SCole Faust 1972*c217d954SCole Faust#define vstore_partial_2_0 NO_STORE 1973*c217d954SCole Faust#define vstore_partial_2_1 vstore_partial_1 1974*c217d954SCole Faust#define vstore_partial_2_2 vstore_partial_2 1975*c217d954SCole Faust#define vstore_partial_2_3 NO_STORE 1976*c217d954SCole Faust#define vstore_partial_2_4 NO_STORE 1977*c217d954SCole Faust#define vstore_partial_2_5 NO_STORE 1978*c217d954SCole Faust#define vstore_partial_2_6 NO_STORE 1979*c217d954SCole Faust#define vstore_partial_2_7 NO_STORE 1980*c217d954SCole Faust#define vstore_partial_2_8 NO_STORE 1981*c217d954SCole Faust#define vstore_partial_2_9 NO_STORE 1982*c217d954SCole Faust#define vstore_partial_2_10 NO_STORE 1983*c217d954SCole Faust#define vstore_partial_2_11 NO_STORE 1984*c217d954SCole Faust#define vstore_partial_2_12 NO_STORE 1985*c217d954SCole Faust#define vstore_partial_2_13 NO_STORE 1986*c217d954SCole Faust#define vstore_partial_2_14 NO_STORE 1987*c217d954SCole Faust#define vstore_partial_2_15 NO_STORE 1988*c217d954SCole Faust#define vstore_partial_2_16 NO_STORE 1989*c217d954SCole Faust 1990*c217d954SCole Faust#define vstore_partial_3_0 NO_STORE 1991*c217d954SCole Faust#define vstore_partial_3_1 vstore_partial_1 1992*c217d954SCole Faust#define vstore_partial_3_2 vstore_partial_2 1993*c217d954SCole Faust#define vstore_partial_3_3 vstore_partial_3 1994*c217d954SCole Faust#define vstore_partial_3_4 NO_STORE 1995*c217d954SCole Faust#define vstore_partial_3_5 NO_STORE 1996*c217d954SCole Faust#define vstore_partial_3_6 NO_STORE 1997*c217d954SCole Faust#define vstore_partial_3_7 NO_STORE 1998*c217d954SCole Faust#define vstore_partial_3_8 NO_STORE 1999*c217d954SCole Faust#define vstore_partial_3_9 NO_STORE 2000*c217d954SCole Faust#define vstore_partial_3_10 NO_STORE 2001*c217d954SCole Faust#define vstore_partial_3_11 NO_STORE 2002*c217d954SCole Faust#define vstore_partial_3_12 NO_STORE 2003*c217d954SCole Faust#define vstore_partial_3_13 NO_STORE 2004*c217d954SCole Faust#define vstore_partial_3_14 NO_STORE 2005*c217d954SCole Faust#define vstore_partial_3_15 NO_STORE 2006*c217d954SCole Faust#define vstore_partial_3_16 NO_STORE 2007*c217d954SCole Faust 2008*c217d954SCole Faust#define vstore_partial_4_0 NO_STORE 2009*c217d954SCole Faust#define vstore_partial_4_1 vstore_partial_1 2010*c217d954SCole Faust#define vstore_partial_4_2 vstore_partial_2 2011*c217d954SCole Faust#define vstore_partial_4_3 vstore_partial_3 2012*c217d954SCole Faust#define vstore_partial_4_4 vstore_partial_4 2013*c217d954SCole Faust#define vstore_partial_4_5 NO_STORE 2014*c217d954SCole Faust#define vstore_partial_4_6 NO_STORE 2015*c217d954SCole Faust#define vstore_partial_4_7 NO_STORE 2016*c217d954SCole Faust#define vstore_partial_4_8 NO_STORE 2017*c217d954SCole Faust#define vstore_partial_4_9 NO_STORE 2018*c217d954SCole Faust#define vstore_partial_4_10 NO_STORE 2019*c217d954SCole Faust#define vstore_partial_4_11 NO_STORE 2020*c217d954SCole Faust#define vstore_partial_4_12 NO_STORE 2021*c217d954SCole Faust#define vstore_partial_4_13 NO_STORE 2022*c217d954SCole Faust#define vstore_partial_4_14 NO_STORE 2023*c217d954SCole Faust#define vstore_partial_4_15 NO_STORE 2024*c217d954SCole Faust#define vstore_partial_4_16 NO_STORE 2025*c217d954SCole Faust 2026*c217d954SCole Faust#define vstore_partial_8_0 NO_STORE 2027*c217d954SCole Faust#define vstore_partial_8_1 vstore_partial_1 2028*c217d954SCole Faust#define vstore_partial_8_2 vstore_partial_2 2029*c217d954SCole Faust#define vstore_partial_8_3 vstore_partial_3 2030*c217d954SCole Faust#define vstore_partial_8_4 vstore_partial_4 2031*c217d954SCole Faust#define vstore_partial_8_5 vstore_partial_5 2032*c217d954SCole Faust#define vstore_partial_8_6 vstore_partial_6 2033*c217d954SCole Faust#define vstore_partial_8_7 vstore_partial_7 2034*c217d954SCole Faust#define vstore_partial_8_8 vstore_partial_8 2035*c217d954SCole Faust#define vstore_partial_8_9 NO_STORE 2036*c217d954SCole Faust#define vstore_partial_8_10 NO_STORE 2037*c217d954SCole Faust#define vstore_partial_8_11 NO_STORE 2038*c217d954SCole Faust#define vstore_partial_8_12 NO_STORE 2039*c217d954SCole Faust#define vstore_partial_8_13 NO_STORE 2040*c217d954SCole Faust#define vstore_partial_8_14 NO_STORE 2041*c217d954SCole Faust#define vstore_partial_8_15 NO_STORE 2042*c217d954SCole Faust#define vstore_partial_8_16 NO_STORE 2043*c217d954SCole Faust 2044*c217d954SCole Faust#define vstore_partial_16_0 NO_STORE 2045*c217d954SCole Faust#define vstore_partial_16_1 vstore_partial_1 2046*c217d954SCole Faust#define vstore_partial_16_2 vstore_partial_2 2047*c217d954SCole Faust#define vstore_partial_16_3 vstore_partial_3 2048*c217d954SCole Faust#define vstore_partial_16_4 vstore_partial_4 2049*c217d954SCole Faust#define vstore_partial_16_5 vstore_partial_5 2050*c217d954SCole Faust#define vstore_partial_16_6 vstore_partial_6 2051*c217d954SCole Faust#define vstore_partial_16_7 vstore_partial_7 2052*c217d954SCole Faust#define vstore_partial_16_8 vstore_partial_8 2053*c217d954SCole Faust#define vstore_partial_16_9 vstore_partial_9 2054*c217d954SCole Faust#define vstore_partial_16_10 vstore_partial_10 2055*c217d954SCole Faust#define vstore_partial_16_11 vstore_partial_11 2056*c217d954SCole Faust#define vstore_partial_16_12 vstore_partial_12 2057*c217d954SCole Faust#define vstore_partial_16_13 vstore_partial_13 2058*c217d954SCole Faust#define vstore_partial_16_14 vstore_partial_14 2059*c217d954SCole Faust#define vstore_partial_16_15 vstore_partial_15 2060*c217d954SCole Faust#define vstore_partial_16_16 vstore_partial_16 2061*c217d954SCole Faust 2062*c217d954SCole Faust 2063*c217d954SCole Faust#define vstore_partial_1(DATA, OFFSET, PTR) \ 2064*c217d954SCole Faust vstore1(DATA.s0, OFFSET, PTR); 2065*c217d954SCole Faust 2066*c217d954SCole Faust#define vstore_partial_2(DATA, OFFSET, PTR) \ 2067*c217d954SCole Faust vstore2(DATA.s01, OFFSET, PTR); 2068*c217d954SCole Faust 2069*c217d954SCole Faust#define vstore_partial_3(DATA, OFFSET, PTR) \ 2070*c217d954SCole Faust vstore3(DATA.s012, OFFSET, PTR); 2071*c217d954SCole Faust 2072*c217d954SCole Faust#define vstore_partial_4(DATA, OFFSET, PTR) \ 2073*c217d954SCole Faust vstore4(DATA.s0123, OFFSET, PTR); 2074*c217d954SCole Faust 2075*c217d954SCole Faust#define vstore_partial_5(DATA, OFFSET, PTR) \ 2076*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 2077*c217d954SCole Faust vstore1(DATA.s4, OFFSET, PTR + 4); 2078*c217d954SCole Faust 2079*c217d954SCole Faust#define vstore_partial_6(DATA, OFFSET, PTR) \ 2080*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 2081*c217d954SCole Faust vstore_partial_2(DATA.s45, OFFSET, PTR + 4); 2082*c217d954SCole Faust 2083*c217d954SCole Faust#define vstore_partial_7(DATA, OFFSET, PTR) \ 2084*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 2085*c217d954SCole Faust vstore_partial_3(DATA.s456, OFFSET, PTR + 4); 2086*c217d954SCole Faust 2087*c217d954SCole Faust#define vstore_partial_8(DATA, OFFSET, PTR) \ 2088*c217d954SCole Faust vstore8(DATA.s01234567, OFFSET, PTR); 2089*c217d954SCole Faust 2090*c217d954SCole Faust#define vstore_partial_9(DATA, OFFSET, PTR) \ 2091*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2092*c217d954SCole Faust vstore1(DATA.s8, OFFSET, PTR + 8); 2093*c217d954SCole Faust 2094*c217d954SCole Faust#define vstore_partial_10(DATA, OFFSET, PTR) \ 2095*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2096*c217d954SCole Faust vstore_partial_2(DATA.s89, OFFSET, PTR + 8); 2097*c217d954SCole Faust 2098*c217d954SCole Faust#define vstore_partial_11(DATA, OFFSET, PTR) \ 2099*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2100*c217d954SCole Faust vstore_partial_3(DATA.s89a, OFFSET, PTR + 8); 2101*c217d954SCole Faust 2102*c217d954SCole Faust#define vstore_partial_12(DATA, OFFSET, PTR) \ 2103*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2104*c217d954SCole Faust vstore_partial_4(DATA.s89ab, OFFSET, PTR + 8); 2105*c217d954SCole Faust 2106*c217d954SCole Faust#define vstore_partial_13(DATA, OFFSET, PTR) \ 2107*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2108*c217d954SCole Faust vstore_partial_5(DATA.s89abcdef, OFFSET, PTR + 8); 2109*c217d954SCole Faust 2110*c217d954SCole Faust#define vstore_partial_14(DATA, OFFSET, PTR) \ 2111*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2112*c217d954SCole Faust vstore_partial_6(DATA.s89abcdef, OFFSET, PTR + 8); 2113*c217d954SCole Faust 2114*c217d954SCole Faust#define vstore_partial_15(DATA, OFFSET, PTR) \ 2115*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2116*c217d954SCole Faust vstore_partial_7(DATA.s89abcdef, OFFSET, PTR + 8); 2117*c217d954SCole Faust 2118*c217d954SCole Faust#define vstore_partial_16(DATA, OFFSET, PTR) \ 2119*c217d954SCole Faust vstore16(DATA, OFFSET, PTR); 2120*c217d954SCole Faust 2121*c217d954SCole Faust 2122*c217d954SCole Faust 2123*c217d954SCole Faust 2124*c217d954SCole Faust 2125*c217d954SCole Faust#define convert_float_sat convert_float 2126*c217d954SCole Faust#define convert_float1_sat convert_float 2127*c217d954SCole Faust#define convert_float2_sat convert_float2 2128*c217d954SCole Faust#define convert_float3_sat convert_float3 2129*c217d954SCole Faust#define convert_float4_sat convert_float4 2130*c217d954SCole Faust#define convert_float8_sat convert_float8 2131*c217d954SCole Faust#define convert_float16_sat convert_float16 2132*c217d954SCole Faust#define convert_half_sat convert_float 2133*c217d954SCole Faust#define convert_half1_sat convert_half 2134*c217d954SCole Faust#define convert_half2_sat convert_half2 2135*c217d954SCole Faust#define convert_half3_sat convert_half3 2136*c217d954SCole Faust#define convert_half4_sat convert_half4 2137*c217d954SCole Faust#define convert_half8_sat convert_half8 2138*c217d954SCole Faust#define convert_half16_sat convert_half16 2139*c217d954SCole Faust 2140*c217d954SCole Faust#define convert_float1 convert_float 2141*c217d954SCole Faust#define convert_half1 convert_half 2142*c217d954SCole Faust#define convert_char1 convert_char 2143*c217d954SCole Faust#define convert_uchar1 convert_uchar 2144*c217d954SCole Faust#define convert_short1 convert_short 2145*c217d954SCole Faust#define convert_ushort1 convert_ushort 2146*c217d954SCole Faust#define convert_int1 convert_int 2147*c217d954SCole Faust#define convert_uint1 convert_uint 2148*c217d954SCole Faust#define convert_long1 convert_long 2149*c217d954SCole Faust#define convert_ulong1 convert_ulong 2150*c217d954SCole Faust#define convert_double1 convert_double 2151*c217d954SCole Faust 2152*c217d954SCole Faust#define convert_char1_sat convert_char_sat 2153*c217d954SCole Faust#define convert_uchar1_sat convert_uchar_sat 2154*c217d954SCole Faust#define convert_uchar2_sat convert_uchar2_sat 2155*c217d954SCole Faust#define convert_uchar3_sat convert_uchar3_sat 2156*c217d954SCole Faust#define convert_uchar4_sat convert_uchar4_sat 2157*c217d954SCole Faust#define convert_uchar8_sat convert_uchar8_sat 2158*c217d954SCole Faust#define convert_uchar16_sat convert_uchar16_sat 2159*c217d954SCole Faust#define convert_short1_sat convert_short_sat 2160*c217d954SCole Faust#define convert_ushort1_sat convert_ushort_sat 2161*c217d954SCole Faust#define convert_int1_sat convert_int_sat 2162*c217d954SCole Faust#define convert_uint1_sat convert_uint_sat 2163*c217d954SCole Faust#define convert_long1_sat convert_long_sat 2164*c217d954SCole Faust#define convert_ulong1_sat convert_ulong_sat 2165*c217d954SCole Faust#define convert_double1_sat convert_double_sat 2166*c217d954SCole Faust 2167*c217d954SCole Faust#define VEC_DATA_TYPE_STR(type, size) type##size 2168*c217d954SCole Faust#define VEC_DATA_TYPE(type, size) VEC_DATA_TYPE_STR(type, size) 2169*c217d954SCole Faust 2170*c217d954SCole Faust#define CONVERT_STR(x, type) (convert_##type((x))) 2171*c217d954SCole Faust#define CONVERT(x, type) CONVERT_STR(x, type) 2172*c217d954SCole Faust 2173*c217d954SCole Faust#define CONVERT_SAT_STR(x, type) (convert_##type##_sat((x))) 2174*c217d954SCole Faust#define CONVERT_SAT(x, type) CONVERT_SAT_STR(x, type) 2175*c217d954SCole Faust 2176*c217d954SCole Faust#define CONVERT_SAT_ROUND_STR(x, type, round) (convert_##type##_sat_##round((x))) 2177*c217d954SCole Faust#define CONVERT_SAT_ROUND(x, type, round) CONVERT_SAT_ROUND_STR(x, type, round) 2178*c217d954SCole Faust 2179*c217d954SCole Faust#define select_vec_dt_uchar(size) uchar##size 2180*c217d954SCole Faust#define select_vec_dt_char(size) char##size 2181*c217d954SCole Faust#define select_vec_dt_ushort(size) ushort##size 2182*c217d954SCole Faust#define select_vec_dt_short(size) short##size 2183*c217d954SCole Faust#define select_vec_dt_half(size) short##size 2184*c217d954SCole Faust#define select_vec_dt_uint(size) uint##size 2185*c217d954SCole Faust#define select_vec_dt_int(size) int##size 2186*c217d954SCole Faust#define select_vec_dt_float(size) int##size 2187*c217d954SCole Faust#define select_vec_dt_ulong(size) ulong##size 2188*c217d954SCole Faust#define select_vec_dt_long(size) long##size 2189*c217d954SCole Faust 2190*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE_STR(type, size) select_vec_dt_##type(size) 2191*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE(type, size) SELECT_VEC_DATA_TYPE_STR(type, size) 2192*c217d954SCole Faust#define SELECT_DATA_TYPE(type) SELECT_VEC_DATA_TYPE_STR(type, 1) 2193*c217d954SCole Faust 2194*c217d954SCole Faust#define signed_int_vec_dt_uchar(size) char##size 2195*c217d954SCole Faust#define signed_int_vec_dt_char(size) char##size 2196*c217d954SCole Faust#define signed_int_vec_dt_ushort(size) short##size 2197*c217d954SCole Faust#define signed_int_vec_dt_short(size) short##size 2198*c217d954SCole Faust#define signed_int_vec_dt_half(size) short##size 2199*c217d954SCole Faust#define signed_int_vec_dt_uint(size) int##size 2200*c217d954SCole Faust#define signed_int_vec_dt_int(size) int##size 2201*c217d954SCole Faust#define signed_int_vec_dt_float(size) int##size 2202*c217d954SCole Faust#define signed_int_vec_dt_ulong(size) long##size 2203*c217d954SCole Faust#define signed_int_vec_dt_long(size) long##size 2204*c217d954SCole Faust 2205*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE_STR(type, size) signed_int_vec_dt_##type(size) 2206*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE(type, size) SIGNED_INT_VEC_DATA_TYPE_STR(type, size) 2207*c217d954SCole Faust#define SIGNED_INT_DATA_TYPE(type) SIGNED_INT_VEC_DATA_TYPE_STR(type, 1) 2208*c217d954SCole Faust 2209*c217d954SCole Faust#define sum_reduce_1(x) (x) 2210*c217d954SCole Faust#define sum_reduce_2(x) ((x).s0) + ((x).s1) 2211*c217d954SCole Faust#define sum_reduce_3(x) sum_reduce_2((x).s01) + ((x).s2) 2212*c217d954SCole Faust#define sum_reduce_4(x) sum_reduce_2((x).s01) + sum_reduce_2((x).s23) 2213*c217d954SCole Faust#define sum_reduce_8(x) sum_reduce_4((x).s0123) + sum_reduce_4((x).s4567) 2214*c217d954SCole Faust#define sum_reduce_16(x) sum_reduce_8((x).s01234567) + sum_reduce_8((x).s89ABCDEF) 2215*c217d954SCole Faust 2216*c217d954SCole Faust#define SUM_REDUCE_STR(x, size) sum_reduce_##size(x) 2217*c217d954SCole Faust#define SUM_REDUCE(x, size) SUM_REDUCE_STR(x, size) 2218*c217d954SCole Faust 2219*c217d954SCole Faust#define prod_reduce_1(x) (x) 2220*c217d954SCole Faust#define prod_reduce_2(x) ((x).s0) * ((x).s1) 2221*c217d954SCole Faust#define prod_reduce_3(x) prod_reduce_2((x).s01) * ((x).s2) 2222*c217d954SCole Faust#define prod_reduce_4(x) prod_reduce_2((x).s01) * prod_reduce_2((x).s23) 2223*c217d954SCole Faust#define prod_reduce_8(x) prod_reduce_4((x).s0123) * prod_reduce_4((x).s4567) 2224*c217d954SCole Faust#define prod_reduce_16(x) prod_reduce_8((x).s01234567) * prod_reduce_8((x).s89ABCDEF) 2225*c217d954SCole Faust 2226*c217d954SCole Faust#define PROD_REDUCE_STR(x, size) prod_reduce_##size(x) 2227*c217d954SCole Faust#define PROD_REDUCE(x, size) PROD_REDUCE_STR(x, size) 2228*c217d954SCole Faust 2229*c217d954SCole Faust#define max_reduce_1(x) (x) 2230*c217d954SCole Faust#define max_reduce_2(x) max(((x).s0), ((x).s1)) 2231*c217d954SCole Faust#define max_reduce_3(x) max(max_reduce_2((x).s01), ((x).s2)) 2232*c217d954SCole Faust#define max_reduce_4(x) max(max_reduce_2((x).s01), max_reduce_2((x).s23)) 2233*c217d954SCole Faust#define max_reduce_8(x) max(max_reduce_4((x).s0123), max_reduce_4((x).s4567)) 2234*c217d954SCole Faust#define max_reduce_16(x) max(max_reduce_8((x).s01234567), max_reduce_8((x).s89ABCDEF)) 2235*c217d954SCole Faust 2236*c217d954SCole Faust#define MAX_REDUCE_STR(x, size) max_reduce_##size(x) 2237*c217d954SCole Faust#define MAX_REDUCE(x, size) MAX_REDUCE_STR(x, size) 2238*c217d954SCole Faust 2239*c217d954SCole Faust#define VECTOR_DECLARATION(name) \ 2240*c217d954SCole Faust __global uchar *name##_ptr, \ 2241*c217d954SCole Faust uint name##_stride_x, \ 2242*c217d954SCole Faust uint name##_step_x, \ 2243*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2244*c217d954SCole Faust 2245*c217d954SCole Faust#define IMAGE_DECLARATION(name) \ 2246*c217d954SCole Faust __global uchar *name##_ptr, \ 2247*c217d954SCole Faust uint name##_stride_x, \ 2248*c217d954SCole Faust uint name##_step_x, \ 2249*c217d954SCole Faust uint name##_stride_y, \ 2250*c217d954SCole Faust uint name##_step_y, \ 2251*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2252*c217d954SCole Faust 2253*c217d954SCole Faust#define TENSOR3D_DECLARATION(name) \ 2254*c217d954SCole Faust __global uchar *name##_ptr, \ 2255*c217d954SCole Faust uint name##_stride_x, \ 2256*c217d954SCole Faust uint name##_step_x, \ 2257*c217d954SCole Faust uint name##_stride_y, \ 2258*c217d954SCole Faust uint name##_step_y, \ 2259*c217d954SCole Faust uint name##_stride_z, \ 2260*c217d954SCole Faust uint name##_step_z, \ 2261*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2262*c217d954SCole Faust 2263*c217d954SCole Faust#define TENSOR4D_DECLARATION(name) \ 2264*c217d954SCole Faust __global uchar *name##_ptr, \ 2265*c217d954SCole Faust uint name##_stride_x, \ 2266*c217d954SCole Faust uint name##_step_x, \ 2267*c217d954SCole Faust uint name##_stride_y, \ 2268*c217d954SCole Faust uint name##_step_y, \ 2269*c217d954SCole Faust uint name##_stride_z, \ 2270*c217d954SCole Faust uint name##_step_z, \ 2271*c217d954SCole Faust uint name##_stride_w, \ 2272*c217d954SCole Faust uint name##_step_w, \ 2273*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2274*c217d954SCole Faust 2275*c217d954SCole Faust#define TENSOR5D_DECLARATION(name) \ 2276*c217d954SCole Faust __global uchar *name##_ptr, \ 2277*c217d954SCole Faust uint name##_stride_x, \ 2278*c217d954SCole Faust uint name##_step_x, \ 2279*c217d954SCole Faust uint name##_stride_y, \ 2280*c217d954SCole Faust uint name##_step_y, \ 2281*c217d954SCole Faust uint name##_stride_z, \ 2282*c217d954SCole Faust uint name##_step_z, \ 2283*c217d954SCole Faust uint name##_stride_w, \ 2284*c217d954SCole Faust uint name##_step_w, \ 2285*c217d954SCole Faust uint name##_stride_v, \ 2286*c217d954SCole Faust uint name##_step_v, \ 2287*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2288*c217d954SCole Faust 2289*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT(name) \ 2290*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x) 2291*c217d954SCole Faust 2292*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT_NO_STEP(name) \ 2293*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0) 2294*c217d954SCole Faust 2295*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT(name) \ 2296*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) 2297*c217d954SCole Faust 2298*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name) \ 2299*c217d954SCole Faust update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0) 2300*c217d954SCole Faust 2301*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 2302*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) 2303*c217d954SCole Faust 2304*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT_NO_STEP(name) \ 2305*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) 2306*c217d954SCole Faust 2307*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 2308*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) 2309*c217d954SCole Faust 2310*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT(name) \ 2311*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, \ 2312*c217d954SCole Faust name##_stride_z, name##_step_z) 2313*c217d954SCole Faust 2314*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name) \ 2315*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) 2316*c217d954SCole Faust 2317*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT(name, mod_size) \ 2318*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, \ 2319*c217d954SCole Faust name##_stride_z, name##_step_z, name##_stride_w, name##_step_w, mod_size) 2320*c217d954SCole Faust 2321*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(name, mod_size) \ 2322*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) 2323*c217d954SCole Faust 2324*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_UPDATE_PTR(name) \ 2325*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, \ 2326*c217d954SCole Faust name##_stride_z, name##_step_z) 2327*c217d954SCole Faust 2328*c217d954SCole Faust 2329*c217d954SCole Fausttypedef struct Vector 2330*c217d954SCole Faust{ 2331*c217d954SCole Faust __global uchar *ptr; 2332*c217d954SCole Faust int offset_first_element_in_bytes; 2333*c217d954SCole Faust int stride_x; 2334*c217d954SCole Faust} Vector; 2335*c217d954SCole Faust 2336*c217d954SCole Faust 2337*c217d954SCole Fausttypedef struct Image 2338*c217d954SCole Faust{ 2339*c217d954SCole Faust __global uchar *ptr; 2340*c217d954SCole Faust int offset_first_element_in_bytes; 2341*c217d954SCole Faust int stride_x; 2342*c217d954SCole Faust int stride_y; 2343*c217d954SCole Faust} Image; 2344*c217d954SCole Faust 2345*c217d954SCole Faust 2346*c217d954SCole Fausttypedef struct Tensor3D 2347*c217d954SCole Faust{ 2348*c217d954SCole Faust __global uchar *ptr; 2349*c217d954SCole Faust int offset_first_element_in_bytes; 2350*c217d954SCole Faust int stride_x; 2351*c217d954SCole Faust int stride_y; 2352*c217d954SCole Faust int stride_z; 2353*c217d954SCole Faust} Tensor3D; 2354*c217d954SCole Faust 2355*c217d954SCole Faust 2356*c217d954SCole Fausttypedef struct Tensor4D 2357*c217d954SCole Faust{ 2358*c217d954SCole Faust __global uchar *ptr; 2359*c217d954SCole Faust int offset_first_element_in_bytes; 2360*c217d954SCole Faust int stride_x; 2361*c217d954SCole Faust int stride_y; 2362*c217d954SCole Faust int stride_z; 2363*c217d954SCole Faust int stride_w; 2364*c217d954SCole Faust} Tensor4D; 2365*c217d954SCole Faust 2366*c217d954SCole Faust 2367*c217d954SCole Faustinline Vector update_vector_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x) 2368*c217d954SCole Faust{ 2369*c217d954SCole Faust Vector vector = 2370*c217d954SCole Faust { 2371*c217d954SCole Faust .ptr = ptr, 2372*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2373*c217d954SCole Faust .stride_x = stride_x, 2374*c217d954SCole Faust }; 2375*c217d954SCole Faust vector.ptr += vector.offset_first_element_in_bytes + get_global_id(0) * step_x; 2376*c217d954SCole Faust return vector; 2377*c217d954SCole Faust} 2378*c217d954SCole Faust 2379*c217d954SCole Faust 2380*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) 2381*c217d954SCole Faust{ 2382*c217d954SCole Faust Image img = 2383*c217d954SCole Faust { 2384*c217d954SCole Faust .ptr = ptr, 2385*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2386*c217d954SCole Faust .stride_x = stride_x, 2387*c217d954SCole Faust .stride_y = stride_y 2388*c217d954SCole Faust }; 2389*c217d954SCole Faust img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y; 2390*c217d954SCole Faust return img; 2391*c217d954SCole Faust} 2392*c217d954SCole Faust 2393*c217d954SCole Faust 2394*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) 2395*c217d954SCole Faust{ 2396*c217d954SCole Faust Image img = 2397*c217d954SCole Faust { 2398*c217d954SCole Faust .ptr = ptr, 2399*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2400*c217d954SCole Faust .stride_x = stride_x, 2401*c217d954SCole Faust .stride_y = stride_y 2402*c217d954SCole Faust }; 2403*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; 2404*c217d954SCole Faust return img; 2405*c217d954SCole Faust} 2406*c217d954SCole Faust 2407*c217d954SCole Faust 2408*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) 2409*c217d954SCole Faust{ 2410*c217d954SCole Faust Tensor3D tensor = 2411*c217d954SCole Faust { 2412*c217d954SCole Faust .ptr = ptr, 2413*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2414*c217d954SCole Faust .stride_x = stride_x, 2415*c217d954SCole Faust .stride_y = stride_y, 2416*c217d954SCole Faust .stride_z = stride_z 2417*c217d954SCole Faust }; 2418*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; 2419*c217d954SCole Faust return tensor; 2420*c217d954SCole Faust} 2421*c217d954SCole Faust 2422*c217d954SCole Faust 2423*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) 2424*c217d954SCole Faust{ 2425*c217d954SCole Faust Tensor3D tensor = 2426*c217d954SCole Faust { 2427*c217d954SCole Faust .ptr = ptr, 2428*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2429*c217d954SCole Faust .stride_x = stride_x, 2430*c217d954SCole Faust .stride_y = stride_y, 2431*c217d954SCole Faust .stride_z = stride_z 2432*c217d954SCole Faust }; 2433*c217d954SCole Faust return tensor; 2434*c217d954SCole Faust} 2435*c217d954SCole Faust 2436*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, 2437*c217d954SCole Faust uint step_w, 2438*c217d954SCole Faust uint mod_size) 2439*c217d954SCole Faust{ 2440*c217d954SCole Faust Tensor4D tensor = 2441*c217d954SCole Faust { 2442*c217d954SCole Faust .ptr = ptr, 2443*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2444*c217d954SCole Faust .stride_x = stride_x, 2445*c217d954SCole Faust .stride_y = stride_y, 2446*c217d954SCole Faust .stride_z = stride_z, 2447*c217d954SCole Faust .stride_w = stride_w 2448*c217d954SCole Faust }; 2449*c217d954SCole Faust 2450*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; 2451*c217d954SCole Faust return tensor; 2452*c217d954SCole Faust} 2453*c217d954SCole Faust 2454*c217d954SCole Faust 2455*c217d954SCole Faustinline __global const uchar *vector_offset(const Vector *vec, int x) 2456*c217d954SCole Faust{ 2457*c217d954SCole Faust return vec->ptr + x * vec->stride_x; 2458*c217d954SCole Faust} 2459*c217d954SCole Faust 2460*c217d954SCole Faust 2461*c217d954SCole Faustinline __global uchar *offset(const Image *img, int x, int y) 2462*c217d954SCole Faust{ 2463*c217d954SCole Faust return img->ptr + x * img->stride_x + y * img->stride_y; 2464*c217d954SCole Faust} 2465*c217d954SCole Faust 2466*c217d954SCole Faust 2467*c217d954SCole Faustinline __global const uchar *tensor3D_offset(const Tensor3D *tensor, int x, int y, int z) 2468*c217d954SCole Faust{ 2469*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z; 2470*c217d954SCole Faust} 2471*c217d954SCole Faust 2472*c217d954SCole Faust 2473*c217d954SCole Faustinline __global const uchar *tensor4D_offset(const Tensor4D *tensor, int x, int y, int z, int w) 2474*c217d954SCole Faust{ 2475*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + w * tensor->stride_w; 2476*c217d954SCole Faust} 2477*c217d954SCole Faust 2478*c217d954SCole Faust 2479*c217d954SCole Faustinline __global const uchar *tensor3D_index2ptr(const Tensor3D *tensor, uint width, uint height, uint depth, uint index) 2480*c217d954SCole Faust{ 2481*c217d954SCole Faust uint num_elements = width * height; 2482*c217d954SCole Faust 2483*c217d954SCole Faust const uint z = index / num_elements; 2484*c217d954SCole Faust 2485*c217d954SCole Faust index %= num_elements; 2486*c217d954SCole Faust 2487*c217d954SCole Faust const uint y = index / width; 2488*c217d954SCole Faust 2489*c217d954SCole Faust index %= width; 2490*c217d954SCole Faust 2491*c217d954SCole Faust const uint x = index; 2492*c217d954SCole Faust 2493*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + tensor->offset_first_element_in_bytes; 2494*c217d954SCole Faust} 2495*c217d954SCole Faust 2496*c217d954SCole Faust#endif 2497*c217d954SCole Faust 2498*c217d954SCole Faust 2499*c217d954SCole Faust 2500*c217d954SCole Faust#define REPEAT_3_1(P_X, P_A, P_B, P_C) P_X##_DEF(0, P_A, P_B, P_C) 2501*c217d954SCole Faust#define REPEAT_3_2(P_X, P_A, P_B, P_C) \ 2502*c217d954SCole Faust P_X##_DEF(1, P_A, P_B, P_C); \ 2503*c217d954SCole Faust REPEAT_3_1(P_X, P_A, P_B, P_C) 2504*c217d954SCole Faust#define REPEAT_3_3(P_X, P_A, P_B, P_C) \ 2505*c217d954SCole Faust P_X##_DEF(2, P_A, P_B, P_C); \ 2506*c217d954SCole Faust REPEAT_3_2(P_X, P_A, P_B, P_C) 2507*c217d954SCole Faust#define REPEAT_3_4(P_X, P_A, P_B, P_C) \ 2508*c217d954SCole Faust P_X##_DEF(3, P_A, P_B, P_C); \ 2509*c217d954SCole Faust REPEAT_3_3(P_X, P_A, P_B, P_C) 2510*c217d954SCole Faust#define REPEAT_3_5(P_X, P_A, P_B, P_C) \ 2511*c217d954SCole Faust P_X##_DEF(4, P_A, P_B, P_C); \ 2512*c217d954SCole Faust REPEAT_3_4(P_X, P_A, P_B, P_C) 2513*c217d954SCole Faust#define REPEAT_3_6(P_X, P_A, P_B, P_C) \ 2514*c217d954SCole Faust P_X##_DEF(5, P_A, P_B, P_C); \ 2515*c217d954SCole Faust REPEAT_3_5(P_X, P_A, P_B, P_C) 2516*c217d954SCole Faust#define REPEAT_3_7(P_X, P_A, P_B, P_C) \ 2517*c217d954SCole Faust P_X##_DEF(6, P_A, P_B, P_C); \ 2518*c217d954SCole Faust REPEAT_3_6(P_X, P_A, P_B, P_C) 2519*c217d954SCole Faust#define REPEAT_3_8(P_X, P_A, P_B, P_C) \ 2520*c217d954SCole Faust P_X##_DEF(7, P_A, P_B, P_C); \ 2521*c217d954SCole Faust REPEAT_3_7(P_X, P_A, P_B, P_C) 2522*c217d954SCole Faust#define REPEAT_3_9(P_X, P_A, P_B, P_C) \ 2523*c217d954SCole Faust P_X##_DEF(8, P_A, P_B, P_C); \ 2524*c217d954SCole Faust REPEAT_3_8(P_X, P_A, P_B, P_C) 2525*c217d954SCole Faust#define REPEAT_3_10(P_X, P_A, P_B, P_C) \ 2526*c217d954SCole Faust P_X##_DEF(9, P_A, P_B, P_C); \ 2527*c217d954SCole Faust REPEAT_3_9(P_X, P_A, P_B, P_C) 2528*c217d954SCole Faust#define REPEAT_3_11(P_X, P_A, P_B, P_C) \ 2529*c217d954SCole Faust P_X##_DEF(A, P_A, P_B, P_C); \ 2530*c217d954SCole Faust REPEAT_3_10(P_X, P_A, P_B, P_C) 2531*c217d954SCole Faust#define REPEAT_3_12(P_X, P_A, P_B, P_C) \ 2532*c217d954SCole Faust P_X##_DEF(B, P_A, P_B, P_C); \ 2533*c217d954SCole Faust REPEAT_3_11(P_X, P_A, P_B, P_C) 2534*c217d954SCole Faust#define REPEAT_3_13(P_X, P_A, P_B, P_C) \ 2535*c217d954SCole Faust P_X##_DEF(C, P_A, P_B, P_C); \ 2536*c217d954SCole Faust REPEAT_3_12(P_X, P_A, P_B, P_C) 2537*c217d954SCole Faust#define REPEAT_3_14(P_X, P_A, P_B, P_C) \ 2538*c217d954SCole Faust P_X##_DEF(D, P_A, P_B, P_C); \ 2539*c217d954SCole Faust REPEAT_3_13(P_X, P_A, P_B, P_C) 2540*c217d954SCole Faust#define REPEAT_3_15(P_X, P_A, P_B, P_C) \ 2541*c217d954SCole Faust P_X##_DEF(E, P_A, P_B, P_C); \ 2542*c217d954SCole Faust REPEAT_3_14(P_X, P_A, P_B, P_C) 2543*c217d954SCole Faust#define REPEAT_3_16(P_X, P_A, P_B, P_C) \ 2544*c217d954SCole Faust P_X##_DEF(F, P_A, P_B, P_C); \ 2545*c217d954SCole Faust REPEAT_3_15(P_X, P_A, P_B, P_C) 2546*c217d954SCole Faust 2547*c217d954SCole Faust#define REPEAT_DEF_3_N(P_NUM, P_OP, P_A, P_B, P_C) REPEAT_3_##P_NUM(P_OP, P_A, P_B, P_C) 2548*c217d954SCole Faust#define REPEAT_3_N(P_NUM, P_OP, P_A, P_B, P_C) REPEAT_DEF_3_N(P_NUM, P_OP, P_A, P_B, P_C) 2549*c217d954SCole Faust 2550*c217d954SCole Faust 2551*c217d954SCole Faust#define REPEAT_4_1(P_X, P_A, P_B, P_C, P_D) P_X##_DEF(0, P_A, P_B, P_C, P_D) 2552*c217d954SCole Faust#define REPEAT_4_2(P_X, P_A, P_B, P_C, P_D) \ 2553*c217d954SCole Faust P_X##_DEF(1, P_A, P_B, P_C, P_D); \ 2554*c217d954SCole Faust REPEAT_4_1(P_X, P_A, P_B, P_C, P_D) 2555*c217d954SCole Faust#define REPEAT_4_3(P_X, P_A, P_B, P_C, P_D) \ 2556*c217d954SCole Faust P_X##_DEF(2, P_A, P_B, P_C, P_D); \ 2557*c217d954SCole Faust REPEAT_4_2(P_X, P_A, P_B, P_C, P_D) 2558*c217d954SCole Faust#define REPEAT_4_4(P_X, P_A, P_B, P_C, P_D) \ 2559*c217d954SCole Faust P_X##_DEF(3, P_A, P_B, P_C, P_D); \ 2560*c217d954SCole Faust REPEAT_4_3(P_X, P_A, P_B, P_C, P_D) 2561*c217d954SCole Faust#define REPEAT_4_5(P_X, P_A, P_B, P_C, P_D) \ 2562*c217d954SCole Faust P_X##_DEF(4, P_A, P_B, P_C, P_D); \ 2563*c217d954SCole Faust REPEAT_4_4(P_X, P_A, P_B, P_C, P_D) 2564*c217d954SCole Faust#define REPEAT_4_6(P_X, P_A, P_B, P_C, P_D) \ 2565*c217d954SCole Faust P_X##_DEF(5, P_A, P_B, P_C, P_D); \ 2566*c217d954SCole Faust REPEAT_4_5(P_X, P_A, P_B, P_C, P_D) 2567*c217d954SCole Faust#define REPEAT_4_7(P_X, P_A, P_B, P_C, P_D) \ 2568*c217d954SCole Faust P_X##_DEF(6, P_A, P_B, P_C, P_D); \ 2569*c217d954SCole Faust REPEAT_4_6(P_X, P_A, P_B, P_C, P_D) 2570*c217d954SCole Faust#define REPEAT_4_8(P_X, P_A, P_B, P_C, P_D) \ 2571*c217d954SCole Faust P_X##_DEF(7, P_A, P_B, P_C, P_D); \ 2572*c217d954SCole Faust REPEAT_4_7(P_X, P_A, P_B, P_C, P_D) 2573*c217d954SCole Faust#define REPEAT_4_9(P_X, P_A, P_B, P_C, P_D) \ 2574*c217d954SCole Faust P_X##_DEF(8, P_A, P_B, P_C, P_D); \ 2575*c217d954SCole Faust REPEAT_4_8(P_X, P_A, P_B, P_C, P_D) 2576*c217d954SCole Faust#define REPEAT_4_10(P_X, P_A, P_B, P_C, P_D) \ 2577*c217d954SCole Faust P_X##_DEF(9, P_A, P_B, P_C, P_D); \ 2578*c217d954SCole Faust REPEAT_4_9(P_X, P_A, P_B, P_C, P_D) 2579*c217d954SCole Faust#define REPEAT_4_11(P_X, P_A, P_B, P_C, P_D) \ 2580*c217d954SCole Faust P_X##_DEF(A, P_A, P_B, P_C, P_D); \ 2581*c217d954SCole Faust REPEAT_4_10(P_X, P_A, P_B, P_C, P_D) 2582*c217d954SCole Faust#define REPEAT_4_12(P_X, P_A, P_B, P_C, P_D) \ 2583*c217d954SCole Faust P_X##_DEF(B, P_A, P_B, P_C, P_D); \ 2584*c217d954SCole Faust REPEAT_4_11(P_X, P_A, P_B, P_C, P_D) 2585*c217d954SCole Faust#define REPEAT_4_13(P_X, P_A, P_B, P_C, P_D) \ 2586*c217d954SCole Faust P_X##_DEF(C, P_A, P_B, P_C, P_D); \ 2587*c217d954SCole Faust REPEAT_4_12(P_X, P_A, P_B, P_C, P_D) 2588*c217d954SCole Faust#define REPEAT_4_14(P_X, P_A, P_B, P_C, P_D) \ 2589*c217d954SCole Faust P_X##_DEF(D, P_A, P_B, P_C, P_D); \ 2590*c217d954SCole Faust REPEAT_4_13(P_X, P_A, P_B, P_C, P_D) 2591*c217d954SCole Faust#define REPEAT_4_15(P_X, P_A, P_B, P_C, P_D) \ 2592*c217d954SCole Faust P_X##_DEF(E, P_A, P_B, P_C, P_D); \ 2593*c217d954SCole Faust REPEAT_4_14(P_X, P_A, P_B, P_C, P_D) 2594*c217d954SCole Faust#define REPEAT_4_16(P_X, P_A, P_B, P_C, P_D) \ 2595*c217d954SCole Faust P_X##_DEF(F, P_A, P_B, P_C, P_D); \ 2596*c217d954SCole Faust REPEAT_4_15(P_X, P_A, P_B, P_C, P_D) 2597*c217d954SCole Faust 2598*c217d954SCole Faust#define REPEAT_DEF_4_N(P_NUM, P_OP, P_A, P_B, P_C, P_D) REPEAT_4_##P_NUM(P_OP, P_A, P_B, P_C, P_D) 2599*c217d954SCole Faust#define REPEAT_4_N(P_NUM, P_OP, P_A, P_B, P_C, P_D) REPEAT_DEF_4_N(P_NUM, P_OP, P_A, P_B, P_C, P_D) 2600*c217d954SCole Faust 2601*c217d954SCole Faust 2602*c217d954SCole Faust#define VAR_INIT_TO_CONST_DEF(ID, TYPE, VAR, VAL) TYPE VAR##ID = VAL 2603*c217d954SCole Faust#define REPEAT_VAR_INIT_TO_CONST(N, TYPE, VAR, VAL) REPEAT_3_N(N, VAR_INIT_TO_CONST, TYPE, VAR, VAL) 2604*c217d954SCole Faust 2605*c217d954SCole Faust 2606*c217d954SCole Faust#define VAR_INIT_CONVERT_DEF(ID, TYPE_OUT, VAR_IN, VAR_OUT) TYPE_OUT VAR_OUT##ID = CONVERT(VAR_IN##ID, TYPE_OUT) 2607*c217d954SCole Faust#define REPEAT_VAR_INIT_CONVERT(N, TYPE_OUT, VAR_IN, VAR_OUT) REPEAT_3_N(N, VAR_INIT_CONVERT, TYPE_OUT, VAR_IN, VAR_OUT) 2608*c217d954SCole Faust 2609*c217d954SCole Faust 2610*c217d954SCole Faust#define VAR_INIT_CONVERT_SAT_DEF(ID, TYPE_OUT, VAR_IN, VAR_OUT) TYPE_OUT VAR_OUT##ID = CONVERT_SAT(VAR_IN##ID, TYPE_OUT) 2611*c217d954SCole Faust#define REPEAT_VAR_INIT_CONVERT_SAT(N, TYPE_OUT, VAR_IN, VAR_OUT) REPEAT_3_N(N, VAR_INIT_CONVERT_SAT, TYPE_OUT, VAR_IN, VAR_OUT) 2612*c217d954SCole Faust 2613*c217d954SCole Faust 2614*c217d954SCole Faust#define ADD_CONST_TO_VAR_DEF(ID, TYPE, VAR, VAL) VAR##ID += (TYPE)VAL 2615*c217d954SCole Faust#define REPEAT_ADD_CONST_TO_VAR(N, TYPE, VAR, VAL) REPEAT_3_N(N, ADD_CONST_TO_VAR, TYPE, VAR, VAL) 2616*c217d954SCole Faust 2617*c217d954SCole Faust 2618*c217d954SCole Faust#define MLA_VAR_WITH_CONST_VEC_DEF(ID, VAR_A, VAR_B, VAL) VAR_A##ID += VAR_B##ID * VAL 2619*c217d954SCole Faust#define REPEAT_MLA_VAR_WITH_CONST_VEC(N, VAR_A, VAR_B, VAL) REPEAT_3_N(N, MLA_VAR_WITH_CONST_VEC, VAR_A, VAR_B, VAL) 2620*c217d954SCole Faust 2621*c217d954SCole Faust 2622*c217d954SCole Faust#define ADD_VECTOR_TO_VAR_DEF(ID, TYPE, VAR, VEC) VAR##ID += VEC 2623*c217d954SCole Faust#define REPEAT_ADD_VECTOR_TO_VAR(N, VAR, VEC) REPEAT_3_N(N, ADD_VECTOR_TO_VAR, "", VAR, VEC) 2624*c217d954SCole Faust 2625*c217d954SCole Faust 2626*c217d954SCole Faust#define ADD_TWO_VARS_DEF(ID, TYPE, VAR_A, VAR_B) VAR_A##ID += VAR_B##ID 2627*c217d954SCole Faust#define REPEAT_ADD_TWO_VARS(N, VAR_A, VAR_B) REPEAT_3_N(N, ADD_TWO_VARS, "", VAR_A, VAR_B) 2628*c217d954SCole Faust 2629*c217d954SCole Faust 2630*c217d954SCole Faust#define MAX_CONST_VAR_DEF(ID, TYPE, VAR, VAL) VAR##ID = max(VAR##ID, (TYPE)VAL) 2631*c217d954SCole Faust#define REPEAT_MAX_CONST_VAR(N, TYPE, VAR, VAL) REPEAT_3_N(N, MAX_CONST_VAR, TYPE, VAR, VAL) 2632*c217d954SCole Faust 2633*c217d954SCole Faust 2634*c217d954SCole Faust#define MIN_CONST_VAR_DEF(ID, TYPE, VAR, VAL) VAR##ID = min(VAR##ID, (TYPE)VAL) 2635*c217d954SCole Faust#define REPEAT_MIN_CONST_VAR(N, TYPE, VAR, VAL) REPEAT_3_N(N, MIN_CONST_VAR, TYPE, VAR, VAL) 2636*c217d954SCole Faust 2637*c217d954SCole Faust 2638*c217d954SCole Faust#define ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE_DEF(ID, SIZE, VAR, RES_MUL, RES_SHIFT) VAR##ID = ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE(VAR##ID, RES_MUL, RES_SHIFT, SIZE) 2639*c217d954SCole Faust#define REPEAT_ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE(N, SIZE, VAR, RES_MUL, RES_SHIFT) REPEAT_4_N(N, ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE, SIZE, VAR, RES_MUL, RES_SHIFT) 2640*c217d954SCole Faust 2641*c217d954SCole Faust 2642*c217d954SCole Faust#define ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE_DEF(ID, SIZE, VAR, RES_MUL, RES_SHIFT) VAR##ID = ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE(VAR##ID, RES_MUL, RES_SHIFT, SIZE) 2643*c217d954SCole Faust#define REPEAT_ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE(N, SIZE, VAR, RES_MUL, RES_SHIFT) REPEAT_4_N(N, ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE, SIZE, VAR, RES_MUL, RES_SHIFT) 2644*c217d954SCole Faust 2645*c217d954SCole Faust 2646*c217d954SCole Faust#define ASYMM_MULT_BY_QUANT_MULTIPLIER_PER_CHANNEL_DEF(ID, SIZE, VAR, RES_MUL, RES_SHIFT) \ 2647*c217d954SCole Faust ({ \ 2648*c217d954SCole Faust VEC_DATA_TYPE(int, N0) \ 2649*c217d954SCole Faust VAR##ID_shift_lt0 = ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE(VAR##ID, RES_MUL, RES_SHIFT, N0); \ 2650*c217d954SCole Faust VEC_DATA_TYPE(int, N0) \ 2651*c217d954SCole Faust VAR##ID_shift_gt0 = ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE(VAR##ID, RES_MUL, RES_SHIFT, N0); \ 2652*c217d954SCole Faust VAR##ID = select(VAR##ID_shift_lt0, VAR##ID_shift_gt0, RES_SHIFT >= 0); \ 2653*c217d954SCole Faust }) 2654*c217d954SCole Faust#define REPEAT_ASYMM_MULT_BY_QUANT_MULTIPLIER_PER_CHANNEL(N, SIZE, VAR, RES_MUL, RES_SHIFT) REPEAT_4_N(N, ASYMM_MULT_BY_QUANT_MULTIPLIER_PER_CHANNEL, SIZE, VAR, RES_MUL, RES_SHIFT) 2655*c217d954SCole Faust 2656*c217d954SCole Faust#endif 2657*c217d954SCole Faust 2658*c217d954SCole Faust#if defined(DATA_TYPE_IN_BYTES) && defined(VEC_SIZE_X) && defined(VEC_SIZE_LEFTOVER_X) && defined(VEC_SIZE_Y) && defined(VEC_SIZE_LEFTOVER_Y) 2659*c217d954SCole Faust 2660*c217d954SCole Faust#if VEC_SIZE_X == 1 2661*c217d954SCole Faust#if VEC_SIZE_Y == 1 2662*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2663*c217d954SCole Faust { \ 2664*c217d954SCole Faust u0 \ 2665*c217d954SCole Faust } 2666*c217d954SCole Faust#elif VEC_SIZE_Y == 2 2667*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2668*c217d954SCole Faust { \ 2669*c217d954SCole Faust u0, u1 \ 2670*c217d954SCole Faust } 2671*c217d954SCole Faust#elif VEC_SIZE_Y == 3 2672*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2673*c217d954SCole Faust { \ 2674*c217d954SCole Faust u0, u1, u2 \ 2675*c217d954SCole Faust } 2676*c217d954SCole Faust#elif VEC_SIZE_Y == 4 2677*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2678*c217d954SCole Faust { \ 2679*c217d954SCole Faust u0, u1, u2, u3 \ 2680*c217d954SCole Faust } 2681*c217d954SCole Faust#elif VEC_SIZE_Y == 8 2682*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2683*c217d954SCole Faust { \ 2684*c217d954SCole Faust u0, u1, u2, u3, u4, u5, u6, u7 \ 2685*c217d954SCole Faust } 2686*c217d954SCole Faust#elif VEC_SIZE_Y == 16 2687*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2688*c217d954SCole Faust { \ 2689*c217d954SCole Faust u0, u1, u2, u3, u4, u5, u6, u7, \ 2690*c217d954SCole Faust u8, u9, u10, u11, u12, u13, u14, u15 \ 2691*c217d954SCole Faust } 2692*c217d954SCole Faust#endif 2693*c217d954SCole Faust#else 2694*c217d954SCole Faust#if VEC_SIZE_Y == 1 2695*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2696*c217d954SCole Faust { \ 2697*c217d954SCole Faust u0.val \ 2698*c217d954SCole Faust } 2699*c217d954SCole Faust#elif VEC_SIZE_Y == 2 2700*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2701*c217d954SCole Faust { \ 2702*c217d954SCole Faust u0.val, u1.val \ 2703*c217d954SCole Faust } 2704*c217d954SCole Faust#elif VEC_SIZE_Y == 3 2705*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2706*c217d954SCole Faust { \ 2707*c217d954SCole Faust u0.val, u1.val, u2.val \ 2708*c217d954SCole Faust } 2709*c217d954SCole Faust#elif VEC_SIZE_Y == 4 2710*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2711*c217d954SCole Faust { \ 2712*c217d954SCole Faust u0.val, u1.val, u2.val, u3.val \ 2713*c217d954SCole Faust } 2714*c217d954SCole Faust#elif VEC_SIZE_Y == 8 2715*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2716*c217d954SCole Faust { \ 2717*c217d954SCole Faust u0.val, u1.val, u2.val, u3.val, u4.val, u5.val, u6.val, u7.val \ 2718*c217d954SCole Faust } 2719*c217d954SCole Faust#elif VEC_SIZE_Y == 16 2720*c217d954SCole Faust#define TRANSPOSED_U(val) \ 2721*c217d954SCole Faust { \ 2722*c217d954SCole Faust u0.val, u1.val, u2.val, u3.val, u4.val, u5.val, u6.val, u7.val, \ 2723*c217d954SCole Faust u8.val, u9.val, u10.val, u11.val, u12.val, u13.val, u14.val, u15.val \ 2724*c217d954SCole Faust } 2725*c217d954SCole Faust#endif 2726*c217d954SCole Faust#endif 2727*c217d954SCole Faust 2728*c217d954SCole Faust#if DATA_TYPE_IN_BYTES == 4 2729*c217d954SCole Faust#define DATA_TYPE uint 2730*c217d954SCole Faust#elif DATA_TYPE_IN_BYTES == 2 2731*c217d954SCole Faust#define DATA_TYPE ushort 2732*c217d954SCole Faust#elif DATA_TYPE_IN_BYTES == 1 2733*c217d954SCole Faust#define DATA_TYPE uchar 2734*c217d954SCole Faust#else 2735*c217d954SCole Faust#error DATA_TYPE_IN_BYTES not supported for transpose 2736*c217d954SCole Faust#endif 2737*c217d954SCole Faust 2738*c217d954SCole Faust 2739*c217d954SCole Faust__kernel void transpose(IMAGE_DECLARATION(src), 2740*c217d954SCole Faust IMAGE_DECLARATION(dst)) 2741*c217d954SCole Faust{ 2742*c217d954SCole Faust uint x_offs = max((int)(get_global_id(0) * VEC_SIZE_X - (VEC_SIZE_X - VEC_SIZE_LEFTOVER_X) % VEC_SIZE_X), 0); 2743*c217d954SCole Faust uint y_offs = max((int)(get_global_id(1) * VEC_SIZE_Y - (VEC_SIZE_Y - VEC_SIZE_LEFTOVER_Y) % VEC_SIZE_Y), 0); 2744*c217d954SCole Faust 2745*c217d954SCole Faust 2746*c217d954SCole Faust __global uchar *src_addr = src_ptr + src_offset_first_element_in_bytes + x_offs * DATA_TYPE_IN_BYTES + y_offs * src_stride_y; 2747*c217d954SCole Faust __global uchar *dst_addr = dst_ptr + dst_offset_first_element_in_bytes + y_offs * DATA_TYPE_IN_BYTES + x_offs * dst_stride_y; 2748*c217d954SCole Faust 2749*c217d954SCole Faust 2750*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2751*c217d954SCole Faust u0 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)src_addr); 2752*c217d954SCole Faust#if VEC_SIZE_Y > 1 2753*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2754*c217d954SCole Faust u1 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + src_stride_y)); 2755*c217d954SCole Faust#endif 2756*c217d954SCole Faust#if VEC_SIZE_Y > 2 2757*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2758*c217d954SCole Faust u2 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 2 * src_stride_y)); 2759*c217d954SCole Faust#endif 2760*c217d954SCole Faust#if VEC_SIZE_Y > 3 2761*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2762*c217d954SCole Faust u3 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 3 * src_stride_y)); 2763*c217d954SCole Faust#endif 2764*c217d954SCole Faust#if VEC_SIZE_Y > 4 2765*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2766*c217d954SCole Faust u4 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 4 * src_stride_y)); 2767*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2768*c217d954SCole Faust u5 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 5 * src_stride_y)); 2769*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2770*c217d954SCole Faust u6 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 6 * src_stride_y)); 2771*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2772*c217d954SCole Faust u7 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 7 * src_stride_y)); 2773*c217d954SCole Faust#endif 2774*c217d954SCole Faust#if VEC_SIZE_Y > 8 2775*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2776*c217d954SCole Faust u8 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 8 * src_stride_y)); 2777*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2778*c217d954SCole Faust u9 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 9 * src_stride_y)); 2779*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2780*c217d954SCole Faust u10 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 10 * src_stride_y)); 2781*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2782*c217d954SCole Faust u11 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 11 * src_stride_y)); 2783*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2784*c217d954SCole Faust u12 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 12 * src_stride_y)); 2785*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2786*c217d954SCole Faust u13 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 13 * src_stride_y)); 2787*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2788*c217d954SCole Faust u14 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 14 * src_stride_y)); 2789*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_X) 2790*c217d954SCole Faust u15 = VLOAD(VEC_SIZE_X)(0, (__global DATA_TYPE *)(src_addr + 15 * src_stride_y)); 2791*c217d954SCole Faust#endif 2792*c217d954SCole Faust 2793*c217d954SCole Faust 2794*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2795*c217d954SCole Faust t0 = TRANSPOSED_U(s0); 2796*c217d954SCole Faust#if VEC_SIZE_X > 1 2797*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2798*c217d954SCole Faust t1 = TRANSPOSED_U(s1); 2799*c217d954SCole Faust#endif 2800*c217d954SCole Faust#if VEC_SIZE_X > 2 2801*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2802*c217d954SCole Faust t2 = TRANSPOSED_U(s2); 2803*c217d954SCole Faust#endif 2804*c217d954SCole Faust#if VEC_SIZE_X > 3 2805*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2806*c217d954SCole Faust t3 = TRANSPOSED_U(s3); 2807*c217d954SCole Faust#endif 2808*c217d954SCole Faust#if VEC_SIZE_X > 4 2809*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2810*c217d954SCole Faust t4 = TRANSPOSED_U(s4); 2811*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2812*c217d954SCole Faust t5 = TRANSPOSED_U(s5); 2813*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2814*c217d954SCole Faust t6 = TRANSPOSED_U(s6); 2815*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2816*c217d954SCole Faust t7 = TRANSPOSED_U(s7); 2817*c217d954SCole Faust#endif 2818*c217d954SCole Faust#if VEC_SIZE_X > 8 2819*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2820*c217d954SCole Faust t8 = TRANSPOSED_U(s8); 2821*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2822*c217d954SCole Faust t9 = TRANSPOSED_U(s9); 2823*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2824*c217d954SCole Faust tA = TRANSPOSED_U(sA); 2825*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2826*c217d954SCole Faust tB = TRANSPOSED_U(sB); 2827*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2828*c217d954SCole Faust tC = TRANSPOSED_U(sC); 2829*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2830*c217d954SCole Faust tD = TRANSPOSED_U(sD); 2831*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2832*c217d954SCole Faust tE = TRANSPOSED_U(sE); 2833*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE_Y) 2834*c217d954SCole Faust tF = TRANSPOSED_U(sF); 2835*c217d954SCole Faust#endif 2836*c217d954SCole Faust 2837*c217d954SCole Faust 2838*c217d954SCole Faust REPEAT_VAR_INIT_TO_CONST(VEC_SIZE_X, uint, zout, 0); 2839*c217d954SCole Faust STORE_BLOCK_BOUNDARY_AWARE(VEC_SIZE_X, VEC_SIZE_Y, DATA_TYPE, t, (__global uchar *)dst_addr, dst_stride_y, zout, VEC_SIZE_LEFTOVER_X, VEC_SIZE_LEFTOVER_Y, VEC_SIZE_LEFTOVER_X != 0 2840*c217d954SCole Faust && get_global_id(0) == 0, 2841*c217d954SCole Faust VEC_SIZE_LEFTOVER_Y != 0 && get_global_id(1) == 0); 2842*c217d954SCole Faust} 2843*c217d954SCole Faust 2844*c217d954SCole Faust#endif )"