qcc4cp / qcc

Source code for the book "Quantum Computing for Programmers", Cambridge University Press
Apache License 2.0
83 stars 26 forks source link

Compiling lilxgates in MacBook Air M2 #19

Closed maremnev closed 12 months ago

maremnev commented 1 year ago

Hi!

I tried to run qcc simulator on a MacBook Air with the processor M2. The macOS is Ventura 13.5.2. It works correctly. The python was installed though brew and downloaded by git.

But I can't run it with C++ accelerator, the module returns the message:

**************************************************************`
  WARNING: Could not find 'libxgates.so'.
  Please build it and point PYTHONPATH to it.
  Execution is being re-directed to a Python implementation,
  performance may suffer greatly.
  **************************************************************`

All paths are corrected according libraries place that file WORKSPACE takes into accounts the python positions:

new_local_repository(
    name = "third_party_python",
    build_file = __workspace_dir__ + "/python.BUILD",
    # Configure:
    path = "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers/",
)

new_local_repository(
    name = "third_party_numpy",
    build_file = __workspace_dir__ + "/numpy.BUILD",
    # Configure:
    path = "/Users/maremnev/Library/Python/3.9/lib/python/site-packages/numpy/core/",
)

And variables PATH and PYTHONPATH are corrected too:

export PATH=/Users/maremnev/WorkPlace/qcc:$PATH
export PYTHONPATH=/Users/maremnev/WorkPlace/qcc:$PYTHONPATH

export PYTHONPATH=/Users/maremnev/WorkPlace/qcc/bazel-bin/src/lib:$PYTHONPATH

Command bazel build all returns no errors. But it made in directory qcc/bazel-bin/src/lib files libxgates.a and libxgates.dylib, but python searchs for file libxgates.so.

I guess it's a remainder from Linux.

How to compile the library correctly in Mac? May be it's needed to point the another library in python?

maremnev commented 1 year ago

I eliminated the warning message by copying libxgates.dylib into libxgates.so. But I'm not sure it's correct.

qcc4cp commented 1 year ago

Thanks Mikhail

Yes, this seems to work, I ran into the same issue with a new MacMini I just got. I actually don't know what exactly is happening here ;-) I will investigate and likely update something to make it work across environments. I'll keep you posted.

On Tue, Oct 31, 2023 at 9:02 AM Mikhail Remnev @.***> wrote:

I eliminated the warning message by copying libxgates.dylib into libxgates.so. But I'm not sure it's correct.

— Reply to this email directly, view it on GitHub https://github.com/qcc4cp/qcc/issues/19#issuecomment-1787520516, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASSDND6PPF7OHR4SGLYTBQ3YCEOKVAVCNFSM6AAAAAA6PIBE7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBXGUZDANJRGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Robert Hundt

hundt98847 commented 1 year ago

Hmm, I tried but failed. I think I will have to update the documentation for MacOS and also improve the warning message a bit. Thanks R

On Tue, Oct 31, 2023 at 9:07 AM Robert Hundt @.***> wrote:

Thanks Mikhail

Yes, this seems to work, I ran into the same issue with a new MacMini I just got. I actually don't know what exactly is happening here ;-) I will investigate and likely update something to make it work across environments. I'll keep you posted.

On Tue, Oct 31, 2023 at 9:02 AM Mikhail Remnev @.***> wrote:

I eliminated the warning message by copying libxgates.dylib into libxgates.so. But I'm not sure it's correct.

— Reply to this email directly, view it on GitHub https://github.com/qcc4cp/qcc/issues/19#issuecomment-1787520516, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ASSDND6PPF7OHR4SGLYTBQ3YCEOKVAVCNFSM6AAAAAA6PIBE7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBXGUZDANJRGY>

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Robert Hundt

— Reply to this email directly, view it on GitHub https://github.com/qcc4cp/qcc/issues/19#issuecomment-1787528541, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEWY3GYGNGD5WIHFO4FIUDYCEO23AVCNFSM6AAAAAA6PIBE7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBXGUZDQNJUGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Robert Hundt

qcc4cp commented 1 year ago

Oh wait, as I write this notice, it turns out the solution may be to just rename the rule in the src/lib/BUILD file to specify the full filename (libxgates.so instead of just xgates). I will check that in and test it for the OSs that I have.

Thanks R

On Sat, Nov 4, 2023 at 9:12 AM Robert Hundt @.***> wrote:

Hmm, I tried but failed. I think I will have to update the documentation for MacOS and also improve the warning message a bit. Thanks R

On Tue, Oct 31, 2023 at 9:07 AM Robert Hundt @.***> wrote:

Thanks Mikhail

Yes, this seems to work, I ran into the same issue with a new MacMini I just got. I actually don't know what exactly is happening here ;-) I will investigate and likely update something to make it work across environments. I'll keep you posted.

On Tue, Oct 31, 2023 at 9:02 AM Mikhail Remnev @.***> wrote:

I eliminated the warning message by copying libxgates.dylib into libxgates.so. But I'm not sure it's correct.

— Reply to this email directly, view it on GitHub https://github.com/qcc4cp/qcc/issues/19#issuecomment-1787520516, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ASSDND6PPF7OHR4SGLYTBQ3YCEOKVAVCNFSM6AAAAAA6PIBE7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBXGUZDANJRGY>

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Robert Hundt

— Reply to this email directly, view it on GitHub https://github.com/qcc4cp/qcc/issues/19#issuecomment-1787528541, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABEWY3GYGNGD5WIHFO4FIUDYCEO23AVCNFSM6AAAAAA6PIBE7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBXGUZDQNJUGE>

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Robert Hundt

— Reply to this email directly, view it on GitHub https://github.com/qcc4cp/qcc/issues/19#issuecomment-1793485914, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASSDND2OX6TMMV3PQ7SG6ZLYCZSO7AVCNFSM6AAAAAA6PIBE7OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTGQ4DKOJRGQ . You are receiving this because you commented.Message ID: @.***>

-- Robert Hundt

qcc4cp commented 12 months ago

The fix seems to work. Checked in. Thank you again (I also added your name to the Thank You notes in the README.md).