diff --git a/stim/envi/bsq.h b/stim/envi/bsq.h index 4630926..f1911ae 100644 --- a/stim/envi/bsq.h +++ b/stim/envi/bsq.h @@ -398,10 +398,8 @@ public: size_t slice_bytes = X() * Z() * sizeof(T); //number of bytes in an input batch slice (Y-slice in this case) size_t max_slices_per_batch = mem_per_batch / slice_bytes; //maximum number of slices we can process in one batch given memory constraints - //if(VERBOSE){ - std::cout<<"maximum memory available for processing: "<<(double)binary::buffer_size/(double)1000000<<" MB"<::buffer_size/(double)1000000<<" MB"<(t_end-t_start).count(); t_total += t_batch; @@ -472,29 +470,36 @@ public: free(src[1]); free(dst[0]); free(dst[1]); - if(VERBOSE){ + //if(VERBOSE){ std::cout<<"total time to execute bsq::bil(): "<::buffer_size / buffers; //calculate the maximum memory available for a batch size_t slice_bytes = X() * Z() * sizeof(T); //number of bytes in an input batch slice (Y-slice in this case) size_t max_slices_per_batch = mem_per_batch / slice_bytes; //maximum number of slices we can process in one batch given memory constraints + + std::cout<<"maximum memory available for processing: "<<(double)binary::buffer_size/(double)1000000<<" MB"< rthread; std::future wthread; //create asynchronous threads for reading and writing - readlines(src[0], 0, N[0]); //read the first batch into the 0 source buffer - y_load += N[0]; //increment the loaded slice counter - int b = 1; - - std::chrono::high_resolution_clock::time_point t_start; //high-resolution timers - std::chrono::high_resolution_clock::time_point t_end; + std::chrono::high_resolution_clock::time_point t_start, pt_start; //high-resolution timers + std::chrono::high_resolution_clock::time_point t_end, pt_end; size_t t_batch; //number of milliseconds to process a batch - size_t t_total = 0; - size_t pt_total = 0; - size_t rt_total = 0; + size_t t_total = 0; //total time for operation + size_t pt_total = 0; //total time spent processing data + size_t rt_total = 0; //total time spent reading data + size_t wt_total = 0; + size_t dr = 0; + + rt_total += readlines(src[0], 0, N[0]); //read the first batch into the 0 source buffer + y_load += N[0]; //increment the loaded slice counter + int b = 1; //initialize the double buffer to 0 while(y_proc < Y()){ //while there are still slices to be processed t_start = std::chrono::high_resolution_clock::now(); //start the timer for this batch if(y_load < Y()){ //if there are still slices to be loaded, load them + //if(y_proc > 0){ + + + //} 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]); - + //rt_total += rthread.get(); y_load += N[b]; //increment the number of loaded slices } b = !b; //swap the double-buffer - - pt_total += binary::permute(dst[b], src[b], X(), N[b], Z(), 2, 0, 1); //permute the batch to a BIP file - target.write((char*)dst[b], N[b] * slice_bytes); //write the permuted data to the output file + pt_total += binary::permute(dst[b], src[b], X(), N[b], Z(), 0, 2, 1); //permute the batch to a BIL file + wt_total += writeblock(&target, dst[b], N[b] * slice_bytes); //write the permuted data to the output file y_proc += N[b]; //increment the counter of processed pixels if(PROGRESS) progress = (double)( y_proc + 1 ) / Y() * 100; //increment the progress counter based on the number of processed pixels + if(y_proc < Y()) rt_total += rthread.get(); //if a new batch was set to load, make sure it loads after calculations t_end = std::chrono::high_resolution_clock::now(); t_batch = std::chrono::duration_cast(t_end-t_start).count(); t_total += t_batch; - if(y_load < Y()) rt_total += rthread.get(); //if a batch was threaded to load, make sure it finishes - } - - if(VERBOSE){ - std::cout<<"total time to execute bsq::bil(): "<::data_rate, VERBOSE); //set the batch size based on optimization + //binary::data_rate = dr; + //std::cout<<"New N = "<*)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); + ((bsq*)file)->bip(outfile, PROGRESS, VERBOSE, OPTIMIZATION); //exit(1); } } -- libgit2 0.21.4