@@ -146,8 +146,7 @@ class WritingTask : public Task
146146 , buffer (buffer)
147147 , header (header)
148148 , part_num (part_num)
149- {
150- }
149+ {}
151150
152151 void execute ()
153152 {
@@ -226,9 +225,6 @@ main (int argc, char* argv[])
226225 exit (-1 );
227226 }
228227
229- if (args[" verbose" ].as <bool > ())
230- std::cout << " Recommended # of I/O threads: " << ThreadPool::estimateThreadCountForFileIO () << std::endl;
231-
232228 if (args.count (" compression" ) != 1 || args.count (" file" ) != 1 )
233229 {
234230 std::cout << options.help () << std::endl;
@@ -239,13 +235,18 @@ main (int argc, char* argv[])
239235
240236 auto & src_fn = args[" file" ].as <std::string> ();
241237
242- /* encoding/decoding thread count */
238+ /* thread count */
239+
240+ int global_thread_count = args[" threads" ].as <int > ();
241+ int part_thread_count = args[" part_threads" ].as <int > ();
242+ int proc_thread_count =
243+ (global_thread_count + part_thread_count - 1 ) / part_thread_count;
243244
244- setGlobalThreadCount (args[ " threads " ]. as < int > () );
245+ setGlobalThreadCount (global_thread_count );
245246
246247 /* load src image */
247248
248- MultiPartInputFile src_file (src_fn.c_str ());
249+ MultiPartInputFile src_file (src_fn.c_str (), proc_thread_count );
249250
250251 size_t decoded_size = 0 ;
251252
@@ -337,13 +338,17 @@ main (int argc, char* argv[])
337338 OMemStream o_memfile (&mem_file);
338339
339340 MultiPartOutputFile o_file (
340- o_memfile, headers.data (), headers.size ());
341+ o_memfile,
342+ headers.data (),
343+ headers.size (),
344+ false ,
345+ proc_thread_count);
341346
342347 /* MultiPartOutputFile o_file (
343348 "/var/tmp/out.exr", headers.data (), headers.size ());*/
344349
345350 ThreadPool* thread_pool =
346- new ThreadPool (args[ " part_threads " ]. as < int > () );
351+ new ThreadPool (part_thread_count );
347352 TaskGroup task_group;
348353
349354 auto start = std::chrono::high_resolution_clock::now ();
@@ -373,10 +378,10 @@ main (int argc, char* argv[])
373378
374379 IMemStream i_memfile (&mem_file);
375380
376- MultiPartInputFile i_file (i_memfile);
381+ MultiPartInputFile i_file (i_memfile, proc_thread_count );
377382
378383 ThreadPool* thread_pool =
379- new ThreadPool (args[ " part_threads " ]. as < int > () );
384+ new ThreadPool (part_thread_count );
380385 TaskGroup task_group;
381386
382387 auto start = std::chrono::high_resolution_clock::now ();
0 commit comments