c++ - TBB parallelization of parsing with boots::spirit::qi -
In my program, I use Boost-Spirit-Qi to parse large data sets. Input data are sequential records. I am trying to use TBB to increase the efficiency of parsing. The process for parallel processing is as follows:
typed map map & lt; String, data_struct_t & gt; Mdata_t; Of vector & lt; String & gt; Text; Mdata_t data; Parallel_for (blocked_range & lt; size_t> (0, input.size (), GS), [& amp;] (blocked_range & amp; r) {data_struct_t cs; mdata_t cr; string s ; For (size_t i = r.begin); I & lt; r.end (); i ++) {s = text [i]; Parser :: Job 1 (S, CS); Parse :: Task2 (S, CS); Parse :: Task 3 (S, CS); Parser :: Task 8 (S, CS); CRINSTART (CDTI, CS);} data. INSTECT (CRBBN (), CRand ())}, AP); My program uses only 10% of CPU (2 CPUs, 16 cores) and works on 8 cores I do not understand why not use the remaining 8 cores Used (Single Processor)
Thanks for the advice.
your input.size () might be small or GS is too large to prevent the formation of adequate amounts of parallelism. Otherwise, if the number of threads is a matter of concern, then check the mask of your program's process, when you start it and how to start TBB (for example, if tbb :: task_scheduler_init threads made with fewer numbers).
For CPU usage, it is expected that your work is IO-bound, ie to read the file. It is also possible that the time required to complete a parallel repetition is very different from another repetition. In this case, small iterations can be completed before all the threads are ready. (When you want to accurately measure, you should wait manually when all threads are turned on)
Advice:
You have data.insert Because std :: map is not safe for concurrent modification. Use tbb :: concurrent_unordered_map or simply tbb :: parallel_readuce to merge partial results collected from cr to different codes.
pattern parser :: task 1 (s, cs); ... parser :: Task 8 (s, cs); can also be parallel if the work does not share the global state, see how the pipeline-type parallelism will be enabled for a series of these independent works.
Comments
Post a Comment