Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Koren-Brand <[email protected]>
  • Loading branch information
Koren-Brand committed Nov 10, 2024
1 parent 7c1eff7 commit b76fda5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion icicle/backend/cpu/src/field/cpu_vec_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class VectorOpTask : public TaskBase
public:
T m_intermidiate_res; // pointer to the output. Can be a vector or scalar pointer
uint64_t m_idx_in_batch; // index in the batch. Used in intermediate res tasks
}; // class VectorOpTask
}; // class VectorOpTask

#define NOF_OPERATIONS_PER_TASK 512
#define CONFIG_NOF_THREADS_KEY "n_threads"
Expand Down
6 changes: 3 additions & 3 deletions icicle/backend/cpu/src/hash/cpu_merkle_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ namespace icicle {
}
}

~CPUMerkleTreeBackend() {
for (auto& pair : m_map_segment_id_2_inputs)
{
~CPUMerkleTreeBackend()
{
for (auto& pair : m_map_segment_id_2_inputs) {
delete pair.second; // Ensure all dynamically allocated memory is freed
}
}
Expand Down
2 changes: 1 addition & 1 deletion icicle/include/icicle/fields/quartic_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class QuarticExtensionField
FF::reduce(
(CONFIG::nonresidue_is_negative
? (FF::mul_wide(xs.real, x0) + FF::template mul_unsigned<CONFIG::nonresidue>(FF::mul_wide(xs.im2, x2)))
: (FF::mul_wide(xs.real, x0))-FF::template mul_unsigned<CONFIG::nonresidue>(FF::mul_wide(xs.im2, x2)))),
: (FF::mul_wide(xs.real, x0)) - FF::template mul_unsigned<CONFIG::nonresidue>(FF::mul_wide(xs.im2, x2)))),
FF::reduce(
(CONFIG::nonresidue_is_negative
? FWide::neg(FF::template mul_unsigned<CONFIG::nonresidue>(FF::mul_wide(xs.im3, x2)))
Expand Down
12 changes: 8 additions & 4 deletions icicle/include/icicle/fields/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ struct
#ifdef __CUDA_ARCH__
__align__(LIMBS_ALIGNMENT(1))
#endif
storage<1> {
storage<1>
{
static constexpr unsigned LC = 1;
uint32_t limbs[1];
};
Expand All @@ -27,7 +28,8 @@ struct
#ifdef __CUDA_ARCH__
__align__(LIMBS_ALIGNMENT(1))
#endif
storage<3> {
storage<3>
{
static constexpr unsigned LC = 3;
uint32_t limbs[3];
};
Expand All @@ -38,7 +40,8 @@ struct
#ifdef __CUDA_ARCH__
__align__(LIMBS_ALIGNMENT(LIMBS_COUNT))
#endif
storage {
storage
{
static_assert(LIMBS_COUNT % 2 == 0, "odd number of limbs is not supported\n");
static constexpr unsigned LC = LIMBS_COUNT;
union { // works only with even LIMBS_COUNT
Expand All @@ -52,6 +55,7 @@ struct
#ifdef __CUDA_ARCH__
__align__(LIMBS_ALIGNMENT(LIMBS_COUNT))
#endif
storage_array {
storage_array
{
storage<LIMBS_COUNT> storages[OMEGAS_COUNT];
};
35 changes: 18 additions & 17 deletions icicle/tests/test_hash_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ void test_merkle_tree(
<< "Explicit leaf size should only be given when the given leaves array is a bytes array.";

unsigned leaf_size = explicit_leaf_size > 1 ? explicit_leaf_size : sizeof(T);
auto prover_tree = MerkleTree::create(hashes, leaf_size, output_store_min_layer);
auto verifier_tree = MerkleTree::create(hashes, leaf_size, output_store_min_layer);
auto prover_tree = MerkleTree::create(hashes, leaf_size, output_store_min_layer);
auto verifier_tree = MerkleTree::create(hashes, leaf_size, output_store_min_layer);

// assert that incorrect size fails
if (config.padding_policy == PaddingPolicy::None) {
Expand Down Expand Up @@ -913,7 +913,8 @@ TEST_F(HashApiTest, MerkleTreeLeavesOnDeviceTreeOnHost)
}
}

void deep_copy_byte_array_to_vec(const std::byte* src, std::size_t size, std::vector<std::byte>& dest) {
void deep_copy_byte_array_to_vec(const std::byte* src, std::size_t size, std::vector<std::byte>& dest)
{
dest.resize(size);
std::memcpy(dest.data(), src, size);
}
Expand Down Expand Up @@ -966,35 +967,35 @@ TEST_F(HashApiTest, MerkleTreeLarge)
// test non-pruned path
MerkleProof merkle_proof{};
bool verification_valid = false;
ICICLE_CHECK(
prover_tree.get_merkle_proof(device_leaves, total_input_size, leaf_idx, false /*=pruned*/, config, merkle_proof));
ICICLE_CHECK(prover_tree.get_merkle_proof(
device_leaves, total_input_size, leaf_idx, false /*=pruned*/, config, merkle_proof));
ICICLE_CHECK(verifier_tree.verify(merkle_proof, verification_valid));
ASSERT_TRUE(verification_valid);

// test pruned path
verification_valid = false;
ICICLE_CHECK(
prover_tree.get_merkle_proof(device_leaves, total_input_size, leaf_idx, true /*=pruned*/, config, merkle_proof));
ICICLE_CHECK(prover_tree.get_merkle_proof(
device_leaves, total_input_size, leaf_idx, true /*=pruned*/, config, merkle_proof));
ICICLE_CHECK(verifier_tree.verify(merkle_proof, verification_valid));
ASSERT_TRUE(verification_valid);
}
ICICLE_CHECK(icicle_free(device_leaves));
}

// Check valid tree of each device by comparing their roots
for (int i = 1; i < device_roots.size(); i++)
{
std::vector<std::byte>& first_root = device_roots[0];
std::vector<std::byte>& root = device_roots[i];
for (int i = 1; i < device_roots.size(); i++) {
std::vector<std::byte>& first_root = device_roots[0];
std::vector<std::byte>& root = device_roots[i];
ASSERT_EQ(first_root.size(), root.size());
auto size = root.size();
for (int j = 0; j < size; j++)
{
ASSERT_EQ (first_root[j], root[j]) << "Different tree roots:\n"
<< s_registered_devices[0] << " =\t0x" << HashApiTest::voidPtrToHexString(first_root.data(), size)<< "\n"
<< s_registered_devices[i] << " =\t0x" << HashApiTest::voidPtrToHexString(root.data(), size);
for (int j = 0; j < size; j++) {
ASSERT_EQ(first_root[j], root[j]) << "Different tree roots:\n"
<< s_registered_devices[0] << " =\t0x"
<< HashApiTest::voidPtrToHexString(first_root.data(), size) << "\n"
<< s_registered_devices[i] << " =\t0x"
<< HashApiTest::voidPtrToHexString(root.data(), size);
}
}
}
}

#ifdef POSEIDON
Expand Down

0 comments on commit b76fda5

Please sign in to comment.