diff --git a/stim/envi/bsq.h b/stim/envi/bsq.h index 3df3701..c5b6d36 100644 --- a/stim/envi/bsq.h +++ b/stim/envi/bsq.h @@ -10,7 +10,7 @@ #include #include #include - +#include namespace stim{ @@ -403,7 +403,7 @@ public: dst[1] = (T*) malloc(max_batch_bytes); size_t N[2]; //number of slices stored in buffers 0 and 1 - N[0] = N[1] = min(Y(), max_slices_per_batch); //start with the maximum number of slices that can be stored (may be the entire data set) + N[0] = N[1] = std::min(Y(), max_slices_per_batch); //start with the maximum number of slices that can be stored (may be the entire data set) std::ofstream target(outname.c_str(), std::ios::binary); //open an output file for writing //initialize with buffer 0 (used for double buffering) @@ -425,7 +425,7 @@ public: if(y_load < Y()){ //if there are still slices to be loaded, load them if(y_load + N[b] > Y()) N[b] = Y() - y_load; //if the next batch would process more than the total slices, adjust the batch size rthread = std::async(std::launch::async, &stim::bsq::readlines, this, src[b], y_load, N[b]); - + //rthread.wait(); y_load += N[b]; //increment the number of loaded slices } @@ -438,7 +438,7 @@ public: t_end = std::chrono::high_resolution_clock::now(); t_batch = std::chrono::duration_cast(t_end-t_start).count(); t_total += t_batch; - rthread.wait(); + if(y_load < Y()) rthread.wait(); //if a new batch was set to load, make sure it loads after calculations } std::cout<<"Total time to execute: "<(Y(), max_slices_per_batch); //start with the maximum number of slices that can be stored (may be the entire data set) std::ofstream target(outname.c_str(), std::ios::binary); //open an output file for writing //initialize with buffer 0 (used for double buffering) @@ -506,7 +506,7 @@ public: t_end = std::chrono::high_resolution_clock::now(); t_batch = std::chrono::duration_cast(t_end-t_start).count(); t_total += t_batch; - rthread.wait(); + if(y_load < Y()) rthread.wait(); //if a batch was threaded to load, make sure it finishes } std::cout<<"Total time to execute: "<