Skip to content

Commit 064c32b

Browse files
committed
[chore] Support build on macOS.
1 parent 78a4545 commit 064c32b

5 files changed

Lines changed: 39 additions & 15 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ project(HECATE
3636
set(CMAKE_CXX_STANDARD 17)
3737
set(CMAKE_CXX_STANDARD_REQUIRED True)
3838
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
39-
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
39+
if (NOT DEFINED CMAKE_OSX_ARCHITECTURES)
40+
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
41+
else()
42+
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined,error")
43+
endif()
4044

4145
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
4246
message(STATUS "No build type selected, default to Release")

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ clang,clang++ >= 14.0.0
3535
git clone https://github.com/llvm/llvm-project.git
3636
cd llvm-project
3737
git checkout llvmorg-16.0.0
38+
# To build HECATE on macOS, please add `-DLLVM_BUILD_LLVM_DYLIB=ON`.
3839
cmake -GNinja -Bbuild \
3940
-DCMAKE_C_COMPILER=clang \
4041
-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release \

python/hecate/hecate/expr.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import inspect
55
from subprocess import Popen
66
from collections.abc import Iterable
7+
from platform import system
78
# import torch
89

910
import os
@@ -15,7 +16,15 @@
1516
hecateBuild = hecate_dir+"/build"
1617
heaan_keyset = "/heaan_keyset"
1718
libpath = hecateBuild + "/lib/"
18-
lt = ctypes.CDLL(libpath+"libHecateFrontend.so")
19+
libname = libpath
20+
osname = system()
21+
if osname == 'Linux':
22+
libname = libpath + "libHecateFrontend.so"
23+
elif osname == 'Darwin':
24+
libname = libpath + "libHecateFrontend.dylib"
25+
else:
26+
raise UnsupportedPlatform
27+
lt = ctypes.CDLL(libname)
1928
os.environ['PATH'] = libpath + os.pathsep + os.environ['PATH']
2029

2130

python/hecate/hecate/runner.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import inspect
77
from subprocess import Popen
88
from collections.abc import Iterable
9+
from platform import system
910
# import torch
1011

1112
import os
@@ -24,7 +25,15 @@
2425
hecateBuild = hecate_dir
2526

2627
libpath = hecateBuild / "lib"
27-
lw = ctypes.CDLL(libpath / "libSEAL_HEVM.so")
28+
libname = libpath
29+
osname = system()
30+
if osname == 'Linux':
31+
libname = libpath / "libSEAL_HEVM.so"
32+
elif osname == 'Darwin':
33+
libname = libpath / "libSEAL_HEVM.dylib"
34+
else:
35+
raise UnsupportedPlatform
36+
lw = ctypes.CDLL(libname)
2837
os.environ['PATH'] = str(libpath) + os.pathsep + os.environ['PATH']
2938

3039

@@ -106,6 +115,7 @@ def setInput(self, i, data) :
106115
if not isinstance(data, np.ndarray) :
107116
data = np.array(data, dtype=np.float64)
108117
carr = data.ctypes.data_as(ctypes.POINTER(ctypes.c_double))
118+
print(data)
109119
lw.encrypt(self.vm, i, carr, len(data))
110120

111121
def setDebug (self, enable) :

requirements.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ MarkupSafe==2.1.3
99
mpmath==1.3.0
1010
networkx==3.1
1111
numpy==1.25.2
12-
nvidia-cublas-cu11==11.10.3.66
13-
nvidia-cuda-cupti-cu11==11.7.101
14-
nvidia-cuda-nvrtc-cu11==11.7.99
15-
nvidia-cuda-runtime-cu11==11.7.99
16-
nvidia-cudnn-cu11==8.5.0.96
17-
nvidia-cufft-cu11==10.9.0.58
18-
nvidia-curand-cu11==10.2.10.91
19-
nvidia-cusolver-cu11==11.4.0.1
20-
nvidia-cusparse-cu11==11.7.4.91
21-
nvidia-nccl-cu11==2.14.3
22-
nvidia-nvtx-cu11==11.7.91
12+
nvidia-cublas-cu11==11.10.3.66 ; platform_system=="Linux"
13+
nvidia-cuda-cupti-cu11==11.7.101 ; platform_system=="Linux"
14+
nvidia-cuda-nvrtc-cu11==11.7.99 ; platform_system=="Linux"
15+
nvidia-cuda-runtime-cu11==11.7.99 ; platform_system=="Linux"
16+
nvidia-cudnn-cu11==8.5.0.96 ; platform_system=="Linux"
17+
nvidia-cufft-cu11==10.9.0.58 ; platform_system=="Linux"
18+
nvidia-curand-cu11==10.2.10.91 ; platform_system=="Linux"
19+
nvidia-cusolver-cu11==11.4.0.1 ; platform_system=="Linux"
20+
nvidia-cusparse-cu11==11.7.4.91 ; platform_system=="Linux"
21+
nvidia-nccl-cu11==2.14.3 ; platform_system=="Linux"
22+
nvidia-nvtx-cu11==11.7.91 ; platform_system=="Linux"
2323
Pillow==10.0.0
2424
requests==2.31.0
2525
sympy==1.12
2626
torch==2.0.1
2727
torchvision==0.15.2
28-
triton==2.0.0
28+
triton==2.0.0 ; platform_system=="Linux"
2929
typing_extensions==4.7.1
3030
urllib3==2.0.4

0 commit comments

Comments
 (0)