Skip to content

Commit d520b37

Browse files
committed
Add describe static function to svs.microarchand fix pipelines
1 parent 658c770 commit d520b37

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

.github/workflows/build-linux-arm.yml

+14
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,17 @@ jobs:
7474
CTEST_OUTPUT_ON_FAILURE: 1
7575
working-directory: ${{ runner.temp }}/build/tests
7676
run: ctest -C ${{ matrix.build_type }}
77+
78+
- name: Build Python Bindings
79+
env:
80+
CXX: ${{ matrix.cxx }}
81+
CC: ${{ matrix.cc }}
82+
run: |
83+
cd bindings/python
84+
python -m pip install .
85+
86+
- name: Run Python Microarch Test
87+
run: |
88+
cd bindings/python
89+
python -c "import svs; svs.microarch.describe()"
90+
python -m unittest discover -p "test_microarch.py" -s .

.github/workflows/build-linux.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ jobs:
103103
104104
- name: Run Python Microarch Test with SDE
105105
run: |
106+
cd bindings/python
106107
for flag in nhm hsw skx clx icl spr; do
107108
echo "SDE emulation: $flag"
108109
export SDE_FLAG=$flag
109-
sde64 -$flag -- bash ${GITHUB_WORKSPACE}/.github/scripts/get_cpu_info.sh
110+
sde64 -$flag -- python -c "import svs; svs.microarch.describe()"
110111
sde64 -$flag -- python -m unittest discover -p "test_microarch.py" -s .
111112
done

.github/workflows/build-macos.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,17 @@ jobs:
8787
CTEST_OUTPUT_ON_FAILURE: 1
8888
working-directory: ${{ runner.temp }}/build/tests
8989
run: ctest -C ${{ matrix.build_type }}
90+
91+
- name: Build Python Bindings
92+
env:
93+
CXX: ${{ matrix.cxx }}
94+
CC: ${{ matrix.cc }}
95+
run: |
96+
cd bindings/python
97+
python -m pip install .
98+
99+
- name: Run Python Microarch Test
100+
run: |
101+
cd bindings/python
102+
python -c "import svs; svs.microarch.describe()"
103+
python -m unittest discover -p "test_microarch.py" -s .

bindings/python/src/python_bindings.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
// stl
4545
#include <filesystem>
4646
#include <optional>
47+
#include <iostream>
4748

4849
namespace py = pybind11;
4950

@@ -188,6 +189,13 @@ Convert the `fvecs` file on disk with 32-bit floating point entries to a `fvecs`
188189

189190
wrap_conversion(m);
190191

192+
m.def(
193+
"_print_cpu_extensions_status",
194+
[]() {
195+
svs::arch::write_extensions_status(std::cout);
196+
}
197+
);
198+
191199
// Wrapper for svs::arch::MicroArchEnvironment
192200
py::class_<svs::arch::MicroArchEnvironment>(m, "microarch", "Microarchitecture management singleton")
193201
.def_static(
@@ -233,6 +241,36 @@ Convert the `fvecs` file on disk with 32-bit floating point entries to a `fvecs`
233241
return result;
234242
},
235243
"Returns a list of compiled microarchitectures."
244+
)
245+
.def_static(
246+
"describe",
247+
[]() {
248+
std::ostream& out = std::cout;
249+
auto& arch_env = svs::arch::MicroArchEnvironment::get_instance();
250+
251+
// Print support status for all ISA extensions
252+
svs::arch::write_extensions_status(out);
253+
254+
// Print current microarchitecture
255+
auto current_arch = arch_env.get_microarch();
256+
out << "\nCurrent µarch: " << svs::arch::microarch_to_string(current_arch) << std::endl;
257+
258+
// Print all supported microarchitectures
259+
const auto& supported_archs = arch_env.get_supported_microarchs();
260+
out << "\nSupported µarchs: ";
261+
for (const auto& arch : supported_archs) {
262+
out << svs::arch::microarch_to_string(arch) << " ";
263+
}
264+
out << std::endl;
265+
266+
// Print all compiled microarchitectures
267+
const auto& compiled_archs = arch_env.get_compiled_microarchs();
268+
out << "\nCompiled µarchs: ";
269+
for (const auto& arch : compiled_archs) {
270+
out << svs::arch::microarch_to_string(arch) << " ";
271+
}
272+
out << std::endl;
273+
}
236274
);
237275

238276
// Allocators

0 commit comments

Comments
 (0)