-
Notifications
You must be signed in to change notification settings - Fork 332
ballet: Add Reed-Solomon module #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ce96866
ballet: Add Reed-Solomon encoder
ptaffet-jump 757f626
Extend to 67 data and parity shreds
ptaffet-jump e5d74c2
reedsol: Add recovery
ptaffet-jump 0815cb2
Minor polishing
kbowers-jump 154e1f5
fix bugs in gen_pi_noavx_generic
ptaffet-jump 6c4789e
refactor to improve compilation time
ptaffet-jump File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$(call add-hdrs,fd_reedsol.h) | ||
ifdef FD_HAS_GFNI | ||
$(call add-asms,fd_reedsol_gfni_32,fd_reedsol) | ||
endif | ||
$(call add-objs,fd_reedsol,fd_reedsol) | ||
$(call add-objs,fd_reedsol_encode_16,fd_reedsol) | ||
$(call add-objs,fd_reedsol_encode_32,fd_reedsol) | ||
$(call add-objs,fd_reedsol_encode_64,fd_reedsol) | ||
$(call add-objs,fd_reedsol_encode_128,fd_reedsol) | ||
$(call add-objs,fd_reedsol_recover_16,fd_reedsol) | ||
$(call add-objs,fd_reedsol_recover_32,fd_reedsol) | ||
$(call add-objs,fd_reedsol_recover_64,fd_reedsol) | ||
$(call add-objs,fd_reedsol_recover_128,fd_reedsol) | ||
$(call add-objs,fd_reedsol_recover_256,fd_reedsol) | ||
$(call add-objs,fd_reedsol_pi,fd_reedsol) | ||
$(call make-unit-test,test_reedsol,test_reedsol,fd_reedsol fd_util) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include "fd_reedsol_private.h" | ||
|
||
/* Include the constants in one central spot */ | ||
|
||
#if FD_REEDSOL_ARITH_IMPL==0 | ||
FD_IMPORT_BINARY( fd_reedsol_arith_consts_generic_mul, "src/ballet/reedsol/constants/generic_constants.bin" ); | ||
#elif FD_REEDSOL_ARITH_IMPL==1 | ||
FD_IMPORT_BINARY( fd_reedsol_arith_consts_avx_mul, "src/ballet/reedsol/constants/avx2_constants.bin" ); | ||
#else | ||
FD_IMPORT_BINARY( fd_reedsol_arith_consts_gfni_mul, "src/ballet/reedsol/constants/gfni_constants.bin" ); | ||
#endif | ||
|
||
void | ||
fd_reedsol_encode_fini( fd_reedsol_t * rs ) { | ||
|
||
# if FD_REEDSOL_ARITH_IMPL==2 | ||
if( FD_LIKELY( (rs->data_shred_cnt==32UL) & (rs->parity_shred_cnt==32UL ) ) ) | ||
fd_reedsol_private_encode_32_32( rs->shred_sz, rs->encode.data_shred, rs->encode.parity_shred, rs->scratch ); | ||
else | ||
# endif | ||
if( FD_UNLIKELY( rs->data_shred_cnt<=16UL ) ) | ||
fd_reedsol_private_encode_16 ( rs->shred_sz, rs->encode.data_shred, rs->data_shred_cnt, rs->encode.parity_shred, rs->parity_shred_cnt ); | ||
else if( FD_LIKELY( rs->data_shred_cnt<=32UL ) ) | ||
fd_reedsol_private_encode_32 ( rs->shred_sz, rs->encode.data_shred, rs->data_shred_cnt, rs->encode.parity_shred, rs->parity_shred_cnt ); | ||
else if( FD_LIKELY( rs->data_shred_cnt<=64UL ) ) | ||
fd_reedsol_private_encode_64 ( rs->shred_sz, rs->encode.data_shred, rs->data_shred_cnt, rs->encode.parity_shred, rs->parity_shred_cnt ); | ||
else | ||
fd_reedsol_private_encode_128( rs->shred_sz, rs->encode.data_shred, rs->data_shred_cnt, rs->encode.parity_shred, rs->parity_shred_cnt ); | ||
|
||
rs->data_shred_cnt = 0UL; | ||
rs->parity_shred_cnt = 0UL; | ||
} | ||
|
||
int | ||
fd_reedsol_recover_fini( fd_reedsol_t * rs ) { | ||
|
||
ulong data_shred_cnt = rs->data_shred_cnt; | ||
ulong parity_shred_cnt = rs->parity_shred_cnt; | ||
|
||
rs->data_shred_cnt = 0UL; | ||
rs->parity_shred_cnt = 0UL; | ||
|
||
/* How many shreds do we need to consider in order to find | ||
rs->data_shred_cnt un-erased? */ | ||
|
||
ulong unerased = 0UL; | ||
ulong i = 0UL; | ||
for( ; i<data_shred_cnt + parity_shred_cnt; i++ ) { | ||
unerased += !rs->recover.erased[ i ]; | ||
if( unerased==data_shred_cnt ) break; | ||
} | ||
if( FD_UNLIKELY( unerased!=data_shred_cnt ) ) return FD_REEDSOL_ERR_PARTIAL; | ||
|
||
# if 0 /* TODO: Add first variant for slightly more performance */ | ||
if( FD_LIKELY( i==data_shred_cnt ) ) { | ||
// Common case: we have all of the data shreds | ||
if( FD_UNLIKELY( i<=16UL ) ) | ||
return fd_reedsol_private_recover_first_16( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt ); | ||
if( FD_LIKELY( i<=32UL ) ) | ||
return fd_reedsol_private_recover_first_32( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt ); | ||
if( FD_LIKELY( i<=64UL ) ) | ||
return fd_reedsol_private_recover_first_64( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt ); | ||
return fd_reedsol_private_recover_first_128( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt ); | ||
} | ||
# endif | ||
|
||
if( FD_UNLIKELY( i<16UL ) ) | ||
return fd_reedsol_private_recover_var_16( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt, rs->recover.erased ); | ||
if( FD_LIKELY( i<32UL ) ) | ||
return fd_reedsol_private_recover_var_32( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt, rs->recover.erased ); | ||
if( FD_LIKELY( i<64UL ) ) | ||
return fd_reedsol_private_recover_var_64( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt, rs->recover.erased ); | ||
if( FD_LIKELY( i<128UL ) ) | ||
return fd_reedsol_private_recover_var_128( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt, rs->recover.erased ); | ||
|
||
return fd_reedsol_private_recover_var_256( rs->shred_sz, rs->recover.shred, data_shred_cnt, parity_shred_cnt, rs->recover.erased ); | ||
} | ||
|
||
char const * | ||
fd_reedsol_strerror( int err ) { | ||
switch( err ) { | ||
case FD_REEDSOL_SUCCESS: return "success"; | ||
case FD_REEDSOL_ERR_CORRUPT: return "corrupt"; | ||
case FD_REEDSOL_ERR_PARTIAL: return "partial"; | ||
default: break; | ||
} | ||
return "unknown"; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you encode these dependencies into the Makefile