-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathisa_coverage_test.sh
More file actions
69 lines (62 loc) · 2.17 KB
/
isa_coverage_test.sh
File metadata and controls
69 lines (62 loc) · 2.17 KB
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
#!/usr/bin/env bash
#===============================================================================
# Copyright contributors to the oneDAL project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================
#
# Verifies that libonedal_core.so contains CPU dispatch symbols for all
# required ISA variants: sse2, sse42, avx2, avx512 (CpuType E0/E2/E4/E6).
#
# Make builds all 4 ISA variants by default. Building via //:release
# automatically compiles all ISA variants (cfg transition on release rule).
# This test enforces that contract.
set -euo pipefail
LIB="${1:-}"
if [[ -z "${LIB}" ]]; then
echo "Usage: $0 <path-to-libonedal_core.so>"
exit 1
fi
if [[ ! -f "${LIB}" ]]; then
echo "ERROR: Library not found: ${LIB}"
exit 1
fi
PASS=0
FAIL=0
check_isa() {
local cpu_type="$1" # e.g. CpuTypeE2
local isa_name="$2" # e.g. sse42
local count
count=$(nm -D "${LIB}" | grep -c "${cpu_type}" || true)
if [[ "${count}" -gt 0 ]]; then
echo " OK ${isa_name} (${cpu_type}): ${count} dispatch symbols"
PASS=$((PASS + 1))
else
echo " FAIL ${isa_name} (${cpu_type}): 0 dispatch symbols found"
echo " Build via //:release (uses all ISAs via cfg transition) or pass --cpu=all"
FAIL=$((FAIL + 1))
fi
}
echo "=== ISA coverage check: $(basename "${LIB}") ==="
check_isa "CpuTypeE0" "sse2"
check_isa "CpuTypeE2" "sse42"
check_isa "CpuTypeE4" "avx2"
check_isa "CpuTypeE6" "avx512"
echo ""
if [[ "${FAIL}" -gt 0 ]]; then
echo "RESULT: FAILED (${FAIL} ISA(s) missing, ${PASS} present)"
exit 1
else
echo "RESULT: PASSED (all 4 ISA variants present)"
exit 0
fi