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

Add option to use 64-bit rapidhash for MacOS build #104

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

Conversation

msricher
Copy link
Collaborator

@msricher msricher commented Mar 6, 2025

Uses 64-bit rapidhash implementation instead of 128-bit spookyhash. For playing around on a Mac laptop, this should be fine.

Sets up spookyhash or rapidhash based on whether the command uname -s outputs 'Darwin' (the MacOS kernel).

Uses 64-bit rapidhash implementation instead of 128-bit spookyhash.
For playing around on a Mac laptop, this should be fine.

Sets up spookyhash or rapidhash based on whether
the command `uname -s` outputs 'Darwin' (the MacOS kernal).
@msricher msricher requested review from FanwangM and marco-2023 March 6, 2025 14:18
@FanwangM
Copy link
Contributor

FanwangM commented Mar 6, 2025

Thanks for this improvement. I have tried to install the package in a MacOS which ends up with the following errors,

In [1]: import pyci
-------------------------------------------------------------------------
ModuleNotFoundError                     Traceback (most recent call last)
Cell In[1], line 1
----> 1 import pyci

File /xxxx/xxxxx/tmp_py311/lib/python3.11/site-packages/pyci/__init__.py:18
      1 # This file is part of PyCI.
      2 #
      3 # PyCI is free software: you can redistribute it and/or modify it under
   (...)
     13 # You should have received a copy of the GNU General Public License
     14 # along with PyCI. If not, see <http://www.gnu.org/licenses/>.
     16 r"""PyCI module."""
---> 18 from pyci._pyci import __version__, c_long, c_ulong, c_double
     19 from pyci._pyci import secondquant_op, wavefunction, one_spin_wfn, two_spin_wfn
     20 from pyci._pyci import doci_wfn, fullci_wfn, genci_wfn, sparse_op

ModuleNotFoundError: No module named 'pyci._pyci'

The package was installed with pip install . after cloning the package. @msricher

@msricher
Copy link
Collaborator Author

msricher commented Mar 6, 2025

Ok, this seems to be a problem with file paths. It must need to be installed to different directory, or with a different file extension, for it to work. Although it seems to compile now, which is the hard part.

@msricher
Copy link
Collaborator Author

msricher commented Mar 6, 2025

Can you try renaming the .so file to .dylib and trying again?

@FanwangM
Copy link
Contributor

FanwangM commented Mar 7, 2025

I don't fully understand what you mean by It must need to be installed in a different directory or with a different file extension for it to work. because I installed it with pip install ., which actually installed the pyci in the virtual environment.

Following your suggestions of renaming .so to .dylib, but I was not able to find any .so file from the source or the installed codes. Can you provide more explanations? Thanks.

@msricher

@msricher
Copy link
Collaborator Author

msricher commented Mar 7, 2025

The instruction say to run make before pip install ., which compiles the C extension module, pyci.so (or similar name). Can you do that and then try renaming it from .so to .dylib?

@FanwangM
Copy link
Contributor

FanwangM commented Mar 7, 2025

yes, I just did that. Currently, I got errors when running make. I tried to install rapidhash manually, but didn't figure out a solution. Any suggestions on how to address the issue? Thanks.

c++ -std=c++14 -Wall -Wextra -pipe -O3 -fPIC -flto=auto -fvisibility=hidden -pthread -Ipyci/include -Ixxxx/tmp_py311/include/python3.11 -Ixxxx/tmp_py311/lib/python3.11/site-packages/numpy/_core/include -Ideps/eigen -Ideps/spectra/include -Ideps/parallel-hashmap -Ideps/pybind11/include -undefined dynamic_lookup -D_PYCI_VERSION='0.6.1' -D_GIT_BRANCH='rapidhash_macos' -D_BUILD_TIME='2025-03-07 18:15:43' -D_COMPILER_VERSION='Apple clang version 16.0.0 (clang-1600.0.26.6)' -D_USE_RAPIDHASH='1' -c pyci/src/SpookyV2.cpp -o pyci/src/SpookyV2.o
clang++: warning: argument unused during compilation: '-undefined dynamic_lookup' [-Wunused-command-line-argument]
c++ -std=c++14 -Wall -Wextra -pipe -O3 -fPIC -flto=auto -fvisibility=hidden -pthread -Ipyci/include -Ixxxx/tmp_py311/include/python3.11 -Ixxxx/tmp_py311/lib/python3.11/site-packages/numpy/_core/include -Ideps/eigen -Ideps/spectra/include -Ideps/parallel-hashmap -Ideps/pybind11/include -undefined dynamic_lookup -D_PYCI_VERSION='0.6.1' -D_GIT_BRANCH='rapidhash_macos' -D_BUILD_TIME='2025-03-07 18:15:43' -D_COMPILER_VERSION='Apple clang version 16.0.0 (clang-1600.0.26.6)' -D_USE_RAPIDHASH='1' -c pyci/src/ap1rog.cpp -o pyci/src/ap1rog.o
clang++: warning: argument unused during compilation: '-undefined dynamic_lookup' [-Wunused-command-line-argument]
In file included from pyci/src/ap1rog.cpp:16:
pyci/include/pyci.h:45:10: fatal error: 'rapidhash.h' file not found
   45 | #include <rapidhash.h>
      |          ^~~~~~~~~~~~~
1 error generated.
make: *** [pyci/src/ap1rog.o] Error 1

@msricher
Copy link
Collaborator Author

msricher commented Mar 7, 2025 via email

@msricher
Copy link
Collaborator Author

msricher commented Mar 7, 2025

OK, it should build now. Can you try the latest commit, and then if not, by renaming the .so->.dylib?

@FanwangM
Copy link
Contributor

FanwangM commented Mar 8, 2025

Still got errors when run make. Here is part of the error messages,

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/sort.h:51:1: note: candidate template ignored: substitution failure [with _AlgPolicy = std::_ClassicAlgPolicy, _Compare = std::__less<void, void> &, _ForwardIterator = std::sort_with_arg::value_iterator_t<double, long>]
   51 | __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c) {
      | ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/sort.h:92:7: error: no matching function for call to object of type 'std::__less<void, void>'
   92 |   if (__c(*__x4, *__x3)) {
      |       ^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/comp.h:40:60: note: candidate template ignored: substitution failure [with _Tp = value_reference_t<double, long>, _Up = value_reference_t<double, long>]
   40 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __lhs, const _Up& __rhs) const {
      |                                                            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make: *** [pyci/src/sparseop.o] Error 1

@msricher
Copy link
Collaborator Author

msricher commented Mar 8, 2025

Okay, I can't debug it over messages, I really need access to a Mac or someone with a Mac and proficiency in C++. It might be an issue with the CFLAGS in the Makefile, but I'd have to play around with them. Thanks for trying, though.

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