BUILD (8680B)
1 # Placeholder for cc_test, do not remove 2 3 package( 4 default_applicable_licenses = ["//:license"], 5 default_visibility = ["//visibility:public"], 6 ) 7 8 licenses(["notice"]) 9 10 # Unused on Bazel builds, where this is not defined/known; Copybara replaces 11 # usages with an empty list. 12 COMPAT = [ 13 "//buildenv/target:non_prod", # includes mobile/vendor. 14 ] 15 16 cc_library( 17 name = "intel", 18 # hdrs = select({ 19 # "//third_party/bazel_platforms/cpu:x86_64": [ 20 # "avx512-16bit-common.h", 21 # "avx512-16bit-qsort.hpp", 22 # "avx512-32bit-qsort.hpp", 23 # "avx512-64bit-common.h", 24 # "avx512-64bit-qsort.hpp", 25 # "avx512-common-qsort.h", 26 # ], 27 # "//conditions:default": [], 28 # }), 29 compatible_with = [], 30 ) 31 32 cc_library( 33 name = "vxsort", 34 srcs = [ 35 # "vxsort/isa_detection.cpp", 36 # "vxsort/isa_detection_msvc.cpp", 37 # "vxsort/isa_detection_sane.cpp", 38 # "vxsort/machine_traits.avx2.cpp", 39 # "vxsort/smallsort/avx2_load_mask_tables.cpp", 40 # "vxsort/smallsort/bitonic_sort.AVX2.double.generated.cpp", 41 # "vxsort/smallsort/bitonic_sort.AVX2.float.generated.cpp", 42 # "vxsort/smallsort/bitonic_sort.AVX2.int32_t.generated.cpp", 43 # "vxsort/smallsort/bitonic_sort.AVX2.int64_t.generated.cpp", 44 # "vxsort/smallsort/bitonic_sort.AVX2.uint32_t.generated.cpp", 45 # "vxsort/smallsort/bitonic_sort.AVX2.uint64_t.generated.cpp", 46 # "vxsort/smallsort/bitonic_sort.AVX512.double.generated.cpp", 47 # "vxsort/smallsort/bitonic_sort.AVX512.float.generated.cpp", 48 # "vxsort/smallsort/bitonic_sort.AVX512.int32_t.generated.cpp", 49 # "vxsort/smallsort/bitonic_sort.AVX512.int64_t.generated.cpp", 50 # "vxsort/smallsort/bitonic_sort.AVX512.uint32_t.generated.cpp", 51 # "vxsort/smallsort/bitonic_sort.AVX512.uint64_t.generated.cpp", 52 # "vxsort/vxsort_stats.cpp", 53 ], 54 hdrs = [ 55 # "vxsort/alignment.h", 56 # "vxsort/defs.h", 57 # "vxsort/isa_detection.h", 58 # "vxsort/machine_traits.avx2.h", 59 # "vxsort/machine_traits.avx512.h", 60 # "vxsort/machine_traits.h", 61 # "vxsort/packer.h", 62 # "vxsort/smallsort/bitonic_sort.AVX2.double.generated.h", 63 # "vxsort/smallsort/bitonic_sort.AVX2.float.generated.h", 64 # "vxsort/smallsort/bitonic_sort.AVX2.int32_t.generated.h", 65 # "vxsort/smallsort/bitonic_sort.AVX2.int64_t.generated.h", 66 # "vxsort/smallsort/bitonic_sort.AVX2.uint32_t.generated.h", 67 # "vxsort/smallsort/bitonic_sort.AVX2.uint64_t.generated.h", 68 # "vxsort/smallsort/bitonic_sort.AVX512.double.generated.h", 69 # "vxsort/smallsort/bitonic_sort.AVX512.float.generated.h", 70 # "vxsort/smallsort/bitonic_sort.AVX512.int32_t.generated.h", 71 # "vxsort/smallsort/bitonic_sort.AVX512.int64_t.generated.h", 72 # "vxsort/smallsort/bitonic_sort.AVX512.uint32_t.generated.h", 73 # "vxsort/smallsort/bitonic_sort.AVX512.uint64_t.generated.h", 74 # "vxsort/smallsort/bitonic_sort.h", 75 # "vxsort/vxsort.h", 76 # "vxsort/vxsort_stats.h", 77 ], 78 compatible_with = [], 79 textual_hdrs = [ 80 # "vxsort/vxsort_targets_disable.h", 81 # "vxsort/vxsort_targets_enable_avx2.h", 82 # "vxsort/vxsort_targets_enable_avx512.h", 83 ], 84 ) 85 86 VQSORT_SRCS = [ 87 # Split into separate files to reduce MSVC build time. 88 "vqsort_128a.cc", 89 "vqsort_128d.cc", 90 "vqsort_f16a.cc", 91 "vqsort_f16d.cc", 92 "vqsort_f32a.cc", 93 "vqsort_f32d.cc", 94 "vqsort_f64a.cc", 95 "vqsort_f64d.cc", 96 "vqsort_i16a.cc", 97 "vqsort_i16d.cc", 98 "vqsort_i32a.cc", 99 "vqsort_i32d.cc", 100 "vqsort_i64a.cc", 101 "vqsort_i64d.cc", 102 # vqsort_kv64a.cc is in :vqsort_k32v32 and vqsort.cc is in :vqsort_shared. 103 "vqsort_kv128a.cc", 104 "vqsort_kv128d.cc", 105 "vqsort_u16a.cc", 106 "vqsort_u16d.cc", 107 "vqsort_u32a.cc", 108 "vqsort_u32d.cc", 109 "vqsort_u64a.cc", 110 "vqsort_u64d.cc", 111 ] 112 113 VQSORT_TEXTUAL_HDRS = [ 114 "shared-inl.h", 115 "sorting_networks-inl.h", 116 "traits-inl.h", 117 "traits128-inl.h", 118 "vqsort-inl.h", 119 # Placeholder for internal instrumentation. Do not remove. 120 ] 121 122 # both :vqsort_k32v32 and :vqsort depend on this. 123 cc_library( 124 name = "vqsort_shared", 125 srcs = [ 126 "vqsort.cc", 127 ], 128 hdrs = [ 129 "order.h", # part of public interface, included by vqsort.h 130 "vqsort.h", # public interface 131 ], 132 compatible_with = [], 133 local_defines = ["hwy_contrib_EXPORTS"], 134 textual_hdrs = VQSORT_TEXTUAL_HDRS, 135 deps = [ 136 "//:algo", 137 "//:hwy", 138 ], 139 ) 140 141 cc_library( 142 name = "vqsort_k32v32", 143 srcs = [ 144 "vqsort_kv64a.cc", 145 "vqsort_kv64d.cc", 146 ], 147 hdrs = [ 148 "order.h", # part of public interface, included by vqsort.h 149 "vqsort.h", # public interface 150 ], 151 compatible_with = [], 152 local_defines = ["hwy_contrib_EXPORTS"], 153 textual_hdrs = VQSORT_TEXTUAL_HDRS, 154 deps = [ 155 ":vqsort_shared", 156 "//:algo", 157 "//:hwy", 158 ], 159 ) 160 161 cc_library( 162 name = "vqsort", 163 srcs = VQSORT_SRCS, 164 hdrs = [ 165 "order.h", # part of public interface, included by vqsort.h 166 "vqsort.h", # public interface 167 ], 168 compatible_with = [], 169 local_defines = ["hwy_contrib_EXPORTS"], 170 textual_hdrs = VQSORT_TEXTUAL_HDRS, 171 deps = [ 172 ":intel", # required if HAVE_INTEL 173 ":vqsort_k32v32", 174 ":vqsort_shared", 175 ":vxsort", # required if HAVE_VXSORT 176 "//:algo", 177 "//:hwy", 178 "//:nanobenchmark", 179 ], 180 ) 181 182 # ----------------------------------------------------------------------------- 183 # Internal-only targets 184 185 # Same as vqsort, but add HWY_COMPILE_ALL_ATTAINABLE to ensure we cover all 186 # targets. Do not enable this in the main vqsort because it increases 187 # compile times. 188 cc_library( 189 name = "vqsort_for_test", 190 srcs = VQSORT_SRCS, 191 hdrs = [ 192 "order.h", # part of public interface, included by vqsort.h 193 "vqsort.h", # public interface 194 ], 195 compatible_with = [], 196 local_defines = [ 197 "hwy_contrib_EXPORTS", 198 # Build for all targets because sort_test will dynamic-dispatch to all. 199 "HWY_COMPILE_ALL_ATTAINABLE", 200 ], 201 textual_hdrs = VQSORT_TEXTUAL_HDRS, 202 deps = [ 203 "//:algo", 204 "//:hwy", 205 "//:nanobenchmark", 206 ], 207 ) 208 209 cc_library( 210 name = "helpers", 211 testonly = 1, 212 textual_hdrs = [ 213 "algo-inl.h", 214 "result-inl.h", 215 ], 216 deps = [ 217 ":vqsort", 218 "//:nanobenchmark", 219 # Required for HAVE_PDQSORT, but that is unused and this is 220 # unavailable to Bazel builds, hence commented out. 221 # "//third_party/boost/allowed", 222 # Avoid ips4o and thus TBB to work around hwloc build failure. 223 ], 224 ) 225 226 cc_binary( 227 name = "print_network", 228 testonly = 1, 229 srcs = ["print_network.cc"], 230 deps = [ 231 ":helpers", 232 ":vqsort", 233 "//:hwy", 234 ], 235 ) 236 237 TEST_MAIN = select({ 238 "//:compiler_msvc": [], 239 "//conditions:default": ["@com_google_googletest//:gtest_main"], 240 }) 241 242 cc_test( 243 name = "sort_unit_test", 244 size = "small", 245 srcs = ["sort_unit_test.cc"], 246 # Do not enable fully_static_link (pthread crash on bazel) 247 local_defines = ["HWY_IS_TEST"], 248 # for test_suite. 249 tags = ["hwy_ops_test"], 250 deps = [ 251 ":helpers", 252 ":vqsort_for_test", 253 "//:hwy", 254 "//:hwy_test_util", 255 ] + TEST_MAIN, 256 ) 257 258 cc_test( 259 name = "sort_test", 260 size = "medium", 261 timeout = "long", 262 srcs = ["sort_test.cc"], 263 # Do not enable fully_static_link (pthread crash on bazel) 264 local_defines = ["HWY_IS_TEST"], 265 # for test_suite. 266 tags = ["hwy_ops_test"], 267 deps = [ 268 ":helpers", 269 ":vqsort_for_test", 270 "//:hwy", 271 "//:hwy_test_util", 272 "//:thread_pool", 273 "//:topology", 274 ] + TEST_MAIN, 275 ) 276 277 cc_test( 278 name = "bench_sort", 279 size = "medium", 280 srcs = ["bench_sort.cc"], 281 # Do not enable fully_static_link (pthread crash on bazel) 282 local_defines = ["HWY_IS_TEST"], 283 # for test_suite. 284 tags = ["hwy_ops_test"], 285 deps = [ 286 ":helpers", 287 ":vqsort", 288 "//:hwy", 289 "//:hwy_test_util", 290 "//:nanobenchmark", 291 "//:thread_pool", 292 ] + TEST_MAIN, 293 ) 294 295 cc_binary( 296 name = "bench_parallel", 297 testonly = 1, 298 srcs = ["bench_parallel.cc"], 299 # Do not enable fully_static_link (pthread crash on bazel) 300 local_defines = ["HWY_IS_TEST"], 301 deps = [ 302 ":helpers", 303 ":vqsort", 304 "//:hwy", 305 "//:hwy_test_util", 306 "//:nanobenchmark", 307 ] + TEST_MAIN, 308 )