Skip to content

Commit

Permalink
repo sync (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinxc authored Dec 14, 2023
1 parent 9945ba7 commit f362c45
Show file tree
Hide file tree
Showing 71 changed files with 2,211 additions and 1,812 deletions.
4 changes: 0 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,3 @@ build:macos --host_macos_minimum_os=12.0

build:linux --copt=-fopenmp
build:linux --linkopt=-fopenmp

build:asan --features=asan
build:ubsan --features=ubsan

11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
>
> please add your unreleased change here.
- [Feature] Add Odd-Even Merge Sort to replace the bitonic sort.
- [Feature] Add radix sort support for ABY3.
- [Feature] Integrate with secretflow/psi.
- [Feature] Add Linux aarch64 support.
- [Improvement] Optimize sort memory usage.
- [Feature] Add Odd-Even Merge Sort to replace the bitonic sort
- [Feature] Add radix sort support for ABY3
- [Feature] Integrate with secretflow/psi
- [Feature] Add Linux aarch64 support
- [Feature] Add equal support for SEMI2K and ABY3
- [Improvement] Optimize sort memory usage
- [Deprecated] macOS 11.x is no longer supported

## 20231108
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ bazel build //... -c opt
bazel test //...

# [optional] build & test with ASAN or UBSAN, for macOS users please use configs with macOS prefix
bazel test //... --config=[macos-]asan
bazel test //... --config=[macos-]ubsan
bazel test //... --features=asan
bazel test //... --features=ubsan
```

### Bazel build options
Expand Down
70 changes: 70 additions & 0 deletions libspu/mpc/ab_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -687,4 +687,74 @@ TEST_P(ConversionTest, MSB) {
});
}

TEST_P(ConversionTest, EqualAA) {
const auto factory = std::get<0>(GetParam());
const RuntimeConfig& conf = std::get<1>(GetParam());
const size_t npc = std::get<2>(GetParam());

utils::simulate(npc, [&](std::shared_ptr<yacl::link::Context> lctx) {
auto obj = factory(conf, lctx);

if (!obj->hasKernel("equal_aa")) {
return;
}
/* GIVEN */
auto r0 = rand_p(obj.get(), kShape);
auto r1 = rand_p(obj.get(), kShape);
auto r2 = rand_p(obj.get(), kShape);
std::memcpy(r2.data().data(), r0.data().data(), 16);
std::vector<Value> test_values = {r0, r1, r2};

for (auto& test_value : test_values) {
auto l_value = p2a(obj.get(), r0);
auto r_value = p2a(obj.get(), test_value);
auto prev = obj->prot()->getState<Communicator>()->getStats();
auto tmp = dynDispatch(obj.get(), "equal_aa", l_value, r_value);
auto cost = obj->prot()->getState<Communicator>()->getStats() - prev;
auto out_value = b2p(obj.get(), tmp);
auto t_value = equal_pp(obj.get(), r0, test_value);

/* THEN */
EXPECT_VALUE_EQ(out_value, t_value);
EXPECT_TRUE(verifyCost(obj->prot()->getKernel("equal_aa"), "equal_aa",
conf.field(), kShape, npc, cost));
}
});
}

TEST_P(ConversionTest, EqualAP) {
const auto factory = std::get<0>(GetParam());
const RuntimeConfig& conf = std::get<1>(GetParam());
const size_t npc = std::get<2>(GetParam());

utils::simulate(npc, [&](std::shared_ptr<yacl::link::Context> lctx) {
auto obj = factory(conf, lctx);

if (!obj->hasKernel("equal_ap")) {
return;
}
/* GIVEN */
auto r0 = rand_p(obj.get(), kShape);
auto r1 = rand_p(obj.get(), kShape);
auto r2 = rand_p(obj.get(), kShape);
std::memcpy(r2.data().data(), r0.data().data(), 16);
std::vector<Value> test_values = {r0, r1, r2};

for (auto& test_value : test_values) {
auto l_value = p2a(obj.get(), r0);
auto r_value = test_value;
auto prev = obj->prot()->getState<Communicator>()->getStats();
auto tmp = dynDispatch(obj.get(), "equal_ap", l_value, r_value);
auto cost = obj->prot()->getState<Communicator>()->getStats() - prev;
auto out_value = b2p(obj.get(), tmp);
auto t_value = equal_pp(obj.get(), r0, test_value);

/* THEN */
EXPECT_VALUE_EQ(out_value, t_value);
EXPECT_TRUE(verifyCost(obj->prot()->getKernel("equal_ap"), "equal_ap",
conf.field(), kShape, npc, cost));
}
});
}

} // namespace spu::mpc::test
Loading

0 comments on commit f362c45

Please sign in to comment.