Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac support #67

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Mac support #67

wants to merge 2 commits into from

Conversation

thebabush
Copy link

@thebabush thebabush commented Nov 6, 2024

Hi guys,

as pointed out on Twitter, amazing stuff.

This is me trying to add Mac support. Problem being lapjv doesn't work on Mac and I'd rather fix things on the python side than figuring out Cpp builds. It also seems like lapjv was never compiled on non-x86 as it pulls immintrin.h at the top level.

So yeah, I pulled in lapx and this is what I get for tests on py312:

% uv tool run tox run -e py312
.pkg: _optional_hooks> python /Users/ciao/.cache/uv/archive-v0/-gLQxuIFvlfE9VPhZaeST/lib/python3.12/site-packages/pyproject_api/_backend.py True mesonpy
.pkg: get_requires_for_build_wheel> python /Users/ciao/.cache/uv/archive-v0/-gLQxuIFvlfE9VPhZaeST/lib/python3.12/site-packages/pyproject_api/_backend.py True mesonpy
.pkg: build_wheel> python /Users/ciao/.cache/uv/archive-v0/-gLQxuIFvlfE9VPhZaeST/lib/python3.12/site-packages/pyproject_api/_backend.py True mesonpy
py312: install_package> python -I -m pip install --force-reinstall --no-deps /Users/ciao/src/qbindiff/.tox/.tmp/package/16/qbindiff-1.2.2-cp312-cp312-macosx_15_0_arm64.whl
py312: commands[0]> pytest --color=yes
=============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0
cachedir: .tox/py312/.pytest_cache
rootdir: /Users/ciao/src/qbindiff
configfile: pyproject.toml
collected 16 items

tests/test_binary.py ..                                                                                                                                                     [ 12%]
tests/test_graph.py ...                                                                                                                                                     [ 31%]
tests/test_sparse_matrix.py ........                                                                                                                                        [ 81%]
tests/test_squares.py ...                                                                                                                                                   [100%]

=============================================================================== 16 passed in 45.42s ===============================================================================
.pkg: _exit> python /Users/ciao/.cache/uv/archive-v0/-gLQxuIFvlfE9VPhZaeST/lib/python3.12/site-packages/pyproject_api/_backend.py True mesonpy
  py312: OK (50.08=setup[4.50]+cmd[45.59] seconds)
  congratulations :) (50.11 seconds)

Hopefully your tests would catch a problem in my commits? 😬
I'm open to trying out more stuff (now I'm moving to actually trying out qbindiff).

Performance-wise I have no idea how lapx compares to lapjv, but from a quick look at the code lapx isn't doing any fancy optimization.

Side note: matcher.py mentions col_indices but lapjv calls the same return value row_ind_lapjv. I didn't rename in the outer function, but that looks weird to my monkey brain.

@thebabush
Copy link
Author

Side note 2: there's also this guy https://github.com/raphaelreme/pylapy that wraps lapx / etc in a package and defaults to the best implementation on the current system. Maybe you should just depend on that?

@patacca patacca self-assigned this Nov 7, 2024
@patacca
Copy link
Collaborator

patacca commented Nov 7, 2024

Thanks for the PR, indeed lapjv was intended to be a linear assignment problem solver optimized for intel SSE/AVX2. This means that it will never work on aarch64 architecture. I see no problem in using another library for mac. In fact we might even ditch lapjv entirely in favor of lapx just to relax the dependencies that are already heavy enough ^^.

On a side note regarding python 3.12, officially qbindiff is not supporting it yet because capstone was not supporting it either. Recently, though, they released a version compatible with python 3.12 so we should address that as well.

@thebabush
Copy link
Author

This means that it will never work on aarch64 architecture.

Technically they have a slow path in C I believe? But yeah agreed.

In fact we might even ditch lapjv entirely in favor of lapx just to relax the dependencies that are already heavy enough ^^

I don't know how much faster/efficient lapjv is so idk, but pylapy could solve all the issues by falling back to the best implementation available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants