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

#380 support multiple architectures for solver binaries z3 #395

Merged
merged 70 commits into from
Jan 26, 2025

Conversation

kfriedberger
Copy link
Member

@kfriedberger kfriedberger commented Sep 17, 2024

This branch / pull request exists for tracking some steps towards supporting multiple architectures. I will use Z3 as example, because it was requested several times. Some explanation can be found in #380 .

I will not yet commit binaries to any public archive (Ivy or Maven) until we can make sure that the new approach is backwards-compatible (e.g. default architecture x86 can be used as before) and we have a maintainable code base (including scripts and documentation for publication and testing).

@kfriedberger
Copy link
Member Author

kfriedberger commented Sep 29, 2024

This PR is currently blocked by sosy-lab/java-common-lib#43 to test execution on ARM64.

// UPDATE: The wording "blocked" is too much. Z3 is still not available for ARM64 on Linux, so local development is not affected and we could merge this PR.

@kfriedberger
Copy link
Member Author

kfriedberger commented Sep 29, 2024

The current state seems to work as expected. I tested:

  • publishing solver Z3 to Ivy and Maven, including x64 and arm64 for several operating systems ✔️
  • downloading from Ivy is backwards-compatible for Z3 (e.g., just increment the version of Z3). This works without changing the ivy-settings. We still need to find a way for publishing JavaSMT itself with a reasonable configuration.
  • downloading from Maven requires more smaller changes. For example, as shown in this change: 958dbc3

Z3 is already published in Maven and Ivy, and works well with JavaSMT 5.0.1.
Feel free to test and give feedback.

As I do not have an ARM-based Apple machine available, maybe @ThomasHaas and @hernanponcedeleon can test whether it works as expected. Thanks.

@kfriedberger
Copy link
Member Author

kfriedberger commented Sep 29, 2024

If there is positive feedback, I will also publish Z3 in its latest version 4.13.2 to Ivy and Maven. The publication of Z3 is even more automated now than it was before.

@ThomasHaas
Copy link
Contributor

It seems to work on ARM-based Macs now. Good job :)

@kfriedberger kfriedberger marked this pull request as ready for review October 12, 2024 11:43
@kfriedberger
Copy link
Member Author

kfriedberger commented Oct 12, 2024

Z3 was published to Ant/Ivy and Maven in versions 4.13.2 and 4.13.3.

There are some smaller issues that are currently blocking this PR from merging:

Not tested, not finished, just a draft.
This should keep the existing cache valid and re-usable.
Otherwise, we would create a new cache structure within the existing cache, with redundant entries.
With this change, we limit the redundancy to arch- or classifier-specific entries.
We could include x64 and ARM64 dependencies for Z3.
However, the default stays by only x64.
…rs, but only all other files.

This cleanup aligns better with Maven guidelines.
This is a small change for all upcoming publications to Maven and the Maven users.
…cture.

Additionally, we upload Java sources and JavaDoc for z3 to the Maven repository.

We need to test whether the uploaded files work as expected.
Let the user decide what to load,
e.g. on a minimal system only load for one specific OS and arch.
See Z3Prover/z3#7419 for details.
If required, the Z3 parser automatically converts Boolean formulas `f` to e.g. `ITE(f 1 0)`,
which makes them comparable to Integer symbols and numbers 0/1.
@kfriedberger
Copy link
Member Author

kfriedberger commented Jan 19, 2025

@daniel-raffler and @baierd : could you take a look and provide feedback? I would like to merge this PR in near time.

Beside Java-based solvers SMTInterpol and Princess, we now have 4 native solvers that are working on ARM64 platform:

  • with Linux on ARM64: Z3, MathSAT5, Bitwuzla, and OpenSMT.
  • with Windows and MacOS on ARM64: Z3

The current changes to Ivy are backwards-compatible and allow to use and update existing JavaSMT integrations without further changes (such as in CPAchecker). If the user wants to use binary solvers for ARM64, he can modify his Ivy dependency to load the corresponding files.

We already provide the corresponding files in Maven, so the user specify them via the pom-file..

Copy link
Collaborator

@baierd baierd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall very nice. I will test this PR on my Windows machine later today.

I have some small questions/suggestions, but did not find anything mayor.

build/build-maven-publish.xml Show resolved Hide resolved
build/build-publish-solvers/macros.xml Show resolved Hide resolved
build/build-maven-publish.xml Show resolved Hide resolved
@baierd
Copy link
Collaborator

baierd commented Jan 25, 2025

Something that might be worth a try is adding a static info() method that tries to read your OS and gives you information about available solvers, dependencies and requirements (e.g. copy the Windows binaries for a Dev build), or possibly even checks those requirements for you.

@kfriedberger
Copy link
Member Author

I would not expect such a info-feature from a library, but only in the main application.

The compilation will fail,
because JavaSMT is not yet released in a new version,
and some library names have been changed.
@kfriedberger
Copy link
Member Author

For executing and testing the ARM-based binaries, you can apply Podman/Docker with Qemu.
A corresponding Dockerfile would look like this:

FROM arm64v8/ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
ENV LANG=C.UTF-8

RUN apt-get update && apt-get install -y --no-install-recommends \
  wget curl \
  ant git \
  openjdk-17-jre-headless \
  openjdk-17-jdk-headless \
  libgomp1

Build with:

podman build --platform=linux/arm64 - < ubuntu2204-arm64.Dockerfile

The output will contain the ID in the last line.

Run with:

podman run -it \
    --mount type=bind,source=${HOME}/workspace,target=/workspace \
    --workdir /workspace/java-smt \
    ID

Podman/Docker with qemu is emulating ARM64 on x64 about 3-10 times slower than normal execution. I am thinking about an ARM-based CI, however Podman/Docker with Qemu might be too slow for that.

@kfriedberger kfriedberger requested a review from baierd January 25, 2025 20:04
Copy link
Collaborator

@baierd baierd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for incorporating my suggestions!

Do we want to document the Podman/Docker info in some file or issue?

@kfriedberger
Copy link
Member Author

The Podman/Docker file might be interesting for additional CI jobs. We will surely come across that topic in #384.

@kfriedberger kfriedberger merged commit ba42ae4 into master Jan 26, 2025
2 of 3 checks passed
@kfriedberger kfriedberger deleted the 380-multi-architecture-solver-binaries-z3 branch January 26, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants