Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ build:linux-release --action_env=BAZEL_LINKLIBS=-l%:libstdc++.a:-l%:libgcc.a
# platform specific config
# Bazel will automatic pick platform config since we have enable_platform_specific_config set
build:macos --copt=-Wno-unused-command-line-argument
build:macos --copt=-Wno-vla-cxx-extension
build:macos --features=-supports_dynamic_linker
build:macos --macos_minimum_os=12.0
build:macos --host_macos_minimum_os=12.0

# Fix yacl VLA warning on macOS Clang (Xcode 16.4+)
build --per_file_copt=external/yacl.*openssl.*@-Wno-vla-cxx-extension
# Fix brpc deprecated protobuf API warning
build --per_file_copt=external/yacl.*brpc.*@-Wno-deprecated-declarations
build --per_file_copt=external/brpc.*@-Wno-deprecated-declarations

# NOTE: fix build on linux_aarch64, since `build:linux_aarch64` works only if `--config linux_aarch64` option included.
build:linux --cxxopt=-Wno-mismatched-new-delete

Expand Down
10 changes: 8 additions & 2 deletions .circleci/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ commands:
- run:
name: Setup BuildBuddy Cache
command: ../devtools/bazel_cache_setup.py
- run:
name: Install Intel HEXL
command: |
export HEXL_ROOT="${HOME}/.local/hexl"
./bazel/install_hexl.sh "${HEXL_ROOT}"
echo "export HEXL_ROOT=${HEXL_ROOT}" >> "${BASH_ENV}"
- run:
name: "build"
command: bazel build //... -c opt --ui_event_filters=-info,-debug,-warning --jobs 20
Expand Down Expand Up @@ -76,8 +82,8 @@ jobs:
- build_and_test
macos_ut:
macos:
xcode: 16.2.0
resource_class: macos.m1.large.gen1
xcode: 16.4.0
resource_class: m4pro.medium
steps:
- checkout
- run:
Expand Down
Empty file added .codex
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ ossutil_output/

psi/apps/pir/docker/linux/
psi/apps/pir/docker/version.txt
.vscode/
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ part of the project.

In general, please use clang-format to format code, and follow clang-tidy tips.

For Bazel files (`MODULE.bazel`, `*.bzl`, `BUILD`, `BUILD.bazel`), please use `buildifier`.

Most of the code style is derived from the
[Google C++ style guidelines](https://google.github.io/styleguide/cppguide.html), except:

Expand Down Expand Up @@ -57,6 +59,10 @@ docker exec -it psi-dev-$(whoami) bash

```sh
Install gcc>=11.2, cmake>=3.26, ninja, nasm>=2.15, python>=3.10, bazelisk, xxd, lld

# Install Intel HEXL, or set HEXL_ROOT to an existing install prefix.
./bazel/install_hexl.sh "$HOME/.local/hexl"
export HEXL_ROOT="$HOME/.local/hexl"
```

#### macOS
Expand All @@ -80,6 +86,10 @@ brew install bazelisk cmake ninja libomp wget

# For Intel mac only
brew install nasm

# Install Intel HEXL, or set HEXL_ROOT to an existing install prefix.
./bazel/install_hexl.sh "$HOME/.local/hexl"
export HEXL_ROOT="$HOME/.local/hexl"
```

### Build & UnitTest
Expand Down
4 changes: 4 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ use_repo(

new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")

hexl_repository = use_repo_rule("//bazel:hexl_repo.bzl", "hexl_repository")

new_local_repository(
name = "macos_omp_x64",
build_file = "@yacl//bazel:local_openmp_macos.BUILD",
Expand All @@ -70,6 +72,8 @@ new_local_repository(
path = "/opt/homebrew/opt/libomp/",
)

hexl_repository(name = "hexl")

bazel_dep(name = "kuscia", version = "0.14.0b0")
bazel_dep(name = "perfetto", version = "41.0")

Expand Down
122 changes: 0 additions & 122 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,4 @@ Please refer to [PSI V2 Benchmark](docs/user_guide/psi_v2_benchmark.md)
## APSI Benchmark

Please refer to [APSI Benchmark](docs/user_guide/apsi_benchmark.md)

15 changes: 15 additions & 0 deletions bazel/hexl.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library")

package(default_visibility = ["//visibility:public"])

cc_import(
name = "hexl_lib",
static_library = "lib/libhexl.a",
)

cc_library(
name = "hexl",
hdrs = glob(["include/hexl/**/*.h", "include/hexl/**/*.hpp"]),
includes = ["include"],
deps = [":hexl_lib"],
)
65 changes: 65 additions & 0 deletions bazel/hexl_repo.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
_HEXL_BUILD = """load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library")

package(default_visibility = ["//visibility:public"])

cc_import(
name = "hexl_lib",
static_library = "lib/libhexl.a",
)

cc_library(
name = "hexl",
hdrs = glob(["include/hexl/**/*.h", "include/hexl/**/*.hpp"]),
includes = ["include"],
deps = [":hexl_lib"],
)
"""

_HEXL_STUB_BUILD = """load("@rules_cc//cc:defs.bzl", "cc_library")

package(default_visibility = ["//visibility:public"])

cc_library(
name = "hexl",
)
"""

def _hexl_repository_impl(repository_ctx):
roots = []
env_root = repository_ctx.os.environ.get("HEXL_ROOT", "")
if env_root:
roots.append(env_root)

roots.extend([
"/usr/local/opt/intel-hexl",
"/usr/local",
"/opt/homebrew/opt/intel-hexl",
"/opt/homebrew",
"/usr",
])

for root in roots:
include_dir = repository_ctx.path(root + "/include")
header_dir = repository_ctx.path(root + "/include/hexl")
for lib_dir_name in ["lib", "lib64"]:
lib_dir = repository_ctx.path(root + "/" + lib_dir_name)
static_lib = repository_ctx.path(root + "/" + lib_dir_name + "/libhexl.a")
if header_dir.exists and static_lib.exists:
repository_ctx.symlink(include_dir, "include")
repository_ctx.symlink(lib_dir, "lib")
repository_ctx.file("BUILD.bazel", _HEXL_BUILD)
repository_ctx.file("WORKSPACE.bazel", "workspace(name = \"hexl\")\n")
return

# HEXL not found — create a stub so the workspace resolves on non-x86
# platforms. Targets that actually depend on @hexl are gated by
# target_compatible_with = ["@platforms//cpu:x86_64"] and will never be
# built on ARM / macOS Apple Silicon.
repository_ctx.file("BUILD.bazel", _HEXL_STUB_BUILD)
repository_ctx.file("WORKSPACE.bazel", "workspace(name = \"hexl\")\n")

hexl_repository = repository_rule(
implementation = _hexl_repository_impl,
environ = ["HEXL_ROOT"],
local = True,
)
42 changes: 42 additions & 0 deletions bazel/install_hexl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -euo pipefail

hexl_version="${HEXL_VERSION:-v1.2.6}"
install_prefix="${1:-${HEXL_ROOT:-${HOME}/.local/hexl}}"
arch="$(uname -m)"

case "${arch}" in
x86_64|amd64)
;;
*)
printf 'Skipping Intel HEXL installation on unsupported architecture %s\n' \
"${arch}"
exit 0
;;
esac

if [[ -f "${install_prefix}/lib/libhexl.a" && -d "${install_prefix}/include/hexl" ]]; then
printf 'Intel HEXL already installed at %s\n' "${install_prefix}"
exit 0
fi

parallelism="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)"
workdir="$(mktemp -d)"
repo_dir="${workdir}/hexl"
build_dir="${workdir}/build"

cleanup() {
rm -rf "${workdir}"
}

trap cleanup EXIT

printf 'Installing Intel HEXL %s into %s\n' "${hexl_version}" "${install_prefix}"

git clone --depth 1 --branch "${hexl_version}" https://github.com/IntelLabs/hexl.git "${repo_dir}"

cmake -S "${repo_dir}" -B "${build_dir}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${install_prefix}" -DHEXL_BENCHMARK=OFF -DHEXL_COVERAGE=OFF -DHEXL_DOCS=OFF -DHEXL_SHARED_LIB=OFF -DHEXL_TESTING=OFF -DHEXL_TREAT_WARNING_AS_ERROR=OFF

cmake --build "${build_dir}" --parallel "${parallelism}"
cmake --install "${build_dir}"
2 changes: 1 addition & 1 deletion bazel/psi.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ WARNING_FLAGS = [
]
DEBUG_FLAGS = ["-O0", "-g", "-DSPDLOG_ACTIVE_LEVEL=1"]
RELEASE_FLAGS = ["-O2"]
FAST_FLAGS = ["-O1"]
FAST_FLAGS = ["-O3"]

def _psi_copts():
return select({
Expand Down
2 changes: 2 additions & 0 deletions docs/user_guide/pir.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Supported Protocols
+----------------+-------------+---------------+
| APSI | Keyword PIR | Single Server |
+----------------+-------------+---------------+
| YPIR | Index PIR | Single Server |
+----------------+-------------+---------------+

At this moment, SealPIR is under development.

Expand Down
1 change: 1 addition & 0 deletions psi/algorithm/pir_interface/pir_type.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum PirType {
INVALID = 0;
SEAL_PIR = 1;
SPIRAL_PIR = 2;
YPIR_PIR = 3;
}

message PirTypeProto {
Expand Down
Loading
Loading