From 4767a4c39d33a3748a318e0d7b2d183630aace9e Mon Sep 17 00:00:00 2001 From: Raghuveer Devulapalli Date: Thu, 7 Sep 2023 13:35:39 -0700 Subject: [PATCH] Replace zmm_t with reg_t --- src/avx512-64bit-argsort.hpp | 12 +- src/avx512-64bit-keyvalue-networks.hpp | 360 ++++++++++++------------- src/avx512-common-argsort.h | 16 +- src/avx512-common-qsort.h | 80 +++--- 4 files changed, 234 insertions(+), 234 deletions(-) diff --git a/src/avx512-64bit-argsort.hpp b/src/avx512-64bit-argsort.hpp index 7c6a34c1..c9c5e961 100644 --- a/src/avx512-64bit-argsort.hpp +++ b/src/avx512-64bit-argsort.hpp @@ -67,7 +67,7 @@ X86_SIMD_SORT_INLINE void argsort_8_64bit(type_t *arr, int64_t *arg, int32_t N) { using reg_t = typename vtype::reg_t; typename vtype::opmask_t load_mask = (0x01 << N) - 0x01; - argzmm_t argzmm = argtype::maskz_loadu(load_mask, arg); + argreg_t argzmm = argtype::maskz_loadu(load_mask, arg); reg_t arrzmm = vtype::template mask_i64gather( vtype::zmm_max(), load_mask, argzmm, arr); arrzmm = sort_zmm_64bit(arrzmm, argzmm); @@ -83,8 +83,8 @@ X86_SIMD_SORT_INLINE void argsort_16_64bit(type_t *arr, int64_t *arg, int32_t N) } using reg_t = typename vtype::reg_t; typename vtype::opmask_t load_mask = (0x01 << (N - 8)) - 0x01; - argzmm_t argzmm1 = argtype::loadu(arg); - argzmm_t argzmm2 = argtype::maskz_loadu(load_mask, arg + 8); + argreg_t argzmm1 = argtype::loadu(arg); + argreg_t argzmm2 = argtype::maskz_loadu(load_mask, arg + 8); reg_t arrzmm1 = vtype::i64gather(arr, arg); reg_t arrzmm2 = vtype::template mask_i64gather( vtype::zmm_max(), load_mask, argzmm2, arr); @@ -106,7 +106,7 @@ X86_SIMD_SORT_INLINE void argsort_32_64bit(type_t *arr, int64_t *arg, int32_t N) using reg_t = typename vtype::reg_t; using opmask_t = typename vtype::opmask_t; reg_t arrzmm[4]; - argzmm_t argzmm[4]; + argreg_t argzmm[4]; X86_SIMD_SORT_UNROLL_LOOP(2) for (int ii = 0; ii < 2; ++ii) { @@ -149,7 +149,7 @@ X86_SIMD_SORT_INLINE void argsort_64_64bit(type_t *arr, int64_t *arg, int32_t N) using reg_t = typename vtype::reg_t; using opmask_t = typename vtype::opmask_t; reg_t arrzmm[8]; - argzmm_t argzmm[8]; + argreg_t argzmm[8]; X86_SIMD_SORT_UNROLL_LOOP(4) for (int ii = 0; ii < 4; ++ii) { @@ -201,7 +201,7 @@ X86_SIMD_SORT_UNROLL_LOOP(4) // using reg_t = typename vtype::reg_t; // using opmask_t = typename vtype::opmask_t; // reg_t arrzmm[16]; -// argzmm_t argzmm[16]; +// argreg_t argzmm[16]; // //X86_SIMD_SORT_UNROLL_LOOP(8) // for (int ii = 0; ii < 8; ++ii) { diff --git a/src/avx512-64bit-keyvalue-networks.hpp b/src/avx512-64bit-keyvalue-networks.hpp index bae8fa6d..62da3f77 100644 --- a/src/avx512-64bit-keyvalue-networks.hpp +++ b/src/avx512-64bit-keyvalue-networks.hpp @@ -128,45 +128,45 @@ X86_SIMD_SORT_INLINE void bitonic_merge_four_zmm_64bit(reg_t *key_zmm, index_type index_zmm2r = vtype2::permutexvar(rev_index2, index_zmm[2]); index_type index_zmm3r = vtype2::permutexvar(rev_index2, index_zmm[3]); - reg_t key_zmm_t1 = vtype1::min(key_zmm[0], key_zmm3r); - reg_t key_zmm_t2 = vtype1::min(key_zmm[1], key_zmm2r); + reg_t key_reg_t1 = vtype1::min(key_zmm[0], key_zmm3r); + reg_t key_reg_t2 = vtype1::min(key_zmm[1], key_zmm2r); reg_t key_zmm_m1 = vtype1::max(key_zmm[0], key_zmm3r); reg_t key_zmm_m2 = vtype1::max(key_zmm[1], key_zmm2r); - typename vtype1::opmask_t movmask1 = vtype1::eq(key_zmm_t1, key_zmm[0]); - typename vtype1::opmask_t movmask2 = vtype1::eq(key_zmm_t2, key_zmm[1]); + typename vtype1::opmask_t movmask1 = vtype1::eq(key_reg_t1, key_zmm[0]); + typename vtype1::opmask_t movmask2 = vtype1::eq(key_reg_t2, key_zmm[1]); - index_type index_zmm_t1 + index_type index_reg_t1 = vtype2::mask_mov(index_zmm3r, movmask1, index_zmm[0]); index_type index_zmm_m1 = vtype2::mask_mov(index_zmm[0], movmask1, index_zmm3r); - index_type index_zmm_t2 + index_type index_reg_t2 = vtype2::mask_mov(index_zmm2r, movmask2, index_zmm[1]); index_type index_zmm_m2 = vtype2::mask_mov(index_zmm[1], movmask2, index_zmm2r); // 2) Recursive half clearer: 16 - reg_t key_zmm_t3 = vtype1::permutexvar(rev_index1, key_zmm_m2); - reg_t key_zmm_t4 = vtype1::permutexvar(rev_index1, key_zmm_m1); - index_type index_zmm_t3 = vtype2::permutexvar(rev_index2, index_zmm_m2); - index_type index_zmm_t4 = vtype2::permutexvar(rev_index2, index_zmm_m1); + reg_t key_reg_t3 = vtype1::permutexvar(rev_index1, key_zmm_m2); + reg_t key_reg_t4 = vtype1::permutexvar(rev_index1, key_zmm_m1); + index_type index_reg_t3 = vtype2::permutexvar(rev_index2, index_zmm_m2); + index_type index_reg_t4 = vtype2::permutexvar(rev_index2, index_zmm_m1); - reg_t key_zmm0 = vtype1::min(key_zmm_t1, key_zmm_t2); - reg_t key_zmm1 = vtype1::max(key_zmm_t1, key_zmm_t2); - reg_t key_zmm2 = vtype1::min(key_zmm_t3, key_zmm_t4); - reg_t key_zmm3 = vtype1::max(key_zmm_t3, key_zmm_t4); + reg_t key_zmm0 = vtype1::min(key_reg_t1, key_reg_t2); + reg_t key_zmm1 = vtype1::max(key_reg_t1, key_reg_t2); + reg_t key_zmm2 = vtype1::min(key_reg_t3, key_reg_t4); + reg_t key_zmm3 = vtype1::max(key_reg_t3, key_reg_t4); - movmask1 = vtype1::eq(key_zmm0, key_zmm_t1); - movmask2 = vtype1::eq(key_zmm2, key_zmm_t3); + movmask1 = vtype1::eq(key_zmm0, key_reg_t1); + movmask2 = vtype1::eq(key_zmm2, key_reg_t3); index_type index_zmm0 - = vtype2::mask_mov(index_zmm_t2, movmask1, index_zmm_t1); + = vtype2::mask_mov(index_reg_t2, movmask1, index_reg_t1); index_type index_zmm1 - = vtype2::mask_mov(index_zmm_t1, movmask1, index_zmm_t2); + = vtype2::mask_mov(index_reg_t1, movmask1, index_reg_t2); index_type index_zmm2 - = vtype2::mask_mov(index_zmm_t4, movmask2, index_zmm_t3); + = vtype2::mask_mov(index_reg_t4, movmask2, index_reg_t3); index_type index_zmm3 - = vtype2::mask_mov(index_zmm_t3, movmask2, index_zmm_t4); + = vtype2::mask_mov(index_reg_t3, movmask2, index_reg_t4); key_zmm[0] = bitonic_merge_zmm_64bit(key_zmm0, index_zmm0); key_zmm[1] = bitonic_merge_zmm_64bit(key_zmm1, index_zmm1); @@ -197,80 +197,80 @@ X86_SIMD_SORT_INLINE void bitonic_merge_eight_zmm_64bit(reg_t *key_zmm, index_type index_zmm6r = vtype2::permutexvar(rev_index2, index_zmm[6]); index_type index_zmm7r = vtype2::permutexvar(rev_index2, index_zmm[7]); - reg_t key_zmm_t1 = vtype1::min(key_zmm[0], key_zmm7r); - reg_t key_zmm_t2 = vtype1::min(key_zmm[1], key_zmm6r); - reg_t key_zmm_t3 = vtype1::min(key_zmm[2], key_zmm5r); - reg_t key_zmm_t4 = vtype1::min(key_zmm[3], key_zmm4r); + reg_t key_reg_t1 = vtype1::min(key_zmm[0], key_zmm7r); + reg_t key_reg_t2 = vtype1::min(key_zmm[1], key_zmm6r); + reg_t key_reg_t3 = vtype1::min(key_zmm[2], key_zmm5r); + reg_t key_reg_t4 = vtype1::min(key_zmm[3], key_zmm4r); reg_t key_zmm_m1 = vtype1::max(key_zmm[0], key_zmm7r); reg_t key_zmm_m2 = vtype1::max(key_zmm[1], key_zmm6r); reg_t key_zmm_m3 = vtype1::max(key_zmm[2], key_zmm5r); reg_t key_zmm_m4 = vtype1::max(key_zmm[3], key_zmm4r); - typename vtype1::opmask_t movmask1 = vtype1::eq(key_zmm_t1, key_zmm[0]); - typename vtype1::opmask_t movmask2 = vtype1::eq(key_zmm_t2, key_zmm[1]); - typename vtype1::opmask_t movmask3 = vtype1::eq(key_zmm_t3, key_zmm[2]); - typename vtype1::opmask_t movmask4 = vtype1::eq(key_zmm_t4, key_zmm[3]); + typename vtype1::opmask_t movmask1 = vtype1::eq(key_reg_t1, key_zmm[0]); + typename vtype1::opmask_t movmask2 = vtype1::eq(key_reg_t2, key_zmm[1]); + typename vtype1::opmask_t movmask3 = vtype1::eq(key_reg_t3, key_zmm[2]); + typename vtype1::opmask_t movmask4 = vtype1::eq(key_reg_t4, key_zmm[3]); - index_type index_zmm_t1 + index_type index_reg_t1 = vtype2::mask_mov(index_zmm7r, movmask1, index_zmm[0]); index_type index_zmm_m1 = vtype2::mask_mov(index_zmm[0], movmask1, index_zmm7r); - index_type index_zmm_t2 + index_type index_reg_t2 = vtype2::mask_mov(index_zmm6r, movmask2, index_zmm[1]); index_type index_zmm_m2 = vtype2::mask_mov(index_zmm[1], movmask2, index_zmm6r); - index_type index_zmm_t3 + index_type index_reg_t3 = vtype2::mask_mov(index_zmm5r, movmask3, index_zmm[2]); index_type index_zmm_m3 = vtype2::mask_mov(index_zmm[2], movmask3, index_zmm5r); - index_type index_zmm_t4 + index_type index_reg_t4 = vtype2::mask_mov(index_zmm4r, movmask4, index_zmm[3]); index_type index_zmm_m4 = vtype2::mask_mov(index_zmm[3], movmask4, index_zmm4r); - reg_t key_zmm_t5 = vtype1::permutexvar(rev_index1, key_zmm_m4); - reg_t key_zmm_t6 = vtype1::permutexvar(rev_index1, key_zmm_m3); - reg_t key_zmm_t7 = vtype1::permutexvar(rev_index1, key_zmm_m2); - reg_t key_zmm_t8 = vtype1::permutexvar(rev_index1, key_zmm_m1); - index_type index_zmm_t5 = vtype2::permutexvar(rev_index2, index_zmm_m4); - index_type index_zmm_t6 = vtype2::permutexvar(rev_index2, index_zmm_m3); - index_type index_zmm_t7 = vtype2::permutexvar(rev_index2, index_zmm_m2); - index_type index_zmm_t8 = vtype2::permutexvar(rev_index2, index_zmm_m1); - - COEX(key_zmm_t1, key_zmm_t3, index_zmm_t1, index_zmm_t3); - COEX(key_zmm_t2, key_zmm_t4, index_zmm_t2, index_zmm_t4); - COEX(key_zmm_t5, key_zmm_t7, index_zmm_t5, index_zmm_t7); - COEX(key_zmm_t6, key_zmm_t8, index_zmm_t6, index_zmm_t8); - COEX(key_zmm_t1, key_zmm_t2, index_zmm_t1, index_zmm_t2); - COEX(key_zmm_t3, key_zmm_t4, index_zmm_t3, index_zmm_t4); - COEX(key_zmm_t5, key_zmm_t6, index_zmm_t5, index_zmm_t6); - COEX(key_zmm_t7, key_zmm_t8, index_zmm_t7, index_zmm_t8); + reg_t key_reg_t5 = vtype1::permutexvar(rev_index1, key_zmm_m4); + reg_t key_reg_t6 = vtype1::permutexvar(rev_index1, key_zmm_m3); + reg_t key_reg_t7 = vtype1::permutexvar(rev_index1, key_zmm_m2); + reg_t key_reg_t8 = vtype1::permutexvar(rev_index1, key_zmm_m1); + index_type index_reg_t5 = vtype2::permutexvar(rev_index2, index_zmm_m4); + index_type index_reg_t6 = vtype2::permutexvar(rev_index2, index_zmm_m3); + index_type index_reg_t7 = vtype2::permutexvar(rev_index2, index_zmm_m2); + index_type index_reg_t8 = vtype2::permutexvar(rev_index2, index_zmm_m1); + + COEX(key_reg_t1, key_reg_t3, index_reg_t1, index_reg_t3); + COEX(key_reg_t2, key_reg_t4, index_reg_t2, index_reg_t4); + COEX(key_reg_t5, key_reg_t7, index_reg_t5, index_reg_t7); + COEX(key_reg_t6, key_reg_t8, index_reg_t6, index_reg_t8); + COEX(key_reg_t1, key_reg_t2, index_reg_t1, index_reg_t2); + COEX(key_reg_t3, key_reg_t4, index_reg_t3, index_reg_t4); + COEX(key_reg_t5, key_reg_t6, index_reg_t5, index_reg_t6); + COEX(key_reg_t7, key_reg_t8, index_reg_t7, index_reg_t8); key_zmm[0] - = bitonic_merge_zmm_64bit(key_zmm_t1, index_zmm_t1); + = bitonic_merge_zmm_64bit(key_reg_t1, index_reg_t1); key_zmm[1] - = bitonic_merge_zmm_64bit(key_zmm_t2, index_zmm_t2); + = bitonic_merge_zmm_64bit(key_reg_t2, index_reg_t2); key_zmm[2] - = bitonic_merge_zmm_64bit(key_zmm_t3, index_zmm_t3); + = bitonic_merge_zmm_64bit(key_reg_t3, index_reg_t3); key_zmm[3] - = bitonic_merge_zmm_64bit(key_zmm_t4, index_zmm_t4); + = bitonic_merge_zmm_64bit(key_reg_t4, index_reg_t4); key_zmm[4] - = bitonic_merge_zmm_64bit(key_zmm_t5, index_zmm_t5); + = bitonic_merge_zmm_64bit(key_reg_t5, index_reg_t5); key_zmm[5] - = bitonic_merge_zmm_64bit(key_zmm_t6, index_zmm_t6); + = bitonic_merge_zmm_64bit(key_reg_t6, index_reg_t6); key_zmm[6] - = bitonic_merge_zmm_64bit(key_zmm_t7, index_zmm_t7); + = bitonic_merge_zmm_64bit(key_reg_t7, index_reg_t7); key_zmm[7] - = bitonic_merge_zmm_64bit(key_zmm_t8, index_zmm_t8); - - index_zmm[0] = index_zmm_t1; - index_zmm[1] = index_zmm_t2; - index_zmm[2] = index_zmm_t3; - index_zmm[3] = index_zmm_t4; - index_zmm[4] = index_zmm_t5; - index_zmm[5] = index_zmm_t6; - index_zmm[6] = index_zmm_t7; - index_zmm[7] = index_zmm_t8; + = bitonic_merge_zmm_64bit(key_reg_t8, index_reg_t8); + + index_zmm[0] = index_reg_t1; + index_zmm[1] = index_reg_t2; + index_zmm[2] = index_reg_t3; + index_zmm[3] = index_reg_t4; + index_zmm[4] = index_reg_t5; + index_zmm[5] = index_reg_t6; + index_zmm[6] = index_reg_t7; + index_zmm[7] = index_reg_t8; } template (key_zmm_t1, key_zmm_t5, index_zmm_t1, index_zmm_t5); - COEX(key_zmm_t2, key_zmm_t6, index_zmm_t2, index_zmm_t6); - COEX(key_zmm_t3, key_zmm_t7, index_zmm_t3, index_zmm_t7); - COEX(key_zmm_t4, key_zmm_t8, index_zmm_t4, index_zmm_t8); - COEX(key_zmm_t9, key_zmm_t13, index_zmm_t9, index_zmm_t13); + index_zmm[7], vtype1::eq(key_reg_t8, key_zmm[7]), index_zmm8r); + + reg_t key_reg_t9 = vtype1::permutexvar(rev_index1, key_zmm_m8); + reg_t key_reg_t10 = vtype1::permutexvar(rev_index1, key_zmm_m7); + reg_t key_reg_t11 = vtype1::permutexvar(rev_index1, key_zmm_m6); + reg_t key_reg_t12 = vtype1::permutexvar(rev_index1, key_zmm_m5); + reg_t key_reg_t13 = vtype1::permutexvar(rev_index1, key_zmm_m4); + reg_t key_reg_t14 = vtype1::permutexvar(rev_index1, key_zmm_m3); + reg_t key_reg_t15 = vtype1::permutexvar(rev_index1, key_zmm_m2); + reg_t key_reg_t16 = vtype1::permutexvar(rev_index1, key_zmm_m1); + index_type index_reg_t9 = vtype2::permutexvar(rev_index2, index_zmm_m8); + index_type index_reg_t10 = vtype2::permutexvar(rev_index2, index_zmm_m7); + index_type index_reg_t11 = vtype2::permutexvar(rev_index2, index_zmm_m6); + index_type index_reg_t12 = vtype2::permutexvar(rev_index2, index_zmm_m5); + index_type index_reg_t13 = vtype2::permutexvar(rev_index2, index_zmm_m4); + index_type index_reg_t14 = vtype2::permutexvar(rev_index2, index_zmm_m3); + index_type index_reg_t15 = vtype2::permutexvar(rev_index2, index_zmm_m2); + index_type index_reg_t16 = vtype2::permutexvar(rev_index2, index_zmm_m1); + + COEX(key_reg_t1, key_reg_t5, index_reg_t1, index_reg_t5); + COEX(key_reg_t2, key_reg_t6, index_reg_t2, index_reg_t6); + COEX(key_reg_t3, key_reg_t7, index_reg_t3, index_reg_t7); + COEX(key_reg_t4, key_reg_t8, index_reg_t4, index_reg_t8); + COEX(key_reg_t9, key_reg_t13, index_reg_t9, index_reg_t13); COEX( - key_zmm_t10, key_zmm_t14, index_zmm_t10, index_zmm_t14); + key_reg_t10, key_reg_t14, index_reg_t10, index_reg_t14); COEX( - key_zmm_t11, key_zmm_t15, index_zmm_t11, index_zmm_t15); + key_reg_t11, key_reg_t15, index_reg_t11, index_reg_t15); COEX( - key_zmm_t12, key_zmm_t16, index_zmm_t12, index_zmm_t16); + key_reg_t12, key_reg_t16, index_reg_t12, index_reg_t16); - COEX(key_zmm_t1, key_zmm_t3, index_zmm_t1, index_zmm_t3); - COEX(key_zmm_t2, key_zmm_t4, index_zmm_t2, index_zmm_t4); - COEX(key_zmm_t5, key_zmm_t7, index_zmm_t5, index_zmm_t7); - COEX(key_zmm_t6, key_zmm_t8, index_zmm_t6, index_zmm_t8); - COEX(key_zmm_t9, key_zmm_t11, index_zmm_t9, index_zmm_t11); + COEX(key_reg_t1, key_reg_t3, index_reg_t1, index_reg_t3); + COEX(key_reg_t2, key_reg_t4, index_reg_t2, index_reg_t4); + COEX(key_reg_t5, key_reg_t7, index_reg_t5, index_reg_t7); + COEX(key_reg_t6, key_reg_t8, index_reg_t6, index_reg_t8); + COEX(key_reg_t9, key_reg_t11, index_reg_t9, index_reg_t11); COEX( - key_zmm_t10, key_zmm_t12, index_zmm_t10, index_zmm_t12); + key_reg_t10, key_reg_t12, index_reg_t10, index_reg_t12); COEX( - key_zmm_t13, key_zmm_t15, index_zmm_t13, index_zmm_t15); + key_reg_t13, key_reg_t15, index_reg_t13, index_reg_t15); COEX( - key_zmm_t14, key_zmm_t16, index_zmm_t14, index_zmm_t16); + key_reg_t14, key_reg_t16, index_reg_t14, index_reg_t16); - COEX(key_zmm_t1, key_zmm_t2, index_zmm_t1, index_zmm_t2); - COEX(key_zmm_t3, key_zmm_t4, index_zmm_t3, index_zmm_t4); - COEX(key_zmm_t5, key_zmm_t6, index_zmm_t5, index_zmm_t6); - COEX(key_zmm_t7, key_zmm_t8, index_zmm_t7, index_zmm_t8); - COEX(key_zmm_t9, key_zmm_t10, index_zmm_t9, index_zmm_t10); + COEX(key_reg_t1, key_reg_t2, index_reg_t1, index_reg_t2); + COEX(key_reg_t3, key_reg_t4, index_reg_t3, index_reg_t4); + COEX(key_reg_t5, key_reg_t6, index_reg_t5, index_reg_t6); + COEX(key_reg_t7, key_reg_t8, index_reg_t7, index_reg_t8); + COEX(key_reg_t9, key_reg_t10, index_reg_t9, index_reg_t10); COEX( - key_zmm_t11, key_zmm_t12, index_zmm_t11, index_zmm_t12); + key_reg_t11, key_reg_t12, index_reg_t11, index_reg_t12); COEX( - key_zmm_t13, key_zmm_t14, index_zmm_t13, index_zmm_t14); + key_reg_t13, key_reg_t14, index_reg_t13, index_reg_t14); COEX( - key_zmm_t15, key_zmm_t16, index_zmm_t15, index_zmm_t16); + key_reg_t15, key_reg_t16, index_reg_t15, index_reg_t16); // key_zmm[0] - = bitonic_merge_zmm_64bit(key_zmm_t1, index_zmm_t1); + = bitonic_merge_zmm_64bit(key_reg_t1, index_reg_t1); key_zmm[1] - = bitonic_merge_zmm_64bit(key_zmm_t2, index_zmm_t2); + = bitonic_merge_zmm_64bit(key_reg_t2, index_reg_t2); key_zmm[2] - = bitonic_merge_zmm_64bit(key_zmm_t3, index_zmm_t3); + = bitonic_merge_zmm_64bit(key_reg_t3, index_reg_t3); key_zmm[3] - = bitonic_merge_zmm_64bit(key_zmm_t4, index_zmm_t4); + = bitonic_merge_zmm_64bit(key_reg_t4, index_reg_t4); key_zmm[4] - = bitonic_merge_zmm_64bit(key_zmm_t5, index_zmm_t5); + = bitonic_merge_zmm_64bit(key_reg_t5, index_reg_t5); key_zmm[5] - = bitonic_merge_zmm_64bit(key_zmm_t6, index_zmm_t6); + = bitonic_merge_zmm_64bit(key_reg_t6, index_reg_t6); key_zmm[6] - = bitonic_merge_zmm_64bit(key_zmm_t7, index_zmm_t7); + = bitonic_merge_zmm_64bit(key_reg_t7, index_reg_t7); key_zmm[7] - = bitonic_merge_zmm_64bit(key_zmm_t8, index_zmm_t8); + = bitonic_merge_zmm_64bit(key_reg_t8, index_reg_t8); key_zmm[8] - = bitonic_merge_zmm_64bit(key_zmm_t9, index_zmm_t9); - key_zmm[9] = bitonic_merge_zmm_64bit(key_zmm_t10, - index_zmm_t10); - key_zmm[10] = bitonic_merge_zmm_64bit(key_zmm_t11, - index_zmm_t11); - key_zmm[11] = bitonic_merge_zmm_64bit(key_zmm_t12, - index_zmm_t12); - key_zmm[12] = bitonic_merge_zmm_64bit(key_zmm_t13, - index_zmm_t13); - key_zmm[13] = bitonic_merge_zmm_64bit(key_zmm_t14, - index_zmm_t14); - key_zmm[14] = bitonic_merge_zmm_64bit(key_zmm_t15, - index_zmm_t15); - key_zmm[15] = bitonic_merge_zmm_64bit(key_zmm_t16, - index_zmm_t16); - - index_zmm[0] = index_zmm_t1; - index_zmm[1] = index_zmm_t2; - index_zmm[2] = index_zmm_t3; - index_zmm[3] = index_zmm_t4; - index_zmm[4] = index_zmm_t5; - index_zmm[5] = index_zmm_t6; - index_zmm[6] = index_zmm_t7; - index_zmm[7] = index_zmm_t8; - index_zmm[8] = index_zmm_t9; - index_zmm[9] = index_zmm_t10; - index_zmm[10] = index_zmm_t11; - index_zmm[11] = index_zmm_t12; - index_zmm[12] = index_zmm_t13; - index_zmm[13] = index_zmm_t14; - index_zmm[14] = index_zmm_t15; - index_zmm[15] = index_zmm_t16; + = bitonic_merge_zmm_64bit(key_reg_t9, index_reg_t9); + key_zmm[9] = bitonic_merge_zmm_64bit(key_reg_t10, + index_reg_t10); + key_zmm[10] = bitonic_merge_zmm_64bit(key_reg_t11, + index_reg_t11); + key_zmm[11] = bitonic_merge_zmm_64bit(key_reg_t12, + index_reg_t12); + key_zmm[12] = bitonic_merge_zmm_64bit(key_reg_t13, + index_reg_t13); + key_zmm[13] = bitonic_merge_zmm_64bit(key_reg_t14, + index_reg_t14); + key_zmm[14] = bitonic_merge_zmm_64bit(key_reg_t15, + index_reg_t15); + key_zmm[15] = bitonic_merge_zmm_64bit(key_reg_t16, + index_reg_t16); + + index_zmm[0] = index_reg_t1; + index_zmm[1] = index_reg_t2; + index_zmm[2] = index_reg_t3; + index_zmm[3] = index_reg_t4; + index_zmm[4] = index_reg_t5; + index_zmm[5] = index_reg_t6; + index_zmm[6] = index_reg_t7; + index_zmm[7] = index_reg_t8; + index_zmm[8] = index_reg_t9; + index_zmm[9] = index_reg_t10; + index_zmm[10] = index_reg_t11; + index_zmm[11] = index_reg_t12; + index_zmm[12] = index_reg_t13; + index_zmm[13] = index_reg_t14; + index_zmm[14] = index_reg_t15; + index_zmm[15] = index_reg_t16; } diff --git a/src/avx512-common-argsort.h b/src/avx512-common-argsort.h index 5c73aede..375afc0b 100644 --- a/src/avx512-common-argsort.h +++ b/src/avx512-common-argsort.h @@ -13,7 +13,7 @@ #include using argtype = zmm_vector; -using argzmm_t = typename argtype::reg_t; +using argreg_t = typename argtype::reg_t; /* * Parition one ZMM register based on the pivot and returns the index of the @@ -23,7 +23,7 @@ template static inline int32_t partition_vec(type_t *arg, int64_t left, int64_t right, - const argzmm_t arg_vec, + const argreg_t arg_vec, const reg_t curr_vec, const reg_t pivot_vec, reg_t *smallest_vec, @@ -74,7 +74,7 @@ static inline int64_t partition_avx512(type_t *arr, reg_t max_vec = vtype::set1(*biggest); if (right - left == vtype::numlanes) { - argzmm_t argvec = argtype::loadu(arg + left); + argreg_t argvec = argtype::loadu(arg + left); reg_t vec = vtype::i64gather(arr, arg + left); int32_t amount_gt_pivot = partition_vec(arg, left, @@ -90,9 +90,9 @@ static inline int64_t partition_avx512(type_t *arr, } // first and last vtype::numlanes values are partitioned at the end - argzmm_t argvec_left = argtype::loadu(arg + left); + argreg_t argvec_left = argtype::loadu(arg + left); reg_t vec_left = vtype::i64gather(arr, arg + left); - argzmm_t argvec_right = argtype::loadu(arg + (right - vtype::numlanes)); + argreg_t argvec_right = argtype::loadu(arg + (right - vtype::numlanes)); reg_t vec_right = vtype::i64gather(arr, arg + (right - vtype::numlanes)); // store points of the vectors int64_t r_store = right - vtype::numlanes; @@ -101,7 +101,7 @@ static inline int64_t partition_avx512(type_t *arr, left += vtype::numlanes; right -= vtype::numlanes; while (right - left != 0) { - argzmm_t arg_vec; + argreg_t arg_vec; reg_t curr_vec; /* * if fewer elements are stored on the right side of the array, @@ -195,7 +195,7 @@ static inline int64_t partition_avx512_unrolled(type_t *arr, // first and last vtype::numlanes values are partitioned at the end reg_t vec_left[num_unroll], vec_right[num_unroll]; - argzmm_t argvec_left[num_unroll], argvec_right[num_unroll]; + argreg_t argvec_left[num_unroll], argvec_right[num_unroll]; X86_SIMD_SORT_UNROLL_LOOP(8) for (int ii = 0; ii < num_unroll; ++ii) { argvec_left[ii] = argtype::loadu(arg + left + vtype::numlanes * ii); @@ -212,7 +212,7 @@ X86_SIMD_SORT_UNROLL_LOOP(8) left += num_unroll * vtype::numlanes; right -= num_unroll * vtype::numlanes; while (right - left != 0) { - argzmm_t arg_vec[num_unroll]; + argreg_t arg_vec[num_unroll]; reg_t curr_vec[num_unroll]; /* * if fewer elements are stored on the right side of the array, diff --git a/src/avx512-common-qsort.h b/src/avx512-common-qsort.h index 4ebd9475..45430e0e 100644 --- a/src/avx512-common-qsort.h +++ b/src/avx512-common-qsort.h @@ -484,16 +484,16 @@ X86_SIMD_SORT_UNROLL_LOOP(8) template -static void COEX(zmm_t1 &key1, zmm_t1 &key2, zmm_t2 &index1, zmm_t2 &index2) + typename reg_t1 = typename vtype1::reg_t, + typename reg_t2 = typename vtype2::reg_t> +static void COEX(reg_t1 &key1, reg_t1 &key2, reg_t2 &index1, reg_t2 &index2) { - zmm_t1 key_t1 = vtype1::min(key1, key2); - zmm_t1 key_t2 = vtype1::max(key1, key2); + reg_t1 key_t1 = vtype1::min(key1, key2); + reg_t1 key_t2 = vtype1::max(key1, key2); - zmm_t2 index_t1 + reg_t2 index_t1 = vtype2::mask_mov(index2, vtype1::eq(key_t1, key1), index1); - zmm_t2 index_t2 + reg_t2 index_t2 = vtype2::mask_mov(index1, vtype1::eq(key_t1, key1), index2); key1 = key_t1; @@ -503,16 +503,16 @@ static void COEX(zmm_t1 &key1, zmm_t1 &key2, zmm_t2 &index1, zmm_t2 &index2) } template -static inline zmm_t1 cmp_merge(zmm_t1 in1, - zmm_t1 in2, - zmm_t2 &indexes1, - zmm_t2 indexes2, +static inline reg_t1 cmp_merge(reg_t1 in1, + reg_t1 in2, + reg_t2 &indexes1, + reg_t2 indexes2, opmask_t mask) { - zmm_t1 tmp_keys = cmp_merge(in1, in2, mask); + reg_t1 tmp_keys = cmp_merge(in1, in2, mask); indexes1 = vtype2::mask_mov(indexes2, vtype1::eq(tmp_keys, in1), indexes1); return tmp_keys; // 0 -> min, 1 -> max } @@ -525,17 +525,17 @@ template + typename reg_t1 = typename vtype1::reg_t, + typename reg_t2 = typename vtype2::reg_t> static inline int32_t partition_vec(type_t1 *keys, type_t2 *indexes, int64_t left, int64_t right, - const zmm_t1 keys_vec, - const zmm_t2 indexes_vec, - const zmm_t1 pivot_vec, - zmm_t1 *smallest_vec, - zmm_t1 *biggest_vec) + const reg_t1 keys_vec, + const reg_t2 indexes_vec, + const reg_t1 pivot_vec, + reg_t1 *smallest_vec, + reg_t1 *biggest_vec) { /* which elements are larger than the pivot */ typename vtype1::opmask_t gt_mask = vtype1::ge(keys_vec, pivot_vec); @@ -560,8 +560,8 @@ template + typename reg_t1 = typename vtype1::reg_t, + typename reg_t2 = typename vtype2::reg_t> static inline int64_t partition_avx512(type_t1 *keys, type_t2 *indexes, int64_t left, @@ -587,15 +587,15 @@ static inline int64_t partition_avx512(type_t1 *keys, if (left == right) return left; /* less than vtype1::numlanes elements in the array */ - zmm_t1 pivot_vec = vtype1::set1(pivot); - zmm_t1 min_vec = vtype1::set1(*smallest); - zmm_t1 max_vec = vtype1::set1(*biggest); + reg_t1 pivot_vec = vtype1::set1(pivot); + reg_t1 min_vec = vtype1::set1(*smallest); + reg_t1 max_vec = vtype1::set1(*biggest); if (right - left == vtype1::numlanes) { - zmm_t1 keys_vec = vtype1::loadu(keys + left); + reg_t1 keys_vec = vtype1::loadu(keys + left); int32_t amount_gt_pivot; - zmm_t2 indexes_vec = vtype2::loadu(indexes + left); + reg_t2 indexes_vec = vtype2::loadu(indexes + left); amount_gt_pivot = partition_vec(keys, indexes, left, @@ -612,10 +612,10 @@ static inline int64_t partition_avx512(type_t1 *keys, } // first and last vtype1::numlanes values are partitioned at the end - zmm_t1 keys_vec_left = vtype1::loadu(keys + left); - zmm_t1 keys_vec_right = vtype1::loadu(keys + (right - vtype1::numlanes)); - zmm_t2 indexes_vec_left; - zmm_t2 indexes_vec_right; + reg_t1 keys_vec_left = vtype1::loadu(keys + left); + reg_t1 keys_vec_right = vtype1::loadu(keys + (right - vtype1::numlanes)); + reg_t2 indexes_vec_left; + reg_t2 indexes_vec_right; indexes_vec_left = vtype2::loadu(indexes + left); indexes_vec_right = vtype2::loadu(indexes + (right - vtype1::numlanes)); @@ -626,8 +626,8 @@ static inline int64_t partition_avx512(type_t1 *keys, left += vtype1::numlanes; right -= vtype1::numlanes; while (right - left != 0) { - zmm_t1 keys_vec; - zmm_t2 indexes_vec; + reg_t1 keys_vec; + reg_t2 indexes_vec; /* * if fewer elements are stored on the right side of the array, * then next elements are loaded from the right side, @@ -757,7 +757,7 @@ X86_SIMD_SORT_INLINE type_t get_pivot_32bit(type_t *arr, { // median of 16 int64_t size = (right - left) / 16; - using zmm_t = typename vtype::reg_t; + using reg_t = typename vtype::reg_t; type_t vec_arr[16] = {arr[left + size], arr[left + 2 * size], arr[left + 3 * size], @@ -774,8 +774,8 @@ X86_SIMD_SORT_INLINE type_t get_pivot_32bit(type_t *arr, arr[left + 14 * size], arr[left + 15 * size], arr[left + 16 * size]}; - zmm_t rand_vec = vtype::loadu(vec_arr); - zmm_t sort = vtype::sort_vec(rand_vec); + reg_t rand_vec = vtype::loadu(vec_arr); + reg_t sort = vtype::sort_vec(rand_vec); // pivot will never be a nan, since there are no nan's! return ((type_t *)&sort)[8]; } @@ -787,8 +787,8 @@ X86_SIMD_SORT_INLINE type_t get_pivot_64bit(type_t *arr, { // median of 8 int64_t size = (right - left) / 8; - using zmm_t = typename vtype::reg_t; - zmm_t rand_vec = vtype::set(arr[left + size], + using reg_t = typename vtype::reg_t; + reg_t rand_vec = vtype::set(arr[left + size], arr[left + 2 * size], arr[left + 3 * size], arr[left + 4 * size], @@ -797,7 +797,7 @@ X86_SIMD_SORT_INLINE type_t get_pivot_64bit(type_t *arr, arr[left + 7 * size], arr[left + 8 * size]); // pivot will never be a nan, since there are no nan's! - zmm_t sort = vtype::sort_vec(rand_vec); + reg_t sort = vtype::sort_vec(rand_vec); return ((type_t *)&sort)[4]; }