diff --git a/stim/envi/binary.h b/stim/envi/binary.h index 2540b4a..aeab5b5 100644 --- a/stim/envi/binary.h +++ b/stim/envi/binary.h @@ -54,7 +54,7 @@ protected: public: //constructor initializes a stream optimizer - stream_optimizer(size_t min_batch_size, size_t max_batch_size, double a = 0.001, double probe_step = 5, size_t window = 2000){ + stream_optimizer(size_t min_batch_size, size_t max_batch_size, double a = 0.003, size_t probe_step = 5, size_t window = 2000){ //Bps = 0; //initialize to zero bytes per second processed Bps[0] = Bps[1] = 0; //initialize the bits per second to 0 interval_B = 0; //zero bytes have been processed at initialization @@ -72,25 +72,26 @@ public: forward_diff = true; //start with the forward difference (since we start at the maximum batch size) } - size_t update(size_t bytes_processed, size_t ms_spent){ + size_t update(size_t bytes_processed, size_t ms_spent, size_t& data_rate, bool VERBOSE = false){ interval_B += bytes_processed; //increment the number of bytes processed interval_ms += ms_spent; //increment the number of milliseconds spent processing + data_rate = interval_B / interval_ms; //if we have sufficient information to evaluate the optimization function at this point if(interval_ms < window_ms){ //if insufficient time has passed to get a reliable Bps measurement return n[0]; } else{ //if we have collected enough information for a reliable Bps estimate - size_t new_Bps = interval_B / interval_ms; //calculate the current Bps - + if(Bps[0] == 0){ //if n[0] hasn't been evaluated yet, this is the first step - Bps[0] = new_Bps; //set the initial Bps value + Bps[0] = data_rate; //set the initial Bps value n[1] = n[0] - h; //set the position of the next sample point - std::cout<<"Bps value at n = "<::buffer_size/(double)1000000<<" MB"<(t_end-t_start).count(); t_total += t_batch; - if(y_load < Y()) rt_total += rthread.get(); //if a new batch was set to load, make sure it loads after calculations - N[b] = O.update(N[!b] * slice_bytes, t_batch, data_rate); //set the batch size based on optimization + if(OPTIMIZATION) + N[b] = O.update(N[!b] * slice_bytes, t_batch, binary::data_rate, VERBOSE); //set the batch size based on optimization + //binary::data_rate = dr; //std::cout<<"New N = "<*)file)->set_buffer(memfrac); + ((bsq*)file)->set_buffer_frac(memfrac); else if(header.data_type == envi_header::float64) - ((bsq*)file)->set_buffer(memfrac); + ((bsq*)file)->set_buffer_frac(memfrac); else std::cout<<"ERROR: unidentified data type"<*)file)->set_buffer(memfrac); + ((bil*)file)->set_buffer_frac(memfrac); else if(header.data_type == envi_header::float64) - ((bil*)file)->set_buffer(memfrac); + ((bil*)file)->set_buffer_frac(memfrac); else std::cout<<"ERROR: unidentified data type"<*)file)->set_buffer(memfrac); + ((bip*)file)->set_buffer_frac(memfrac); else if(header.data_type == envi_header::float64) - ((bip*)file)->set_buffer(memfrac); + ((bip*)file)->set_buffer_frac(memfrac); + else + std::cout<<"ERROR: unidentified data type"<*)file)->set_buffer_raw(bytes); + else if(header.data_type == envi_header::float64) + ((bsq*)file)->set_buffer_raw(bytes); + else + std::cout<<"ERROR: unidentified data type"<*)file)->set_buffer_raw(bytes); + else if(header.data_type == envi_header::float64) + ((bil*)file)->set_buffer_raw(bytes); + else + std::cout<<"ERROR: unidentified data type"<*)file)->set_buffer_raw(bytes); + else if(header.data_type == envi_header::float64) + ((bip*)file)->set_buffer_raw(bytes); else std::cout<<"ERROR: unidentified data type"<*)file)->get_data_rate(); + else if(header.data_type == envi_header::float64) + return ((bsq*)file)->get_data_rate(); + else + std::cout<<"ERROR: unidentified data type"<*)file)->get_data_rate(); + else if(header.data_type == envi_header::float64) + return ((bil*)file)->get_data_rate(); + else + std::cout<<"ERROR: unidentified data type"<*)file)->get_data_rate(); + else if(header.data_type == envi_header::float64) + return ((bip*)file)->get_data_rate(); + else + std::cout<<"ERROR: unidentified data type"< BIL - ((bsq*)file)->bil(outfile, PROGRESS, VERBOSE); + ((bsq*)file)->bil(outfile, PROGRESS, VERBOSE, OPTIMIZATION); else if(interleave == envi_header::BIP){ //ERROR //std::cout<<"ERROR: conversion from BSQ to BIP isn't practical; use BSQ->BIL->BIP instead"<*)file)->bip(outfile, PROGRESS, VERBOSE); @@ -533,10 +613,10 @@ public: exit(1); } else if(interleave == envi_header::BIL) //convert BSQ -> BIL - ((bsq*)file)->bil(outfile, PROGRESS); + ((bsq*)file)->bil(outfile, PROGRESS, OPTIMIZATION); else if(interleave == envi_header::BIP){ //ERROR //std::cout<<"ERROR: conversion from BSQ to BIP isn't practical; use BSQ->BIL->BIP instead"<*)file)->bip(outfile, PROGRESS); + ((bsq*)file)->bip(outfile, PROGRESS, OPTIMIZATION); //exit(1); } } -- libgit2 0.21.4