1*c217d954SCole FaustR"( 2*c217d954SCole Faust 3*c217d954SCole Faust 4*c217d954SCole Faust 5*c217d954SCole Faust#ifndef ARM_COMPUTE_HELPER_H 6*c217d954SCole Faust#define ARM_COMPUTE_HELPER_H 7*c217d954SCole Faust 8*c217d954SCole Faust 9*c217d954SCole Faust 10*c217d954SCole Faust 11*c217d954SCole Faust#define STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 12*c217d954SCole Faust VSTORE(N0) \ 13*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 14*c217d954SCole Faust 15*c217d954SCole Faust#define STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 16*c217d954SCole Faust STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 17*c217d954SCole Faust VSTORE(N0) \ 18*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 19*c217d954SCole Faust 20*c217d954SCole Faust#define STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 21*c217d954SCole Faust STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 22*c217d954SCole Faust VSTORE(N0) \ 23*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 24*c217d954SCole Faust 25*c217d954SCole Faust#define STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 26*c217d954SCole Faust STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 27*c217d954SCole Faust VSTORE(N0) \ 28*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 29*c217d954SCole Faust 30*c217d954SCole Faust#define STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 31*c217d954SCole Faust STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 32*c217d954SCole Faust VSTORE(N0) \ 33*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 34*c217d954SCole Faust 35*c217d954SCole Faust#define STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 36*c217d954SCole Faust STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 37*c217d954SCole Faust VSTORE(N0) \ 38*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 39*c217d954SCole Faust 40*c217d954SCole Faust#define STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 41*c217d954SCole Faust STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 42*c217d954SCole Faust VSTORE(N0) \ 43*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 44*c217d954SCole Faust 45*c217d954SCole Faust#define STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 46*c217d954SCole Faust STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 47*c217d954SCole Faust VSTORE(N0) \ 48*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 49*c217d954SCole Faust 50*c217d954SCole Faust#define STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 51*c217d954SCole Faust STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 52*c217d954SCole Faust VSTORE(N0) \ 53*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 54*c217d954SCole Faust 55*c217d954SCole Faust#define STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 56*c217d954SCole Faust STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 57*c217d954SCole Faust VSTORE(N0) \ 58*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 59*c217d954SCole Faust 60*c217d954SCole Faust#define STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 61*c217d954SCole Faust STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 62*c217d954SCole Faust VSTORE(N0) \ 63*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 64*c217d954SCole Faust 65*c217d954SCole Faust#define STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 66*c217d954SCole Faust STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 67*c217d954SCole Faust VSTORE(N0) \ 68*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 69*c217d954SCole Faust 70*c217d954SCole Faust#define STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 71*c217d954SCole Faust STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 72*c217d954SCole Faust VSTORE(N0) \ 73*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 74*c217d954SCole Faust 75*c217d954SCole Faust#define STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 76*c217d954SCole Faust STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 77*c217d954SCole Faust VSTORE(N0) \ 78*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 79*c217d954SCole Faust 80*c217d954SCole Faust#define STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 81*c217d954SCole Faust STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 82*c217d954SCole Faust VSTORE(N0) \ 83*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 84*c217d954SCole Faust 85*c217d954SCole Faust#define STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 86*c217d954SCole Faust STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 87*c217d954SCole Faust VSTORE(N0) \ 88*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 89*c217d954SCole Faust 90*c217d954SCole Faust 91*c217d954SCole Faust 92*c217d954SCole Faust#define CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 93*c217d954SCole Faust VSTORE(N0) \ 94*c217d954SCole Faust (CONVERT_SAT((BASENAME##0), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 95*c217d954SCole Faust 96*c217d954SCole Faust#define CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 97*c217d954SCole Faust CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 98*c217d954SCole Faust VSTORE(N0) \ 99*c217d954SCole Faust (CONVERT_SAT((BASENAME##1), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 100*c217d954SCole Faust 101*c217d954SCole Faust#define CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 102*c217d954SCole Faust CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 103*c217d954SCole Faust VSTORE(N0) \ 104*c217d954SCole Faust (CONVERT_SAT((BASENAME##2), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 105*c217d954SCole Faust 106*c217d954SCole Faust#define CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 107*c217d954SCole Faust CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 108*c217d954SCole Faust VSTORE(N0) \ 109*c217d954SCole Faust (CONVERT_SAT((BASENAME##3), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 110*c217d954SCole Faust 111*c217d954SCole Faust#define CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 112*c217d954SCole Faust CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 113*c217d954SCole Faust VSTORE(N0) \ 114*c217d954SCole Faust (CONVERT_SAT((BASENAME##4), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 115*c217d954SCole Faust 116*c217d954SCole Faust#define CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 117*c217d954SCole Faust CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 118*c217d954SCole Faust VSTORE(N0) \ 119*c217d954SCole Faust (CONVERT_SAT((BASENAME##5), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 120*c217d954SCole Faust 121*c217d954SCole Faust#define CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 122*c217d954SCole Faust CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 123*c217d954SCole Faust VSTORE(N0) \ 124*c217d954SCole Faust (CONVERT_SAT((BASENAME##6), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 125*c217d954SCole Faust 126*c217d954SCole Faust#define CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 127*c217d954SCole Faust CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 128*c217d954SCole Faust VSTORE(N0) \ 129*c217d954SCole Faust (CONVERT_SAT((BASENAME##7), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 130*c217d954SCole Faust 131*c217d954SCole Faust#define CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 132*c217d954SCole Faust CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 133*c217d954SCole Faust VSTORE(N0) \ 134*c217d954SCole Faust (CONVERT_SAT((BASENAME##8), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 135*c217d954SCole Faust 136*c217d954SCole Faust#define CONVERT_STORE_ROW_10(N0, DATA, BASENAME, PTR, STRIDE_Y, Z) \ 137*c217d954SCole Faust CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 138*c217d954SCole Faust VSTORE(N0) \ 139*c217d954SCole Faust (CONVERT_SAT((BASENAME##9), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 140*c217d954SCole Faust 141*c217d954SCole Faust#define CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 142*c217d954SCole Faust CONVERT_STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 143*c217d954SCole Faust VSTORE(N0) \ 144*c217d954SCole Faust (CONVERT_SAT((BASENAME##A), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 145*c217d954SCole Faust 146*c217d954SCole Faust#define CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 147*c217d954SCole Faust CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 148*c217d954SCole Faust VSTORE(N0) \ 149*c217d954SCole Faust (CONVERT_SAT((BASENAME##B), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 150*c217d954SCole Faust 151*c217d954SCole Faust#define CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 152*c217d954SCole Faust CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 153*c217d954SCole Faust VSTORE(N0) \ 154*c217d954SCole Faust (CONVERT_SAT((BASENAME##C), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 155*c217d954SCole Faust 156*c217d954SCole Faust#define CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 157*c217d954SCole Faust CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 158*c217d954SCole Faust VSTORE(N0) \ 159*c217d954SCole Faust (CONVERT_SAT((BASENAME##D), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 160*c217d954SCole Faust 161*c217d954SCole Faust#define CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 162*c217d954SCole Faust CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 163*c217d954SCole Faust VSTORE(N0) \ 164*c217d954SCole Faust (CONVERT_SAT((BASENAME##E), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 165*c217d954SCole Faust 166*c217d954SCole Faust#define CONVERT_STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 167*c217d954SCole Faust CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 168*c217d954SCole Faust VSTORE(N0) \ 169*c217d954SCole Faust (CONVERT_SAT((BASENAME##F), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 170*c217d954SCole Faust 171*c217d954SCole Faust 172*c217d954SCole Faust 173*c217d954SCole Faust 174*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) 175*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) 176*c217d954SCole Faust 177*c217d954SCole Faust 178*c217d954SCole Faust 179*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) 180*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) 181*c217d954SCole Faust 182*c217d954SCole Faust 183*c217d954SCole Faust 184*c217d954SCole Faust#define STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 185*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 186*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 187*c217d954SCole Faust 188*c217d954SCole Faust#define STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 189*c217d954SCole Faust STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 190*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 191*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 192*c217d954SCole Faust 193*c217d954SCole Faust#define STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 194*c217d954SCole Faust STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 195*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 196*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 197*c217d954SCole Faust 198*c217d954SCole Faust#define STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 199*c217d954SCole Faust STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 200*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 201*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 202*c217d954SCole Faust 203*c217d954SCole Faust#define STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 204*c217d954SCole Faust STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 205*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 206*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 207*c217d954SCole Faust 208*c217d954SCole Faust#define STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 209*c217d954SCole Faust STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 210*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 211*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 212*c217d954SCole Faust 213*c217d954SCole Faust#define STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 214*c217d954SCole Faust STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 215*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 216*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 217*c217d954SCole Faust 218*c217d954SCole Faust#define STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 219*c217d954SCole Faust STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 220*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 221*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 222*c217d954SCole Faust 223*c217d954SCole Faust#define STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 224*c217d954SCole Faust STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 225*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 226*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 227*c217d954SCole Faust 228*c217d954SCole Faust#define STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 229*c217d954SCole Faust STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 230*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 231*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 232*c217d954SCole Faust 233*c217d954SCole Faust#define STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 234*c217d954SCole Faust STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 235*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 236*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 237*c217d954SCole Faust 238*c217d954SCole Faust#define STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 239*c217d954SCole Faust STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 240*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 241*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 242*c217d954SCole Faust 243*c217d954SCole Faust#define STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 244*c217d954SCole Faust STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 245*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 246*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 247*c217d954SCole Faust 248*c217d954SCole Faust#define STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 249*c217d954SCole Faust STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 250*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 251*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 252*c217d954SCole Faust 253*c217d954SCole Faust#define STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 254*c217d954SCole Faust STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 255*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 256*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 257*c217d954SCole Faust 258*c217d954SCole Faust#define STORE_ROW_PARTIAL_16(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 259*c217d954SCole Faust STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 260*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 261*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 262*c217d954SCole Faust 263*c217d954SCole Faust 264*c217d954SCole Faust 265*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) 266*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) 267*c217d954SCole Faust 268*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) \ 269*c217d954SCole Faust if(!(PARTIAL_COND_X) && !(PARTIAL_COND_Y)) \ 270*c217d954SCole Faust { \ 271*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 272*c217d954SCole Faust } \ 273*c217d954SCole Faust else if((PARTIAL_COND_Y) && !(PARTIAL_COND_X)) \ 274*c217d954SCole Faust { \ 275*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 276*c217d954SCole Faust } \ 277*c217d954SCole Faust else if(!(PARTIAL_COND_Y) && (PARTIAL_COND_X)) \ 278*c217d954SCole Faust { \ 279*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 280*c217d954SCole Faust } \ 281*c217d954SCole Faust else \ 282*c217d954SCole Faust { \ 283*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 284*c217d954SCole Faust } 285*c217d954SCole Faust 286*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) \ 287*c217d954SCole Faust if(!(PARTIAL_COND_X)) \ 288*c217d954SCole Faust { \ 289*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 290*c217d954SCole Faust } \ 291*c217d954SCole Faust else \ 292*c217d954SCole Faust { \ 293*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 294*c217d954SCole Faust } 295*c217d954SCole Faust 296*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) \ 297*c217d954SCole Faust if(!(PARTIAL_COND_Y)) \ 298*c217d954SCole Faust { \ 299*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 300*c217d954SCole Faust } \ 301*c217d954SCole Faust else \ 302*c217d954SCole Faust { \ 303*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 304*c217d954SCole Faust } 305*c217d954SCole Faust 306*c217d954SCole Faust 307*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) && defined(PARTIAL_STORE_N0) 308*c217d954SCole Faust 309*c217d954SCole Faust 310*c217d954SCole Faust#if PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 == 0 311*c217d954SCole Faust 312*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) \ 313*c217d954SCole Faust STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 314*c217d954SCole Faust 315*c217d954SCole Faust#elif PARTIAL_STORE_M0 > 0 && PARTIAL_STORE_N0 == 0 316*c217d954SCole Faust 317*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) \ 318*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) 319*c217d954SCole Faust 320*c217d954SCole Faust#elif PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 > 0 321*c217d954SCole Faust 322*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) \ 323*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) 324*c217d954SCole Faust 325*c217d954SCole Faust#else 326*c217d954SCole Faust 327*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) \ 328*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) 329*c217d954SCole Faust 330*c217d954SCole Faust#endif 331*c217d954SCole Faust 332*c217d954SCole Faust#endif 333*c217d954SCole Faust 334*c217d954SCole Faust 335*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) 336*c217d954SCole Faust 337*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 338*c217d954SCole Faust ((uint)(max(0, (int)(y * M0) - (int)((M0 - PARTIAL_STORE_M0) % M0)))) 339*c217d954SCole Faust#else 340*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 341*c217d954SCole Faust ((uint)(y * M0)) 342*c217d954SCole Faust#endif 343*c217d954SCole Faust 344*c217d954SCole Faust 345*c217d954SCole Faust 346*c217d954SCole Faust#define STORE_VECTOR_SELECT(basename, data_type, ptr, vec_size, leftover, cond) \ 347*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(1, vec_size, data_type, basename, ptr, 0, 0, leftover, cond) 348*c217d954SCole Faust 349*c217d954SCole Faust 350*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 351*c217d954SCole Faust#pragma OPENCL EXTENSION cl_khr_fp16 : enable 352*c217d954SCole Faust#endif 353*c217d954SCole Faust 354*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ENABLED) && defined(cl_arm_integer_dot_product_int8) 355*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable 356*c217d954SCole Faust#endif 357*c217d954SCole Faust 358*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED) && defined(cl_arm_integer_dot_product_accumulate_int8) 359*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable 360*c217d954SCole Faust#endif 361*c217d954SCole Faust 362*c217d954SCole Faust#if defined(ARM_COMPUTE_DEBUG_ENABLED) && defined(cl_arm_printf) 363*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_printf : enable 364*c217d954SCole Faust#endif 365*c217d954SCole Faust 366*c217d954SCole Faust#define GPU_ARCH_MIDGARD 0x100 367*c217d954SCole Faust#define GPU_ARCH_BIFROST 0x200 368*c217d954SCole Faust#define GPU_ARCH_VALHALL 0x300 369*c217d954SCole Faust 370*c217d954SCole Faust 371*c217d954SCole Faust#define CONCAT(a, b) a##b 372*c217d954SCole Faust 373*c217d954SCole Faust 374*c217d954SCole Faust#define EXPAND(x) x 375*c217d954SCole Faust 376*c217d954SCole Faust 377*c217d954SCole Faust#define CLAMP(x, min_val, max_val) min(max(x, min_val), max_val) 378*c217d954SCole Faust 379*c217d954SCole Faust 380*c217d954SCole Faust#define REV1(x) ((x)) 381*c217d954SCole Faust#define REV2(x) ((x).s10) 382*c217d954SCole Faust#define REV3(x) ((x).s210) 383*c217d954SCole Faust#define REV4(x) ((x).s3210) 384*c217d954SCole Faust#define REV8(x) ((x).s76543210) 385*c217d954SCole Faust#define REV16(x) ((x).sFEDCBA9876543210) 386*c217d954SCole Faust 387*c217d954SCole Faust 388*c217d954SCole Faust 389*c217d954SCole Faust#define REVERSE_STR(x, s) REV##s((x)) 390*c217d954SCole Faust#define REVERSE(x, s) REVERSE_STR(x, s) 391*c217d954SCole Faust 392*c217d954SCole Faust 393*c217d954SCole Faust 394*c217d954SCole Faust#define ROT1_0(x) ((x)) 395*c217d954SCole Faust#define ROT1_1(x) ((x)) 396*c217d954SCole Faust 397*c217d954SCole Faust#define ROT2_0(x) ((x)) 398*c217d954SCole Faust#define ROT2_1(x) ((x).s10) 399*c217d954SCole Faust#define ROT2_2(x) ((x)) 400*c217d954SCole Faust 401*c217d954SCole Faust#define ROT3_0(x) ((x)) 402*c217d954SCole Faust#define ROT3_1(x) ((x).s201) 403*c217d954SCole Faust#define ROT3_2(x) ((x).s120) 404*c217d954SCole Faust#define ROT3_3(x) ((x)) 405*c217d954SCole Faust 406*c217d954SCole Faust#define ROT4_0(x) ((x)) 407*c217d954SCole Faust#define ROT4_1(x) ((x).s3012) 408*c217d954SCole Faust#define ROT4_2(x) ((x).s2301) 409*c217d954SCole Faust#define ROT4_3(x) ((x).s1230) 410*c217d954SCole Faust#define ROT4_4(x) ((x)) 411*c217d954SCole Faust 412*c217d954SCole Faust#define ROT8_0(x) ((x)) 413*c217d954SCole Faust#define ROT8_1(x) ((x).s70123456) 414*c217d954SCole Faust#define ROT8_2(x) ((x).s67012345) 415*c217d954SCole Faust#define ROT8_3(x) ((x).s56701234) 416*c217d954SCole Faust#define ROT8_4(x) ((x).s45670123) 417*c217d954SCole Faust#define ROT8_5(x) ((x).s34567012) 418*c217d954SCole Faust#define ROT8_6(x) ((x).s23456701) 419*c217d954SCole Faust#define ROT8_7(x) ((x).s12345670) 420*c217d954SCole Faust#define ROT8_8(x) ((x)) 421*c217d954SCole Faust 422*c217d954SCole Faust#define ROT16_0(x) ((x)) 423*c217d954SCole Faust#define ROT16_1(x) ((x).sF0123456789ABCDE) 424*c217d954SCole Faust#define ROT16_2(x) ((x).sEF0123456789ABCD) 425*c217d954SCole Faust#define ROT16_3(x) ((x).sDEF0123456789ABC) 426*c217d954SCole Faust#define ROT16_4(x) ((x).sCDEF0123456789AB) 427*c217d954SCole Faust#define ROT16_5(x) ((x).sBCDEF0123456789A) 428*c217d954SCole Faust#define ROT16_6(x) ((x).sABCDEF0123456789) 429*c217d954SCole Faust#define ROT16_7(x) ((x).s9ABCDEF012345678) 430*c217d954SCole Faust#define ROT16_8(x) ((x).s89ABCDEF01234567) 431*c217d954SCole Faust#define ROT16_9(x) ((x).s789ABCDEF0123456) 432*c217d954SCole Faust#define ROT16_10(x) ((x).s6789ABCDEF012345) 433*c217d954SCole Faust#define ROT16_11(x) ((x).s56789ABCDEF01234) 434*c217d954SCole Faust#define ROT16_12(x) ((x).s456789ABCDEF0123) 435*c217d954SCole Faust#define ROT16_13(x) ((x).s3456789ABCDEF012) 436*c217d954SCole Faust#define ROT16_14(x) ((x).s23456789ABCDEF01) 437*c217d954SCole Faust#define ROT16_15(x) ((x).s123456789ABCDEF0) 438*c217d954SCole Faust#define ROT16_16(x) ((x)) 439*c217d954SCole Faust 440*c217d954SCole Faust 441*c217d954SCole Faust 442*c217d954SCole Faust#define ROTATE_STR(x, s, n) ROT##s##_##n(x) 443*c217d954SCole Faust#define ROTATE(x, s, n) ROTATE_STR(x, s, n) 444*c217d954SCole Faust 445*c217d954SCole Faust 446*c217d954SCole Faust 447*c217d954SCole Faust#define V_OFFS1(dt) (dt##1)(0) 448*c217d954SCole Faust#define V_OFFS2(dt) (dt##2)(0, 1) 449*c217d954SCole Faust#define V_OFFS3(dt) (dt##3)(0, 1, 2) 450*c217d954SCole Faust#define V_OFFS4(dt) (dt##4)(0, 1, 2, 3) 451*c217d954SCole Faust#define V_OFFS8(dt) (dt##8)(0, 1, 2, 3, 4, 5, 6, 7) 452*c217d954SCole Faust#define V_OFFS16(dt) (dt##16)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) 453*c217d954SCole Faust 454*c217d954SCole Faust 455*c217d954SCole Faust 456*c217d954SCole Faust#define VEC_OFFS_STR(dt, s) V_OFFS##s(dt) 457*c217d954SCole Faust#define VEC_OFFS(dt, s) VEC_OFFS_STR(dt, s) 458*c217d954SCole Faust 459*c217d954SCole Faust 460*c217d954SCole Faust#define VLOAD_STR(size) vload##size 461*c217d954SCole Faust#define VLOAD(size) VLOAD_STR(size) 462*c217d954SCole Faust 463*c217d954SCole Faust 464*c217d954SCole Faust#define VLOAD_PARTIAL_STR(size, load_size) vload_partial_##size##_##load_size 465*c217d954SCole Faust#define VLOAD_PARTIAL(size, load_size) VLOAD_PARTIAL_STR(size, load_size) 466*c217d954SCole Faust 467*c217d954SCole Faust#define NO_LOAD(data, offs, ptr) \ 468*c217d954SCole Faust { \ 469*c217d954SCole Faust } 470*c217d954SCole Faust 471*c217d954SCole Faust 472*c217d954SCole Faust#define vload_partial_1_0 NO_LOAD 473*c217d954SCole Faust#define vload_partial_1_1 vload1 474*c217d954SCole Faust#define vload_partial_1_2 NO_LOAD 475*c217d954SCole Faust#define vload_partial_1_3 NO_LOAD 476*c217d954SCole Faust#define vload_partial_1_4 NO_LOAD 477*c217d954SCole Faust#define vload_partial_1_5 NO_LOAD 478*c217d954SCole Faust#define vload_partial_1_6 NO_LOAD 479*c217d954SCole Faust#define vload_partial_1_7 NO_LOAD 480*c217d954SCole Faust#define vload_partial_1_8 NO_LOAD 481*c217d954SCole Faust#define vload_partial_1_9 NO_LOAD 482*c217d954SCole Faust#define vload_partial_1_10 NO_LOAD 483*c217d954SCole Faust#define vload_partial_1_11 NO_LOAD 484*c217d954SCole Faust#define vload_partial_1_12 NO_LOAD 485*c217d954SCole Faust#define vload_partial_1_13 NO_LOAD 486*c217d954SCole Faust#define vload_partial_1_14 NO_LOAD 487*c217d954SCole Faust#define vload_partial_1_15 NO_LOAD 488*c217d954SCole Faust#define vload_partial_1_16 NO_LOAD 489*c217d954SCole Faust 490*c217d954SCole Faust#define vload_partial_2_0 NO_LOAD 491*c217d954SCole Faust#define vload_partial_2_1 vload_partial_1 492*c217d954SCole Faust#define vload_partial_2_2 vload_partial_2 493*c217d954SCole Faust#define vload_partial_2_3 NO_LOAD 494*c217d954SCole Faust#define vload_partial_2_4 NO_LOAD 495*c217d954SCole Faust#define vload_partial_2_5 NO_LOAD 496*c217d954SCole Faust#define vload_partial_2_6 NO_LOAD 497*c217d954SCole Faust#define vload_partial_2_7 NO_LOAD 498*c217d954SCole Faust#define vload_partial_2_8 NO_LOAD 499*c217d954SCole Faust#define vload_partial_2_9 NO_LOAD 500*c217d954SCole Faust#define vload_partial_2_10 NO_LOAD 501*c217d954SCole Faust#define vload_partial_2_11 NO_LOAD 502*c217d954SCole Faust#define vload_partial_2_12 NO_LOAD 503*c217d954SCole Faust#define vload_partial_2_13 NO_LOAD 504*c217d954SCole Faust#define vload_partial_2_14 NO_LOAD 505*c217d954SCole Faust#define vload_partial_2_15 NO_LOAD 506*c217d954SCole Faust#define vload_partial_2_16 NO_LOAD 507*c217d954SCole Faust 508*c217d954SCole Faust#define vload_partial_3_0 NO_LOAD 509*c217d954SCole Faust#define vload_partial_3_1 vload_partial_1 510*c217d954SCole Faust#define vload_partial_3_2 vload_partial_2 511*c217d954SCole Faust#define vload_partial_3_3 vload_partial_3 512*c217d954SCole Faust#define vload_partial_3_4 NO_LOAD 513*c217d954SCole Faust#define vload_partial_3_5 NO_LOAD 514*c217d954SCole Faust#define vload_partial_3_6 NO_LOAD 515*c217d954SCole Faust#define vload_partial_3_7 NO_LOAD 516*c217d954SCole Faust#define vload_partial_3_8 NO_LOAD 517*c217d954SCole Faust#define vload_partial_3_9 NO_LOAD 518*c217d954SCole Faust#define vload_partial_3_10 NO_LOAD 519*c217d954SCole Faust#define vload_partial_3_11 NO_LOAD 520*c217d954SCole Faust#define vload_partial_3_12 NO_LOAD 521*c217d954SCole Faust#define vload_partial_3_13 NO_LOAD 522*c217d954SCole Faust#define vload_partial_3_14 NO_LOAD 523*c217d954SCole Faust#define vload_partial_3_15 NO_LOAD 524*c217d954SCole Faust#define vload_partial_3_16 NO_LOAD 525*c217d954SCole Faust 526*c217d954SCole Faust#define vload_partial_4_0 NO_LOAD 527*c217d954SCole Faust#define vload_partial_4_1 vload_partial_1 528*c217d954SCole Faust#define vload_partial_4_2 vload_partial_2 529*c217d954SCole Faust#define vload_partial_4_3 vload_partial_3 530*c217d954SCole Faust#define vload_partial_4_4 vload_partial_4 531*c217d954SCole Faust#define vload_partial_4_5 NO_LOAD 532*c217d954SCole Faust#define vload_partial_4_6 NO_LOAD 533*c217d954SCole Faust#define vload_partial_4_7 NO_LOAD 534*c217d954SCole Faust#define vload_partial_4_8 NO_LOAD 535*c217d954SCole Faust#define vload_partial_4_9 NO_LOAD 536*c217d954SCole Faust#define vload_partial_4_10 NO_LOAD 537*c217d954SCole Faust#define vload_partial_4_11 NO_LOAD 538*c217d954SCole Faust#define vload_partial_4_12 NO_LOAD 539*c217d954SCole Faust#define vload_partial_4_13 NO_LOAD 540*c217d954SCole Faust#define vload_partial_4_14 NO_LOAD 541*c217d954SCole Faust#define vload_partial_4_15 NO_LOAD 542*c217d954SCole Faust#define vload_partial_4_16 NO_LOAD 543*c217d954SCole Faust 544*c217d954SCole Faust#define vload_partial_8_0 NO_LOAD 545*c217d954SCole Faust#define vload_partial_8_1 vload_partial_1 546*c217d954SCole Faust#define vload_partial_8_2 vload_partial_2 547*c217d954SCole Faust#define vload_partial_8_3 vload_partial_3 548*c217d954SCole Faust#define vload_partial_8_4 vload_partial_4 549*c217d954SCole Faust#define vload_partial_8_5 vload_partial_5 550*c217d954SCole Faust#define vload_partial_8_6 vload_partial_6 551*c217d954SCole Faust#define vload_partial_8_7 vload_partial_7 552*c217d954SCole Faust#define vload_partial_8_8 vload_partial_8 553*c217d954SCole Faust#define vload_partial_8_9 NO_LOAD 554*c217d954SCole Faust#define vload_partial_8_10 NO_LOAD 555*c217d954SCole Faust#define vload_partial_8_11 NO_LOAD 556*c217d954SCole Faust#define vload_partial_8_12 NO_LOAD 557*c217d954SCole Faust#define vload_partial_8_13 NO_LOAD 558*c217d954SCole Faust#define vload_partial_8_14 NO_LOAD 559*c217d954SCole Faust#define vload_partial_8_15 NO_LOAD 560*c217d954SCole Faust#define vload_partial_8_16 NO_LOAD 561*c217d954SCole Faust 562*c217d954SCole Faust#define vload_partial_16_0 NO_LOAD 563*c217d954SCole Faust#define vload_partial_16_1 vload_partial_1 564*c217d954SCole Faust#define vload_partial_16_2 vload_partial_2 565*c217d954SCole Faust#define vload_partial_16_3 vload_partial_3 566*c217d954SCole Faust#define vload_partial_16_4 vload_partial_4 567*c217d954SCole Faust#define vload_partial_16_5 vload_partial_5 568*c217d954SCole Faust#define vload_partial_16_6 vload_partial_6 569*c217d954SCole Faust#define vload_partial_16_7 vload_partial_7 570*c217d954SCole Faust#define vload_partial_16_8 vload_partial_8 571*c217d954SCole Faust#define vload_partial_16_9 vload_partial_9 572*c217d954SCole Faust#define vload_partial_16_10 vload_partial_10 573*c217d954SCole Faust#define vload_partial_16_11 vload_partial_11 574*c217d954SCole Faust#define vload_partial_16_12 vload_partial_12 575*c217d954SCole Faust#define vload_partial_16_13 vload_partial_13 576*c217d954SCole Faust#define vload_partial_16_14 vload_partial_14 577*c217d954SCole Faust#define vload_partial_16_15 vload_partial_15 578*c217d954SCole Faust#define vload_partial_16_16 vload_partial_16 579*c217d954SCole Faust 580*c217d954SCole Faust 581*c217d954SCole Faust#define vload_partial_1(DATA, OFFSET, PTR) \ 582*c217d954SCole Faust DATA.s0 = vload1(OFFSET, PTR); 583*c217d954SCole Faust 584*c217d954SCole Faust#define vload_partial_2(DATA, OFFSET, PTR) \ 585*c217d954SCole Faust DATA.s01 = vload2(OFFSET, PTR); 586*c217d954SCole Faust 587*c217d954SCole Faust#define vload_partial_3(DATA, OFFSET, PTR) \ 588*c217d954SCole Faust DATA.s012 = vload3(OFFSET, PTR); 589*c217d954SCole Faust 590*c217d954SCole Faust#define vload_partial_4(DATA, OFFSET, PTR) \ 591*c217d954SCole Faust DATA.s0123 = vload4(OFFSET, PTR); 592*c217d954SCole Faust 593*c217d954SCole Faust#define vload_partial_5(DATA, OFFSET, PTR) \ 594*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 595*c217d954SCole Faust DATA.s4 = vload1(OFFSET, PTR + 4); 596*c217d954SCole Faust 597*c217d954SCole Faust#define vload_partial_6(DATA, OFFSET, PTR) \ 598*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 599*c217d954SCole Faust vload_partial_2(DATA.s45, OFFSET, PTR + 4); 600*c217d954SCole Faust 601*c217d954SCole Faust#define vload_partial_7(DATA, OFFSET, PTR) \ 602*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 603*c217d954SCole Faust vload_partial_3(DATA.s456, OFFSET, PTR + 4); 604*c217d954SCole Faust 605*c217d954SCole Faust#define vload_partial_8(DATA, OFFSET, PTR) \ 606*c217d954SCole Faust DATA.s01234567 = vload8(OFFSET, PTR); 607*c217d954SCole Faust 608*c217d954SCole Faust#define vload_partial_9(DATA, OFFSET, PTR) \ 609*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 610*c217d954SCole Faust DATA.s8 = vload1(OFFSET, PTR + 8); 611*c217d954SCole Faust 612*c217d954SCole Faust#define vload_partial_10(DATA, OFFSET, PTR) \ 613*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 614*c217d954SCole Faust vload_partial_2(DATA.s89, OFFSET, PTR + 8); 615*c217d954SCole Faust 616*c217d954SCole Faust#define vload_partial_11(DATA, OFFSET, PTR) \ 617*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 618*c217d954SCole Faust vload_partial_3(DATA.s89A, OFFSET, PTR + 8); 619*c217d954SCole Faust 620*c217d954SCole Faust#define vload_partial_12(DATA, OFFSET, PTR) \ 621*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 622*c217d954SCole Faust vload_partial_4(DATA.s89AB, OFFSET, PTR + 8); 623*c217d954SCole Faust 624*c217d954SCole Faust#define vload_partial_13(DATA, OFFSET, PTR) \ 625*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 626*c217d954SCole Faust vload_partial_5(DATA.s89ABCDEF, OFFSET, PTR + 8); 627*c217d954SCole Faust 628*c217d954SCole Faust#define vload_partial_14(DATA, OFFSET, PTR) \ 629*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 630*c217d954SCole Faust vload_partial_6(DATA.s89ABCDEF, OFFSET, PTR + 8); 631*c217d954SCole Faust 632*c217d954SCole Faust#define vload_partial_15(DATA, OFFSET, PTR) \ 633*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 634*c217d954SCole Faust vload_partial_7(DATA.s89ABCDEF, OFFSET, PTR + 8); 635*c217d954SCole Faust 636*c217d954SCole Faust#define vload_partial_16(DATA, OFFSET, PTR) \ 637*c217d954SCole Faust DATA = vload16(OFFSET, PTR); 638*c217d954SCole Faust 639*c217d954SCole Faust 640*c217d954SCole Faust 641*c217d954SCole Faust#define PIXEL_UNIT4 1 642*c217d954SCole Faust#define PIXEL_UNIT8 2 643*c217d954SCole Faust#define PIXEL_UNIT16 4 644*c217d954SCole Faust 645*c217d954SCole Faust 646*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) PIXEL_UNIT##vec_size 647*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT(vec_size) CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) 648*c217d954SCole Faust 649*c217d954SCole Faust 650*c217d954SCole Faust#define read_image2d_floatx1(img, x_coord, y_coord) (float4)(read_imagef(img, (int2)(x_coord, y_coord))); 651*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))); 652*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))); 653*c217d954SCole Faust 654*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 655*c217d954SCole Faust#define read_image2d_halfx1(img, x_coord, y_coord) (half4)(read_imageh(img, (int2)(x_coord, y_coord))); 656*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))); 657*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))); 658*c217d954SCole Faust#endif 659*c217d954SCole Faust 660*c217d954SCole Faust#define write_image2d_floatx1(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values)); 661*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)); 662*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)); 663*c217d954SCole Faust 664*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 665*c217d954SCole Faust#define write_image2d_halfx1(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values)); 666*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)); 667*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)); 668*c217d954SCole Faust#endif 669*c217d954SCole Faust 670*c217d954SCole Faust 671*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) 672*c217d954SCole Faust#define READ_IMAGE2D(data_type, n0, img, x_coord, y_coord) READ_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord) 673*c217d954SCole Faust 674*c217d954SCole Faust 675*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) 676*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) 677*c217d954SCole Faust 678*c217d954SCole Faust#define VSTORE_STR(size) vstore##size 679*c217d954SCole Faust#define VSTORE(size) VSTORE_STR(size) 680*c217d954SCole Faust 681*c217d954SCole Faust#define float1 float 682*c217d954SCole Faust#define half1 half 683*c217d954SCole Faust#define char1 char 684*c217d954SCole Faust#define uchar1 uchar 685*c217d954SCole Faust#define short1 short 686*c217d954SCole Faust#define ushort1 ushort 687*c217d954SCole Faust#define int1 int 688*c217d954SCole Faust#define uint1 uint 689*c217d954SCole Faust#define long1 long 690*c217d954SCole Faust#define ulong1 ulong 691*c217d954SCole Faust#define double1 double 692*c217d954SCole Faust 693*c217d954SCole Faust#define vload1(OFFSET, PTR) *(OFFSET + PTR) 694*c217d954SCole Faust#define vstore1(DATA, OFFSET, PTR) *(OFFSET + PTR) = DATA 695*c217d954SCole Faust 696*c217d954SCole Faust 697*c217d954SCole Faust#define VSTORE_PARTIAL_STR(size, store_size) vstore_partial_##size##_##store_size 698*c217d954SCole Faust#define VSTORE_PARTIAL(size, store_size) VSTORE_PARTIAL_STR(size, store_size) 699*c217d954SCole Faust 700*c217d954SCole Faust#define NO_STORE(data, offs, ptr) \ 701*c217d954SCole Faust { \ 702*c217d954SCole Faust } 703*c217d954SCole Faust 704*c217d954SCole Faust 705*c217d954SCole Faust#define vstore_partial_1_0 NO_STORE 706*c217d954SCole Faust#define vstore_partial_1_1 vstore1 707*c217d954SCole Faust#define vstore_partial_1_2 NO_STORE 708*c217d954SCole Faust#define vstore_partial_1_3 NO_STORE 709*c217d954SCole Faust#define vstore_partial_1_4 NO_STORE 710*c217d954SCole Faust#define vstore_partial_1_5 NO_STORE 711*c217d954SCole Faust#define vstore_partial_1_6 NO_STORE 712*c217d954SCole Faust#define vstore_partial_1_7 NO_STORE 713*c217d954SCole Faust#define vstore_partial_1_8 NO_STORE 714*c217d954SCole Faust#define vstore_partial_1_9 NO_STORE 715*c217d954SCole Faust#define vstore_partial_1_10 NO_STORE 716*c217d954SCole Faust#define vstore_partial_1_11 NO_STORE 717*c217d954SCole Faust#define vstore_partial_1_12 NO_STORE 718*c217d954SCole Faust#define vstore_partial_1_13 NO_STORE 719*c217d954SCole Faust#define vstore_partial_1_14 NO_STORE 720*c217d954SCole Faust#define vstore_partial_1_15 NO_STORE 721*c217d954SCole Faust#define vstore_partial_1_16 NO_STORE 722*c217d954SCole Faust 723*c217d954SCole Faust#define vstore_partial_2_0 NO_STORE 724*c217d954SCole Faust#define vstore_partial_2_1 vstore_partial_1 725*c217d954SCole Faust#define vstore_partial_2_2 vstore_partial_2 726*c217d954SCole Faust#define vstore_partial_2_3 NO_STORE 727*c217d954SCole Faust#define vstore_partial_2_4 NO_STORE 728*c217d954SCole Faust#define vstore_partial_2_5 NO_STORE 729*c217d954SCole Faust#define vstore_partial_2_6 NO_STORE 730*c217d954SCole Faust#define vstore_partial_2_7 NO_STORE 731*c217d954SCole Faust#define vstore_partial_2_8 NO_STORE 732*c217d954SCole Faust#define vstore_partial_2_9 NO_STORE 733*c217d954SCole Faust#define vstore_partial_2_10 NO_STORE 734*c217d954SCole Faust#define vstore_partial_2_11 NO_STORE 735*c217d954SCole Faust#define vstore_partial_2_12 NO_STORE 736*c217d954SCole Faust#define vstore_partial_2_13 NO_STORE 737*c217d954SCole Faust#define vstore_partial_2_14 NO_STORE 738*c217d954SCole Faust#define vstore_partial_2_15 NO_STORE 739*c217d954SCole Faust#define vstore_partial_2_16 NO_STORE 740*c217d954SCole Faust 741*c217d954SCole Faust#define vstore_partial_3_0 NO_STORE 742*c217d954SCole Faust#define vstore_partial_3_1 vstore_partial_1 743*c217d954SCole Faust#define vstore_partial_3_2 vstore_partial_2 744*c217d954SCole Faust#define vstore_partial_3_3 vstore_partial_3 745*c217d954SCole Faust#define vstore_partial_3_4 NO_STORE 746*c217d954SCole Faust#define vstore_partial_3_5 NO_STORE 747*c217d954SCole Faust#define vstore_partial_3_6 NO_STORE 748*c217d954SCole Faust#define vstore_partial_3_7 NO_STORE 749*c217d954SCole Faust#define vstore_partial_3_8 NO_STORE 750*c217d954SCole Faust#define vstore_partial_3_9 NO_STORE 751*c217d954SCole Faust#define vstore_partial_3_10 NO_STORE 752*c217d954SCole Faust#define vstore_partial_3_11 NO_STORE 753*c217d954SCole Faust#define vstore_partial_3_12 NO_STORE 754*c217d954SCole Faust#define vstore_partial_3_13 NO_STORE 755*c217d954SCole Faust#define vstore_partial_3_14 NO_STORE 756*c217d954SCole Faust#define vstore_partial_3_15 NO_STORE 757*c217d954SCole Faust#define vstore_partial_3_16 NO_STORE 758*c217d954SCole Faust 759*c217d954SCole Faust#define vstore_partial_4_0 NO_STORE 760*c217d954SCole Faust#define vstore_partial_4_1 vstore_partial_1 761*c217d954SCole Faust#define vstore_partial_4_2 vstore_partial_2 762*c217d954SCole Faust#define vstore_partial_4_3 vstore_partial_3 763*c217d954SCole Faust#define vstore_partial_4_4 vstore_partial_4 764*c217d954SCole Faust#define vstore_partial_4_5 NO_STORE 765*c217d954SCole Faust#define vstore_partial_4_6 NO_STORE 766*c217d954SCole Faust#define vstore_partial_4_7 NO_STORE 767*c217d954SCole Faust#define vstore_partial_4_8 NO_STORE 768*c217d954SCole Faust#define vstore_partial_4_9 NO_STORE 769*c217d954SCole Faust#define vstore_partial_4_10 NO_STORE 770*c217d954SCole Faust#define vstore_partial_4_11 NO_STORE 771*c217d954SCole Faust#define vstore_partial_4_12 NO_STORE 772*c217d954SCole Faust#define vstore_partial_4_13 NO_STORE 773*c217d954SCole Faust#define vstore_partial_4_14 NO_STORE 774*c217d954SCole Faust#define vstore_partial_4_15 NO_STORE 775*c217d954SCole Faust#define vstore_partial_4_16 NO_STORE 776*c217d954SCole Faust 777*c217d954SCole Faust#define vstore_partial_8_0 NO_STORE 778*c217d954SCole Faust#define vstore_partial_8_1 vstore_partial_1 779*c217d954SCole Faust#define vstore_partial_8_2 vstore_partial_2 780*c217d954SCole Faust#define vstore_partial_8_3 vstore_partial_3 781*c217d954SCole Faust#define vstore_partial_8_4 vstore_partial_4 782*c217d954SCole Faust#define vstore_partial_8_5 vstore_partial_5 783*c217d954SCole Faust#define vstore_partial_8_6 vstore_partial_6 784*c217d954SCole Faust#define vstore_partial_8_7 vstore_partial_7 785*c217d954SCole Faust#define vstore_partial_8_8 vstore_partial_8 786*c217d954SCole Faust#define vstore_partial_8_9 NO_STORE 787*c217d954SCole Faust#define vstore_partial_8_10 NO_STORE 788*c217d954SCole Faust#define vstore_partial_8_11 NO_STORE 789*c217d954SCole Faust#define vstore_partial_8_12 NO_STORE 790*c217d954SCole Faust#define vstore_partial_8_13 NO_STORE 791*c217d954SCole Faust#define vstore_partial_8_14 NO_STORE 792*c217d954SCole Faust#define vstore_partial_8_15 NO_STORE 793*c217d954SCole Faust#define vstore_partial_8_16 NO_STORE 794*c217d954SCole Faust 795*c217d954SCole Faust#define vstore_partial_16_0 NO_STORE 796*c217d954SCole Faust#define vstore_partial_16_1 vstore_partial_1 797*c217d954SCole Faust#define vstore_partial_16_2 vstore_partial_2 798*c217d954SCole Faust#define vstore_partial_16_3 vstore_partial_3 799*c217d954SCole Faust#define vstore_partial_16_4 vstore_partial_4 800*c217d954SCole Faust#define vstore_partial_16_5 vstore_partial_5 801*c217d954SCole Faust#define vstore_partial_16_6 vstore_partial_6 802*c217d954SCole Faust#define vstore_partial_16_7 vstore_partial_7 803*c217d954SCole Faust#define vstore_partial_16_8 vstore_partial_8 804*c217d954SCole Faust#define vstore_partial_16_9 vstore_partial_9 805*c217d954SCole Faust#define vstore_partial_16_10 vstore_partial_10 806*c217d954SCole Faust#define vstore_partial_16_11 vstore_partial_11 807*c217d954SCole Faust#define vstore_partial_16_12 vstore_partial_12 808*c217d954SCole Faust#define vstore_partial_16_13 vstore_partial_13 809*c217d954SCole Faust#define vstore_partial_16_14 vstore_partial_14 810*c217d954SCole Faust#define vstore_partial_16_15 vstore_partial_15 811*c217d954SCole Faust#define vstore_partial_16_16 vstore_partial_16 812*c217d954SCole Faust 813*c217d954SCole Faust 814*c217d954SCole Faust#define vstore_partial_1(DATA, OFFSET, PTR) \ 815*c217d954SCole Faust vstore1(DATA.s0, OFFSET, PTR); 816*c217d954SCole Faust 817*c217d954SCole Faust#define vstore_partial_2(DATA, OFFSET, PTR) \ 818*c217d954SCole Faust vstore2(DATA.s01, OFFSET, PTR); 819*c217d954SCole Faust 820*c217d954SCole Faust#define vstore_partial_3(DATA, OFFSET, PTR) \ 821*c217d954SCole Faust vstore3(DATA.s012, OFFSET, PTR); 822*c217d954SCole Faust 823*c217d954SCole Faust#define vstore_partial_4(DATA, OFFSET, PTR) \ 824*c217d954SCole Faust vstore4(DATA.s0123, OFFSET, PTR); 825*c217d954SCole Faust 826*c217d954SCole Faust#define vstore_partial_5(DATA, OFFSET, PTR) \ 827*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 828*c217d954SCole Faust vstore1(DATA.s4, OFFSET, PTR + 4); 829*c217d954SCole Faust 830*c217d954SCole Faust#define vstore_partial_6(DATA, OFFSET, PTR) \ 831*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 832*c217d954SCole Faust vstore_partial_2(DATA.s45, OFFSET, PTR + 4); 833*c217d954SCole Faust 834*c217d954SCole Faust#define vstore_partial_7(DATA, OFFSET, PTR) \ 835*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 836*c217d954SCole Faust vstore_partial_3(DATA.s456, OFFSET, PTR + 4); 837*c217d954SCole Faust 838*c217d954SCole Faust#define vstore_partial_8(DATA, OFFSET, PTR) \ 839*c217d954SCole Faust vstore8(DATA.s01234567, OFFSET, PTR); 840*c217d954SCole Faust 841*c217d954SCole Faust#define vstore_partial_9(DATA, OFFSET, PTR) \ 842*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 843*c217d954SCole Faust vstore1(DATA.s8, OFFSET, PTR + 8); 844*c217d954SCole Faust 845*c217d954SCole Faust#define vstore_partial_10(DATA, OFFSET, PTR) \ 846*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 847*c217d954SCole Faust vstore_partial_2(DATA.s89, OFFSET, PTR + 8); 848*c217d954SCole Faust 849*c217d954SCole Faust#define vstore_partial_11(DATA, OFFSET, PTR) \ 850*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 851*c217d954SCole Faust vstore_partial_3(DATA.s89a, OFFSET, PTR + 8); 852*c217d954SCole Faust 853*c217d954SCole Faust#define vstore_partial_12(DATA, OFFSET, PTR) \ 854*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 855*c217d954SCole Faust vstore_partial_4(DATA.s89ab, OFFSET, PTR + 8); 856*c217d954SCole Faust 857*c217d954SCole Faust#define vstore_partial_13(DATA, OFFSET, PTR) \ 858*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 859*c217d954SCole Faust vstore_partial_5(DATA.s89abcdef, OFFSET, PTR + 8); 860*c217d954SCole Faust 861*c217d954SCole Faust#define vstore_partial_14(DATA, OFFSET, PTR) \ 862*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 863*c217d954SCole Faust vstore_partial_6(DATA.s89abcdef, OFFSET, PTR + 8); 864*c217d954SCole Faust 865*c217d954SCole Faust#define vstore_partial_15(DATA, OFFSET, PTR) \ 866*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 867*c217d954SCole Faust vstore_partial_7(DATA.s89abcdef, OFFSET, PTR + 8); 868*c217d954SCole Faust 869*c217d954SCole Faust#define vstore_partial_16(DATA, OFFSET, PTR) \ 870*c217d954SCole Faust vstore16(DATA, OFFSET, PTR); 871*c217d954SCole Faust 872*c217d954SCole Faust 873*c217d954SCole Faust 874*c217d954SCole Faust 875*c217d954SCole Faust 876*c217d954SCole Faust#define convert_float_sat convert_float 877*c217d954SCole Faust#define convert_float1_sat convert_float 878*c217d954SCole Faust#define convert_float2_sat convert_float2 879*c217d954SCole Faust#define convert_float3_sat convert_float3 880*c217d954SCole Faust#define convert_float4_sat convert_float4 881*c217d954SCole Faust#define convert_float8_sat convert_float8 882*c217d954SCole Faust#define convert_float16_sat convert_float16 883*c217d954SCole Faust#define convert_half_sat convert_float 884*c217d954SCole Faust#define convert_half1_sat convert_half 885*c217d954SCole Faust#define convert_half2_sat convert_half2 886*c217d954SCole Faust#define convert_half3_sat convert_half3 887*c217d954SCole Faust#define convert_half4_sat convert_half4 888*c217d954SCole Faust#define convert_half8_sat convert_half8 889*c217d954SCole Faust#define convert_half16_sat convert_half16 890*c217d954SCole Faust 891*c217d954SCole Faust#define convert_float1 convert_float 892*c217d954SCole Faust#define convert_half1 convert_half 893*c217d954SCole Faust#define convert_char1 convert_char 894*c217d954SCole Faust#define convert_uchar1 convert_uchar 895*c217d954SCole Faust#define convert_short1 convert_short 896*c217d954SCole Faust#define convert_ushort1 convert_ushort 897*c217d954SCole Faust#define convert_int1 convert_int 898*c217d954SCole Faust#define convert_uint1 convert_uint 899*c217d954SCole Faust#define convert_long1 convert_long 900*c217d954SCole Faust#define convert_ulong1 convert_ulong 901*c217d954SCole Faust#define convert_double1 convert_double 902*c217d954SCole Faust 903*c217d954SCole Faust#define convert_char1_sat convert_char_sat 904*c217d954SCole Faust#define convert_uchar1_sat convert_uchar_sat 905*c217d954SCole Faust#define convert_uchar2_sat convert_uchar2_sat 906*c217d954SCole Faust#define convert_uchar3_sat convert_uchar3_sat 907*c217d954SCole Faust#define convert_uchar4_sat convert_uchar4_sat 908*c217d954SCole Faust#define convert_uchar8_sat convert_uchar8_sat 909*c217d954SCole Faust#define convert_uchar16_sat convert_uchar16_sat 910*c217d954SCole Faust#define convert_short1_sat convert_short_sat 911*c217d954SCole Faust#define convert_ushort1_sat convert_ushort_sat 912*c217d954SCole Faust#define convert_int1_sat convert_int_sat 913*c217d954SCole Faust#define convert_uint1_sat convert_uint_sat 914*c217d954SCole Faust#define convert_long1_sat convert_long_sat 915*c217d954SCole Faust#define convert_ulong1_sat convert_ulong_sat 916*c217d954SCole Faust#define convert_double1_sat convert_double_sat 917*c217d954SCole Faust 918*c217d954SCole Faust#define VEC_DATA_TYPE_STR(type, size) type##size 919*c217d954SCole Faust#define VEC_DATA_TYPE(type, size) VEC_DATA_TYPE_STR(type, size) 920*c217d954SCole Faust 921*c217d954SCole Faust#define CONVERT_STR(x, type) (convert_##type((x))) 922*c217d954SCole Faust#define CONVERT(x, type) CONVERT_STR(x, type) 923*c217d954SCole Faust 924*c217d954SCole Faust#define CONVERT_SAT_STR(x, type) (convert_##type##_sat((x))) 925*c217d954SCole Faust#define CONVERT_SAT(x, type) CONVERT_SAT_STR(x, type) 926*c217d954SCole Faust 927*c217d954SCole Faust#define CONVERT_SAT_ROUND_STR(x, type, round) (convert_##type##_sat_##round((x))) 928*c217d954SCole Faust#define CONVERT_SAT_ROUND(x, type, round) CONVERT_SAT_ROUND_STR(x, type, round) 929*c217d954SCole Faust 930*c217d954SCole Faust#define select_vec_dt_uchar(size) uchar##size 931*c217d954SCole Faust#define select_vec_dt_char(size) char##size 932*c217d954SCole Faust#define select_vec_dt_ushort(size) ushort##size 933*c217d954SCole Faust#define select_vec_dt_short(size) short##size 934*c217d954SCole Faust#define select_vec_dt_half(size) short##size 935*c217d954SCole Faust#define select_vec_dt_uint(size) uint##size 936*c217d954SCole Faust#define select_vec_dt_int(size) int##size 937*c217d954SCole Faust#define select_vec_dt_float(size) int##size 938*c217d954SCole Faust#define select_vec_dt_ulong(size) ulong##size 939*c217d954SCole Faust#define select_vec_dt_long(size) long##size 940*c217d954SCole Faust 941*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE_STR(type, size) select_vec_dt_##type(size) 942*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE(type, size) SELECT_VEC_DATA_TYPE_STR(type, size) 943*c217d954SCole Faust#define SELECT_DATA_TYPE(type) SELECT_VEC_DATA_TYPE_STR(type, 1) 944*c217d954SCole Faust 945*c217d954SCole Faust#define signed_int_vec_dt_uchar(size) char##size 946*c217d954SCole Faust#define signed_int_vec_dt_char(size) char##size 947*c217d954SCole Faust#define signed_int_vec_dt_ushort(size) short##size 948*c217d954SCole Faust#define signed_int_vec_dt_short(size) short##size 949*c217d954SCole Faust#define signed_int_vec_dt_half(size) short##size 950*c217d954SCole Faust#define signed_int_vec_dt_uint(size) int##size 951*c217d954SCole Faust#define signed_int_vec_dt_int(size) int##size 952*c217d954SCole Faust#define signed_int_vec_dt_float(size) int##size 953*c217d954SCole Faust#define signed_int_vec_dt_ulong(size) long##size 954*c217d954SCole Faust#define signed_int_vec_dt_long(size) long##size 955*c217d954SCole Faust 956*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE_STR(type, size) signed_int_vec_dt_##type(size) 957*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE(type, size) SIGNED_INT_VEC_DATA_TYPE_STR(type, size) 958*c217d954SCole Faust#define SIGNED_INT_DATA_TYPE(type) SIGNED_INT_VEC_DATA_TYPE_STR(type, 1) 959*c217d954SCole Faust 960*c217d954SCole Faust#define sum_reduce_1(x) (x) 961*c217d954SCole Faust#define sum_reduce_2(x) ((x).s0) + ((x).s1) 962*c217d954SCole Faust#define sum_reduce_3(x) sum_reduce_2((x).s01) + ((x).s2) 963*c217d954SCole Faust#define sum_reduce_4(x) sum_reduce_2((x).s01) + sum_reduce_2((x).s23) 964*c217d954SCole Faust#define sum_reduce_8(x) sum_reduce_4((x).s0123) + sum_reduce_4((x).s4567) 965*c217d954SCole Faust#define sum_reduce_16(x) sum_reduce_8((x).s01234567) + sum_reduce_8((x).s89ABCDEF) 966*c217d954SCole Faust 967*c217d954SCole Faust#define SUM_REDUCE_STR(x, size) sum_reduce_##size(x) 968*c217d954SCole Faust#define SUM_REDUCE(x, size) SUM_REDUCE_STR(x, size) 969*c217d954SCole Faust 970*c217d954SCole Faust#define prod_reduce_1(x) (x) 971*c217d954SCole Faust#define prod_reduce_2(x) ((x).s0) * ((x).s1) 972*c217d954SCole Faust#define prod_reduce_3(x) prod_reduce_2((x).s01) * ((x).s2) 973*c217d954SCole Faust#define prod_reduce_4(x) prod_reduce_2((x).s01) * prod_reduce_2((x).s23) 974*c217d954SCole Faust#define prod_reduce_8(x) prod_reduce_4((x).s0123) * prod_reduce_4((x).s4567) 975*c217d954SCole Faust#define prod_reduce_16(x) prod_reduce_8((x).s01234567) * prod_reduce_8((x).s89ABCDEF) 976*c217d954SCole Faust 977*c217d954SCole Faust#define PROD_REDUCE_STR(x, size) prod_reduce_##size(x) 978*c217d954SCole Faust#define PROD_REDUCE(x, size) PROD_REDUCE_STR(x, size) 979*c217d954SCole Faust 980*c217d954SCole Faust#define max_reduce_1(x) (x) 981*c217d954SCole Faust#define max_reduce_2(x) max(((x).s0), ((x).s1)) 982*c217d954SCole Faust#define max_reduce_3(x) max(max_reduce_2((x).s01), ((x).s2)) 983*c217d954SCole Faust#define max_reduce_4(x) max(max_reduce_2((x).s01), max_reduce_2((x).s23)) 984*c217d954SCole Faust#define max_reduce_8(x) max(max_reduce_4((x).s0123), max_reduce_4((x).s4567)) 985*c217d954SCole Faust#define max_reduce_16(x) max(max_reduce_8((x).s01234567), max_reduce_8((x).s89ABCDEF)) 986*c217d954SCole Faust 987*c217d954SCole Faust#define MAX_REDUCE_STR(x, size) max_reduce_##size(x) 988*c217d954SCole Faust#define MAX_REDUCE(x, size) MAX_REDUCE_STR(x, size) 989*c217d954SCole Faust 990*c217d954SCole Faust#define VECTOR_DECLARATION(name) \ 991*c217d954SCole Faust __global uchar *name##_ptr, \ 992*c217d954SCole Faust uint name##_stride_x, \ 993*c217d954SCole Faust uint name##_step_x, \ 994*c217d954SCole Faust uint name##_offset_first_element_in_bytes 995*c217d954SCole Faust 996*c217d954SCole Faust#define IMAGE_DECLARATION(name) \ 997*c217d954SCole Faust __global uchar *name##_ptr, \ 998*c217d954SCole Faust uint name##_stride_x, \ 999*c217d954SCole Faust uint name##_step_x, \ 1000*c217d954SCole Faust uint name##_stride_y, \ 1001*c217d954SCole Faust uint name##_step_y, \ 1002*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1003*c217d954SCole Faust 1004*c217d954SCole Faust#define TENSOR3D_DECLARATION(name) \ 1005*c217d954SCole Faust __global uchar *name##_ptr, \ 1006*c217d954SCole Faust uint name##_stride_x, \ 1007*c217d954SCole Faust uint name##_step_x, \ 1008*c217d954SCole Faust uint name##_stride_y, \ 1009*c217d954SCole Faust uint name##_step_y, \ 1010*c217d954SCole Faust uint name##_stride_z, \ 1011*c217d954SCole Faust uint name##_step_z, \ 1012*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1013*c217d954SCole Faust 1014*c217d954SCole Faust#define TENSOR4D_DECLARATION(name) \ 1015*c217d954SCole Faust __global uchar *name##_ptr, \ 1016*c217d954SCole Faust uint name##_stride_x, \ 1017*c217d954SCole Faust uint name##_step_x, \ 1018*c217d954SCole Faust uint name##_stride_y, \ 1019*c217d954SCole Faust uint name##_step_y, \ 1020*c217d954SCole Faust uint name##_stride_z, \ 1021*c217d954SCole Faust uint name##_step_z, \ 1022*c217d954SCole Faust uint name##_stride_w, \ 1023*c217d954SCole Faust uint name##_step_w, \ 1024*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1025*c217d954SCole Faust 1026*c217d954SCole Faust#define TENSOR5D_DECLARATION(name) \ 1027*c217d954SCole Faust __global uchar *name##_ptr, \ 1028*c217d954SCole Faust uint name##_stride_x, \ 1029*c217d954SCole Faust uint name##_step_x, \ 1030*c217d954SCole Faust uint name##_stride_y, \ 1031*c217d954SCole Faust uint name##_step_y, \ 1032*c217d954SCole Faust uint name##_stride_z, \ 1033*c217d954SCole Faust uint name##_step_z, \ 1034*c217d954SCole Faust uint name##_stride_w, \ 1035*c217d954SCole Faust uint name##_step_w, \ 1036*c217d954SCole Faust uint name##_stride_v, \ 1037*c217d954SCole Faust uint name##_step_v, \ 1038*c217d954SCole Faust uint name##_offset_first_element_in_bytes 1039*c217d954SCole Faust 1040*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT(name) \ 1041*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x) 1042*c217d954SCole Faust 1043*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT_NO_STEP(name) \ 1044*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0) 1045*c217d954SCole Faust 1046*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT(name) \ 1047*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) 1048*c217d954SCole Faust 1049*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name) \ 1050*c217d954SCole Faust update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0) 1051*c217d954SCole Faust 1052*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 1053*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) 1054*c217d954SCole Faust 1055*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT_NO_STEP(name) \ 1056*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) 1057*c217d954SCole Faust 1058*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 1059*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) 1060*c217d954SCole Faust 1061*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT(name) \ 1062*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, \ 1063*c217d954SCole Faust name##_stride_z, name##_step_z) 1064*c217d954SCole Faust 1065*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name) \ 1066*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) 1067*c217d954SCole Faust 1068*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT(name, mod_size) \ 1069*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, \ 1070*c217d954SCole Faust name##_stride_z, name##_step_z, name##_stride_w, name##_step_w, mod_size) 1071*c217d954SCole Faust 1072*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(name, mod_size) \ 1073*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) 1074*c217d954SCole Faust 1075*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_UPDATE_PTR(name) \ 1076*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, \ 1077*c217d954SCole Faust name##_stride_z, name##_step_z) 1078*c217d954SCole Faust 1079*c217d954SCole Faust 1080*c217d954SCole Fausttypedef struct Vector 1081*c217d954SCole Faust{ 1082*c217d954SCole Faust __global uchar *ptr; 1083*c217d954SCole Faust int offset_first_element_in_bytes; 1084*c217d954SCole Faust int stride_x; 1085*c217d954SCole Faust} Vector; 1086*c217d954SCole Faust 1087*c217d954SCole Faust 1088*c217d954SCole Fausttypedef struct Image 1089*c217d954SCole Faust{ 1090*c217d954SCole Faust __global uchar *ptr; 1091*c217d954SCole Faust int offset_first_element_in_bytes; 1092*c217d954SCole Faust int stride_x; 1093*c217d954SCole Faust int stride_y; 1094*c217d954SCole Faust} Image; 1095*c217d954SCole Faust 1096*c217d954SCole Faust 1097*c217d954SCole Fausttypedef struct Tensor3D 1098*c217d954SCole Faust{ 1099*c217d954SCole Faust __global uchar *ptr; 1100*c217d954SCole Faust int offset_first_element_in_bytes; 1101*c217d954SCole Faust int stride_x; 1102*c217d954SCole Faust int stride_y; 1103*c217d954SCole Faust int stride_z; 1104*c217d954SCole Faust} Tensor3D; 1105*c217d954SCole Faust 1106*c217d954SCole Faust 1107*c217d954SCole Fausttypedef struct Tensor4D 1108*c217d954SCole Faust{ 1109*c217d954SCole Faust __global uchar *ptr; 1110*c217d954SCole Faust int offset_first_element_in_bytes; 1111*c217d954SCole Faust int stride_x; 1112*c217d954SCole Faust int stride_y; 1113*c217d954SCole Faust int stride_z; 1114*c217d954SCole Faust int stride_w; 1115*c217d954SCole Faust} Tensor4D; 1116*c217d954SCole Faust 1117*c217d954SCole Faust 1118*c217d954SCole Faustinline Vector update_vector_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x) 1119*c217d954SCole Faust{ 1120*c217d954SCole Faust Vector vector = 1121*c217d954SCole Faust { 1122*c217d954SCole Faust .ptr = ptr, 1123*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1124*c217d954SCole Faust .stride_x = stride_x, 1125*c217d954SCole Faust }; 1126*c217d954SCole Faust vector.ptr += vector.offset_first_element_in_bytes + get_global_id(0) * step_x; 1127*c217d954SCole Faust return vector; 1128*c217d954SCole Faust} 1129*c217d954SCole Faust 1130*c217d954SCole Faust 1131*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) 1132*c217d954SCole Faust{ 1133*c217d954SCole Faust Image img = 1134*c217d954SCole Faust { 1135*c217d954SCole Faust .ptr = ptr, 1136*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1137*c217d954SCole Faust .stride_x = stride_x, 1138*c217d954SCole Faust .stride_y = stride_y 1139*c217d954SCole Faust }; 1140*c217d954SCole Faust img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y; 1141*c217d954SCole Faust return img; 1142*c217d954SCole Faust} 1143*c217d954SCole Faust 1144*c217d954SCole Faust 1145*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) 1146*c217d954SCole Faust{ 1147*c217d954SCole Faust Image img = 1148*c217d954SCole Faust { 1149*c217d954SCole Faust .ptr = ptr, 1150*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1151*c217d954SCole Faust .stride_x = stride_x, 1152*c217d954SCole Faust .stride_y = stride_y 1153*c217d954SCole Faust }; 1154*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; 1155*c217d954SCole Faust return img; 1156*c217d954SCole Faust} 1157*c217d954SCole Faust 1158*c217d954SCole Faust 1159*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) 1160*c217d954SCole Faust{ 1161*c217d954SCole Faust Tensor3D tensor = 1162*c217d954SCole Faust { 1163*c217d954SCole Faust .ptr = ptr, 1164*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1165*c217d954SCole Faust .stride_x = stride_x, 1166*c217d954SCole Faust .stride_y = stride_y, 1167*c217d954SCole Faust .stride_z = stride_z 1168*c217d954SCole Faust }; 1169*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; 1170*c217d954SCole Faust return tensor; 1171*c217d954SCole Faust} 1172*c217d954SCole Faust 1173*c217d954SCole Faust 1174*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) 1175*c217d954SCole Faust{ 1176*c217d954SCole Faust Tensor3D tensor = 1177*c217d954SCole Faust { 1178*c217d954SCole Faust .ptr = ptr, 1179*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1180*c217d954SCole Faust .stride_x = stride_x, 1181*c217d954SCole Faust .stride_y = stride_y, 1182*c217d954SCole Faust .stride_z = stride_z 1183*c217d954SCole Faust }; 1184*c217d954SCole Faust return tensor; 1185*c217d954SCole Faust} 1186*c217d954SCole Faust 1187*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, 1188*c217d954SCole Faust uint step_w, 1189*c217d954SCole Faust uint mod_size) 1190*c217d954SCole Faust{ 1191*c217d954SCole Faust Tensor4D tensor = 1192*c217d954SCole Faust { 1193*c217d954SCole Faust .ptr = ptr, 1194*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 1195*c217d954SCole Faust .stride_x = stride_x, 1196*c217d954SCole Faust .stride_y = stride_y, 1197*c217d954SCole Faust .stride_z = stride_z, 1198*c217d954SCole Faust .stride_w = stride_w 1199*c217d954SCole Faust }; 1200*c217d954SCole Faust 1201*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; 1202*c217d954SCole Faust return tensor; 1203*c217d954SCole Faust} 1204*c217d954SCole Faust 1205*c217d954SCole Faust 1206*c217d954SCole Faustinline __global const uchar *vector_offset(const Vector *vec, int x) 1207*c217d954SCole Faust{ 1208*c217d954SCole Faust return vec->ptr + x * vec->stride_x; 1209*c217d954SCole Faust} 1210*c217d954SCole Faust 1211*c217d954SCole Faust 1212*c217d954SCole Faustinline __global uchar *offset(const Image *img, int x, int y) 1213*c217d954SCole Faust{ 1214*c217d954SCole Faust return img->ptr + x * img->stride_x + y * img->stride_y; 1215*c217d954SCole Faust} 1216*c217d954SCole Faust 1217*c217d954SCole Faust 1218*c217d954SCole Faustinline __global const uchar *tensor3D_offset(const Tensor3D *tensor, int x, int y, int z) 1219*c217d954SCole Faust{ 1220*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z; 1221*c217d954SCole Faust} 1222*c217d954SCole Faust 1223*c217d954SCole Faust 1224*c217d954SCole Faustinline __global const uchar *tensor4D_offset(const Tensor4D *tensor, int x, int y, int z, int w) 1225*c217d954SCole Faust{ 1226*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + w * tensor->stride_w; 1227*c217d954SCole Faust} 1228*c217d954SCole Faust 1229*c217d954SCole Faust 1230*c217d954SCole Faustinline __global const uchar *tensor3D_index2ptr(const Tensor3D *tensor, uint width, uint height, uint depth, uint index) 1231*c217d954SCole Faust{ 1232*c217d954SCole Faust uint num_elements = width * height; 1233*c217d954SCole Faust 1234*c217d954SCole Faust const uint z = index / num_elements; 1235*c217d954SCole Faust 1236*c217d954SCole Faust index %= num_elements; 1237*c217d954SCole Faust 1238*c217d954SCole Faust const uint y = index / width; 1239*c217d954SCole Faust 1240*c217d954SCole Faust index %= width; 1241*c217d954SCole Faust 1242*c217d954SCole Faust const uint x = index; 1243*c217d954SCole Faust 1244*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + tensor->offset_first_element_in_bytes; 1245*c217d954SCole Faust} 1246*c217d954SCole Faust 1247*c217d954SCole Faust#endif 1248*c217d954SCole Faust 1249*c217d954SCole Faust#if GPU_ARCH == GPU_ARCH_BIFROST 1250*c217d954SCole Faust#define MLA(a, b, c) (fma(c, b, a)) 1251*c217d954SCole Faust#else 1252*c217d954SCole Faust#define MLA(a, b, c) ((b) * (c) + (a)) 1253*c217d954SCole Faust#endif 1254*c217d954SCole Faust 1255*c217d954SCole Faust 1256*c217d954SCole Faust#define hard_swish_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (x * ((min(max((x + (DATA_TYPE)3.0), (DATA_TYPE)0.0), (DATA_TYPE)6.0)) * (DATA_TYPE)0.166666667)) 1257*c217d954SCole Faust 1258*c217d954SCole Faust 1259*c217d954SCole Faust#define logistic_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) ((DATA_TYPE)1.0 / ((DATA_TYPE)1.0 + exp(-x))) 1260*c217d954SCole Faust 1261*c217d954SCole Faust 1262*c217d954SCole Faust#define tanh_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) ((DATA_TYPE)A_VAL * tanh((DATA_TYPE)B_VAL * x)) 1263*c217d954SCole Faust 1264*c217d954SCole Faust 1265*c217d954SCole Faust#define relu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (max((DATA_TYPE)0.0, x)) 1266*c217d954SCole Faust 1267*c217d954SCole Faust 1268*c217d954SCole Faust#define brelu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (min((DATA_TYPE)A_VAL, max((DATA_TYPE)0.0, x))) 1269*c217d954SCole Faust 1270*c217d954SCole Faust 1271*c217d954SCole Faust#define lu_brelu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (min(max(x, (DATA_TYPE)B_VAL), (DATA_TYPE)A_VAL)) 1272*c217d954SCole Faust 1273*c217d954SCole Faust 1274*c217d954SCole Faust#define lrelu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) ((min(x, (DATA_TYPE)0.0) * (DATA_TYPE)A_VAL) + max(x, (DATA_TYPE)0.0)) 1275*c217d954SCole Faust 1276*c217d954SCole Faust 1277*c217d954SCole Faust#define srelu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (log((DATA_TYPE)1.0 + exp(x))) 1278*c217d954SCole Faust 1279*c217d954SCole Faust 1280*c217d954SCole Faust#define elu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (select(((DATA_TYPE)A_VAL * (exp(x) - (DATA_TYPE)1.0)), x, (SELECT_VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE))isgreaterequal(x, (DATA_TYPE)0.0))) 1281*c217d954SCole Faust 1282*c217d954SCole Faust 1283*c217d954SCole Faust#define abs_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (fabs(x)) 1284*c217d954SCole Faust 1285*c217d954SCole Faust 1286*c217d954SCole Faust#define square_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (x * x) 1287*c217d954SCole Faust 1288*c217d954SCole Faust 1289*c217d954SCole Faust#define sqrt_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (sqrt(x)) 1290*c217d954SCole Faust 1291*c217d954SCole Faust 1292*c217d954SCole Faust#define linear_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (MLA((DATA_TYPE)B_VAL, (DATA_TYPE)A_VAL, x)) 1293*c217d954SCole Faust 1294*c217d954SCole Faust 1295*c217d954SCole Faust#define gelu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (x * (DATA_TYPE)0.5 * ((DATA_TYPE)1.0 + erf(x / (DATA_TYPE)1.41421356237))) 1296*c217d954SCole Faust 1297*c217d954SCole Faust 1298*c217d954SCole Faust#define identity_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (x) 1299*c217d954SCole Faust 1300*c217d954SCole Faust#define ACT_OP(op, DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) op##_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) 1301*c217d954SCole Faust 1302*c217d954SCole Faust#define ACTIVATION(op, DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) ACT_OP(op, DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) 1303*c217d954SCole Faust 1304*c217d954SCole Faust#ifndef ARM_COMPUTE_HELPER_H 1305*c217d954SCole Faust#define ARM_COMPUTE_HELPER_H 1306*c217d954SCole Faust 1307*c217d954SCole Faust 1308*c217d954SCole Faust 1309*c217d954SCole Faust 1310*c217d954SCole Faust#define STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1311*c217d954SCole Faust VSTORE(N0) \ 1312*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 1313*c217d954SCole Faust 1314*c217d954SCole Faust#define STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1315*c217d954SCole Faust STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1316*c217d954SCole Faust VSTORE(N0) \ 1317*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 1318*c217d954SCole Faust 1319*c217d954SCole Faust#define STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1320*c217d954SCole Faust STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1321*c217d954SCole Faust VSTORE(N0) \ 1322*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 1323*c217d954SCole Faust 1324*c217d954SCole Faust#define STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1325*c217d954SCole Faust STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1326*c217d954SCole Faust VSTORE(N0) \ 1327*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 1328*c217d954SCole Faust 1329*c217d954SCole Faust#define STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1330*c217d954SCole Faust STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1331*c217d954SCole Faust VSTORE(N0) \ 1332*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 1333*c217d954SCole Faust 1334*c217d954SCole Faust#define STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1335*c217d954SCole Faust STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1336*c217d954SCole Faust VSTORE(N0) \ 1337*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 1338*c217d954SCole Faust 1339*c217d954SCole Faust#define STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1340*c217d954SCole Faust STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1341*c217d954SCole Faust VSTORE(N0) \ 1342*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 1343*c217d954SCole Faust 1344*c217d954SCole Faust#define STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1345*c217d954SCole Faust STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1346*c217d954SCole Faust VSTORE(N0) \ 1347*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 1348*c217d954SCole Faust 1349*c217d954SCole Faust#define STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1350*c217d954SCole Faust STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1351*c217d954SCole Faust VSTORE(N0) \ 1352*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 1353*c217d954SCole Faust 1354*c217d954SCole Faust#define STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1355*c217d954SCole Faust STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1356*c217d954SCole Faust VSTORE(N0) \ 1357*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 1358*c217d954SCole Faust 1359*c217d954SCole Faust#define STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1360*c217d954SCole Faust STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1361*c217d954SCole Faust VSTORE(N0) \ 1362*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 1363*c217d954SCole Faust 1364*c217d954SCole Faust#define STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1365*c217d954SCole Faust STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1366*c217d954SCole Faust VSTORE(N0) \ 1367*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 1368*c217d954SCole Faust 1369*c217d954SCole Faust#define STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1370*c217d954SCole Faust STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1371*c217d954SCole Faust VSTORE(N0) \ 1372*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 1373*c217d954SCole Faust 1374*c217d954SCole Faust#define STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1375*c217d954SCole Faust STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1376*c217d954SCole Faust VSTORE(N0) \ 1377*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 1378*c217d954SCole Faust 1379*c217d954SCole Faust#define STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1380*c217d954SCole Faust STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1381*c217d954SCole Faust VSTORE(N0) \ 1382*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 1383*c217d954SCole Faust 1384*c217d954SCole Faust#define STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1385*c217d954SCole Faust STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1386*c217d954SCole Faust VSTORE(N0) \ 1387*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 1388*c217d954SCole Faust 1389*c217d954SCole Faust 1390*c217d954SCole Faust 1391*c217d954SCole Faust#define CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1392*c217d954SCole Faust VSTORE(N0) \ 1393*c217d954SCole Faust (CONVERT_SAT((BASENAME##0), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 1394*c217d954SCole Faust 1395*c217d954SCole Faust#define CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1396*c217d954SCole Faust CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1397*c217d954SCole Faust VSTORE(N0) \ 1398*c217d954SCole Faust (CONVERT_SAT((BASENAME##1), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 1399*c217d954SCole Faust 1400*c217d954SCole Faust#define CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1401*c217d954SCole Faust CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1402*c217d954SCole Faust VSTORE(N0) \ 1403*c217d954SCole Faust (CONVERT_SAT((BASENAME##2), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 1404*c217d954SCole Faust 1405*c217d954SCole Faust#define CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1406*c217d954SCole Faust CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1407*c217d954SCole Faust VSTORE(N0) \ 1408*c217d954SCole Faust (CONVERT_SAT((BASENAME##3), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 1409*c217d954SCole Faust 1410*c217d954SCole Faust#define CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1411*c217d954SCole Faust CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1412*c217d954SCole Faust VSTORE(N0) \ 1413*c217d954SCole Faust (CONVERT_SAT((BASENAME##4), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 1414*c217d954SCole Faust 1415*c217d954SCole Faust#define CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1416*c217d954SCole Faust CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1417*c217d954SCole Faust VSTORE(N0) \ 1418*c217d954SCole Faust (CONVERT_SAT((BASENAME##5), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 1419*c217d954SCole Faust 1420*c217d954SCole Faust#define CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1421*c217d954SCole Faust CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1422*c217d954SCole Faust VSTORE(N0) \ 1423*c217d954SCole Faust (CONVERT_SAT((BASENAME##6), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 1424*c217d954SCole Faust 1425*c217d954SCole Faust#define CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1426*c217d954SCole Faust CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1427*c217d954SCole Faust VSTORE(N0) \ 1428*c217d954SCole Faust (CONVERT_SAT((BASENAME##7), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 1429*c217d954SCole Faust 1430*c217d954SCole Faust#define CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1431*c217d954SCole Faust CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1432*c217d954SCole Faust VSTORE(N0) \ 1433*c217d954SCole Faust (CONVERT_SAT((BASENAME##8), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 1434*c217d954SCole Faust 1435*c217d954SCole Faust#define CONVERT_STORE_ROW_10(N0, DATA, BASENAME, PTR, STRIDE_Y, Z) \ 1436*c217d954SCole Faust CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1437*c217d954SCole Faust VSTORE(N0) \ 1438*c217d954SCole Faust (CONVERT_SAT((BASENAME##9), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 1439*c217d954SCole Faust 1440*c217d954SCole Faust#define CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1441*c217d954SCole Faust CONVERT_STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1442*c217d954SCole Faust VSTORE(N0) \ 1443*c217d954SCole Faust (CONVERT_SAT((BASENAME##A), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 1444*c217d954SCole Faust 1445*c217d954SCole Faust#define CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1446*c217d954SCole Faust CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1447*c217d954SCole Faust VSTORE(N0) \ 1448*c217d954SCole Faust (CONVERT_SAT((BASENAME##B), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 1449*c217d954SCole Faust 1450*c217d954SCole Faust#define CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1451*c217d954SCole Faust CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1452*c217d954SCole Faust VSTORE(N0) \ 1453*c217d954SCole Faust (CONVERT_SAT((BASENAME##C), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 1454*c217d954SCole Faust 1455*c217d954SCole Faust#define CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1456*c217d954SCole Faust CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1457*c217d954SCole Faust VSTORE(N0) \ 1458*c217d954SCole Faust (CONVERT_SAT((BASENAME##D), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 1459*c217d954SCole Faust 1460*c217d954SCole Faust#define CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1461*c217d954SCole Faust CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1462*c217d954SCole Faust VSTORE(N0) \ 1463*c217d954SCole Faust (CONVERT_SAT((BASENAME##E), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 1464*c217d954SCole Faust 1465*c217d954SCole Faust#define CONVERT_STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1466*c217d954SCole Faust CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1467*c217d954SCole Faust VSTORE(N0) \ 1468*c217d954SCole Faust (CONVERT_SAT((BASENAME##F), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 1469*c217d954SCole Faust 1470*c217d954SCole Faust 1471*c217d954SCole Faust 1472*c217d954SCole Faust 1473*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) 1474*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) 1475*c217d954SCole Faust 1476*c217d954SCole Faust 1477*c217d954SCole Faust 1478*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) 1479*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) 1480*c217d954SCole Faust 1481*c217d954SCole Faust 1482*c217d954SCole Faust 1483*c217d954SCole Faust#define STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1484*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1485*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 1486*c217d954SCole Faust 1487*c217d954SCole Faust#define STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1488*c217d954SCole Faust STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1489*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1490*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 1491*c217d954SCole Faust 1492*c217d954SCole Faust#define STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1493*c217d954SCole Faust STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1494*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1495*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 1496*c217d954SCole Faust 1497*c217d954SCole Faust#define STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1498*c217d954SCole Faust STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1499*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1500*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 1501*c217d954SCole Faust 1502*c217d954SCole Faust#define STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1503*c217d954SCole Faust STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1504*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1505*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 1506*c217d954SCole Faust 1507*c217d954SCole Faust#define STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1508*c217d954SCole Faust STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1509*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1510*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 1511*c217d954SCole Faust 1512*c217d954SCole Faust#define STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1513*c217d954SCole Faust STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1514*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1515*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 1516*c217d954SCole Faust 1517*c217d954SCole Faust#define STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1518*c217d954SCole Faust STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1519*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1520*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 1521*c217d954SCole Faust 1522*c217d954SCole Faust#define STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1523*c217d954SCole Faust STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1524*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1525*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 1526*c217d954SCole Faust 1527*c217d954SCole Faust#define STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1528*c217d954SCole Faust STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1529*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1530*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 1531*c217d954SCole Faust 1532*c217d954SCole Faust#define STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1533*c217d954SCole Faust STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1534*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1535*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 1536*c217d954SCole Faust 1537*c217d954SCole Faust#define STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1538*c217d954SCole Faust STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1539*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1540*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 1541*c217d954SCole Faust 1542*c217d954SCole Faust#define STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1543*c217d954SCole Faust STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1544*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1545*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 1546*c217d954SCole Faust 1547*c217d954SCole Faust#define STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1548*c217d954SCole Faust STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1549*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1550*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 1551*c217d954SCole Faust 1552*c217d954SCole Faust#define STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1553*c217d954SCole Faust STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1554*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1555*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 1556*c217d954SCole Faust 1557*c217d954SCole Faust#define STORE_ROW_PARTIAL_16(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1558*c217d954SCole Faust STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \ 1559*c217d954SCole Faust VSTORE_PARTIAL(N0, STORE_N0) \ 1560*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 1561*c217d954SCole Faust 1562*c217d954SCole Faust 1563*c217d954SCole Faust 1564*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) 1565*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) 1566*c217d954SCole Faust 1567*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) \ 1568*c217d954SCole Faust if(!(PARTIAL_COND_X) && !(PARTIAL_COND_Y)) \ 1569*c217d954SCole Faust { \ 1570*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1571*c217d954SCole Faust } \ 1572*c217d954SCole Faust else if((PARTIAL_COND_Y) && !(PARTIAL_COND_X)) \ 1573*c217d954SCole Faust { \ 1574*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1575*c217d954SCole Faust } \ 1576*c217d954SCole Faust else if(!(PARTIAL_COND_Y) && (PARTIAL_COND_X)) \ 1577*c217d954SCole Faust { \ 1578*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1579*c217d954SCole Faust } \ 1580*c217d954SCole Faust else \ 1581*c217d954SCole Faust { \ 1582*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1583*c217d954SCole Faust } 1584*c217d954SCole Faust 1585*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) \ 1586*c217d954SCole Faust if(!(PARTIAL_COND_X)) \ 1587*c217d954SCole Faust { \ 1588*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1589*c217d954SCole Faust } \ 1590*c217d954SCole Faust else \ 1591*c217d954SCole Faust { \ 1592*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1593*c217d954SCole Faust } 1594*c217d954SCole Faust 1595*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) \ 1596*c217d954SCole Faust if(!(PARTIAL_COND_Y)) \ 1597*c217d954SCole Faust { \ 1598*c217d954SCole Faust STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1599*c217d954SCole Faust } \ 1600*c217d954SCole Faust else \ 1601*c217d954SCole Faust { \ 1602*c217d954SCole Faust STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z); \ 1603*c217d954SCole Faust } 1604*c217d954SCole Faust 1605*c217d954SCole Faust 1606*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) && defined(PARTIAL_STORE_N0) 1607*c217d954SCole Faust 1608*c217d954SCole Faust 1609*c217d954SCole Faust#if PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 == 0 1610*c217d954SCole Faust 1611*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) \ 1612*c217d954SCole Faust STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 1613*c217d954SCole Faust 1614*c217d954SCole Faust#elif PARTIAL_STORE_M0 > 0 && PARTIAL_STORE_N0 == 0 1615*c217d954SCole Faust 1616*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) \ 1617*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) 1618*c217d954SCole Faust 1619*c217d954SCole Faust#elif PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 > 0 1620*c217d954SCole Faust 1621*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) \ 1622*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) 1623*c217d954SCole Faust 1624*c217d954SCole Faust#else 1625*c217d954SCole Faust 1626*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) \ 1627*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) 1628*c217d954SCole Faust 1629*c217d954SCole Faust#endif 1630*c217d954SCole Faust 1631*c217d954SCole Faust#endif 1632*c217d954SCole Faust 1633*c217d954SCole Faust 1634*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) 1635*c217d954SCole Faust 1636*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 1637*c217d954SCole Faust ((uint)(max(0, (int)(y * M0) - (int)((M0 - PARTIAL_STORE_M0) % M0)))) 1638*c217d954SCole Faust#else 1639*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \ 1640*c217d954SCole Faust ((uint)(y * M0)) 1641*c217d954SCole Faust#endif 1642*c217d954SCole Faust 1643*c217d954SCole Faust 1644*c217d954SCole Faust 1645*c217d954SCole Faust#define STORE_VECTOR_SELECT(basename, data_type, ptr, vec_size, leftover, cond) \ 1646*c217d954SCole Faust STORE_BLOCK_PARTIAL_IN_X(1, vec_size, data_type, basename, ptr, 0, 0, leftover, cond) 1647*c217d954SCole Faust 1648*c217d954SCole Faust 1649*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 1650*c217d954SCole Faust#pragma OPENCL EXTENSION cl_khr_fp16 : enable 1651*c217d954SCole Faust#endif 1652*c217d954SCole Faust 1653*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ENABLED) && defined(cl_arm_integer_dot_product_int8) 1654*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable 1655*c217d954SCole Faust#endif 1656*c217d954SCole Faust 1657*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED) && defined(cl_arm_integer_dot_product_accumulate_int8) 1658*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable 1659*c217d954SCole Faust#endif 1660*c217d954SCole Faust 1661*c217d954SCole Faust#if defined(ARM_COMPUTE_DEBUG_ENABLED) && defined(cl_arm_printf) 1662*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_printf : enable 1663*c217d954SCole Faust#endif 1664*c217d954SCole Faust 1665*c217d954SCole Faust#define GPU_ARCH_MIDGARD 0x100 1666*c217d954SCole Faust#define GPU_ARCH_BIFROST 0x200 1667*c217d954SCole Faust#define GPU_ARCH_VALHALL 0x300 1668*c217d954SCole Faust 1669*c217d954SCole Faust 1670*c217d954SCole Faust#define CONCAT(a, b) a##b 1671*c217d954SCole Faust 1672*c217d954SCole Faust 1673*c217d954SCole Faust#define EXPAND(x) x 1674*c217d954SCole Faust 1675*c217d954SCole Faust 1676*c217d954SCole Faust#define CLAMP(x, min_val, max_val) min(max(x, min_val), max_val) 1677*c217d954SCole Faust 1678*c217d954SCole Faust 1679*c217d954SCole Faust#define REV1(x) ((x)) 1680*c217d954SCole Faust#define REV2(x) ((x).s10) 1681*c217d954SCole Faust#define REV3(x) ((x).s210) 1682*c217d954SCole Faust#define REV4(x) ((x).s3210) 1683*c217d954SCole Faust#define REV8(x) ((x).s76543210) 1684*c217d954SCole Faust#define REV16(x) ((x).sFEDCBA9876543210) 1685*c217d954SCole Faust 1686*c217d954SCole Faust 1687*c217d954SCole Faust 1688*c217d954SCole Faust#define REVERSE_STR(x, s) REV##s((x)) 1689*c217d954SCole Faust#define REVERSE(x, s) REVERSE_STR(x, s) 1690*c217d954SCole Faust 1691*c217d954SCole Faust 1692*c217d954SCole Faust 1693*c217d954SCole Faust#define ROT1_0(x) ((x)) 1694*c217d954SCole Faust#define ROT1_1(x) ((x)) 1695*c217d954SCole Faust 1696*c217d954SCole Faust#define ROT2_0(x) ((x)) 1697*c217d954SCole Faust#define ROT2_1(x) ((x).s10) 1698*c217d954SCole Faust#define ROT2_2(x) ((x)) 1699*c217d954SCole Faust 1700*c217d954SCole Faust#define ROT3_0(x) ((x)) 1701*c217d954SCole Faust#define ROT3_1(x) ((x).s201) 1702*c217d954SCole Faust#define ROT3_2(x) ((x).s120) 1703*c217d954SCole Faust#define ROT3_3(x) ((x)) 1704*c217d954SCole Faust 1705*c217d954SCole Faust#define ROT4_0(x) ((x)) 1706*c217d954SCole Faust#define ROT4_1(x) ((x).s3012) 1707*c217d954SCole Faust#define ROT4_2(x) ((x).s2301) 1708*c217d954SCole Faust#define ROT4_3(x) ((x).s1230) 1709*c217d954SCole Faust#define ROT4_4(x) ((x)) 1710*c217d954SCole Faust 1711*c217d954SCole Faust#define ROT8_0(x) ((x)) 1712*c217d954SCole Faust#define ROT8_1(x) ((x).s70123456) 1713*c217d954SCole Faust#define ROT8_2(x) ((x).s67012345) 1714*c217d954SCole Faust#define ROT8_3(x) ((x).s56701234) 1715*c217d954SCole Faust#define ROT8_4(x) ((x).s45670123) 1716*c217d954SCole Faust#define ROT8_5(x) ((x).s34567012) 1717*c217d954SCole Faust#define ROT8_6(x) ((x).s23456701) 1718*c217d954SCole Faust#define ROT8_7(x) ((x).s12345670) 1719*c217d954SCole Faust#define ROT8_8(x) ((x)) 1720*c217d954SCole Faust 1721*c217d954SCole Faust#define ROT16_0(x) ((x)) 1722*c217d954SCole Faust#define ROT16_1(x) ((x).sF0123456789ABCDE) 1723*c217d954SCole Faust#define ROT16_2(x) ((x).sEF0123456789ABCD) 1724*c217d954SCole Faust#define ROT16_3(x) ((x).sDEF0123456789ABC) 1725*c217d954SCole Faust#define ROT16_4(x) ((x).sCDEF0123456789AB) 1726*c217d954SCole Faust#define ROT16_5(x) ((x).sBCDEF0123456789A) 1727*c217d954SCole Faust#define ROT16_6(x) ((x).sABCDEF0123456789) 1728*c217d954SCole Faust#define ROT16_7(x) ((x).s9ABCDEF012345678) 1729*c217d954SCole Faust#define ROT16_8(x) ((x).s89ABCDEF01234567) 1730*c217d954SCole Faust#define ROT16_9(x) ((x).s789ABCDEF0123456) 1731*c217d954SCole Faust#define ROT16_10(x) ((x).s6789ABCDEF012345) 1732*c217d954SCole Faust#define ROT16_11(x) ((x).s56789ABCDEF01234) 1733*c217d954SCole Faust#define ROT16_12(x) ((x).s456789ABCDEF0123) 1734*c217d954SCole Faust#define ROT16_13(x) ((x).s3456789ABCDEF012) 1735*c217d954SCole Faust#define ROT16_14(x) ((x).s23456789ABCDEF01) 1736*c217d954SCole Faust#define ROT16_15(x) ((x).s123456789ABCDEF0) 1737*c217d954SCole Faust#define ROT16_16(x) ((x)) 1738*c217d954SCole Faust 1739*c217d954SCole Faust 1740*c217d954SCole Faust 1741*c217d954SCole Faust#define ROTATE_STR(x, s, n) ROT##s##_##n(x) 1742*c217d954SCole Faust#define ROTATE(x, s, n) ROTATE_STR(x, s, n) 1743*c217d954SCole Faust 1744*c217d954SCole Faust 1745*c217d954SCole Faust 1746*c217d954SCole Faust#define V_OFFS1(dt) (dt##1)(0) 1747*c217d954SCole Faust#define V_OFFS2(dt) (dt##2)(0, 1) 1748*c217d954SCole Faust#define V_OFFS3(dt) (dt##3)(0, 1, 2) 1749*c217d954SCole Faust#define V_OFFS4(dt) (dt##4)(0, 1, 2, 3) 1750*c217d954SCole Faust#define V_OFFS8(dt) (dt##8)(0, 1, 2, 3, 4, 5, 6, 7) 1751*c217d954SCole Faust#define V_OFFS16(dt) (dt##16)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) 1752*c217d954SCole Faust 1753*c217d954SCole Faust 1754*c217d954SCole Faust 1755*c217d954SCole Faust#define VEC_OFFS_STR(dt, s) V_OFFS##s(dt) 1756*c217d954SCole Faust#define VEC_OFFS(dt, s) VEC_OFFS_STR(dt, s) 1757*c217d954SCole Faust 1758*c217d954SCole Faust 1759*c217d954SCole Faust#define VLOAD_STR(size) vload##size 1760*c217d954SCole Faust#define VLOAD(size) VLOAD_STR(size) 1761*c217d954SCole Faust 1762*c217d954SCole Faust 1763*c217d954SCole Faust#define VLOAD_PARTIAL_STR(size, load_size) vload_partial_##size##_##load_size 1764*c217d954SCole Faust#define VLOAD_PARTIAL(size, load_size) VLOAD_PARTIAL_STR(size, load_size) 1765*c217d954SCole Faust 1766*c217d954SCole Faust#define NO_LOAD(data, offs, ptr) \ 1767*c217d954SCole Faust { \ 1768*c217d954SCole Faust } 1769*c217d954SCole Faust 1770*c217d954SCole Faust 1771*c217d954SCole Faust#define vload_partial_1_0 NO_LOAD 1772*c217d954SCole Faust#define vload_partial_1_1 vload1 1773*c217d954SCole Faust#define vload_partial_1_2 NO_LOAD 1774*c217d954SCole Faust#define vload_partial_1_3 NO_LOAD 1775*c217d954SCole Faust#define vload_partial_1_4 NO_LOAD 1776*c217d954SCole Faust#define vload_partial_1_5 NO_LOAD 1777*c217d954SCole Faust#define vload_partial_1_6 NO_LOAD 1778*c217d954SCole Faust#define vload_partial_1_7 NO_LOAD 1779*c217d954SCole Faust#define vload_partial_1_8 NO_LOAD 1780*c217d954SCole Faust#define vload_partial_1_9 NO_LOAD 1781*c217d954SCole Faust#define vload_partial_1_10 NO_LOAD 1782*c217d954SCole Faust#define vload_partial_1_11 NO_LOAD 1783*c217d954SCole Faust#define vload_partial_1_12 NO_LOAD 1784*c217d954SCole Faust#define vload_partial_1_13 NO_LOAD 1785*c217d954SCole Faust#define vload_partial_1_14 NO_LOAD 1786*c217d954SCole Faust#define vload_partial_1_15 NO_LOAD 1787*c217d954SCole Faust#define vload_partial_1_16 NO_LOAD 1788*c217d954SCole Faust 1789*c217d954SCole Faust#define vload_partial_2_0 NO_LOAD 1790*c217d954SCole Faust#define vload_partial_2_1 vload_partial_1 1791*c217d954SCole Faust#define vload_partial_2_2 vload_partial_2 1792*c217d954SCole Faust#define vload_partial_2_3 NO_LOAD 1793*c217d954SCole Faust#define vload_partial_2_4 NO_LOAD 1794*c217d954SCole Faust#define vload_partial_2_5 NO_LOAD 1795*c217d954SCole Faust#define vload_partial_2_6 NO_LOAD 1796*c217d954SCole Faust#define vload_partial_2_7 NO_LOAD 1797*c217d954SCole Faust#define vload_partial_2_8 NO_LOAD 1798*c217d954SCole Faust#define vload_partial_2_9 NO_LOAD 1799*c217d954SCole Faust#define vload_partial_2_10 NO_LOAD 1800*c217d954SCole Faust#define vload_partial_2_11 NO_LOAD 1801*c217d954SCole Faust#define vload_partial_2_12 NO_LOAD 1802*c217d954SCole Faust#define vload_partial_2_13 NO_LOAD 1803*c217d954SCole Faust#define vload_partial_2_14 NO_LOAD 1804*c217d954SCole Faust#define vload_partial_2_15 NO_LOAD 1805*c217d954SCole Faust#define vload_partial_2_16 NO_LOAD 1806*c217d954SCole Faust 1807*c217d954SCole Faust#define vload_partial_3_0 NO_LOAD 1808*c217d954SCole Faust#define vload_partial_3_1 vload_partial_1 1809*c217d954SCole Faust#define vload_partial_3_2 vload_partial_2 1810*c217d954SCole Faust#define vload_partial_3_3 vload_partial_3 1811*c217d954SCole Faust#define vload_partial_3_4 NO_LOAD 1812*c217d954SCole Faust#define vload_partial_3_5 NO_LOAD 1813*c217d954SCole Faust#define vload_partial_3_6 NO_LOAD 1814*c217d954SCole Faust#define vload_partial_3_7 NO_LOAD 1815*c217d954SCole Faust#define vload_partial_3_8 NO_LOAD 1816*c217d954SCole Faust#define vload_partial_3_9 NO_LOAD 1817*c217d954SCole Faust#define vload_partial_3_10 NO_LOAD 1818*c217d954SCole Faust#define vload_partial_3_11 NO_LOAD 1819*c217d954SCole Faust#define vload_partial_3_12 NO_LOAD 1820*c217d954SCole Faust#define vload_partial_3_13 NO_LOAD 1821*c217d954SCole Faust#define vload_partial_3_14 NO_LOAD 1822*c217d954SCole Faust#define vload_partial_3_15 NO_LOAD 1823*c217d954SCole Faust#define vload_partial_3_16 NO_LOAD 1824*c217d954SCole Faust 1825*c217d954SCole Faust#define vload_partial_4_0 NO_LOAD 1826*c217d954SCole Faust#define vload_partial_4_1 vload_partial_1 1827*c217d954SCole Faust#define vload_partial_4_2 vload_partial_2 1828*c217d954SCole Faust#define vload_partial_4_3 vload_partial_3 1829*c217d954SCole Faust#define vload_partial_4_4 vload_partial_4 1830*c217d954SCole Faust#define vload_partial_4_5 NO_LOAD 1831*c217d954SCole Faust#define vload_partial_4_6 NO_LOAD 1832*c217d954SCole Faust#define vload_partial_4_7 NO_LOAD 1833*c217d954SCole Faust#define vload_partial_4_8 NO_LOAD 1834*c217d954SCole Faust#define vload_partial_4_9 NO_LOAD 1835*c217d954SCole Faust#define vload_partial_4_10 NO_LOAD 1836*c217d954SCole Faust#define vload_partial_4_11 NO_LOAD 1837*c217d954SCole Faust#define vload_partial_4_12 NO_LOAD 1838*c217d954SCole Faust#define vload_partial_4_13 NO_LOAD 1839*c217d954SCole Faust#define vload_partial_4_14 NO_LOAD 1840*c217d954SCole Faust#define vload_partial_4_15 NO_LOAD 1841*c217d954SCole Faust#define vload_partial_4_16 NO_LOAD 1842*c217d954SCole Faust 1843*c217d954SCole Faust#define vload_partial_8_0 NO_LOAD 1844*c217d954SCole Faust#define vload_partial_8_1 vload_partial_1 1845*c217d954SCole Faust#define vload_partial_8_2 vload_partial_2 1846*c217d954SCole Faust#define vload_partial_8_3 vload_partial_3 1847*c217d954SCole Faust#define vload_partial_8_4 vload_partial_4 1848*c217d954SCole Faust#define vload_partial_8_5 vload_partial_5 1849*c217d954SCole Faust#define vload_partial_8_6 vload_partial_6 1850*c217d954SCole Faust#define vload_partial_8_7 vload_partial_7 1851*c217d954SCole Faust#define vload_partial_8_8 vload_partial_8 1852*c217d954SCole Faust#define vload_partial_8_9 NO_LOAD 1853*c217d954SCole Faust#define vload_partial_8_10 NO_LOAD 1854*c217d954SCole Faust#define vload_partial_8_11 NO_LOAD 1855*c217d954SCole Faust#define vload_partial_8_12 NO_LOAD 1856*c217d954SCole Faust#define vload_partial_8_13 NO_LOAD 1857*c217d954SCole Faust#define vload_partial_8_14 NO_LOAD 1858*c217d954SCole Faust#define vload_partial_8_15 NO_LOAD 1859*c217d954SCole Faust#define vload_partial_8_16 NO_LOAD 1860*c217d954SCole Faust 1861*c217d954SCole Faust#define vload_partial_16_0 NO_LOAD 1862*c217d954SCole Faust#define vload_partial_16_1 vload_partial_1 1863*c217d954SCole Faust#define vload_partial_16_2 vload_partial_2 1864*c217d954SCole Faust#define vload_partial_16_3 vload_partial_3 1865*c217d954SCole Faust#define vload_partial_16_4 vload_partial_4 1866*c217d954SCole Faust#define vload_partial_16_5 vload_partial_5 1867*c217d954SCole Faust#define vload_partial_16_6 vload_partial_6 1868*c217d954SCole Faust#define vload_partial_16_7 vload_partial_7 1869*c217d954SCole Faust#define vload_partial_16_8 vload_partial_8 1870*c217d954SCole Faust#define vload_partial_16_9 vload_partial_9 1871*c217d954SCole Faust#define vload_partial_16_10 vload_partial_10 1872*c217d954SCole Faust#define vload_partial_16_11 vload_partial_11 1873*c217d954SCole Faust#define vload_partial_16_12 vload_partial_12 1874*c217d954SCole Faust#define vload_partial_16_13 vload_partial_13 1875*c217d954SCole Faust#define vload_partial_16_14 vload_partial_14 1876*c217d954SCole Faust#define vload_partial_16_15 vload_partial_15 1877*c217d954SCole Faust#define vload_partial_16_16 vload_partial_16 1878*c217d954SCole Faust 1879*c217d954SCole Faust 1880*c217d954SCole Faust#define vload_partial_1(DATA, OFFSET, PTR) \ 1881*c217d954SCole Faust DATA.s0 = vload1(OFFSET, PTR); 1882*c217d954SCole Faust 1883*c217d954SCole Faust#define vload_partial_2(DATA, OFFSET, PTR) \ 1884*c217d954SCole Faust DATA.s01 = vload2(OFFSET, PTR); 1885*c217d954SCole Faust 1886*c217d954SCole Faust#define vload_partial_3(DATA, OFFSET, PTR) \ 1887*c217d954SCole Faust DATA.s012 = vload3(OFFSET, PTR); 1888*c217d954SCole Faust 1889*c217d954SCole Faust#define vload_partial_4(DATA, OFFSET, PTR) \ 1890*c217d954SCole Faust DATA.s0123 = vload4(OFFSET, PTR); 1891*c217d954SCole Faust 1892*c217d954SCole Faust#define vload_partial_5(DATA, OFFSET, PTR) \ 1893*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 1894*c217d954SCole Faust DATA.s4 = vload1(OFFSET, PTR + 4); 1895*c217d954SCole Faust 1896*c217d954SCole Faust#define vload_partial_6(DATA, OFFSET, PTR) \ 1897*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 1898*c217d954SCole Faust vload_partial_2(DATA.s45, OFFSET, PTR + 4); 1899*c217d954SCole Faust 1900*c217d954SCole Faust#define vload_partial_7(DATA, OFFSET, PTR) \ 1901*c217d954SCole Faust vload_partial_4(DATA.s0123, OFFSET, PTR); \ 1902*c217d954SCole Faust vload_partial_3(DATA.s456, OFFSET, PTR + 4); 1903*c217d954SCole Faust 1904*c217d954SCole Faust#define vload_partial_8(DATA, OFFSET, PTR) \ 1905*c217d954SCole Faust DATA.s01234567 = vload8(OFFSET, PTR); 1906*c217d954SCole Faust 1907*c217d954SCole Faust#define vload_partial_9(DATA, OFFSET, PTR) \ 1908*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1909*c217d954SCole Faust DATA.s8 = vload1(OFFSET, PTR + 8); 1910*c217d954SCole Faust 1911*c217d954SCole Faust#define vload_partial_10(DATA, OFFSET, PTR) \ 1912*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1913*c217d954SCole Faust vload_partial_2(DATA.s89, OFFSET, PTR + 8); 1914*c217d954SCole Faust 1915*c217d954SCole Faust#define vload_partial_11(DATA, OFFSET, PTR) \ 1916*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1917*c217d954SCole Faust vload_partial_3(DATA.s89A, OFFSET, PTR + 8); 1918*c217d954SCole Faust 1919*c217d954SCole Faust#define vload_partial_12(DATA, OFFSET, PTR) \ 1920*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1921*c217d954SCole Faust vload_partial_4(DATA.s89AB, OFFSET, PTR + 8); 1922*c217d954SCole Faust 1923*c217d954SCole Faust#define vload_partial_13(DATA, OFFSET, PTR) \ 1924*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1925*c217d954SCole Faust vload_partial_5(DATA.s89ABCDEF, OFFSET, PTR + 8); 1926*c217d954SCole Faust 1927*c217d954SCole Faust#define vload_partial_14(DATA, OFFSET, PTR) \ 1928*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1929*c217d954SCole Faust vload_partial_6(DATA.s89ABCDEF, OFFSET, PTR + 8); 1930*c217d954SCole Faust 1931*c217d954SCole Faust#define vload_partial_15(DATA, OFFSET, PTR) \ 1932*c217d954SCole Faust vload_partial_8(DATA.s01234567, OFFSET, PTR); \ 1933*c217d954SCole Faust vload_partial_7(DATA.s89ABCDEF, OFFSET, PTR + 8); 1934*c217d954SCole Faust 1935*c217d954SCole Faust#define vload_partial_16(DATA, OFFSET, PTR) \ 1936*c217d954SCole Faust DATA = vload16(OFFSET, PTR); 1937*c217d954SCole Faust 1938*c217d954SCole Faust 1939*c217d954SCole Faust 1940*c217d954SCole Faust#define PIXEL_UNIT4 1 1941*c217d954SCole Faust#define PIXEL_UNIT8 2 1942*c217d954SCole Faust#define PIXEL_UNIT16 4 1943*c217d954SCole Faust 1944*c217d954SCole Faust 1945*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) PIXEL_UNIT##vec_size 1946*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT(vec_size) CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) 1947*c217d954SCole Faust 1948*c217d954SCole Faust 1949*c217d954SCole Faust#define read_image2d_floatx1(img, x_coord, y_coord) (float4)(read_imagef(img, (int2)(x_coord, y_coord))); 1950*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))); 1951*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))); 1952*c217d954SCole Faust 1953*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 1954*c217d954SCole Faust#define read_image2d_halfx1(img, x_coord, y_coord) (half4)(read_imageh(img, (int2)(x_coord, y_coord))); 1955*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))); 1956*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))); 1957*c217d954SCole Faust#endif 1958*c217d954SCole Faust 1959*c217d954SCole Faust#define write_image2d_floatx1(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values)); 1960*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)); 1961*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)); 1962*c217d954SCole Faust 1963*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16) 1964*c217d954SCole Faust#define write_image2d_halfx1(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values)); 1965*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)); 1966*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)); 1967*c217d954SCole Faust#endif 1968*c217d954SCole Faust 1969*c217d954SCole Faust 1970*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) 1971*c217d954SCole Faust#define READ_IMAGE2D(data_type, n0, img, x_coord, y_coord) READ_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord) 1972*c217d954SCole Faust 1973*c217d954SCole Faust 1974*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) 1975*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) 1976*c217d954SCole Faust 1977*c217d954SCole Faust#define VSTORE_STR(size) vstore##size 1978*c217d954SCole Faust#define VSTORE(size) VSTORE_STR(size) 1979*c217d954SCole Faust 1980*c217d954SCole Faust#define float1 float 1981*c217d954SCole Faust#define half1 half 1982*c217d954SCole Faust#define char1 char 1983*c217d954SCole Faust#define uchar1 uchar 1984*c217d954SCole Faust#define short1 short 1985*c217d954SCole Faust#define ushort1 ushort 1986*c217d954SCole Faust#define int1 int 1987*c217d954SCole Faust#define uint1 uint 1988*c217d954SCole Faust#define long1 long 1989*c217d954SCole Faust#define ulong1 ulong 1990*c217d954SCole Faust#define double1 double 1991*c217d954SCole Faust 1992*c217d954SCole Faust#define vload1(OFFSET, PTR) *(OFFSET + PTR) 1993*c217d954SCole Faust#define vstore1(DATA, OFFSET, PTR) *(OFFSET + PTR) = DATA 1994*c217d954SCole Faust 1995*c217d954SCole Faust 1996*c217d954SCole Faust#define VSTORE_PARTIAL_STR(size, store_size) vstore_partial_##size##_##store_size 1997*c217d954SCole Faust#define VSTORE_PARTIAL(size, store_size) VSTORE_PARTIAL_STR(size, store_size) 1998*c217d954SCole Faust 1999*c217d954SCole Faust#define NO_STORE(data, offs, ptr) \ 2000*c217d954SCole Faust { \ 2001*c217d954SCole Faust } 2002*c217d954SCole Faust 2003*c217d954SCole Faust 2004*c217d954SCole Faust#define vstore_partial_1_0 NO_STORE 2005*c217d954SCole Faust#define vstore_partial_1_1 vstore1 2006*c217d954SCole Faust#define vstore_partial_1_2 NO_STORE 2007*c217d954SCole Faust#define vstore_partial_1_3 NO_STORE 2008*c217d954SCole Faust#define vstore_partial_1_4 NO_STORE 2009*c217d954SCole Faust#define vstore_partial_1_5 NO_STORE 2010*c217d954SCole Faust#define vstore_partial_1_6 NO_STORE 2011*c217d954SCole Faust#define vstore_partial_1_7 NO_STORE 2012*c217d954SCole Faust#define vstore_partial_1_8 NO_STORE 2013*c217d954SCole Faust#define vstore_partial_1_9 NO_STORE 2014*c217d954SCole Faust#define vstore_partial_1_10 NO_STORE 2015*c217d954SCole Faust#define vstore_partial_1_11 NO_STORE 2016*c217d954SCole Faust#define vstore_partial_1_12 NO_STORE 2017*c217d954SCole Faust#define vstore_partial_1_13 NO_STORE 2018*c217d954SCole Faust#define vstore_partial_1_14 NO_STORE 2019*c217d954SCole Faust#define vstore_partial_1_15 NO_STORE 2020*c217d954SCole Faust#define vstore_partial_1_16 NO_STORE 2021*c217d954SCole Faust 2022*c217d954SCole Faust#define vstore_partial_2_0 NO_STORE 2023*c217d954SCole Faust#define vstore_partial_2_1 vstore_partial_1 2024*c217d954SCole Faust#define vstore_partial_2_2 vstore_partial_2 2025*c217d954SCole Faust#define vstore_partial_2_3 NO_STORE 2026*c217d954SCole Faust#define vstore_partial_2_4 NO_STORE 2027*c217d954SCole Faust#define vstore_partial_2_5 NO_STORE 2028*c217d954SCole Faust#define vstore_partial_2_6 NO_STORE 2029*c217d954SCole Faust#define vstore_partial_2_7 NO_STORE 2030*c217d954SCole Faust#define vstore_partial_2_8 NO_STORE 2031*c217d954SCole Faust#define vstore_partial_2_9 NO_STORE 2032*c217d954SCole Faust#define vstore_partial_2_10 NO_STORE 2033*c217d954SCole Faust#define vstore_partial_2_11 NO_STORE 2034*c217d954SCole Faust#define vstore_partial_2_12 NO_STORE 2035*c217d954SCole Faust#define vstore_partial_2_13 NO_STORE 2036*c217d954SCole Faust#define vstore_partial_2_14 NO_STORE 2037*c217d954SCole Faust#define vstore_partial_2_15 NO_STORE 2038*c217d954SCole Faust#define vstore_partial_2_16 NO_STORE 2039*c217d954SCole Faust 2040*c217d954SCole Faust#define vstore_partial_3_0 NO_STORE 2041*c217d954SCole Faust#define vstore_partial_3_1 vstore_partial_1 2042*c217d954SCole Faust#define vstore_partial_3_2 vstore_partial_2 2043*c217d954SCole Faust#define vstore_partial_3_3 vstore_partial_3 2044*c217d954SCole Faust#define vstore_partial_3_4 NO_STORE 2045*c217d954SCole Faust#define vstore_partial_3_5 NO_STORE 2046*c217d954SCole Faust#define vstore_partial_3_6 NO_STORE 2047*c217d954SCole Faust#define vstore_partial_3_7 NO_STORE 2048*c217d954SCole Faust#define vstore_partial_3_8 NO_STORE 2049*c217d954SCole Faust#define vstore_partial_3_9 NO_STORE 2050*c217d954SCole Faust#define vstore_partial_3_10 NO_STORE 2051*c217d954SCole Faust#define vstore_partial_3_11 NO_STORE 2052*c217d954SCole Faust#define vstore_partial_3_12 NO_STORE 2053*c217d954SCole Faust#define vstore_partial_3_13 NO_STORE 2054*c217d954SCole Faust#define vstore_partial_3_14 NO_STORE 2055*c217d954SCole Faust#define vstore_partial_3_15 NO_STORE 2056*c217d954SCole Faust#define vstore_partial_3_16 NO_STORE 2057*c217d954SCole Faust 2058*c217d954SCole Faust#define vstore_partial_4_0 NO_STORE 2059*c217d954SCole Faust#define vstore_partial_4_1 vstore_partial_1 2060*c217d954SCole Faust#define vstore_partial_4_2 vstore_partial_2 2061*c217d954SCole Faust#define vstore_partial_4_3 vstore_partial_3 2062*c217d954SCole Faust#define vstore_partial_4_4 vstore_partial_4 2063*c217d954SCole Faust#define vstore_partial_4_5 NO_STORE 2064*c217d954SCole Faust#define vstore_partial_4_6 NO_STORE 2065*c217d954SCole Faust#define vstore_partial_4_7 NO_STORE 2066*c217d954SCole Faust#define vstore_partial_4_8 NO_STORE 2067*c217d954SCole Faust#define vstore_partial_4_9 NO_STORE 2068*c217d954SCole Faust#define vstore_partial_4_10 NO_STORE 2069*c217d954SCole Faust#define vstore_partial_4_11 NO_STORE 2070*c217d954SCole Faust#define vstore_partial_4_12 NO_STORE 2071*c217d954SCole Faust#define vstore_partial_4_13 NO_STORE 2072*c217d954SCole Faust#define vstore_partial_4_14 NO_STORE 2073*c217d954SCole Faust#define vstore_partial_4_15 NO_STORE 2074*c217d954SCole Faust#define vstore_partial_4_16 NO_STORE 2075*c217d954SCole Faust 2076*c217d954SCole Faust#define vstore_partial_8_0 NO_STORE 2077*c217d954SCole Faust#define vstore_partial_8_1 vstore_partial_1 2078*c217d954SCole Faust#define vstore_partial_8_2 vstore_partial_2 2079*c217d954SCole Faust#define vstore_partial_8_3 vstore_partial_3 2080*c217d954SCole Faust#define vstore_partial_8_4 vstore_partial_4 2081*c217d954SCole Faust#define vstore_partial_8_5 vstore_partial_5 2082*c217d954SCole Faust#define vstore_partial_8_6 vstore_partial_6 2083*c217d954SCole Faust#define vstore_partial_8_7 vstore_partial_7 2084*c217d954SCole Faust#define vstore_partial_8_8 vstore_partial_8 2085*c217d954SCole Faust#define vstore_partial_8_9 NO_STORE 2086*c217d954SCole Faust#define vstore_partial_8_10 NO_STORE 2087*c217d954SCole Faust#define vstore_partial_8_11 NO_STORE 2088*c217d954SCole Faust#define vstore_partial_8_12 NO_STORE 2089*c217d954SCole Faust#define vstore_partial_8_13 NO_STORE 2090*c217d954SCole Faust#define vstore_partial_8_14 NO_STORE 2091*c217d954SCole Faust#define vstore_partial_8_15 NO_STORE 2092*c217d954SCole Faust#define vstore_partial_8_16 NO_STORE 2093*c217d954SCole Faust 2094*c217d954SCole Faust#define vstore_partial_16_0 NO_STORE 2095*c217d954SCole Faust#define vstore_partial_16_1 vstore_partial_1 2096*c217d954SCole Faust#define vstore_partial_16_2 vstore_partial_2 2097*c217d954SCole Faust#define vstore_partial_16_3 vstore_partial_3 2098*c217d954SCole Faust#define vstore_partial_16_4 vstore_partial_4 2099*c217d954SCole Faust#define vstore_partial_16_5 vstore_partial_5 2100*c217d954SCole Faust#define vstore_partial_16_6 vstore_partial_6 2101*c217d954SCole Faust#define vstore_partial_16_7 vstore_partial_7 2102*c217d954SCole Faust#define vstore_partial_16_8 vstore_partial_8 2103*c217d954SCole Faust#define vstore_partial_16_9 vstore_partial_9 2104*c217d954SCole Faust#define vstore_partial_16_10 vstore_partial_10 2105*c217d954SCole Faust#define vstore_partial_16_11 vstore_partial_11 2106*c217d954SCole Faust#define vstore_partial_16_12 vstore_partial_12 2107*c217d954SCole Faust#define vstore_partial_16_13 vstore_partial_13 2108*c217d954SCole Faust#define vstore_partial_16_14 vstore_partial_14 2109*c217d954SCole Faust#define vstore_partial_16_15 vstore_partial_15 2110*c217d954SCole Faust#define vstore_partial_16_16 vstore_partial_16 2111*c217d954SCole Faust 2112*c217d954SCole Faust 2113*c217d954SCole Faust#define vstore_partial_1(DATA, OFFSET, PTR) \ 2114*c217d954SCole Faust vstore1(DATA.s0, OFFSET, PTR); 2115*c217d954SCole Faust 2116*c217d954SCole Faust#define vstore_partial_2(DATA, OFFSET, PTR) \ 2117*c217d954SCole Faust vstore2(DATA.s01, OFFSET, PTR); 2118*c217d954SCole Faust 2119*c217d954SCole Faust#define vstore_partial_3(DATA, OFFSET, PTR) \ 2120*c217d954SCole Faust vstore3(DATA.s012, OFFSET, PTR); 2121*c217d954SCole Faust 2122*c217d954SCole Faust#define vstore_partial_4(DATA, OFFSET, PTR) \ 2123*c217d954SCole Faust vstore4(DATA.s0123, OFFSET, PTR); 2124*c217d954SCole Faust 2125*c217d954SCole Faust#define vstore_partial_5(DATA, OFFSET, PTR) \ 2126*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 2127*c217d954SCole Faust vstore1(DATA.s4, OFFSET, PTR + 4); 2128*c217d954SCole Faust 2129*c217d954SCole Faust#define vstore_partial_6(DATA, OFFSET, PTR) \ 2130*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 2131*c217d954SCole Faust vstore_partial_2(DATA.s45, OFFSET, PTR + 4); 2132*c217d954SCole Faust 2133*c217d954SCole Faust#define vstore_partial_7(DATA, OFFSET, PTR) \ 2134*c217d954SCole Faust vstore_partial_4(DATA.s0123, OFFSET, PTR); \ 2135*c217d954SCole Faust vstore_partial_3(DATA.s456, OFFSET, PTR + 4); 2136*c217d954SCole Faust 2137*c217d954SCole Faust#define vstore_partial_8(DATA, OFFSET, PTR) \ 2138*c217d954SCole Faust vstore8(DATA.s01234567, OFFSET, PTR); 2139*c217d954SCole Faust 2140*c217d954SCole Faust#define vstore_partial_9(DATA, OFFSET, PTR) \ 2141*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2142*c217d954SCole Faust vstore1(DATA.s8, OFFSET, PTR + 8); 2143*c217d954SCole Faust 2144*c217d954SCole Faust#define vstore_partial_10(DATA, OFFSET, PTR) \ 2145*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2146*c217d954SCole Faust vstore_partial_2(DATA.s89, OFFSET, PTR + 8); 2147*c217d954SCole Faust 2148*c217d954SCole Faust#define vstore_partial_11(DATA, OFFSET, PTR) \ 2149*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2150*c217d954SCole Faust vstore_partial_3(DATA.s89a, OFFSET, PTR + 8); 2151*c217d954SCole Faust 2152*c217d954SCole Faust#define vstore_partial_12(DATA, OFFSET, PTR) \ 2153*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2154*c217d954SCole Faust vstore_partial_4(DATA.s89ab, OFFSET, PTR + 8); 2155*c217d954SCole Faust 2156*c217d954SCole Faust#define vstore_partial_13(DATA, OFFSET, PTR) \ 2157*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2158*c217d954SCole Faust vstore_partial_5(DATA.s89abcdef, OFFSET, PTR + 8); 2159*c217d954SCole Faust 2160*c217d954SCole Faust#define vstore_partial_14(DATA, OFFSET, PTR) \ 2161*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2162*c217d954SCole Faust vstore_partial_6(DATA.s89abcdef, OFFSET, PTR + 8); 2163*c217d954SCole Faust 2164*c217d954SCole Faust#define vstore_partial_15(DATA, OFFSET, PTR) \ 2165*c217d954SCole Faust vstore_partial_8(DATA.s01234567, OFFSET, PTR); \ 2166*c217d954SCole Faust vstore_partial_7(DATA.s89abcdef, OFFSET, PTR + 8); 2167*c217d954SCole Faust 2168*c217d954SCole Faust#define vstore_partial_16(DATA, OFFSET, PTR) \ 2169*c217d954SCole Faust vstore16(DATA, OFFSET, PTR); 2170*c217d954SCole Faust 2171*c217d954SCole Faust 2172*c217d954SCole Faust 2173*c217d954SCole Faust 2174*c217d954SCole Faust 2175*c217d954SCole Faust#define convert_float_sat convert_float 2176*c217d954SCole Faust#define convert_float1_sat convert_float 2177*c217d954SCole Faust#define convert_float2_sat convert_float2 2178*c217d954SCole Faust#define convert_float3_sat convert_float3 2179*c217d954SCole Faust#define convert_float4_sat convert_float4 2180*c217d954SCole Faust#define convert_float8_sat convert_float8 2181*c217d954SCole Faust#define convert_float16_sat convert_float16 2182*c217d954SCole Faust#define convert_half_sat convert_float 2183*c217d954SCole Faust#define convert_half1_sat convert_half 2184*c217d954SCole Faust#define convert_half2_sat convert_half2 2185*c217d954SCole Faust#define convert_half3_sat convert_half3 2186*c217d954SCole Faust#define convert_half4_sat convert_half4 2187*c217d954SCole Faust#define convert_half8_sat convert_half8 2188*c217d954SCole Faust#define convert_half16_sat convert_half16 2189*c217d954SCole Faust 2190*c217d954SCole Faust#define convert_float1 convert_float 2191*c217d954SCole Faust#define convert_half1 convert_half 2192*c217d954SCole Faust#define convert_char1 convert_char 2193*c217d954SCole Faust#define convert_uchar1 convert_uchar 2194*c217d954SCole Faust#define convert_short1 convert_short 2195*c217d954SCole Faust#define convert_ushort1 convert_ushort 2196*c217d954SCole Faust#define convert_int1 convert_int 2197*c217d954SCole Faust#define convert_uint1 convert_uint 2198*c217d954SCole Faust#define convert_long1 convert_long 2199*c217d954SCole Faust#define convert_ulong1 convert_ulong 2200*c217d954SCole Faust#define convert_double1 convert_double 2201*c217d954SCole Faust 2202*c217d954SCole Faust#define convert_char1_sat convert_char_sat 2203*c217d954SCole Faust#define convert_uchar1_sat convert_uchar_sat 2204*c217d954SCole Faust#define convert_uchar2_sat convert_uchar2_sat 2205*c217d954SCole Faust#define convert_uchar3_sat convert_uchar3_sat 2206*c217d954SCole Faust#define convert_uchar4_sat convert_uchar4_sat 2207*c217d954SCole Faust#define convert_uchar8_sat convert_uchar8_sat 2208*c217d954SCole Faust#define convert_uchar16_sat convert_uchar16_sat 2209*c217d954SCole Faust#define convert_short1_sat convert_short_sat 2210*c217d954SCole Faust#define convert_ushort1_sat convert_ushort_sat 2211*c217d954SCole Faust#define convert_int1_sat convert_int_sat 2212*c217d954SCole Faust#define convert_uint1_sat convert_uint_sat 2213*c217d954SCole Faust#define convert_long1_sat convert_long_sat 2214*c217d954SCole Faust#define convert_ulong1_sat convert_ulong_sat 2215*c217d954SCole Faust#define convert_double1_sat convert_double_sat 2216*c217d954SCole Faust 2217*c217d954SCole Faust#define VEC_DATA_TYPE_STR(type, size) type##size 2218*c217d954SCole Faust#define VEC_DATA_TYPE(type, size) VEC_DATA_TYPE_STR(type, size) 2219*c217d954SCole Faust 2220*c217d954SCole Faust#define CONVERT_STR(x, type) (convert_##type((x))) 2221*c217d954SCole Faust#define CONVERT(x, type) CONVERT_STR(x, type) 2222*c217d954SCole Faust 2223*c217d954SCole Faust#define CONVERT_SAT_STR(x, type) (convert_##type##_sat((x))) 2224*c217d954SCole Faust#define CONVERT_SAT(x, type) CONVERT_SAT_STR(x, type) 2225*c217d954SCole Faust 2226*c217d954SCole Faust#define CONVERT_SAT_ROUND_STR(x, type, round) (convert_##type##_sat_##round((x))) 2227*c217d954SCole Faust#define CONVERT_SAT_ROUND(x, type, round) CONVERT_SAT_ROUND_STR(x, type, round) 2228*c217d954SCole Faust 2229*c217d954SCole Faust#define select_vec_dt_uchar(size) uchar##size 2230*c217d954SCole Faust#define select_vec_dt_char(size) char##size 2231*c217d954SCole Faust#define select_vec_dt_ushort(size) ushort##size 2232*c217d954SCole Faust#define select_vec_dt_short(size) short##size 2233*c217d954SCole Faust#define select_vec_dt_half(size) short##size 2234*c217d954SCole Faust#define select_vec_dt_uint(size) uint##size 2235*c217d954SCole Faust#define select_vec_dt_int(size) int##size 2236*c217d954SCole Faust#define select_vec_dt_float(size) int##size 2237*c217d954SCole Faust#define select_vec_dt_ulong(size) ulong##size 2238*c217d954SCole Faust#define select_vec_dt_long(size) long##size 2239*c217d954SCole Faust 2240*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE_STR(type, size) select_vec_dt_##type(size) 2241*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE(type, size) SELECT_VEC_DATA_TYPE_STR(type, size) 2242*c217d954SCole Faust#define SELECT_DATA_TYPE(type) SELECT_VEC_DATA_TYPE_STR(type, 1) 2243*c217d954SCole Faust 2244*c217d954SCole Faust#define signed_int_vec_dt_uchar(size) char##size 2245*c217d954SCole Faust#define signed_int_vec_dt_char(size) char##size 2246*c217d954SCole Faust#define signed_int_vec_dt_ushort(size) short##size 2247*c217d954SCole Faust#define signed_int_vec_dt_short(size) short##size 2248*c217d954SCole Faust#define signed_int_vec_dt_half(size) short##size 2249*c217d954SCole Faust#define signed_int_vec_dt_uint(size) int##size 2250*c217d954SCole Faust#define signed_int_vec_dt_int(size) int##size 2251*c217d954SCole Faust#define signed_int_vec_dt_float(size) int##size 2252*c217d954SCole Faust#define signed_int_vec_dt_ulong(size) long##size 2253*c217d954SCole Faust#define signed_int_vec_dt_long(size) long##size 2254*c217d954SCole Faust 2255*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE_STR(type, size) signed_int_vec_dt_##type(size) 2256*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE(type, size) SIGNED_INT_VEC_DATA_TYPE_STR(type, size) 2257*c217d954SCole Faust#define SIGNED_INT_DATA_TYPE(type) SIGNED_INT_VEC_DATA_TYPE_STR(type, 1) 2258*c217d954SCole Faust 2259*c217d954SCole Faust#define sum_reduce_1(x) (x) 2260*c217d954SCole Faust#define sum_reduce_2(x) ((x).s0) + ((x).s1) 2261*c217d954SCole Faust#define sum_reduce_3(x) sum_reduce_2((x).s01) + ((x).s2) 2262*c217d954SCole Faust#define sum_reduce_4(x) sum_reduce_2((x).s01) + sum_reduce_2((x).s23) 2263*c217d954SCole Faust#define sum_reduce_8(x) sum_reduce_4((x).s0123) + sum_reduce_4((x).s4567) 2264*c217d954SCole Faust#define sum_reduce_16(x) sum_reduce_8((x).s01234567) + sum_reduce_8((x).s89ABCDEF) 2265*c217d954SCole Faust 2266*c217d954SCole Faust#define SUM_REDUCE_STR(x, size) sum_reduce_##size(x) 2267*c217d954SCole Faust#define SUM_REDUCE(x, size) SUM_REDUCE_STR(x, size) 2268*c217d954SCole Faust 2269*c217d954SCole Faust#define prod_reduce_1(x) (x) 2270*c217d954SCole Faust#define prod_reduce_2(x) ((x).s0) * ((x).s1) 2271*c217d954SCole Faust#define prod_reduce_3(x) prod_reduce_2((x).s01) * ((x).s2) 2272*c217d954SCole Faust#define prod_reduce_4(x) prod_reduce_2((x).s01) * prod_reduce_2((x).s23) 2273*c217d954SCole Faust#define prod_reduce_8(x) prod_reduce_4((x).s0123) * prod_reduce_4((x).s4567) 2274*c217d954SCole Faust#define prod_reduce_16(x) prod_reduce_8((x).s01234567) * prod_reduce_8((x).s89ABCDEF) 2275*c217d954SCole Faust 2276*c217d954SCole Faust#define PROD_REDUCE_STR(x, size) prod_reduce_##size(x) 2277*c217d954SCole Faust#define PROD_REDUCE(x, size) PROD_REDUCE_STR(x, size) 2278*c217d954SCole Faust 2279*c217d954SCole Faust#define max_reduce_1(x) (x) 2280*c217d954SCole Faust#define max_reduce_2(x) max(((x).s0), ((x).s1)) 2281*c217d954SCole Faust#define max_reduce_3(x) max(max_reduce_2((x).s01), ((x).s2)) 2282*c217d954SCole Faust#define max_reduce_4(x) max(max_reduce_2((x).s01), max_reduce_2((x).s23)) 2283*c217d954SCole Faust#define max_reduce_8(x) max(max_reduce_4((x).s0123), max_reduce_4((x).s4567)) 2284*c217d954SCole Faust#define max_reduce_16(x) max(max_reduce_8((x).s01234567), max_reduce_8((x).s89ABCDEF)) 2285*c217d954SCole Faust 2286*c217d954SCole Faust#define MAX_REDUCE_STR(x, size) max_reduce_##size(x) 2287*c217d954SCole Faust#define MAX_REDUCE(x, size) MAX_REDUCE_STR(x, size) 2288*c217d954SCole Faust 2289*c217d954SCole Faust#define VECTOR_DECLARATION(name) \ 2290*c217d954SCole Faust __global uchar *name##_ptr, \ 2291*c217d954SCole Faust uint name##_stride_x, \ 2292*c217d954SCole Faust uint name##_step_x, \ 2293*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2294*c217d954SCole Faust 2295*c217d954SCole Faust#define IMAGE_DECLARATION(name) \ 2296*c217d954SCole Faust __global uchar *name##_ptr, \ 2297*c217d954SCole Faust uint name##_stride_x, \ 2298*c217d954SCole Faust uint name##_step_x, \ 2299*c217d954SCole Faust uint name##_stride_y, \ 2300*c217d954SCole Faust uint name##_step_y, \ 2301*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2302*c217d954SCole Faust 2303*c217d954SCole Faust#define TENSOR3D_DECLARATION(name) \ 2304*c217d954SCole Faust __global uchar *name##_ptr, \ 2305*c217d954SCole Faust uint name##_stride_x, \ 2306*c217d954SCole Faust uint name##_step_x, \ 2307*c217d954SCole Faust uint name##_stride_y, \ 2308*c217d954SCole Faust uint name##_step_y, \ 2309*c217d954SCole Faust uint name##_stride_z, \ 2310*c217d954SCole Faust uint name##_step_z, \ 2311*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2312*c217d954SCole Faust 2313*c217d954SCole Faust#define TENSOR4D_DECLARATION(name) \ 2314*c217d954SCole Faust __global uchar *name##_ptr, \ 2315*c217d954SCole Faust uint name##_stride_x, \ 2316*c217d954SCole Faust uint name##_step_x, \ 2317*c217d954SCole Faust uint name##_stride_y, \ 2318*c217d954SCole Faust uint name##_step_y, \ 2319*c217d954SCole Faust uint name##_stride_z, \ 2320*c217d954SCole Faust uint name##_step_z, \ 2321*c217d954SCole Faust uint name##_stride_w, \ 2322*c217d954SCole Faust uint name##_step_w, \ 2323*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2324*c217d954SCole Faust 2325*c217d954SCole Faust#define TENSOR5D_DECLARATION(name) \ 2326*c217d954SCole Faust __global uchar *name##_ptr, \ 2327*c217d954SCole Faust uint name##_stride_x, \ 2328*c217d954SCole Faust uint name##_step_x, \ 2329*c217d954SCole Faust uint name##_stride_y, \ 2330*c217d954SCole Faust uint name##_step_y, \ 2331*c217d954SCole Faust uint name##_stride_z, \ 2332*c217d954SCole Faust uint name##_step_z, \ 2333*c217d954SCole Faust uint name##_stride_w, \ 2334*c217d954SCole Faust uint name##_step_w, \ 2335*c217d954SCole Faust uint name##_stride_v, \ 2336*c217d954SCole Faust uint name##_step_v, \ 2337*c217d954SCole Faust uint name##_offset_first_element_in_bytes 2338*c217d954SCole Faust 2339*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT(name) \ 2340*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x) 2341*c217d954SCole Faust 2342*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT_NO_STEP(name) \ 2343*c217d954SCole Faust update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0) 2344*c217d954SCole Faust 2345*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT(name) \ 2346*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) 2347*c217d954SCole Faust 2348*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name) \ 2349*c217d954SCole Faust update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0) 2350*c217d954SCole Faust 2351*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 2352*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) 2353*c217d954SCole Faust 2354*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT_NO_STEP(name) \ 2355*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) 2356*c217d954SCole Faust 2357*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \ 2358*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) 2359*c217d954SCole Faust 2360*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT(name) \ 2361*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, \ 2362*c217d954SCole Faust name##_stride_z, name##_step_z) 2363*c217d954SCole Faust 2364*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name) \ 2365*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) 2366*c217d954SCole Faust 2367*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT(name, mod_size) \ 2368*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, \ 2369*c217d954SCole Faust name##_stride_z, name##_step_z, name##_stride_w, name##_step_w, mod_size) 2370*c217d954SCole Faust 2371*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(name, mod_size) \ 2372*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) 2373*c217d954SCole Faust 2374*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_UPDATE_PTR(name) \ 2375*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, \ 2376*c217d954SCole Faust name##_stride_z, name##_step_z) 2377*c217d954SCole Faust 2378*c217d954SCole Faust 2379*c217d954SCole Fausttypedef struct Vector 2380*c217d954SCole Faust{ 2381*c217d954SCole Faust __global uchar *ptr; 2382*c217d954SCole Faust int offset_first_element_in_bytes; 2383*c217d954SCole Faust int stride_x; 2384*c217d954SCole Faust} Vector; 2385*c217d954SCole Faust 2386*c217d954SCole Faust 2387*c217d954SCole Fausttypedef struct Image 2388*c217d954SCole Faust{ 2389*c217d954SCole Faust __global uchar *ptr; 2390*c217d954SCole Faust int offset_first_element_in_bytes; 2391*c217d954SCole Faust int stride_x; 2392*c217d954SCole Faust int stride_y; 2393*c217d954SCole Faust} Image; 2394*c217d954SCole Faust 2395*c217d954SCole Faust 2396*c217d954SCole Fausttypedef struct Tensor3D 2397*c217d954SCole Faust{ 2398*c217d954SCole Faust __global uchar *ptr; 2399*c217d954SCole Faust int offset_first_element_in_bytes; 2400*c217d954SCole Faust int stride_x; 2401*c217d954SCole Faust int stride_y; 2402*c217d954SCole Faust int stride_z; 2403*c217d954SCole Faust} Tensor3D; 2404*c217d954SCole Faust 2405*c217d954SCole Faust 2406*c217d954SCole Fausttypedef struct Tensor4D 2407*c217d954SCole Faust{ 2408*c217d954SCole Faust __global uchar *ptr; 2409*c217d954SCole Faust int offset_first_element_in_bytes; 2410*c217d954SCole Faust int stride_x; 2411*c217d954SCole Faust int stride_y; 2412*c217d954SCole Faust int stride_z; 2413*c217d954SCole Faust int stride_w; 2414*c217d954SCole Faust} Tensor4D; 2415*c217d954SCole Faust 2416*c217d954SCole Faust 2417*c217d954SCole Faustinline Vector update_vector_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x) 2418*c217d954SCole Faust{ 2419*c217d954SCole Faust Vector vector = 2420*c217d954SCole Faust { 2421*c217d954SCole Faust .ptr = ptr, 2422*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2423*c217d954SCole Faust .stride_x = stride_x, 2424*c217d954SCole Faust }; 2425*c217d954SCole Faust vector.ptr += vector.offset_first_element_in_bytes + get_global_id(0) * step_x; 2426*c217d954SCole Faust return vector; 2427*c217d954SCole Faust} 2428*c217d954SCole Faust 2429*c217d954SCole Faust 2430*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) 2431*c217d954SCole Faust{ 2432*c217d954SCole Faust Image img = 2433*c217d954SCole Faust { 2434*c217d954SCole Faust .ptr = ptr, 2435*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2436*c217d954SCole Faust .stride_x = stride_x, 2437*c217d954SCole Faust .stride_y = stride_y 2438*c217d954SCole Faust }; 2439*c217d954SCole Faust img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y; 2440*c217d954SCole Faust return img; 2441*c217d954SCole Faust} 2442*c217d954SCole Faust 2443*c217d954SCole Faust 2444*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) 2445*c217d954SCole Faust{ 2446*c217d954SCole Faust Image img = 2447*c217d954SCole Faust { 2448*c217d954SCole Faust .ptr = ptr, 2449*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2450*c217d954SCole Faust .stride_x = stride_x, 2451*c217d954SCole Faust .stride_y = stride_y 2452*c217d954SCole Faust }; 2453*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; 2454*c217d954SCole Faust return img; 2455*c217d954SCole Faust} 2456*c217d954SCole Faust 2457*c217d954SCole Faust 2458*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) 2459*c217d954SCole Faust{ 2460*c217d954SCole Faust Tensor3D tensor = 2461*c217d954SCole Faust { 2462*c217d954SCole Faust .ptr = ptr, 2463*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2464*c217d954SCole Faust .stride_x = stride_x, 2465*c217d954SCole Faust .stride_y = stride_y, 2466*c217d954SCole Faust .stride_z = stride_z 2467*c217d954SCole Faust }; 2468*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; 2469*c217d954SCole Faust return tensor; 2470*c217d954SCole Faust} 2471*c217d954SCole Faust 2472*c217d954SCole Faust 2473*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) 2474*c217d954SCole Faust{ 2475*c217d954SCole Faust Tensor3D tensor = 2476*c217d954SCole Faust { 2477*c217d954SCole Faust .ptr = ptr, 2478*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2479*c217d954SCole Faust .stride_x = stride_x, 2480*c217d954SCole Faust .stride_y = stride_y, 2481*c217d954SCole Faust .stride_z = stride_z 2482*c217d954SCole Faust }; 2483*c217d954SCole Faust return tensor; 2484*c217d954SCole Faust} 2485*c217d954SCole Faust 2486*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, 2487*c217d954SCole Faust uint step_w, 2488*c217d954SCole Faust uint mod_size) 2489*c217d954SCole Faust{ 2490*c217d954SCole Faust Tensor4D tensor = 2491*c217d954SCole Faust { 2492*c217d954SCole Faust .ptr = ptr, 2493*c217d954SCole Faust .offset_first_element_in_bytes = offset_first_element_in_bytes, 2494*c217d954SCole Faust .stride_x = stride_x, 2495*c217d954SCole Faust .stride_y = stride_y, 2496*c217d954SCole Faust .stride_z = stride_z, 2497*c217d954SCole Faust .stride_w = stride_w 2498*c217d954SCole Faust }; 2499*c217d954SCole Faust 2500*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; 2501*c217d954SCole Faust return tensor; 2502*c217d954SCole Faust} 2503*c217d954SCole Faust 2504*c217d954SCole Faust 2505*c217d954SCole Faustinline __global const uchar *vector_offset(const Vector *vec, int x) 2506*c217d954SCole Faust{ 2507*c217d954SCole Faust return vec->ptr + x * vec->stride_x; 2508*c217d954SCole Faust} 2509*c217d954SCole Faust 2510*c217d954SCole Faust 2511*c217d954SCole Faustinline __global uchar *offset(const Image *img, int x, int y) 2512*c217d954SCole Faust{ 2513*c217d954SCole Faust return img->ptr + x * img->stride_x + y * img->stride_y; 2514*c217d954SCole Faust} 2515*c217d954SCole Faust 2516*c217d954SCole Faust 2517*c217d954SCole Faustinline __global const uchar *tensor3D_offset(const Tensor3D *tensor, int x, int y, int z) 2518*c217d954SCole Faust{ 2519*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z; 2520*c217d954SCole Faust} 2521*c217d954SCole Faust 2522*c217d954SCole Faust 2523*c217d954SCole Faustinline __global const uchar *tensor4D_offset(const Tensor4D *tensor, int x, int y, int z, int w) 2524*c217d954SCole Faust{ 2525*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + w * tensor->stride_w; 2526*c217d954SCole Faust} 2527*c217d954SCole Faust 2528*c217d954SCole Faust 2529*c217d954SCole Faustinline __global const uchar *tensor3D_index2ptr(const Tensor3D *tensor, uint width, uint height, uint depth, uint index) 2530*c217d954SCole Faust{ 2531*c217d954SCole Faust uint num_elements = width * height; 2532*c217d954SCole Faust 2533*c217d954SCole Faust const uint z = index / num_elements; 2534*c217d954SCole Faust 2535*c217d954SCole Faust index %= num_elements; 2536*c217d954SCole Faust 2537*c217d954SCole Faust const uint y = index / width; 2538*c217d954SCole Faust 2539*c217d954SCole Faust index %= width; 2540*c217d954SCole Faust 2541*c217d954SCole Faust const uint x = index; 2542*c217d954SCole Faust 2543*c217d954SCole Faust return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + tensor->offset_first_element_in_bytes; 2544*c217d954SCole Faust} 2545*c217d954SCole Faust 2546*c217d954SCole Faust#endif 2547*c217d954SCole Faust 2548*c217d954SCole Faust 2549*c217d954SCole Faust#define SCALAR_ACCESS_STR(offset, n0, x) scalar_access_##offset##_##n0(x) 2550*c217d954SCole Faust#define SCALAR_ACCESS(offset, n0, x) SCALAR_ACCESS_STR(offset, n0, x) 2551*c217d954SCole Faust 2552*c217d954SCole Faust 2553*c217d954SCole Faust#define scalar_access_0_1(x) ((x).s0) 2554*c217d954SCole Faust#define scalar_access_0_2(x) ((x).s01) 2555*c217d954SCole Faust#define scalar_access_0_3(x) ((x).s012) 2556*c217d954SCole Faust#define scalar_access_0_4(x) ((x).s0123) 2557*c217d954SCole Faust#define scalar_access_0_8(x) ((x).s01234567) 2558*c217d954SCole Faust#define scalar_access_0_16(x) ((x).s0123456789ABCDEF) 2559*c217d954SCole Faust 2560*c217d954SCole Faust 2561*c217d954SCole Faust#define scalar_access_1_1(x) ((x).s1) 2562*c217d954SCole Faust#define scalar_access_1_2(x) ((x).s12) 2563*c217d954SCole Faust#define scalar_access_1_3(x) ((x).s123) 2564*c217d954SCole Faust#define scalar_access_1_4(x) ((x).s1234) 2565*c217d954SCole Faust#define scalar_access_1_8(x) ((x).s12345678) 2566*c217d954SCole Faust 2567*c217d954SCole Faust 2568*c217d954SCole Faust#define scalar_access_2_1(x) ((x).s2) 2569*c217d954SCole Faust#define scalar_access_2_2(x) ((x).s23) 2570*c217d954SCole Faust#define scalar_access_2_3(x) ((x).s234) 2571*c217d954SCole Faust#define scalar_access_2_4(x) ((x).s2345) 2572*c217d954SCole Faust#define scalar_access_2_8(x) ((x).s23456789) 2573*c217d954SCole Faust 2574*c217d954SCole Faust 2575*c217d954SCole Faust#define scalar_access_3_1(x) ((x).s3) 2576*c217d954SCole Faust#define scalar_access_3_2(x) ((x).s34) 2577*c217d954SCole Faust#define scalar_access_3_3(x) ((x).s345) 2578*c217d954SCole Faust#define scalar_access_3_4(x) ((x).s3456) 2579*c217d954SCole Faust#define scalar_access_3_8(x) ((x).s3456789A) 2580*c217d954SCole Faust 2581*c217d954SCole Faust 2582*c217d954SCole Faust#define scalar_access_4_1(x) ((x).s4) 2583*c217d954SCole Faust#define scalar_access_4_2(x) ((x).s45) 2584*c217d954SCole Faust#define scalar_access_4_3(x) ((x).s456) 2585*c217d954SCole Faust#define scalar_access_4_4(x) ((x).s4567) 2586*c217d954SCole Faust#define scalar_access_4_8(x) ((x).s456789AB) 2587*c217d954SCole Faust 2588*c217d954SCole Faust 2589*c217d954SCole Faust#define scalar_access_8_1(x) ((x).s8) 2590*c217d954SCole Faust#define scalar_access_8_2(x) ((x).s89) 2591*c217d954SCole Faust#define scalar_access_8_3(x) ((x).s89A) 2592*c217d954SCole Faust#define scalar_access_8_4(x) ((x).s89AB) 2593*c217d954SCole Faust#define scalar_access_8_8(x) ((x).s89ABCDEF) 2594*c217d954SCole Faust 2595*c217d954SCole Faust 2596*c217d954SCole Faust#define scalar_access_12_1(x) ((x).sC) 2597*c217d954SCole Faust#define scalar_access_12_2(x) ((x).sCD) 2598*c217d954SCole Faust#define scalar_access_12_3(x) ((x).sCDE) 2599*c217d954SCole Faust#define scalar_access_12_4(x) ((x).sCDEF) 2600*c217d954SCole Faust 2601*c217d954SCole Faust 2602*c217d954SCole Faust#define scalar_access_16_1(x) ((x).sF) 2603*c217d954SCole Faust 2604*c217d954SCole Faust 2605*c217d954SCole Faust#define LOAD_TENSOR_ROW_0(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2606*c217d954SCole Faust ({}) 2607*c217d954SCole Faust 2608*c217d954SCole Faust#define LOAD_TENSOR_ROW_1(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2609*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##0) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0)); 2610*c217d954SCole Faust 2611*c217d954SCole Faust#define LOAD_TENSOR_ROW_2(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2612*c217d954SCole Faust LOAD_TENSOR_ROW_1(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2613*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##1) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1)); 2614*c217d954SCole Faust 2615*c217d954SCole Faust#define LOAD_TENSOR_ROW_3(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2616*c217d954SCole Faust LOAD_TENSOR_ROW_2(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2617*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##2) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2)); 2618*c217d954SCole Faust 2619*c217d954SCole Faust#define LOAD_TENSOR_ROW_4(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2620*c217d954SCole Faust LOAD_TENSOR_ROW_3(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2621*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##3) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3)); 2622*c217d954SCole Faust 2623*c217d954SCole Faust#define LOAD_TENSOR_ROW_5(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2624*c217d954SCole Faust LOAD_TENSOR_ROW_4(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2625*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##4) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4)); 2626*c217d954SCole Faust 2627*c217d954SCole Faust#define LOAD_TENSOR_ROW_6(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2628*c217d954SCole Faust LOAD_TENSOR_ROW_5(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2629*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##5) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5)); 2630*c217d954SCole Faust 2631*c217d954SCole Faust#define LOAD_TENSOR_ROW_7(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2632*c217d954SCole Faust LOAD_TENSOR_ROW_6(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2633*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##6) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6)); 2634*c217d954SCole Faust 2635*c217d954SCole Faust#define LOAD_TENSOR_ROW_8(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2636*c217d954SCole Faust LOAD_TENSOR_ROW_7(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2637*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##7) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7)); 2638*c217d954SCole Faust 2639*c217d954SCole Faust#define LOAD_TENSOR_ROW_9(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2640*c217d954SCole Faust LOAD_TENSOR_ROW_8(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2641*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##8) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8)); 2642*c217d954SCole Faust 2643*c217d954SCole Faust#define LOAD_TENSOR_ROW_10(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2644*c217d954SCole Faust LOAD_TENSOR_ROW_9(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2645*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##9) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9)); 2646*c217d954SCole Faust 2647*c217d954SCole Faust#define LOAD_TENSOR_ROW_11(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2648*c217d954SCole Faust LOAD_TENSOR_ROW_10(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2649*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##A) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A)); 2650*c217d954SCole Faust 2651*c217d954SCole Faust#define LOAD_TENSOR_ROW_12(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2652*c217d954SCole Faust LOAD_TENSOR_ROW_11(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2653*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##B) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B)); 2654*c217d954SCole Faust 2655*c217d954SCole Faust#define LOAD_TENSOR_ROW_13(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2656*c217d954SCole Faust LOAD_TENSOR_ROW_12(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2657*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##C) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C)); 2658*c217d954SCole Faust 2659*c217d954SCole Faust#define LOAD_TENSOR_ROW_14(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2660*c217d954SCole Faust LOAD_TENSOR_ROW_13(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2661*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##D) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D)); 2662*c217d954SCole Faust 2663*c217d954SCole Faust#define LOAD_TENSOR_ROW_15(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2664*c217d954SCole Faust LOAD_TENSOR_ROW_14(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2665*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##E) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E)); 2666*c217d954SCole Faust 2667*c217d954SCole Faust#define LOAD_TENSOR_ROW_16(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2668*c217d954SCole Faust LOAD_TENSOR_ROW_15(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) \ 2669*c217d954SCole Faust SCALAR_ACCESS(COL_OFFSET, N0, BASENAME##F) = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F)); 2670*c217d954SCole Faust 2671*c217d954SCole Faust 2672*c217d954SCole Faust 2673*c217d954SCole Faust#define LOAD_TENSOR_STR(M0, N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) LOAD_TENSOR_ROW_##M0(N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) 2674*c217d954SCole Faust#define LOAD_TENSOR(M0, N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) LOAD_TENSOR_STR(M0, N0, DATA_TYPE, BASENAME, PTR, COL_OFFSET, STRIDE_Y, Z) 2675*c217d954SCole Faust 2676*c217d954SCole Faust 2677*c217d954SCole Faust 2678*c217d954SCole Faust#define LOAD_TENSOR_M0X0(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2679*c217d954SCole Faust ({}) 2680*c217d954SCole Faust 2681*c217d954SCole Faust#define LOAD_TENSOR_M0X1(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2682*c217d954SCole Faust LOAD_TENSOR(M0, N0, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); 2683*c217d954SCole Faust 2684*c217d954SCole Faust#define LOAD_TENSOR_M0X2(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2685*c217d954SCole Faust LOAD_TENSOR(M0, N0, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); 2686*c217d954SCole Faust 2687*c217d954SCole Faust#define LOAD_TENSOR_M0X3(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2688*c217d954SCole Faust LOAD_TENSOR(M0, N0, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); 2689*c217d954SCole Faust 2690*c217d954SCole Faust#define LOAD_TENSOR_M0X4(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2691*c217d954SCole Faust LOAD_TENSOR(M0, N0, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); 2692*c217d954SCole Faust 2693*c217d954SCole Faust#define LOAD_TENSOR_M0X5(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2694*c217d954SCole Faust LOAD_TENSOR(M0, 4, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); \ 2695*c217d954SCole Faust LOAD_TENSOR(M0, 1, DATA_TYPE, a, input_ptr + 4 * sizeof(DATA_TYPE), 4, src_stride_y, zin); 2696*c217d954SCole Faust 2697*c217d954SCole Faust#define LOAD_TENSOR_M0X6(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2698*c217d954SCole Faust LOAD_TENSOR(M0, 4, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); \ 2699*c217d954SCole Faust LOAD_TENSOR(M0, 2, DATA_TYPE, a, input_ptr + 4 * sizeof(DATA_TYPE), 4, src_stride_y, zin); 2700*c217d954SCole Faust 2701*c217d954SCole Faust#define LOAD_TENSOR_M0X7(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2702*c217d954SCole Faust LOAD_TENSOR(M0, 4, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); \ 2703*c217d954SCole Faust LOAD_TENSOR(M0, 3, DATA_TYPE, a, input_ptr + 4 * sizeof(DATA_TYPE), 4, src_stride_y, zin); 2704*c217d954SCole Faust 2705*c217d954SCole Faust#define LOAD_TENSOR_M0X8(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2706*c217d954SCole Faust LOAD_TENSOR(M0, N0, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); 2707*c217d954SCole Faust 2708*c217d954SCole Faust#define LOAD_TENSOR_M0X9(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2709*c217d954SCole Faust LOAD_TENSOR(M0, 8, DATA_TYPE, a, input_ptr 0, src_stride_y, zin); \ 2710*c217d954SCole Faust LOAD_TENSOR(M0, 1, DATA_TYPE, a, input_ptr + 8 * sizeof(DATA_TYPE), 8, src_stride_y, zin); 2711*c217d954SCole Faust 2712*c217d954SCole Faust#define LOAD_TENSOR_M0X10(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2713*c217d954SCole Faust LOAD_TENSOR(M0, 8, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); \ 2714*c217d954SCole Faust LOAD_TENSOR(M0, 2, DATA_TYPE, a, input_ptr + 8 * sizeof(DATA_TYPE), 8, src_stride_y, zin); 2715*c217d954SCole Faust 2716*c217d954SCole Faust#define LOAD_TENSOR_M0X11(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2717*c217d954SCole Faust LOAD_TENSOR(M0, 8, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); \ 2718*c217d954SCole Faust LOAD_TENSOR(M0, 3, DATA_TYPE, a, input_ptr + 8 * sizeof(DATA_TYPE), 8, src_stride_y, zin); 2719*c217d954SCole Faust 2720*c217d954SCole Faust#define LOAD_TENSOR_M0X12(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2721*c217d954SCole Faust LOAD_TENSOR(M0, 8, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); \ 2722*c217d954SCole Faust LOAD_TENSOR(M0, 4, DATA_TYPE, a, input_ptr + 8 * sizeof(DATA_TYPE), 8, src_stride_y, zin); 2723*c217d954SCole Faust 2724*c217d954SCole Faust#define LOAD_TENSOR_M0X13(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2725*c217d954SCole Faust LOAD_TENSOR(M0, 8, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); \ 2726*c217d954SCole Faust LOAD_TENSOR(M0, 4, DATA_TYPE, a, input_ptr + 8 * sizeof(DATA_TYPE), 8, src_stride_y, zin); \ 2727*c217d954SCole Faust LOAD_TENSOR(M0, 1, DATA_TYPE, a, input_ptr + 12 * sizeof(DATA_TYPE), 12, src_stride_y, zin); 2728*c217d954SCole Faust 2729*c217d954SCole Faust#define LOAD_TENSOR_M0X14(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2730*c217d954SCole Faust LOAD_TENSOR(M0, 8, DATA_TYPE, a, input_ptr 0, src_stride_y, zin); \ 2731*c217d954SCole Faust LOAD_TENSOR(M0, 4, DATA_TYPE, a, input_ptr + 8 * sizeof(DATA_TYPE), 8, src_stride_y, zin); \ 2732*c217d954SCole Faust LOAD_TENSOR(M0, 2, DATA_TYPE, a, input_ptr + 12 * sizeof(DATA_TYPE), 12, src_stride_y, zin); 2733*c217d954SCole Faust 2734*c217d954SCole Faust#define LOAD_TENSOR_M0X15(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2735*c217d954SCole Faust LOAD_TENSOR(M0, 8, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); \ 2736*c217d954SCole Faust LOAD_TENSOR(M0, 4, DATA_TYPE, a, input_ptr + 8 * sizeof(DATA_TYPE), 8, src_stride_y, zin); \ 2737*c217d954SCole Faust LOAD_TENSOR(M0, 3, DATA_TYPE, a, input_ptr + 12 * sizeof(DATA_TYPE), 12, src_stride_y, zin); 2738*c217d954SCole Faust 2739*c217d954SCole Faust#define LOAD_TENSOR_M0X16(M0, N0, DATA_TYPE, a, input_ptr, src_stride_y, zin) \ 2740*c217d954SCole Faust LOAD_TENSOR(M0, N0, DATA_TYPE, a, input_ptr, 0, src_stride_y, zin); 2741*c217d954SCole Faust 2742*c217d954SCole Faust 2743*c217d954SCole Faust 2744*c217d954SCole Faust#define LOAD_TENSOR_M0XN0_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) LOAD_TENSOR_M0X##N0(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 2745*c217d954SCole Faust#define LOAD_TENSOR_M0XN0(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) LOAD_TENSOR_M0XN0_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) 2746*c217d954SCole Faust 2747*c217d954SCole Faust 2748*c217d954SCole Faust#define LOAD_ROW_1(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2749*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2750*c217d954SCole Faust BASENAME##0 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 0 * STRIDE_Y + Z##0)); 2751*c217d954SCole Faust 2752*c217d954SCole Faust#define LOAD_ROW_2(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2753*c217d954SCole Faust LOAD_ROW_1(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2754*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2755*c217d954SCole Faust BASENAME##1 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 1 * STRIDE_Y + Z##1)); 2756*c217d954SCole Faust 2757*c217d954SCole Faust#define LOAD_ROW_3(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2758*c217d954SCole Faust LOAD_ROW_2(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2759*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2760*c217d954SCole Faust BASENAME##2 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 2 * STRIDE_Y + Z##2)); 2761*c217d954SCole Faust 2762*c217d954SCole Faust#define LOAD_ROW_4(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2763*c217d954SCole Faust LOAD_ROW_3(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2764*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2765*c217d954SCole Faust BASENAME##3 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 3 * STRIDE_Y + Z##3)); 2766*c217d954SCole Faust 2767*c217d954SCole Faust#define LOAD_ROW_5(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2768*c217d954SCole Faust LOAD_ROW_4(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2769*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2770*c217d954SCole Faust BASENAME##4 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 4 * STRIDE_Y + Z##4)); 2771*c217d954SCole Faust 2772*c217d954SCole Faust#define LOAD_ROW_6(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2773*c217d954SCole Faust LOAD_ROW_5(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2774*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2775*c217d954SCole Faust BASENAME##5 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 5 * STRIDE_Y + Z##5)); 2776*c217d954SCole Faust 2777*c217d954SCole Faust#define LOAD_ROW_7(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2778*c217d954SCole Faust LOAD_ROW_6(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2779*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2780*c217d954SCole Faust BASENAME##6 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 6 * STRIDE_Y + Z##6)); 2781*c217d954SCole Faust 2782*c217d954SCole Faust#define LOAD_ROW_8(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2783*c217d954SCole Faust LOAD_ROW_7(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2784*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2785*c217d954SCole Faust BASENAME##7 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 7 * STRIDE_Y + Z##7)); 2786*c217d954SCole Faust 2787*c217d954SCole Faust#define LOAD_ROW_9(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2788*c217d954SCole Faust LOAD_ROW_8(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2789*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2790*c217d954SCole Faust BASENAME##8 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 8 * STRIDE_Y + Z##8)); 2791*c217d954SCole Faust 2792*c217d954SCole Faust#define LOAD_ROW_10(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2793*c217d954SCole Faust LOAD_ROW_9(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2794*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2795*c217d954SCole Faust BASENAME##9 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 9 * STRIDE_Y + Z##9)); 2796*c217d954SCole Faust 2797*c217d954SCole Faust#define LOAD_ROW_11(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2798*c217d954SCole Faust LOAD_ROW_10(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2799*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2800*c217d954SCole Faust BASENAME##A = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 10 * STRIDE_Y + Z##A)); 2801*c217d954SCole Faust 2802*c217d954SCole Faust#define LOAD_ROW_12(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2803*c217d954SCole Faust LOAD_ROW_11(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2804*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2805*c217d954SCole Faust BASENAME##B = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 11 * STRIDE_Y + Z##B)); 2806*c217d954SCole Faust 2807*c217d954SCole Faust#define LOAD_ROW_13(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2808*c217d954SCole Faust LOAD_ROW_12(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2809*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2810*c217d954SCole Faust BASENAME##C = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 12 * STRIDE_Y + Z##C)); 2811*c217d954SCole Faust 2812*c217d954SCole Faust#define LOAD_ROW_14(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2813*c217d954SCole Faust LOAD_ROW_13(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2814*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2815*c217d954SCole Faust BASENAME##D = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 13 * STRIDE_Y + Z##D)); 2816*c217d954SCole Faust 2817*c217d954SCole Faust#define LOAD_ROW_15(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2818*c217d954SCole Faust LOAD_ROW_14(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2819*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2820*c217d954SCole Faust BASENAME##E = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 14 * STRIDE_Y + Z##E)); 2821*c217d954SCole Faust 2822*c217d954SCole Faust#define LOAD_ROW_16(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2823*c217d954SCole Faust LOAD_ROW_15(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2824*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 2825*c217d954SCole Faust BASENAME##F = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + 15 * STRIDE_Y + Z##F)); 2826*c217d954SCole Faust 2827*c217d954SCole Faust 2828*c217d954SCole Faust 2829*c217d954SCole Faust 2830*c217d954SCole Faust#define LOAD_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) LOAD_ROW_##M0(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) 2831*c217d954SCole Faust#define LOAD_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) LOAD_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) 2832*c217d954SCole Faust 2833*c217d954SCole Faust 2834*c217d954SCole Faust 2835*c217d954SCole Faust#define LOAD_ROW_PARTIAL_1(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2836*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2837*c217d954SCole Faust (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + OFFSET + 0 * STRIDE_Y + Z##0)); 2838*c217d954SCole Faust 2839*c217d954SCole Faust#define LOAD_ROW_PARTIAL_2(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2840*c217d954SCole Faust LOAD_ROW_PARTIAL_1(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2841*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2842*c217d954SCole Faust (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + OFFSET + 1 * STRIDE_Y + Z##1)); 2843*c217d954SCole Faust 2844*c217d954SCole Faust#define LOAD_ROW_PARTIAL_3(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2845*c217d954SCole Faust LOAD_ROW_PARTIAL_2(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2846*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2847*c217d954SCole Faust (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + OFFSET + 2 * STRIDE_Y + Z##2)); 2848*c217d954SCole Faust 2849*c217d954SCole Faust#define LOAD_ROW_PARTIAL_4(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2850*c217d954SCole Faust LOAD_ROW_PARTIAL_3(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2851*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2852*c217d954SCole Faust (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + OFFSET + 3 * STRIDE_Y + Z##3)); 2853*c217d954SCole Faust 2854*c217d954SCole Faust#define LOAD_ROW_PARTIAL_5(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2855*c217d954SCole Faust LOAD_ROW_PARTIAL_4(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2856*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2857*c217d954SCole Faust (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + OFFSET + 4 * STRIDE_Y + Z##4)); 2858*c217d954SCole Faust 2859*c217d954SCole Faust#define LOAD_ROW_PARTIAL_6(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2860*c217d954SCole Faust LOAD_ROW_PARTIAL_5(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2861*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2862*c217d954SCole Faust (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + OFFSET + 5 * STRIDE_Y + Z##5)); 2863*c217d954SCole Faust 2864*c217d954SCole Faust#define LOAD_ROW_PARTIAL_7(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2865*c217d954SCole Faust LOAD_ROW_PARTIAL_6(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2866*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2867*c217d954SCole Faust (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + OFFSET + 6 * STRIDE_Y + Z##6)); 2868*c217d954SCole Faust 2869*c217d954SCole Faust#define LOAD_ROW_PARTIAL_8(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2870*c217d954SCole Faust LOAD_ROW_PARTIAL_7(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2871*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2872*c217d954SCole Faust (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + OFFSET + 7 * STRIDE_Y + Z##7)); 2873*c217d954SCole Faust 2874*c217d954SCole Faust#define LOAD_ROW_PARTIAL_9(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2875*c217d954SCole Faust LOAD_ROW_PARTIAL_8(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2876*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2877*c217d954SCole Faust (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + OFFSET + 8 * STRIDE_Y + Z##8)); 2878*c217d954SCole Faust 2879*c217d954SCole Faust#define LOAD_ROW_PARTIAL_10(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2880*c217d954SCole Faust LOAD_ROW_PARTIAL_9(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2881*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2882*c217d954SCole Faust (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + OFFSET + 9 * STRIDE_Y + Z##9)); 2883*c217d954SCole Faust 2884*c217d954SCole Faust#define LOAD_ROW_PARTIAL_11(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2885*c217d954SCole Faust LOAD_ROW_PARTIAL_10(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2886*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2887*c217d954SCole Faust (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + OFFSET + 10 * STRIDE_Y + Z##A)); 2888*c217d954SCole Faust 2889*c217d954SCole Faust#define LOAD_ROW_PARTIAL_12(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2890*c217d954SCole Faust LOAD_ROW_PARTIAL_11(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2891*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2892*c217d954SCole Faust (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + OFFSET + 11 * STRIDE_Y + Z##B)); 2893*c217d954SCole Faust 2894*c217d954SCole Faust#define LOAD_ROW_PARTIAL_13(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2895*c217d954SCole Faust LOAD_ROW_PARTIAL_12(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2896*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2897*c217d954SCole Faust (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + OFFSET + 12 * STRIDE_Y + Z##C)); 2898*c217d954SCole Faust 2899*c217d954SCole Faust#define LOAD_ROW_PARTIAL_14(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2900*c217d954SCole Faust LOAD_ROW_PARTIAL_13(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2901*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2902*c217d954SCole Faust (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + OFFSET + 13 * STRIDE_Y + Z##D)); 2903*c217d954SCole Faust 2904*c217d954SCole Faust#define LOAD_ROW_PARTIAL_15(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2905*c217d954SCole Faust LOAD_ROW_PARTIAL_14(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2906*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2907*c217d954SCole Faust (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + OFFSET + 14 * STRIDE_Y + Z##E)); 2908*c217d954SCole Faust 2909*c217d954SCole Faust#define LOAD_ROW_PARTIAL_16(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2910*c217d954SCole Faust LOAD_ROW_PARTIAL_15(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) \ 2911*c217d954SCole Faust VLOAD_PARTIAL(N0, LOAD_N0) \ 2912*c217d954SCole Faust (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + OFFSET + 15 * STRIDE_Y + Z##F)); 2913*c217d954SCole Faust 2914*c217d954SCole Faust 2915*c217d954SCole Faust 2916*c217d954SCole Faust#define LOAD_BLOCK_PARTIAL_STR(LOAD_M0, LOAD_N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) LOAD_ROW_PARTIAL_##LOAD_M0(N0, LOAD_N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) 2917*c217d954SCole Faust#define LOAD_BLOCK_PARTIAL(LOAD_M0, LOAD_N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) LOAD_BLOCK_PARTIAL_STR(LOAD_M0, LOAD_N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) 2918*c217d954SCole Faust 2919*c217d954SCole Faust#define LOAD_BLOCK_PARTIAL_IN_X_AND_Y(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 2920*c217d954SCole Faust if(!(PARTIAL_COND_X) && !(PARTIAL_COND_Y)) \ 2921*c217d954SCole Faust { \ 2922*c217d954SCole Faust LOAD_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z); \ 2923*c217d954SCole Faust } \ 2924*c217d954SCole Faust else if((PARTIAL_COND_Y) && !(PARTIAL_COND_X)) \ 2925*c217d954SCole Faust { \ 2926*c217d954SCole Faust LOAD_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z); \ 2927*c217d954SCole Faust } \ 2928*c217d954SCole Faust else if(!(PARTIAL_COND_Y) && (PARTIAL_COND_X)) \ 2929*c217d954SCole Faust { \ 2930*c217d954SCole Faust LOAD_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z); \ 2931*c217d954SCole Faust } \ 2932*c217d954SCole Faust else \ 2933*c217d954SCole Faust { \ 2934*c217d954SCole Faust LOAD_BLOCK_PARTIAL(PARTIAL_STORE_M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z); \ 2935*c217d954SCole Faust } 2936*c217d954SCole Faust 2937*c217d954SCole Faust#define LOAD_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) \ 2938*c217d954SCole Faust if(!(PARTIAL_COND_X)) \ 2939*c217d954SCole Faust { \ 2940*c217d954SCole Faust LOAD_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z); \ 2941*c217d954SCole Faust } \ 2942*c217d954SCole Faust else \ 2943*c217d954SCole Faust { \ 2944*c217d954SCole Faust LOAD_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z); \ 2945*c217d954SCole Faust } 2946*c217d954SCole Faust 2947*c217d954SCole Faust#define LOAD_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) \ 2948*c217d954SCole Faust if(!(PARTIAL_COND_Y)) \ 2949*c217d954SCole Faust { \ 2950*c217d954SCole Faust LOAD_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z); \ 2951*c217d954SCole Faust } \ 2952*c217d954SCole Faust else \ 2953*c217d954SCole Faust { \ 2954*c217d954SCole Faust LOAD_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z); \ 2955*c217d954SCole Faust } 2956*c217d954SCole Faust 2957*c217d954SCole Faust 2958*c217d954SCole Faust#if PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 == 0 2959*c217d954SCole Faust 2960*c217d954SCole Faust#define LOAD_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 2961*c217d954SCole Faust LOAD_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z) 2962*c217d954SCole Faust 2963*c217d954SCole Faust#elif PARTIAL_STORE_M0 > 0 && PARTIAL_STORE_N0 == 0 2964*c217d954SCole Faust 2965*c217d954SCole Faust#define LOAD_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 2966*c217d954SCole Faust REPEAT_VAR_INIT_TO_CONST(M0, VEC_DATA_TYPE(DATA_TYPE, N0), BASENAME, 0); \ 2967*c217d954SCole Faust LOAD_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) 2968*c217d954SCole Faust 2969*c217d954SCole Faust#elif PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 > 0 2970*c217d954SCole Faust 2971*c217d954SCole Faust#define LOAD_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 2972*c217d954SCole Faust REPEAT_VAR_INIT_TO_CONST(M0, VEC_DATA_TYPE(DATA_TYPE, N0), BASENAME, 0); \ 2973*c217d954SCole Faust LOAD_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) 2974*c217d954SCole Faust 2975*c217d954SCole Faust#else 2976*c217d954SCole Faust 2977*c217d954SCole Faust#define LOAD_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \ 2978*c217d954SCole Faust REPEAT_VAR_INIT_TO_CONST(M0, VEC_DATA_TYPE(DATA_TYPE, N0), BASENAME, 0); \ 2979*c217d954SCole Faust LOAD_BLOCK_PARTIAL_IN_X_AND_Y(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) 2980*c217d954SCole Faust 2981*c217d954SCole Faust#endif 2982*c217d954SCole Faust 2983*c217d954SCole Faust 2984*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_1(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 2985*c217d954SCole Faust BASENAME##0 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 0 * X_STEP_ROW), (Y_COORD + 0 * Y_STEP_ROW)) 2986*c217d954SCole Faust 2987*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_2(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 2988*c217d954SCole Faust LOAD_TEXTURE2D_ROW_1(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 2989*c217d954SCole Faust BASENAME##1 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 1 * X_STEP_ROW), (Y_COORD + 1 * Y_STEP_ROW)) 2990*c217d954SCole Faust 2991*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_3(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 2992*c217d954SCole Faust LOAD_TEXTURE2D_ROW_2(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 2993*c217d954SCole Faust BASENAME##2 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 2 * X_STEP_ROW), (Y_COORD + 2 * Y_STEP_ROW)) 2994*c217d954SCole Faust 2995*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_4(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 2996*c217d954SCole Faust LOAD_TEXTURE2D_ROW_3(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 2997*c217d954SCole Faust BASENAME##3 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 3 * X_STEP_ROW), (Y_COORD + 3 * Y_STEP_ROW)) 2998*c217d954SCole Faust 2999*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_5(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3000*c217d954SCole Faust LOAD_TEXTURE2D_ROW_4(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3001*c217d954SCole Faust BASENAME##4 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 4 * X_STEP_ROW), (Y_COORD + 4 * Y_STEP_ROW)) 3002*c217d954SCole Faust 3003*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_6(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3004*c217d954SCole Faust LOAD_TEXTURE2D_ROW_5(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3005*c217d954SCole Faust BASENAME##5 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 5 * X_STEP_ROW), (Y_COORD + 5 * Y_STEP_ROW)) 3006*c217d954SCole Faust 3007*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_7(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3008*c217d954SCole Faust LOAD_TEXTURE2D_ROW_6(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3009*c217d954SCole Faust BASENAME##6 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 6 * X_STEP_ROW), (Y_COORD + 6 * Y_STEP_ROW)) 3010*c217d954SCole Faust 3011*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_8(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3012*c217d954SCole Faust LOAD_TEXTURE2D_ROW_7(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3013*c217d954SCole Faust BASENAME##7 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 7 * X_STEP_ROW), (Y_COORD + 7 * Y_STEP_ROW)) 3014*c217d954SCole Faust 3015*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_9(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3016*c217d954SCole Faust LOAD_TEXTURE2D_ROW_8(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3017*c217d954SCole Faust BASENAME##8 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 8 * X_STEP_ROW), (Y_COORD + 8 * Y_STEP_ROW)) 3018*c217d954SCole Faust 3019*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_10(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3020*c217d954SCole Faust LOAD_TEXTURE2D_ROW_9(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3021*c217d954SCole Faust BASENAME##9 = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 9 * X_STEP_ROW), (Y_COORD + 9 * Y_STEP_ROW)) 3022*c217d954SCole Faust 3023*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_11(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3024*c217d954SCole Faust LOAD_TEXTURE2D_ROW_10(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3025*c217d954SCole Faust BASENAME##A = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 10 * X_STEP_ROW), (Y_COORD + 10 * Y_STEP_ROW)) 3026*c217d954SCole Faust 3027*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_12(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3028*c217d954SCole Faust LOAD_TEXTURE2D_ROW_11(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3029*c217d954SCole Faust BASENAME##B = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 11 * X_STEP_ROW), (Y_COORD + 11 * Y_STEP_ROW)) 3030*c217d954SCole Faust 3031*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_13(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3032*c217d954SCole Faust LOAD_TEXTURE2D_ROW_12(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3033*c217d954SCole Faust BASENAME##C = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 12 * X_STEP_ROW), (Y_COORD + 12 * Y_STEP_ROW)) 3034*c217d954SCole Faust 3035*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_14(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3036*c217d954SCole Faust LOAD_TEXTURE2D_ROW_13(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3037*c217d954SCole Faust BASENAME##D = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 13 * X_STEP_ROW), (Y_COORD + 13 * Y_STEP_ROW)) 3038*c217d954SCole Faust 3039*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_15(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3040*c217d954SCole Faust LOAD_TEXTURE2D_ROW_14(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3041*c217d954SCole Faust BASENAME##E = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 14 * X_STEP_ROW), (Y_COORD + 14 * Y_STEP_ROW)) 3042*c217d954SCole Faust 3043*c217d954SCole Faust#define LOAD_TEXTURE2D_ROW_16(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3044*c217d954SCole Faust LOAD_TEXTURE2D_ROW_15(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) \ 3045*c217d954SCole Faust BASENAME##F = READ_IMAGE2D(DATA_TYPE, N0, IMG, (X_COORD + 15 * X_STEP_ROW), (Y_COORD + 15 * Y_STEP_ROW)) 3046*c217d954SCole Faust 3047*c217d954SCole Faust 3048*c217d954SCole Faust 3049*c217d954SCole Faust#define LOAD_TEXTURE2D_STR(M0, N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) LOAD_TEXTURE2D_ROW_##M0(N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) 3050*c217d954SCole Faust#define LOAD_TEXTURE2D(M0, N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) LOAD_TEXTURE2D_STR(M0, N0, DATA_TYPE, BASENAME, IMG, X_COORD, Y_COORD, X_STEP_ROW, Y_STEP_ROW) 3051*c217d954SCole Faust 3052*c217d954SCole Faust 3053*c217d954SCole Faust 3054*c217d954SCole Faust#define LOAD_ROW_INDIRECT_1(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3055*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3056*c217d954SCole Faust BASENAME##0; \ 3057*c217d954SCole Faust if(Y_MASK##0 != 0) \ 3058*c217d954SCole Faust BASENAME##0 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##0 * STRIDE_Y)); \ 3059*c217d954SCole Faust else \ 3060*c217d954SCole Faust BASENAME##0 = 0; 3061*c217d954SCole Faust 3062*c217d954SCole Faust#define LOAD_ROW_INDIRECT_2(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3063*c217d954SCole Faust LOAD_ROW_INDIRECT_1(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3064*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3065*c217d954SCole Faust BASENAME##1; \ 3066*c217d954SCole Faust if(Y_MASK##1 != 0) \ 3067*c217d954SCole Faust BASENAME##1 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##1 * STRIDE_Y)); \ 3068*c217d954SCole Faust else \ 3069*c217d954SCole Faust BASENAME##1 = 0; 3070*c217d954SCole Faust 3071*c217d954SCole Faust#define LOAD_ROW_INDIRECT_3(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3072*c217d954SCole Faust LOAD_ROW_INDIRECT_2(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3073*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3074*c217d954SCole Faust BASENAME##2; \ 3075*c217d954SCole Faust if(Y_MASK##2 != 0) \ 3076*c217d954SCole Faust BASENAME##2 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##2 * STRIDE_Y)); \ 3077*c217d954SCole Faust else \ 3078*c217d954SCole Faust BASENAME##2 = 0; 3079*c217d954SCole Faust 3080*c217d954SCole Faust#define LOAD_ROW_INDIRECT_4(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3081*c217d954SCole Faust LOAD_ROW_INDIRECT_3(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3082*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3083*c217d954SCole Faust BASENAME##3; \ 3084*c217d954SCole Faust if(Y_MASK##3 != 0) \ 3085*c217d954SCole Faust BASENAME##3 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##3 * STRIDE_Y)); \ 3086*c217d954SCole Faust else \ 3087*c217d954SCole Faust BASENAME##3 = 0; 3088*c217d954SCole Faust 3089*c217d954SCole Faust#define LOAD_ROW_INDIRECT_5(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3090*c217d954SCole Faust LOAD_ROW_INDIRECT_4(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3091*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3092*c217d954SCole Faust BASENAME##4; \ 3093*c217d954SCole Faust if(Y_MASK##4 != 0) \ 3094*c217d954SCole Faust BASENAME##4 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##4 * STRIDE_Y)); \ 3095*c217d954SCole Faust else \ 3096*c217d954SCole Faust BASENAME##4 = 0; 3097*c217d954SCole Faust 3098*c217d954SCole Faust#define LOAD_ROW_INDIRECT_6(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3099*c217d954SCole Faust LOAD_ROW_INDIRECT_5(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3100*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3101*c217d954SCole Faust BASENAME##5; \ 3102*c217d954SCole Faust if(Y_MASK##5 != 0) \ 3103*c217d954SCole Faust BASENAME##5 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##5 * STRIDE_Y)); \ 3104*c217d954SCole Faust else \ 3105*c217d954SCole Faust BASENAME##5 = 0; 3106*c217d954SCole Faust 3107*c217d954SCole Faust#define LOAD_ROW_INDIRECT_7(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3108*c217d954SCole Faust LOAD_ROW_INDIRECT_6(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3109*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3110*c217d954SCole Faust BASENAME##6; \ 3111*c217d954SCole Faust if(Y_MASK##6 != 0) \ 3112*c217d954SCole Faust BASENAME##6 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##6 * STRIDE_Y)); \ 3113*c217d954SCole Faust else \ 3114*c217d954SCole Faust BASENAME##6 = 0; 3115*c217d954SCole Faust 3116*c217d954SCole Faust#define LOAD_ROW_INDIRECT_8(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3117*c217d954SCole Faust LOAD_ROW_INDIRECT_7(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3118*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3119*c217d954SCole Faust BASENAME##7; \ 3120*c217d954SCole Faust if(Y_MASK##7 != 0) \ 3121*c217d954SCole Faust BASENAME##7 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##7 * STRIDE_Y)); \ 3122*c217d954SCole Faust else \ 3123*c217d954SCole Faust BASENAME##7 = 0; 3124*c217d954SCole Faust 3125*c217d954SCole Faust#define LOAD_ROW_INDIRECT_9(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3126*c217d954SCole Faust LOAD_ROW_INDIRECT_8(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3127*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3128*c217d954SCole Faust BASENAME##8; \ 3129*c217d954SCole Faust if(Y_MASK##8 != 0) \ 3130*c217d954SCole Faust BASENAME##8 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##8 * STRIDE_Y)); \ 3131*c217d954SCole Faust else \ 3132*c217d954SCole Faust BASENAME##8 = 0; 3133*c217d954SCole Faust 3134*c217d954SCole Faust#define LOAD_ROW_INDIRECT_10(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3135*c217d954SCole Faust LOAD_ROW_INDIRECT_9(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3136*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3137*c217d954SCole Faust BASENAME##9; \ 3138*c217d954SCole Faust if(Y_MASK##9 != 0) \ 3139*c217d954SCole Faust BASENAME##9 = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##9 * STRIDE_Y)); \ 3140*c217d954SCole Faust else \ 3141*c217d954SCole Faust BASENAME##9 = 0; 3142*c217d954SCole Faust 3143*c217d954SCole Faust#define LOAD_ROW_INDIRECT_11(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3144*c217d954SCole Faust LOAD_ROW_INDIRECT_10(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3145*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3146*c217d954SCole Faust BASENAME##A; \ 3147*c217d954SCole Faust if(Y_MASK##A != 0) \ 3148*c217d954SCole Faust BASENAME##A = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##A * STRIDE_Y)); \ 3149*c217d954SCole Faust else \ 3150*c217d954SCole Faust BASENAME##A = 0; 3151*c217d954SCole Faust 3152*c217d954SCole Faust#define LOAD_ROW_INDIRECT_12(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3153*c217d954SCole Faust LOAD_ROW_INDIRECT_11(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3154*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3155*c217d954SCole Faust BASENAME##B; \ 3156*c217d954SCole Faust if(Y_MASK##B != 0) \ 3157*c217d954SCole Faust BASENAME##B = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##B * STRIDE_Y)); \ 3158*c217d954SCole Faust else \ 3159*c217d954SCole Faust BASENAME##B = 0; 3160*c217d954SCole Faust 3161*c217d954SCole Faust#define LOAD_ROW_INDIRECT_13(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3162*c217d954SCole Faust LOAD_ROW_INDIRECT_12(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3163*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3164*c217d954SCole Faust BASENAME##C; \ 3165*c217d954SCole Faust if(Y_MASK##C != 0) \ 3166*c217d954SCole Faust BASENAME##C = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##C * STRIDE_Y)); \ 3167*c217d954SCole Faust else \ 3168*c217d954SCole Faust BASENAME##C = 0; 3169*c217d954SCole Faust 3170*c217d954SCole Faust#define LOAD_ROW_INDIRECT_14(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3171*c217d954SCole Faust LOAD_ROW_INDIRECT_13(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3172*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3173*c217d954SCole Faust BASENAME##D; \ 3174*c217d954SCole Faust if(Y_MASK##D != 0) \ 3175*c217d954SCole Faust BASENAME##D = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##D * STRIDE_Y)); \ 3176*c217d954SCole Faust else \ 3177*c217d954SCole Faust BASENAME##D = 0; 3178*c217d954SCole Faust 3179*c217d954SCole Faust#define LOAD_ROW_INDIRECT_15(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3180*c217d954SCole Faust LOAD_ROW_INDIRECT_14(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3181*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3182*c217d954SCole Faust BASENAME##E; \ 3183*c217d954SCole Faust if(Y_MASK##E != 0) \ 3184*c217d954SCole Faust BASENAME##E = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##E * STRIDE_Y)); \ 3185*c217d954SCole Faust else \ 3186*c217d954SCole Faust BASENAME##E = 0; 3187*c217d954SCole Faust 3188*c217d954SCole Faust#define LOAD_ROW_INDIRECT_16(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3189*c217d954SCole Faust LOAD_ROW_INDIRECT_15(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) \ 3190*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3191*c217d954SCole Faust BASENAME##F; \ 3192*c217d954SCole Faust if(Y_MASK##F != 0) \ 3193*c217d954SCole Faust BASENAME##F = VLOAD(N0)(0, (__global DATA_TYPE *)(PTR + OFFSET + Y##F * STRIDE_Y)); \ 3194*c217d954SCole Faust else \ 3195*c217d954SCole Faust BASENAME##F = 0; 3196*c217d954SCole Faust 3197*c217d954SCole Faust 3198*c217d954SCole Faust#define LOAD_BLOCK_INDIRECT_STR(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) LOAD_ROW_INDIRECT_##M0(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) 3199*c217d954SCole Faust#define LOAD_BLOCK_INDIRECT(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) LOAD_BLOCK_INDIRECT_STR(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y, Y, Y_MASK) 3200*c217d954SCole Faust 3201*c217d954SCole Faust 3202*c217d954SCole Faust#define LOAD_ELEMENT_1(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3203*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3204*c217d954SCole Faust BASENAME##0 = *((__global DATA_TYPE *)(PTR + OFFSET + 0 * STRIDE_Y)); 3205*c217d954SCole Faust 3206*c217d954SCole Faust#define LOAD_ELEMENT_2(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3207*c217d954SCole Faust LOAD_ELEMENT_1(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3208*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3209*c217d954SCole Faust BASENAME##1 = *((__global DATA_TYPE *)(PTR + OFFSET + 1 * STRIDE_Y)); 3210*c217d954SCole Faust 3211*c217d954SCole Faust#define LOAD_ELEMENT_3(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3212*c217d954SCole Faust LOAD_ELEMENT_2(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3213*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3214*c217d954SCole Faust BASENAME##2 = *((__global DATA_TYPE *)(PTR + OFFSET + 2 * STRIDE_Y)); 3215*c217d954SCole Faust 3216*c217d954SCole Faust#define LOAD_ELEMENT_4(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3217*c217d954SCole Faust LOAD_ELEMENT_3(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3218*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3219*c217d954SCole Faust BASENAME##3 = *((__global DATA_TYPE *)(PTR + OFFSET + 3 * STRIDE_Y)); 3220*c217d954SCole Faust 3221*c217d954SCole Faust#define LOAD_ELEMENT_5(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3222*c217d954SCole Faust LOAD_ELEMENT_4(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3223*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3224*c217d954SCole Faust BASENAME##4 = *((__global DATA_TYPE *)(PTR + OFFSET + 4 * STRIDE_Y)); 3225*c217d954SCole Faust 3226*c217d954SCole Faust#define LOAD_ELEMENT_6(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3227*c217d954SCole Faust LOAD_ELEMENT_5(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3228*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3229*c217d954SCole Faust BASENAME##5 = *((__global DATA_TYPE *)(PTR + OFFSET + 5 * STRIDE_Y)); 3230*c217d954SCole Faust 3231*c217d954SCole Faust#define LOAD_ELEMENT_7(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3232*c217d954SCole Faust LOAD_ELEMENT_6(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3233*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3234*c217d954SCole Faust BASENAME##6 = *((__global DATA_TYPE *)(PTR + OFFSET + 6 * STRIDE_Y)); 3235*c217d954SCole Faust 3236*c217d954SCole Faust#define LOAD_ELEMENT_8(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3237*c217d954SCole Faust LOAD_ELEMENT_7(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3238*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3239*c217d954SCole Faust BASENAME##7 = *((__global DATA_TYPE *)(PTR + OFFSET + 7 * STRIDE_Y)); 3240*c217d954SCole Faust 3241*c217d954SCole Faust#define LOAD_ELEMENT_9(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3242*c217d954SCole Faust LOAD_ELEMENT_8(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3243*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3244*c217d954SCole Faust BASENAME##8 = *((__global DATA_TYPE *)(PTR + OFFSET + 8 * STRIDE_Y)); 3245*c217d954SCole Faust 3246*c217d954SCole Faust#define LOAD_ELEMENT_10(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3247*c217d954SCole Faust LOAD_ELEMENT_9(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3248*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3249*c217d954SCole Faust BASENAME##9 = *((__global DATA_TYPE *)(PTR + OFFSET + 9 * STRIDE_Y)); 3250*c217d954SCole Faust 3251*c217d954SCole Faust#define LOAD_ELEMENT_11(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3252*c217d954SCole Faust LOAD_ELEMENT_10(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3253*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3254*c217d954SCole Faust BASENAME##A = *((__global DATA_TYPE *)(PTR + OFFSET + 10 * STRIDE_Y)); 3255*c217d954SCole Faust 3256*c217d954SCole Faust#define LOAD_ELEMENT_12(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3257*c217d954SCole Faust LOAD_ELEMENT_11(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3258*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3259*c217d954SCole Faust BASENAME##B = *((__global DATA_TYPE *)(PTR + OFFSET + 11 * STRIDE_Y)); 3260*c217d954SCole Faust 3261*c217d954SCole Faust#define LOAD_ELEMENT_13(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3262*c217d954SCole Faust LOAD_ELEMENT_12(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3263*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3264*c217d954SCole Faust BASENAME##C = *((__global DATA_TYPE *)(PTR + OFFSET + 12 * STRIDE_Y)); 3265*c217d954SCole Faust 3266*c217d954SCole Faust#define LOAD_ELEMENT_14(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3267*c217d954SCole Faust LOAD_ELEMENT_13(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3268*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3269*c217d954SCole Faust BASENAME##D = *((__global DATA_TYPE *)(PTR + OFFSET + 13 * STRIDE_Y)); 3270*c217d954SCole Faust 3271*c217d954SCole Faust#define LOAD_ELEMENT_15(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3272*c217d954SCole Faust LOAD_ELEMENT_14(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3273*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3274*c217d954SCole Faust BASENAME##E = *((__global DATA_TYPE *)(PTR + OFFSET + 14 * STRIDE_Y)); 3275*c217d954SCole Faust 3276*c217d954SCole Faust#define LOAD_ELEMENT_16(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3277*c217d954SCole Faust LOAD_ELEMENT_15(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) \ 3278*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N0) \ 3279*c217d954SCole Faust BASENAME##F = *((__global DATA_TYPE *)(PTR + OFFSET + 15 * STRIDE_Y)); 3280*c217d954SCole Faust 3281*c217d954SCole Faust 3282*c217d954SCole Faust 3283*c217d954SCole Faust 3284*c217d954SCole Faust#define LOAD_SCALAR_AS_VECTOR_STR(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) LOAD_ELEMENT_##M0(N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) 3285*c217d954SCole Faust#define LOAD_SCALAR_AS_VECTOR(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) LOAD_SCALAR_AS_VECTOR_STR(M0, N0, DATA_TYPE, BASENAME, PTR, OFFSET, STRIDE_Y) 3286*c217d954SCole Faust 3287*c217d954SCole Faust 3288*c217d954SCole Faust 3289*c217d954SCole Faust#define CALCULATE_Z_OFFSET_1(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3290*c217d954SCole Faust Z##0 = (0 + (DATA_TYPE)(Y)) / (DATA_TYPE)HEIGHT_GEMM3D; \ 3291*c217d954SCole Faust Z##0 = min((DATA_TYPE)(DEPTH_GEMM3D - 1), Z##0); \ 3292*c217d954SCole Faust Z##0 *= (CROSS_PLANE_PAD * STRIDE_Y); 3293*c217d954SCole Faust 3294*c217d954SCole Faust#define CALCULATE_Z_OFFSET_2(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3295*c217d954SCole Faust CALCULATE_Z_OFFSET_1(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3296*c217d954SCole Faust Z##1 = (1 + (DATA_TYPE)(Y)) / (DATA_TYPE)HEIGHT_GEMM3D; \ 3297*c217d954SCole Faust Z##1 = min((DATA_TYPE)(DEPTH_GEMM3D - 1), Z##1); \ 3298*c217d954SCole Faust Z##1 *= (CROSS_PLANE_PAD * STRIDE_Y); 3299*c217d954SCole Faust 3300*c217d954SCole Faust#define CALCULATE_Z_OFFSET_3(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3301*c217d954SCole Faust CALCULATE_Z_OFFSET_2(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3302*c217d954SCole Faust Z##2 = (2 + (DATA_TYPE)(Y)) / (DATA_TYPE)HEIGHT_GEMM3D; \ 3303*c217d954SCole Faust Z##2 = min((DATA_TYPE)(DEPTH_GEMM3D - 1), Z##2); \ 3304*c217d954SCole Faust Z##2 *= (CROSS_PLANE_PAD * STRIDE_Y); 3305*c217d954SCole Faust 3306*c217d954SCole Faust#define CALCULATE_Z_OFFSET_4(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3307*c217d954SCole Faust CALCULATE_Z_OFFSET_3(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3308*c217d954SCole Faust Z##3 = (3 + (DATA_TYPE)(Y)) / (DATA_TYPE)HEIGHT_GEMM3D; \ 3309*c217d954SCole Faust Z##3 = min((DATA_TYPE)(DEPTH_GEMM3D - 1), Z##3); \ 3310*c217d954SCole Faust Z##3 *= (CROSS_PLANE_PAD * STRIDE_Y); 3311*c217d954SCole Faust 3312*c217d954SCole Faust#define CALCULATE_Z_OFFSET_5(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3313*c217d954SCole Faust CALCULATE_Z_OFFSET_4(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3314*c217d954SCole Faust Z##4 = (4 + (DATA_TYPE)(Y)) / (DATA_TYPE)HEIGHT_GEMM3D; \ 3315*c217d954SCole Faust Z##4 = min((DATA_TYPE)(DEPTH_GEMM3D - 1), Z##4); \ 3316*c217d954SCole Faust Z##4 *= (CROSS_PLANE_PAD * STRIDE_Y); 3317*c217d954SCole Faust 3318*c217d954SCole Faust#define CALCULATE_Z_OFFSET_6(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3319*c217d954SCole Faust CALCULATE_Z_OFFSET_5(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3320*c217d954SCole Faust Z##5 = (5 + (DATA_TYPE)(Y)) / (DATA_TYPE)HEIGHT_GEMM3D; \ 3321*c217d954SCole Faust Z##5 = min((DATA_TYPE)(DEPTH_GEMM3D - 1), Z##5); \ 3322*c217d954SCole Faust Z##5 *= (CROSS_PLANE_PAD * STRIDE_Y); 3323*c217d954SCole Faust 3324*c217d954SCole Faust#define CALCULATE_Z_OFFSET_7(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3325*c217d954SCole Faust CALCULATE_Z_OFFSET_6(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3326*c217d954SCole Faust Z##6 = (6 + (DATA_TYPE)(Y)) / (DATA_TYPE)HEIGHT_GEMM3D; \ 3327*c217d954SCole Faust Z##6 = min((DATA_TYPE)(DEPTH_GEMM3D - 1), Z##6); \ 3328*c217d954SCole Faust Z##6 *= (CROSS_PLANE_PAD * STRIDE_Y); 3329*c217d954SCole Faust 3330*c217d954SCole Faust#define CALCULATE_Z_OFFSET_8(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3331*c217d954SCole Faust CALCULATE_Z_OFFSET_7(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) \ 3332*c217d954SCole Faust Z##7 = (7 + (DATA_TYPE)(Y)) / (DATA_TYPE)HEIGHT_GEMM3D; \ 3333*c217d954SCole Faust Z##7 = min((DATA_TYPE)(DEPTH_GEMM3D - 1), Z##7); \ 3334*c217d954SCole Faust Z##7 *= (CROSS_PLANE_PAD * STRIDE_Y); 3335*c217d954SCole Faust 3336*c217d954SCole Faust 3337*c217d954SCole Faust 3338*c217d954SCole Faust 3339*c217d954SCole Faust#define CALCULATE_Z_OFFSET_STR(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) CALCULATE_Z_OFFSET_##M0(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) 3340*c217d954SCole Faust#define CALCULATE_Z_OFFSET(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) CALCULATE_Z_OFFSET_STR(M0, DATA_TYPE, Z, Y, HEIGHT_GEMM3D, DEPTH_GEMM3D, CROSS_PLANE_PAD, STRIDE_Y) 3341*c217d954SCole Faust 3342*c217d954SCole Faust 3343*c217d954SCole Faust 3344*c217d954SCole Faust#define SCALE_ROW_1(DATA_TYPE, BASENAME, SCALE) \ 3345*c217d954SCole Faust BASENAME##0 *= (DATA_TYPE)SCALE; 3346*c217d954SCole Faust 3347*c217d954SCole Faust#define SCALE_ROW_2(DATA_TYPE, BASENAME, SCALE) \ 3348*c217d954SCole Faust SCALE_ROW_1(DATA_TYPE, BASENAME, SCALE) \ 3349*c217d954SCole Faust BASENAME##1 *= (DATA_TYPE)SCALE; 3350*c217d954SCole Faust 3351*c217d954SCole Faust#define SCALE_ROW_3(DATA_TYPE, BASENAME, SCALE) \ 3352*c217d954SCole Faust SCALE_ROW_2(DATA_TYPE, BASENAME, SCALE) \ 3353*c217d954SCole Faust BASENAME##2 *= (DATA_TYPE)SCALE; 3354*c217d954SCole Faust 3355*c217d954SCole Faust#define SCALE_ROW_4(DATA_TYPE, BASENAME, SCALE) \ 3356*c217d954SCole Faust SCALE_ROW_3(DATA_TYPE, BASENAME, SCALE) \ 3357*c217d954SCole Faust BASENAME##3 *= (DATA_TYPE)SCALE; 3358*c217d954SCole Faust 3359*c217d954SCole Faust#define SCALE_ROW_5(DATA_TYPE, BASENAME, SCALE) \ 3360*c217d954SCole Faust SCALE_ROW_4(DATA_TYPE, BASENAME, SCALE) \ 3361*c217d954SCole Faust BASENAME##4 *= (DATA_TYPE)SCALE; 3362*c217d954SCole Faust 3363*c217d954SCole Faust#define SCALE_ROW_6(DATA_TYPE, BASENAME, SCALE) \ 3364*c217d954SCole Faust SCALE_ROW_5(DATA_TYPE, BASENAME, SCALE) \ 3365*c217d954SCole Faust BASENAME##5 *= (DATA_TYPE)SCALE; 3366*c217d954SCole Faust 3367*c217d954SCole Faust#define SCALE_ROW_7(DATA_TYPE, BASENAME, SCALE) \ 3368*c217d954SCole Faust SCALE_ROW_6(DATA_TYPE, BASENAME, SCALE) \ 3369*c217d954SCole Faust BASENAME##6 *= (DATA_TYPE)SCALE; 3370*c217d954SCole Faust 3371*c217d954SCole Faust#define SCALE_ROW_8(DATA_TYPE, BASENAME, SCALE) \ 3372*c217d954SCole Faust SCALE_ROW_7(DATA_TYPE, BASENAME, SCALE) \ 3373*c217d954SCole Faust BASENAME##7 *= (DATA_TYPE)SCALE; 3374*c217d954SCole Faust 3375*c217d954SCole Faust#define SCALE_ROW_9(DATA_TYPE, BASENAME, SCALE) \ 3376*c217d954SCole Faust SCALE_ROW_8(DATA_TYPE, BASENAME, SCALE) \ 3377*c217d954SCole Faust BASENAME##8 *= (DATA_TYPE)SCALE; 3378*c217d954SCole Faust 3379*c217d954SCole Faust#define SCALE_ROW_10(DATA_TYPE, BASENAME, SCALE) \ 3380*c217d954SCole Faust SCALE_ROW_9(DATA_TYPE, BASENAME, SCALE) \ 3381*c217d954SCole Faust BASENAME##9 *= (DATA_TYPE)SCALE; 3382*c217d954SCole Faust 3383*c217d954SCole Faust#define SCALE_ROW_11(DATA_TYPE, BASENAME, SCALE) \ 3384*c217d954SCole Faust SCALE_ROW_10(DATA_TYPE, BASENAME, SCALE) \ 3385*c217d954SCole Faust BASENAME##A *= (DATA_TYPE)SCALE; 3386*c217d954SCole Faust 3387*c217d954SCole Faust#define SCALE_ROW_12(DATA_TYPE, BASENAME, SCALE) \ 3388*c217d954SCole Faust SCALE_ROW_11(DATA_TYPE, BASENAME, SCALE) \ 3389*c217d954SCole Faust BASENAME##B *= (DATA_TYPE)SCALE; 3390*c217d954SCole Faust 3391*c217d954SCole Faust#define SCALE_ROW_13(DATA_TYPE, BASENAME, SCALE) \ 3392*c217d954SCole Faust SCALE_ROW_12(DATA_TYPE, BASENAME, SCALE) \ 3393*c217d954SCole Faust BASENAME##C *= (DATA_TYPE)SCALE; 3394*c217d954SCole Faust 3395*c217d954SCole Faust#define SCALE_ROW_14(DATA_TYPE, BASENAME, SCALE) \ 3396*c217d954SCole Faust SCALE_ROW_13(DATA_TYPE, BASENAME, SCALE) \ 3397*c217d954SCole Faust BASENAME##D *= (DATA_TYPE)SCALE; 3398*c217d954SCole Faust 3399*c217d954SCole Faust#define SCALE_ROW_15(DATA_TYPE, BASENAME, SCALE) \ 3400*c217d954SCole Faust SCALE_ROW_14(DATA_TYPE, BASENAME, SCALE) \ 3401*c217d954SCole Faust BASENAME##E *= (DATA_TYPE)SCALE; 3402*c217d954SCole Faust 3403*c217d954SCole Faust#define SCALE_ROW_16(DATA_TYPE, BASENAME, SCALE) \ 3404*c217d954SCole Faust SCALE_ROW_15(DATA_TYPE, BASENAME, SCALE) \ 3405*c217d954SCole Faust BASENAME##F *= (DATA_TYPE)SCALE; 3406*c217d954SCole Faust 3407*c217d954SCole Faust 3408*c217d954SCole Faust 3409*c217d954SCole Faust#define SCALE_BLOCK_STR(N, DATA_TYPE, BASENAME, SCALE) SCALE_ROW_##N(DATA_TYPE, BASENAME, SCALE) 3410*c217d954SCole Faust#define SCALE_BLOCK(N, DATA_TYPE, BASENAME, SCALE) SCALE_BLOCK_STR(N, DATA_TYPE, BASENAME, SCALE) 3411*c217d954SCole Faust 3412*c217d954SCole Faust 3413*c217d954SCole Faust 3414*c217d954SCole Faust#define COLUMN_VECTOR1(IDX_COL, BASENAME, X, TYPE) \ 3415*c217d954SCole Faust TYPE BASENAME##IDX_COL = (TYPE)((X##0).s##IDX_COL); 3416*c217d954SCole Faust#define COLUMN_VECTOR2(IDX_COL, BASENAME, X, TYPE) \ 3417*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 2) \ 3418*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 2))((X##0).s##IDX_COL, (X##1).s##IDX_COL); 3419*c217d954SCole Faust#define COLUMN_VECTOR3(IDX_COL, BASENAME, X, TYPE) \ 3420*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 3) \ 3421*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 3))((X##0).s##IDX_COL, (X##1).s##IDX_COL, (X##2).s##IDX_COL); 3422*c217d954SCole Faust#define COLUMN_VECTOR4(IDX_COL, BASENAME, X, TYPE) \ 3423*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 4) \ 3424*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 4))((X##0).s##IDX_COL, (X##1).s##IDX_COL, (X##2).s##IDX_COL, (X##3).s##IDX_COL); 3425*c217d954SCole Faust#define COLUMN_VECTOR8(IDX_COL, BASENAME, X, TYPE) \ 3426*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 8) \ 3427*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 8))((X##0).s##IDX_COL, (X##1).s##IDX_COL, (X##2).s##IDX_COL, (X##3).s##IDX_COL, (X##4).s##IDX_COL, (X##5).s##IDX_COL, (X##6).s##IDX_COL, (X##7).s##IDX_COL); 3428*c217d954SCole Faust#define COLUMN_VECTOR16(IDX_COL, BASENAME, X, TYPE) \ 3429*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 16) \ 3430*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 16))((X##0).s##IDX_COL, (X##1).s##IDX_COL, (X##2).s##IDX_COL, (X##3).s##IDX_COL, (X##4).s##IDX_COL, (X##5).s##IDX_COL, (X##6).s##IDX_COL, (X##7).s##IDX_COL, (X##8).s##IDX_COL, (X##9).s##IDX_COL, (X##A).s##IDX_COL, (X##B).s##IDX_COL, (X##C).s##IDX_COL, (X##D).s##IDX_COL, (X##E).s##IDX_COL, (X##F).s##IDX_COL); 3431*c217d954SCole Faust 3432*c217d954SCole Faust 3433*c217d954SCole Faust 3434*c217d954SCole Faust#define COLUMN_VECTOR_SCALAR1(IDX_COL, BASENAME, X, TYPE) \ 3435*c217d954SCole Faust TYPE BASENAME##IDX_COL = (TYPE)((X##0)); 3436*c217d954SCole Faust#define COLUMN_VECTOR_SCALAR2(IDX_COL, BASENAME, X, TYPE) \ 3437*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 2) \ 3438*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 2))((X##0), (X##1)); 3439*c217d954SCole Faust#define COLUMN_VECTOR_SCALAR3(IDX_COL, BASENAME, X, TYPE) \ 3440*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 3) \ 3441*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 3))((X##0), (X##1), (X##2)); 3442*c217d954SCole Faust#define COLUMN_VECTOR_SCALAR4(IDX_COL, BASENAME, X, TYPE) \ 3443*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 4) \ 3444*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 4))((X##0), (X##1), (X##2), (X##3)); 3445*c217d954SCole Faust#define COLUMN_VECTOR_SCALAR8(IDX_COL, BASENAME, X, TYPE) \ 3446*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 8) \ 3447*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 8))((X##0), (X##1), (X##2), (X##3), (X##4), (X##5), (X##6), (X##7)); 3448*c217d954SCole Faust#define COLUMN_VECTOR_SCALAR16(IDX_COL, BASENAME, X, TYPE) \ 3449*c217d954SCole Faust VEC_DATA_TYPE(TYPE, 16) \ 3450*c217d954SCole Faust BASENAME##IDX_COL = (VEC_DATA_TYPE(TYPE, 16))((X##0), (X##1), (X##2), (X##3), (X##4), (X##5), (X##6), (X##7), (X##8), (X##9), (X##A), (X##B), (X##C), (X##D), (X##E), (X##F)); 3451*c217d954SCole Faust 3452*c217d954SCole Faust 3453*c217d954SCole Faust 3454*c217d954SCole Faust#define TRANSPOSE_K0X1(K0, BASENAME, BS, TYPE) \ 3455*c217d954SCole Faust COLUMN_VECTOR_SCALAR(K0, 0, BASENAME, BS, TYPE); 3456*c217d954SCole Faust#define TRANSPOSE_K0X2(K0, BASENAME, BS, TYPE) \ 3457*c217d954SCole Faust COLUMN_VECTOR(K0, 0, BASENAME, BS, TYPE); \ 3458*c217d954SCole Faust COLUMN_VECTOR(K0, 1, BASENAME, BS, TYPE); 3459*c217d954SCole Faust#define TRANSPOSE_K0X3(K0, BASENAME, BS, TYPE) \ 3460*c217d954SCole Faust TRANSPOSE_K0X2(K0, BASENAME, BS, TYPE); \ 3461*c217d954SCole Faust COLUMN_VECTOR(K0, 2, BASENAME, BS, TYPE); 3462*c217d954SCole Faust#define TRANSPOSE_K0X4(K0, BASENAME, BS, TYPE) \ 3463*c217d954SCole Faust TRANSPOSE_K0X3(K0, BASENAME, BS, TYPE); \ 3464*c217d954SCole Faust COLUMN_VECTOR(K0, 3, BASENAME, BS, TYPE); 3465*c217d954SCole Faust#define TRANSPOSE_K0X8(K0, BASENAME, BS, TYPE) \ 3466*c217d954SCole Faust TRANSPOSE_K0X4(K0, BASENAME, BS, TYPE); \ 3467*c217d954SCole Faust COLUMN_VECTOR(K0, 4, BASENAME, BS, TYPE); \ 3468*c217d954SCole Faust COLUMN_VECTOR(K0, 5, BASENAME, BS, TYPE); \ 3469*c217d954SCole Faust COLUMN_VECTOR(K0, 6, BASENAME, BS, TYPE); \ 3470*c217d954SCole Faust COLUMN_VECTOR(K0, 7, BASENAME, BS, TYPE); 3471*c217d954SCole Faust#define TRANSPOSE_K0X16(K0, BASENAME, BS, TYPE) \ 3472*c217d954SCole Faust TRANSPOSE_K0X8(K0, BASENAME, BS, TYPE); \ 3473*c217d954SCole Faust COLUMN_VECTOR(K0, 8, BASENAME, BS, TYPE); \ 3474*c217d954SCole Faust COLUMN_VECTOR(K0, 9, BASENAME, BS, TYPE); \ 3475*c217d954SCole Faust COLUMN_VECTOR(K0, A, BASENAME, BS, TYPE); \ 3476*c217d954SCole Faust COLUMN_VECTOR(K0, B, BASENAME, BS, TYPE); \ 3477*c217d954SCole Faust COLUMN_VECTOR(K0, C, BASENAME, BS, TYPE); \ 3478*c217d954SCole Faust COLUMN_VECTOR(K0, D, BASENAME, BS, TYPE); \ 3479*c217d954SCole Faust COLUMN_VECTOR(K0, E, BASENAME, BS, TYPE); \ 3480*c217d954SCole Faust COLUMN_VECTOR(K0, F, BASENAME, BS, TYPE); 3481*c217d954SCole Faust 3482*c217d954SCole Faust 3483*c217d954SCole Faust 3484*c217d954SCole Faust 3485*c217d954SCole Faust#define COLUMN_VECTOR(K0, IDX_COL, BASENAME, BS, TYPE) \ 3486*c217d954SCole Faust CONCAT(COLUMN_VECTOR, K0) \ 3487*c217d954SCole Faust (IDX_COL, BASENAME, BS, TYPE); 3488*c217d954SCole Faust 3489*c217d954SCole Faust 3490*c217d954SCole Faust#define COLUMN_VECTOR_SCALAR(K0, IDX_COL, BASENAME, BS, TYPE) \ 3491*c217d954SCole Faust CONCAT(COLUMN_VECTOR_SCALAR, K0) \ 3492*c217d954SCole Faust (IDX_COL, BASENAME, BS, TYPE); 3493*c217d954SCole Faust 3494*c217d954SCole Faust 3495*c217d954SCole Faust#define TRANSPOSE_K0XN0(K0, N0, BASENAME, BS, TYPE) \ 3496*c217d954SCole Faust CONCAT(TRANSPOSE_K0X, N0) \ 3497*c217d954SCole Faust (K0, BASENAME, BS, TYPE); 3498*c217d954SCole Faust 3499*c217d954SCole Faust 3500*c217d954SCole Faust#define ADD_ROW_1(BASENAME, BIAS) \ 3501*c217d954SCole Faust BASENAME##0 += BIAS##0; 3502*c217d954SCole Faust 3503*c217d954SCole Faust#define ADD_ROW_2(BASENAME, BIAS) \ 3504*c217d954SCole Faust ADD_ROW_1(BASENAME, BIAS) \ 3505*c217d954SCole Faust BASENAME##1 += BIAS##1; 3506*c217d954SCole Faust 3507*c217d954SCole Faust#define ADD_ROW_3(BASENAME, BIAS) \ 3508*c217d954SCole Faust ADD_ROW_2(BASENAME, BIAS) \ 3509*c217d954SCole Faust BASENAME##2 += BIAS##2; 3510*c217d954SCole Faust 3511*c217d954SCole Faust#define ADD_ROW_4(BASENAME, BIAS) \ 3512*c217d954SCole Faust ADD_ROW_3(BASENAME, BIAS) \ 3513*c217d954SCole Faust BASENAME##3 += BIAS##3; 3514*c217d954SCole Faust 3515*c217d954SCole Faust#define ADD_ROW_5(BASENAME, BIAS) \ 3516*c217d954SCole Faust ADD_ROW_4(BASENAME, BIAS) \ 3517*c217d954SCole Faust BASENAME##4 += BIAS##4; 3518*c217d954SCole Faust 3519*c217d954SCole Faust#define ADD_ROW_6(BASENAME, BIAS) \ 3520*c217d954SCole Faust ADD_ROW_5(BASENAME, BIAS) \ 3521*c217d954SCole Faust BASENAME##5 += BIAS##5; 3522*c217d954SCole Faust 3523*c217d954SCole Faust#define ADD_ROW_7(BASENAME, BIAS) \ 3524*c217d954SCole Faust ADD_ROW_6(BASENAME, BIAS) \ 3525*c217d954SCole Faust BASENAME##6 += BIAS##6; 3526*c217d954SCole Faust 3527*c217d954SCole Faust#define ADD_ROW_8(BASENAME, BIAS) \ 3528*c217d954SCole Faust ADD_ROW_7(BASENAME, BIAS) \ 3529*c217d954SCole Faust BASENAME##7 += BIAS##7; 3530*c217d954SCole Faust 3531*c217d954SCole Faust#define ADD_ROW_9(BASENAME, BIAS) \ 3532*c217d954SCole Faust ADD_ROW_8(BASENAME, BIAS) \ 3533*c217d954SCole Faust BASENAME##8 += BIAS##8; 3534*c217d954SCole Faust 3535*c217d954SCole Faust#define ADD_ROW_10(BASENAME, BIAS) \ 3536*c217d954SCole Faust ADD_ROW_9(BASENAME, BIAS) \ 3537*c217d954SCole Faust BASENAME##9 += BIAS##9; 3538*c217d954SCole Faust 3539*c217d954SCole Faust#define ADD_ROW_11(BASENAME, BIAS) \ 3540*c217d954SCole Faust ADD_ROW_10(BASENAME, BIAS) \ 3541*c217d954SCole Faust BASENAME##A += BIAS##A; 3542*c217d954SCole Faust 3543*c217d954SCole Faust#define ADD_ROW_12(BASENAME, BIAS) \ 3544*c217d954SCole Faust ADD_ROW_11(BASENAME, BIAS) \ 3545*c217d954SCole Faust BASENAME##B += BIAS##B; 3546*c217d954SCole Faust 3547*c217d954SCole Faust#define ADD_ROW_13(BASENAME, BIAS) \ 3548*c217d954SCole Faust ADD_ROW_12(BASENAME, BIAS) \ 3549*c217d954SCole Faust BASENAME##C += BIAS##C; 3550*c217d954SCole Faust 3551*c217d954SCole Faust#define ADD_ROW_14(BASENAME, BIAS) \ 3552*c217d954SCole Faust ADD_ROW_13(BASENAME, BIAS) \ 3553*c217d954SCole Faust BASENAME##D += BIAS##D; 3554*c217d954SCole Faust 3555*c217d954SCole Faust#define ADD_ROW_15(BASENAME, BIAS) \ 3556*c217d954SCole Faust ADD_ROW_14(BASENAME, BIAS) \ 3557*c217d954SCole Faust BASENAME##E += BIAS##E; 3558*c217d954SCole Faust 3559*c217d954SCole Faust#define ADD_ROW_16(BASENAME, BIAS) \ 3560*c217d954SCole Faust ADD_ROW_15(BASENAME, BIAS) \ 3561*c217d954SCole Faust BASENAME##F += BIAS##F; 3562*c217d954SCole Faust 3563*c217d954SCole Faust 3564*c217d954SCole Faust 3565*c217d954SCole Faust 3566*c217d954SCole Faust#define ADD_BLOCK_STR(N, BASENAME, BIAS) ADD_ROW_##N(BASENAME, BIAS) 3567*c217d954SCole Faust#define ADD_BLOCK(N, BASENAME, BIAS) ADD_BLOCK_STR(N, BASENAME, BIAS) 3568*c217d954SCole Faust 3569*c217d954SCole Faust 3570*c217d954SCole Faust 3571*c217d954SCole Faust#define ADD_ROW_BROADCAST_1(BASENAME, BIAS) \ 3572*c217d954SCole Faust BASENAME##0 += BIAS; 3573*c217d954SCole Faust 3574*c217d954SCole Faust#define ADD_ROW_BROADCAST_2(BASENAME, BIAS) \ 3575*c217d954SCole Faust ADD_ROW_BROADCAST_1(BASENAME, BIAS) \ 3576*c217d954SCole Faust BASENAME##1 += BIAS; 3577*c217d954SCole Faust 3578*c217d954SCole Faust#define ADD_ROW_BROADCAST_3(BASENAME, BIAS) \ 3579*c217d954SCole Faust ADD_ROW_BROADCAST_2(BASENAME, BIAS) \ 3580*c217d954SCole Faust BASENAME##2 += BIAS; 3581*c217d954SCole Faust 3582*c217d954SCole Faust#define ADD_ROW_BROADCAST_4(BASENAME, BIAS) \ 3583*c217d954SCole Faust ADD_ROW_BROADCAST_3(BASENAME, BIAS) \ 3584*c217d954SCole Faust BASENAME##3 += BIAS; 3585*c217d954SCole Faust 3586*c217d954SCole Faust#define ADD_ROW_BROADCAST_5(BASENAME, BIAS) \ 3587*c217d954SCole Faust ADD_ROW_BROADCAST_4(BASENAME, BIAS) \ 3588*c217d954SCole Faust BASENAME##4 += BIAS; 3589*c217d954SCole Faust 3590*c217d954SCole Faust#define ADD_ROW_BROADCAST_6(BASENAME, BIAS) \ 3591*c217d954SCole Faust ADD_ROW_BROADCAST_5(BASENAME, BIAS) \ 3592*c217d954SCole Faust BASENAME##5 += BIAS; 3593*c217d954SCole Faust 3594*c217d954SCole Faust#define ADD_ROW_BROADCAST_7(BASENAME, BIAS) \ 3595*c217d954SCole Faust ADD_ROW_BROADCAST_6(BASENAME, BIAS) \ 3596*c217d954SCole Faust BASENAME##6 += BIAS; 3597*c217d954SCole Faust 3598*c217d954SCole Faust#define ADD_ROW_BROADCAST_8(BASENAME, BIAS) \ 3599*c217d954SCole Faust ADD_ROW_BROADCAST_7(BASENAME, BIAS) \ 3600*c217d954SCole Faust BASENAME##7 += BIAS; 3601*c217d954SCole Faust 3602*c217d954SCole Faust#define ADD_ROW_BROADCAST_9(BASENAME, BIAS) \ 3603*c217d954SCole Faust ADD_ROW_BROADCAST_8(BASENAME, BIAS) \ 3604*c217d954SCole Faust BASENAME##8 += BIAS; 3605*c217d954SCole Faust 3606*c217d954SCole Faust#define ADD_ROW_BROADCAST_10(BASENAME, BIAS) \ 3607*c217d954SCole Faust ADD_ROW_BROADCAST_9(BASENAME, BIAS) \ 3608*c217d954SCole Faust BASENAME##9 += BIAS; 3609*c217d954SCole Faust 3610*c217d954SCole Faust#define ADD_ROW_BROADCAST_11(BASENAME, BIAS) \ 3611*c217d954SCole Faust ADD_ROW_BROADCAST_10(BASENAME, BIAS) \ 3612*c217d954SCole Faust BASENAME##A += BIAS; 3613*c217d954SCole Faust 3614*c217d954SCole Faust#define ADD_ROW_BROADCAST_12(BASENAME, BIAS) \ 3615*c217d954SCole Faust ADD_ROW_BROADCAST_11(BASENAME, BIAS) \ 3616*c217d954SCole Faust BASENAME##B += BIAS; 3617*c217d954SCole Faust 3618*c217d954SCole Faust#define ADD_ROW_BROADCAST_13(BASENAME, BIAS) \ 3619*c217d954SCole Faust ADD_ROW_BROADCAST_12(BASENAME, BIAS) \ 3620*c217d954SCole Faust BASENAME##C += BIAS; 3621*c217d954SCole Faust 3622*c217d954SCole Faust#define ADD_ROW_BROADCAST_14(BASENAME, BIAS) \ 3623*c217d954SCole Faust ADD_ROW_BROADCAST_13(BASENAME, BIAS) \ 3624*c217d954SCole Faust BASENAME##D += BIAS; 3625*c217d954SCole Faust 3626*c217d954SCole Faust#define ADD_ROW_BROADCAST_15(BASENAME, BIAS) \ 3627*c217d954SCole Faust ADD_ROW_BROADCAST_14(BASENAME, BIAS) \ 3628*c217d954SCole Faust BASENAME##E += BIAS; 3629*c217d954SCole Faust 3630*c217d954SCole Faust#define ADD_ROW_BROADCAST_16(BASENAME, BIAS) \ 3631*c217d954SCole Faust ADD_ROW_BROADCAST_15(BASENAME, BIAS) \ 3632*c217d954SCole Faust BASENAME##F += BIAS; 3633*c217d954SCole Faust 3634*c217d954SCole Faust 3635*c217d954SCole Faust#define ADD_BLOCK_BROADCAST_STR(N, BASENAME, BIAS) ADD_ROW_BROADCAST_##N(BASENAME, BIAS) 3636*c217d954SCole Faust#define ADD_BLOCK_BROADCAST(N, BASENAME, BIAS) ADD_BLOCK_BROADCAST_STR(N, BASENAME, BIAS) 3637*c217d954SCole Faust 3638*c217d954SCole Faust 3639*c217d954SCole Faust 3640*c217d954SCole Faust#define ACTIVATION_ROW_1(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3641*c217d954SCole Faust BASENAME##0 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##0, A_VAL, B_VAL); 3642*c217d954SCole Faust 3643*c217d954SCole Faust#define ACTIVATION_ROW_2(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3644*c217d954SCole Faust ACTIVATION_ROW_1(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3645*c217d954SCole Faust BASENAME##1 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##1, A_VAL, B_VAL); 3646*c217d954SCole Faust 3647*c217d954SCole Faust#define ACTIVATION_ROW_3(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3648*c217d954SCole Faust ACTIVATION_ROW_2(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3649*c217d954SCole Faust BASENAME##2 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##2, A_VAL, B_VAL); 3650*c217d954SCole Faust 3651*c217d954SCole Faust#define ACTIVATION_ROW_4(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3652*c217d954SCole Faust ACTIVATION_ROW_3(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3653*c217d954SCole Faust BASENAME##3 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##3, A_VAL, B_VAL); 3654*c217d954SCole Faust 3655*c217d954SCole Faust#define ACTIVATION_ROW_5(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3656*c217d954SCole Faust ACTIVATION_ROW_4(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3657*c217d954SCole Faust BASENAME##4 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##4, A_VAL, B_VAL); 3658*c217d954SCole Faust 3659*c217d954SCole Faust#define ACTIVATION_ROW_6(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3660*c217d954SCole Faust ACTIVATION_ROW_5(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3661*c217d954SCole Faust BASENAME##5 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##5, A_VAL, B_VAL); 3662*c217d954SCole Faust 3663*c217d954SCole Faust#define ACTIVATION_ROW_7(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3664*c217d954SCole Faust ACTIVATION_ROW_6(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3665*c217d954SCole Faust BASENAME##6 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##6, A_VAL, B_VAL); 3666*c217d954SCole Faust 3667*c217d954SCole Faust#define ACTIVATION_ROW_8(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3668*c217d954SCole Faust ACTIVATION_ROW_7(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3669*c217d954SCole Faust BASENAME##7 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##7, A_VAL, B_VAL); 3670*c217d954SCole Faust 3671*c217d954SCole Faust#define ACTIVATION_ROW_9(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3672*c217d954SCole Faust ACTIVATION_ROW_8(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3673*c217d954SCole Faust BASENAME##8 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##8, A_VAL, B_VAL); 3674*c217d954SCole Faust 3675*c217d954SCole Faust#define ACTIVATION_ROW_10(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3676*c217d954SCole Faust ACTIVATION_ROW_9(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3677*c217d954SCole Faust BASENAME##9 = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##9, A_VAL, B_VAL); 3678*c217d954SCole Faust 3679*c217d954SCole Faust#define ACTIVATION_ROW_11(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3680*c217d954SCole Faust ACTIVATION_ROW_10(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3681*c217d954SCole Faust BASENAME##A = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##A, A_VAL, B_VAL); 3682*c217d954SCole Faust 3683*c217d954SCole Faust#define ACTIVATION_ROW_12(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3684*c217d954SCole Faust ACTIVATION_ROW_11(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3685*c217d954SCole Faust BASENAME##B = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##B, A_VAL, B_VAL); 3686*c217d954SCole Faust 3687*c217d954SCole Faust#define ACTIVATION_ROW_13(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3688*c217d954SCole Faust ACTIVATION_ROW_12(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3689*c217d954SCole Faust BASENAME##C = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##C, A_VAL, B_VAL); 3690*c217d954SCole Faust 3691*c217d954SCole Faust#define ACTIVATION_ROW_14(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3692*c217d954SCole Faust ACTIVATION_ROW_13(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3693*c217d954SCole Faust BASENAME##D = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##D, A_VAL, B_VAL); 3694*c217d954SCole Faust 3695*c217d954SCole Faust#define ACTIVATION_ROW_15(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3696*c217d954SCole Faust ACTIVATION_ROW_14(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3697*c217d954SCole Faust BASENAME##E = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##E, A_VAL, B_VAL); 3698*c217d954SCole Faust 3699*c217d954SCole Faust#define ACTIVATION_ROW_16(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3700*c217d954SCole Faust ACTIVATION_ROW_15(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) \ 3701*c217d954SCole Faust BASENAME##F = ACTIVATION(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME##F, A_VAL, B_VAL); 3702*c217d954SCole Faust 3703*c217d954SCole Faust 3704*c217d954SCole Faust 3705*c217d954SCole Faust#define ACTIVATION_BLOCK_STR(N, ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) ACTIVATION_ROW_##N(ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) 3706*c217d954SCole Faust#define ACTIVATION_BLOCK(N, ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) ACTIVATION_BLOCK_STR(N, ACTIVATION_TYPE, DATA_TYPE, VEC_SIZE, BASENAME, A_VAL, B_VAL) 3707*c217d954SCole Faust 3708*c217d954SCole Faust 3709*c217d954SCole Faust 3710*c217d954SCole Faust#define CONVERT_ROW_1(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3711*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3712*c217d954SCole Faust BASENAME_DST##0 = CONVERT(BASENAME_SRC##0, VEC_DATA_TYPE(DATA_TYPE, N)); 3713*c217d954SCole Faust 3714*c217d954SCole Faust#define CONVERT_ROW_2(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3715*c217d954SCole Faust CONVERT_ROW_1(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3716*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3717*c217d954SCole Faust BASENAME_DST##1 = CONVERT(BASENAME_SRC##1, VEC_DATA_TYPE(DATA_TYPE, N)); 3718*c217d954SCole Faust 3719*c217d954SCole Faust#define CONVERT_ROW_3(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3720*c217d954SCole Faust CONVERT_ROW_2(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3721*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3722*c217d954SCole Faust BASENAME_DST##2 = CONVERT(BASENAME_SRC##2, VEC_DATA_TYPE(DATA_TYPE, N)); 3723*c217d954SCole Faust 3724*c217d954SCole Faust#define CONVERT_ROW_4(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3725*c217d954SCole Faust CONVERT_ROW_3(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3726*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3727*c217d954SCole Faust BASENAME_DST##3 = CONVERT(BASENAME_SRC##3, VEC_DATA_TYPE(DATA_TYPE, N)); 3728*c217d954SCole Faust 3729*c217d954SCole Faust#define CONVERT_ROW_5(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3730*c217d954SCole Faust CONVERT_ROW_4(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3731*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3732*c217d954SCole Faust BASENAME_DST##4 = CONVERT(BASENAME_SRC##4, VEC_DATA_TYPE(DATA_TYPE, N)); 3733*c217d954SCole Faust 3734*c217d954SCole Faust#define CONVERT_ROW_6(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3735*c217d954SCole Faust CONVERT_ROW_5(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3736*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3737*c217d954SCole Faust BASENAME_DST##5 = CONVERT(BASENAME_SRC##5, VEC_DATA_TYPE(DATA_TYPE, N)); 3738*c217d954SCole Faust 3739*c217d954SCole Faust#define CONVERT_ROW_7(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3740*c217d954SCole Faust CONVERT_ROW_6(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3741*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3742*c217d954SCole Faust BASENAME_DST##6 = CONVERT(BASENAME_SRC##6, VEC_DATA_TYPE(DATA_TYPE, N)); 3743*c217d954SCole Faust 3744*c217d954SCole Faust#define CONVERT_ROW_8(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3745*c217d954SCole Faust CONVERT_ROW_7(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3746*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3747*c217d954SCole Faust BASENAME_DST##7 = CONVERT(BASENAME_SRC##7, VEC_DATA_TYPE(DATA_TYPE, N)); 3748*c217d954SCole Faust 3749*c217d954SCole Faust#define CONVERT_ROW_9(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3750*c217d954SCole Faust CONVERT_ROW_8(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3751*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3752*c217d954SCole Faust BASENAME_DST##8 = CONVERT(BASENAME_SRC##8, VEC_DATA_TYPE(DATA_TYPE, N)); 3753*c217d954SCole Faust 3754*c217d954SCole Faust#define CONVERT_ROW_10(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3755*c217d954SCole Faust CONVERT_ROW_9(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3756*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3757*c217d954SCole Faust BASENAME_DST##9 = CONVERT(BASENAME_SRC##9, VEC_DATA_TYPE(DATA_TYPE, N)); 3758*c217d954SCole Faust 3759*c217d954SCole Faust#define CONVERT_ROW_11(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3760*c217d954SCole Faust CONVERT_ROW_10(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3761*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3762*c217d954SCole Faust BASENAME_DST##A = CONVERT(BASENAME_SRC##A, VEC_DATA_TYPE(DATA_TYPE, N)); 3763*c217d954SCole Faust 3764*c217d954SCole Faust#define CONVERT_ROW_12(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3765*c217d954SCole Faust CONVERT_ROW_11(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3766*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3767*c217d954SCole Faust BASENAME_DST##B = CONVERT(BASENAME_SRC##B, VEC_DATA_TYPE(DATA_TYPE, N)); 3768*c217d954SCole Faust 3769*c217d954SCole Faust#define CONVERT_ROW_13(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3770*c217d954SCole Faust CONVERT_ROW_12(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3771*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3772*c217d954SCole Faust BASENAME_DST##C = CONVERT(BASENAME_SRC##C, VEC_DATA_TYPE(DATA_TYPE, N)); 3773*c217d954SCole Faust 3774*c217d954SCole Faust#define CONVERT_ROW_14(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3775*c217d954SCole Faust CONVERT_ROW_13(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3776*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3777*c217d954SCole Faust BASENAME_DST##D = CONVERT(BASENAME_SRC##D, VEC_DATA_TYPE(DATA_TYPE, N)); 3778*c217d954SCole Faust 3779*c217d954SCole Faust#define CONVERT_ROW_15(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3780*c217d954SCole Faust CONVERT_ROW_14(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3781*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3782*c217d954SCole Faust BASENAME_DST##E = CONVERT(BASENAME_SRC##E, VEC_DATA_TYPE(DATA_TYPE, N)); 3783*c217d954SCole Faust 3784*c217d954SCole Faust#define CONVERT_ROW_16(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3785*c217d954SCole Faust CONVERT_ROW_15(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) \ 3786*c217d954SCole Faust VEC_DATA_TYPE(DATA_TYPE, N) \ 3787*c217d954SCole Faust BASENAME_DST##F = CONVERT(BASENAME_SRC##F, VEC_DATA_TYPE(DATA_TYPE, N)); 3788*c217d954SCole Faust 3789*c217d954SCole Faust 3790*c217d954SCole Faust 3791*c217d954SCole Faust#define CONVERT_BLOCK_STR(M, N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) CONVERT_ROW_##M(N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) 3792*c217d954SCole Faust#define CONVERT_BLOCK(M, N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) CONVERT_BLOCK_STR(M, N, DATA_TYPE, BASENAME_SRC, BASENAME_DST) 3793*c217d954SCole Faust )"