Skip to content

Commit

Permalink
Merge pull request #2 from n0-computer/fix-avoid-symbols
Browse files Browse the repository at this point in the history
fix: avoid duplicate symbols
  • Loading branch information
flub authored Nov 24, 2023
2 parents 793f348 + d676542 commit f644fb2
Show file tree
Hide file tree
Showing 41 changed files with 342 additions and 368 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ your `Cargo.toml`. Here's an example of hashing some input bytes:

```rust
// Hash an input all at once.
let hash1 = blake3::hash(b"foobarbaz");
let hash1 = iroh_blake3::hash(b"foobarbaz");

// Hash an input incrementally.
let mut hasher = blake3::Hasher::new();
Expand Down
113 changes: 27 additions & 86 deletions b3sum/Cargo.lock

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

10 changes: 5 additions & 5 deletions b3sum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "b3sum"
name = "iroh-b3sum"
version = "1.4.1"
authors = ["Jack O'Connor <[email protected]>"]
description = "a command line implementation of the BLAKE3 hash function"
Expand All @@ -9,13 +9,13 @@ readme = "README.md"
edition = "2021"

[features]
neon = ["blake3/neon"]
prefer_intrinsics = ["blake3/prefer_intrinsics"]
pure = ["blake3/pure"]
neon = ["iroh-blake3/neon"]
prefer_intrinsics = ["iroh-blake3/prefer_intrinsics"]
pure = ["iroh-blake3/pure"]

[dependencies]
anyhow = "1.0.25"
blake3 = { version = "1", path = "..", features = ["rayon"] }
iroh-blake3 = { version = "1", path = "..", features = ["rayon"] }
clap = { version = "4.0.8", features = ["derive", "wrap_help"] }
hex = "0.4.0"
memmap2 = "0.7.0"
Expand Down
2 changes: 2 additions & 0 deletions b3sum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::io;
use std::io::prelude::*;
use std::path::{Path, PathBuf};

use iroh_blake3 as blake3;

#[cfg(test)]
mod unit_tests;

Expand Down
2 changes: 2 additions & 0 deletions b3sum/src/unit_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::path::Path;

use iroh_blake3 as blake3;

#[test]
fn test_parse_check_line() {
// =========================
Expand Down
4 changes: 3 additions & 1 deletion b3sum/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use std::fs;
use std::io::prelude::*;
use std::path::PathBuf;

use iroh_blake3 as blake3;

pub fn b3sum_exe() -> PathBuf {
env!("CARGO_BIN_EXE_b3sum").into()
env!("CARGO_BIN_EXE_iroh-b3sum").into()
}

#[test]
Expand Down
22 changes: 13 additions & 9 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ extern crate test;

use arrayref::array_ref;
use arrayvec::ArrayVec;
use blake3::guts::{BLOCK_LEN, CHUNK_LEN};
use blake3::platform::{Platform, MAX_SIMD_DEGREE};
use blake3::OUT_LEN;
use iroh_blake3::guts::{BLOCK_LEN, CHUNK_LEN};
use iroh_blake3::platform::{Platform, MAX_SIMD_DEGREE};
use iroh_blake3::OUT_LEN;
use rand::prelude::*;
use test::Bencher;

Expand Down Expand Up @@ -102,7 +102,7 @@ fn bench_many_chunks_fn(b: &mut Bencher, platform: Platform) {
&input_arrays[..],
&[0; 8],
0,
blake3::IncrementCounter::Yes,
iroh_blake3::IncrementCounter::Yes,
0,
0,
0,
Expand Down Expand Up @@ -169,7 +169,7 @@ fn bench_many_parents_fn(b: &mut Bencher, platform: Platform) {
&input_arrays[..],
&[0; 8],
0,
blake3::IncrementCounter::No,
iroh_blake3::IncrementCounter::No,
0,
0,
0,
Expand Down Expand Up @@ -220,7 +220,7 @@ fn bench_many_parents_neon(b: &mut Bencher) {

fn bench_atonce(b: &mut Bencher, len: usize) {
let mut input = RandomInput::new(b, len);
b.iter(|| blake3::hash(input.get()));
b.iter(|| iroh_blake3::hash(input.get()));
}

#[bench]
Expand Down Expand Up @@ -285,7 +285,7 @@ fn bench_atonce_1024_kib(b: &mut Bencher) {

fn bench_incremental(b: &mut Bencher, len: usize) {
let mut input = RandomInput::new(b, len);
b.iter(|| blake3::Hasher::new().update(input.get()).finalize());
b.iter(|| iroh_blake3::Hasher::new().update(input.get()).finalize());
}

#[bench]
Expand Down Expand Up @@ -422,7 +422,11 @@ fn bench_reference_1024_kib(b: &mut Bencher) {
#[cfg(feature = "rayon")]
fn bench_rayon(b: &mut Bencher, len: usize) {
let mut input = RandomInput::new(b, len);
b.iter(|| blake3::Hasher::new().update_rayon(input.get()).finalize());
b.iter(|| {
iroh_blake3::Hasher::new()
.update_rayon(input.get())
.finalize()
});
}

#[bench]
Expand Down Expand Up @@ -508,7 +512,7 @@ fn bench_two_updates(b: &mut Bencher) {
let len = 65536;
let mut input = RandomInput::new(b, len);
b.iter(|| {
let mut hasher = blake3::Hasher::new();
let mut hasher = iroh_blake3::Hasher::new();
let input = input.get();
hasher.update(&input[..1]);
hasher.update(&input[1..]);
Expand Down
16 changes: 8 additions & 8 deletions c/blake3.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ INLINE output_t make_output(const uint32_t input_cv[8],
INLINE void output_chaining_value(const output_t *self, uint8_t cv[32]) {
uint32_t cv_words[8];
memcpy(cv_words, self->input_cv, 32);
blake3_compress_in_place(cv_words, self->block, self->block_len,
iroh_blake3_compress_in_place(cv_words, self->block, self->block_len,
self->counter, self->flags);
store_cv_words(cv, cv_words);
}
Expand All @@ -92,7 +92,7 @@ INLINE void output_root_bytes(const output_t *self, uint64_t seek, uint8_t *out,
size_t offset_within_block = seek % 64;
uint8_t wide_buf[64];
while (out_len > 0) {
blake3_compress_xof(self->input_cv, self->block, self->block_len,
iroh_blake3_compress_xof(self->input_cv, self->block, self->block_len,
output_block_counter, self->flags | ROOT, wide_buf);
size_t available_bytes = 64 - offset_within_block;
size_t memcpy_len;
Expand All @@ -116,7 +116,7 @@ INLINE void chunk_state_update(blake3_chunk_state *self, const uint8_t *input,
input += take;
input_len -= take;
if (input_len > 0) {
blake3_compress_in_place(
iroh_blake3_compress_in_place(
self->cv, self->buf, BLAKE3_BLOCK_LEN, self->chunk_counter,
self->flags | chunk_state_maybe_start_flag(self));
self->blocks_compressed += 1;
Expand All @@ -126,7 +126,7 @@ INLINE void chunk_state_update(blake3_chunk_state *self, const uint8_t *input,
}

while (input_len > BLAKE3_BLOCK_LEN) {
blake3_compress_in_place(self->cv, input, BLAKE3_BLOCK_LEN,
iroh_blake3_compress_in_place(self->cv, input, BLAKE3_BLOCK_LEN,
self->chunk_counter,
self->flags | chunk_state_maybe_start_flag(self));
self->blocks_compressed += 1;
Expand Down Expand Up @@ -261,7 +261,7 @@ INLINE size_t compress_parents_parallel(const uint8_t *child_chaining_values,
// Why not just have the caller split the input on the first update(), instead
// of implementing this special rule? Because we don't want to limit SIMD or
// multi-threading parallelism for that update().
static size_t blake3_compress_subtree_wide(const uint8_t *input,
static size_t iroh_blake3_compress_subtree_wide(const uint8_t *input,
size_t input_len,
const uint32_t key[8],
uint64_t chunk_counter,
Expand Down Expand Up @@ -301,9 +301,9 @@ static size_t blake3_compress_subtree_wide(const uint8_t *input,

// Recurse! If this implementation adds multi-threading support in the
// future, this is where it will go.
size_t left_n = blake3_compress_subtree_wide(input, left_input_len, key,
size_t left_n = iroh_blake3_compress_subtree_wide(input, left_input_len, key,
chunk_counter, flags, cv_array);
size_t right_n = blake3_compress_subtree_wide(
size_t right_n = iroh_blake3_compress_subtree_wide(
right_input, right_input_len, key, right_chunk_counter, flags, right_cvs);

// The special case again. If simd_degree=1, then we'll have left_n=1 and
Expand Down Expand Up @@ -338,7 +338,7 @@ INLINE void compress_subtree_to_parent_node(
#endif

uint8_t cv_array[MAX_SIMD_DEGREE_OR_2 * BLAKE3_OUT_LEN];
size_t num_cvs = blake3_compress_subtree_wide(input, input_len, key,
size_t num_cvs = iroh_blake3_compress_subtree_wide(input, input_len, key,
chunk_counter, flags, cv_array);
assert(num_cvs <= MAX_SIMD_DEGREE_OR_2);

Expand Down
6 changes: 3 additions & 3 deletions c/blake3_avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void blake3_hash8_avx2(const uint8_t *const *inputs, size_t blocks,
}

#if !defined(BLAKE3_NO_SSE41)
void blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs,
void iroh_blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs,
size_t blocks, const uint32_t key[8],
uint64_t counter, bool increment_counter,
uint8_t flags, uint8_t flags_start,
Expand All @@ -300,7 +300,7 @@ void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs,
uint8_t flags_end, uint8_t *out);
#endif

void blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs,
void iroh_blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs,
size_t blocks, const uint32_t key[8],
uint64_t counter, bool increment_counter,
uint8_t flags, uint8_t flags_start,
Expand All @@ -316,7 +316,7 @@ void blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs,
out = &out[DEGREE * BLAKE3_OUT_LEN];
}
#if !defined(BLAKE3_NO_SSE41)
blake3_hash_many_sse41(inputs, num_inputs, blocks, key, counter,
iroh_blake3_hash_many_sse41(inputs, num_inputs, blocks, key, counter,
increment_counter, flags, flags_start, flags_end, out);
#else
blake3_hash_many_portable(inputs, num_inputs, blocks, key, counter,
Expand Down
Loading

0 comments on commit f644fb2

Please sign in to comment.