Skip to content

Instantly share code, notes, and snippets.

@jonathan-beard
Created January 10, 2016 00:58
Show Gist options
  • Save jonathan-beard/19b8fc2cb7dbf7cced29 to your computer and use it in GitHub Desktop.
Save jonathan-beard/19b8fc2cb7dbf7cced29 to your computer and use it in GitHub Desktop.
int
main( int argc, char **argv )
{
const static auto chunksize( 65536 );
using chunk_t = raft::filechunk< chunksize >;
using fr_t = raft::filereader< chunk_t, false >;
using fw_t = filewrite< chunk_t >;
using comp = compress< chunk_t >;
/** variables to set below **/
bool help( false );
int blocksize ( 9 );
int verbosity ( 0 );
int workfactor( 250 );
std::string inputfile( "" );
std::string outputfile( "" );
std::int64_t num_threads( 1 );
CmdArgs cmdargs( argv[ 0 ] /** prog name **/,
std::cout /** std stream **/,
std::cerr /** err stream **/ );
/** set options **/
cmdargs.addOption( new Option< bool >( help,
"-h",
"print this message" ) );
cmdargs.addOption( new Option< int >( blocksize,
"-b",
"set block size to 100k .. 900k" ) );
cmdargs.addOption( new Option< int >( workfactor,
"-e",
"effort" ) );
cmdargs.addOption( new Option< std::string >( inputfile,
"-i",
"input file" ) );
cmdargs.addOption( new Option< std::string >( outputfile,
"-o",
"output file" ) );
cmdargs.addOption( new Option< std::int64_t >( num_threads,
"-th",
"number of worker threads" ) );
/** process args **/
cmdargs.processArgs( argc, argv );
if( help )
{
cmdargs.printArgs();
exit( EXIT_SUCCESS );
}
/** declare kernels **/
fr_t reader( inputfile,
num_threads /** manually set threads for b-marking **/ );
fw_t writer( outputfile,
num_threads /** manually set threads for b-marking **/ );
comp c( blocksize,
verbosity,
workfactor );
/** set-up map **/
raft::map m;
/**
* detect # output ports from reader,
* duplicate c that #, assign each
* output port to the input ports in
* writer
*/
m += reader <= c >= writer;
m.exe();
return( EXIT_SUCCESS );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment