summaryrefslogtreecommitdiffstats
path: root/third_party/highway/hwy/contrib/sort/BUILD
blob: af4ed78837dfd40894a72d98c74bc0ed8f22f5ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package(
    default_applicable_licenses = ["//:license"],
    default_visibility = ["//visibility:public"],
)

licenses(["notice"])

# Unused on Bazel builds, where this is not defined/known; Copybara replaces
# usages with an empty list.
COMPAT = [
    "//buildenv/target:non_prod",  # includes mobile/vendor.
]

# cc_library(
#     name = "vxsort",
#     srcs = [
#         "vxsort/isa_detection.cpp",
#         "vxsort/isa_detection_msvc.cpp",
#         "vxsort/isa_detection_sane.cpp",
#         "vxsort/machine_traits.avx2.cpp",
#         "vxsort/smallsort/avx2_load_mask_tables.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX2.double.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX2.float.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX2.int32_t.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX2.int64_t.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX2.uint32_t.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX2.uint64_t.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX512.double.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX512.float.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX512.int32_t.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX512.int64_t.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX512.uint32_t.generated.cpp",
#         "vxsort/smallsort/bitonic_sort.AVX512.uint64_t.generated.cpp",
#         "vxsort/vxsort_stats.cpp",
#     ],
#     hdrs = [
#         "vxsort/alignment.h",
#         "vxsort/defs.h",
#         "vxsort/isa_detection.h",
#         "vxsort/machine_traits.avx2.h",
#         "vxsort/machine_traits.avx512.h",
#         "vxsort/machine_traits.h",
#         "vxsort/packer.h",
#         "vxsort/smallsort/bitonic_sort.AVX2.double.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX2.float.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX2.int32_t.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX2.int64_t.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX2.uint32_t.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX2.uint64_t.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX512.double.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX512.float.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX512.int32_t.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX512.int64_t.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX512.uint32_t.generated.h",
#         "vxsort/smallsort/bitonic_sort.AVX512.uint64_t.generated.h",
#         "vxsort/smallsort/bitonic_sort.h",
#         "vxsort/vxsort.h",
#         "vxsort/vxsort_stats.h",
#     ],
#     compatible_with = [],
#     textual_hdrs = [
#         "vxsort/vxsort_targets_disable.h",
#         "vxsort/vxsort_targets_enable_avx2.h",
#         "vxsort/vxsort_targets_enable_avx512.h",
#     ],
# )

cc_library(
    name = "vqsort",
    srcs = [
        # Split into separate files to reduce MSVC build time.
        "vqsort.cc",
        "vqsort_128a.cc",
        "vqsort_128d.cc",
        "vqsort_f32a.cc",
        "vqsort_f32d.cc",
        "vqsort_f64a.cc",
        "vqsort_f64d.cc",
        "vqsort_i16a.cc",
        "vqsort_i16d.cc",
        "vqsort_i32a.cc",
        "vqsort_i32d.cc",
        "vqsort_i64a.cc",
        "vqsort_i64d.cc",
        "vqsort_kv64a.cc",
        "vqsort_kv64d.cc",
        "vqsort_kv128a.cc",
        "vqsort_kv128d.cc",
        "vqsort_u16a.cc",
        "vqsort_u16d.cc",
        "vqsort_u32a.cc",
        "vqsort_u32d.cc",
        "vqsort_u64a.cc",
        "vqsort_u64d.cc",
    ],
    hdrs = [
        "vqsort.h",  # public interface
    ],
    compatible_with = [],
    local_defines = ["hwy_contrib_EXPORTS"],
    textual_hdrs = [
        "shared-inl.h",
        "sorting_networks-inl.h",
        "traits-inl.h",
        "traits128-inl.h",
        "vqsort-inl.h",
        # Placeholder for internal instrumentation. Do not remove.
    ],
    deps = [
        # Only if VQSORT_SECURE_RNG is set.
        # "//third_party/absl/random",
        "//:hwy",
        # ":vxsort",  # required if HAVE_VXSORT
    ],
)

# -----------------------------------------------------------------------------
# Internal-only targets

cc_library(
    name = "helpers",
    testonly = 1,
    textual_hdrs = [
        "algo-inl.h",
        "result-inl.h",
    ],
    deps = [
        ":vqsort",
        "//:nanobenchmark",
        # Required for HAVE_PDQSORT, but that is unused and this is
        # unavailable to Bazel builds, hence commented out.
        # "//third_party/boost/allowed",
        # Avoid ips4o and thus TBB to work around hwloc build failure.
    ],
)

cc_binary(
    name = "print_network",
    testonly = 1,
    srcs = ["print_network.cc"],
    deps = [
        ":helpers",
        ":vqsort",
        "//:hwy",
    ],
)

cc_test(
    name = "sort_test",
    size = "medium",
    srcs = ["sort_test.cc"],
    # Do not enable fully_static_link (pthread crash on bazel)
    local_defines = ["HWY_IS_TEST"],
    # for test_suite.
    tags = ["hwy_ops_test"],
    deps = [
        ":helpers",
        ":vqsort",
        "@com_google_googletest//:gtest_main",
        "//:hwy",
        "//:hwy_test_util",
    ],
)

cc_binary(
    name = "bench_sort",
    testonly = 1,
    srcs = ["bench_sort.cc"],
    # Do not enable fully_static_link (pthread crash on bazel)
    local_defines = ["HWY_IS_TEST"],
    deps = [
        ":helpers",
        ":vqsort",
        "@com_google_googletest//:gtest_main",
        "//:hwy",
        "//:hwy_test_util",
    ],
)

cc_binary(
    name = "bench_parallel",
    testonly = 1,
    srcs = ["bench_parallel.cc"],
    # Do not enable fully_static_link (pthread crash on bazel)
    local_defines = ["HWY_IS_TEST"],
    deps = [
        ":helpers",
        ":vqsort",
        "@com_google_googletest//:gtest_main",
        "//:hwy",
        "//:hwy_test_util",
    ],
)