topic Re: How to use TBB for solving sparse linear systems? in IntelĀ® oneAPI Threading Building Blocks
https://community.intel.com/t5/Intel-oneAPI-Threading-Building/How-to-use-TBB-for-solving-sparse-linear-systems/m-p/859545#M5312
Hi, Zhongze<BR /><BR />Unfortunately I am not an expert in the modern scientific algorithms, so I may be wrong in some of my assumptions. First I suppose that algorithms of the METIS family are serial, and thus the stage 1 is serial too. Then I assume that the stage 3 actually consists of two sub-stages: <BR />3.1. Process local matrices (actually sub-matrices of the matrix A). This can be done in parallel.<BR />3.2. Perform reduction of the results obtained at the step 3.1. This probably can also be done in parallel.<BR /><BR />Depending on the specific algorithm used at the step 3.2, two variants are possible. The first one: you use parallel_reduce algorithm where body::operator() executes steps 2 and 3.1 (paired together for each graph partition), and the body::join() method executes step 3.2.<BR /><BR />If the the step 3.2 does not fit the reduction model, then you use parallel_for to execute steps 2 and 3.1, and then what is appropriate for the step 3.2.<BR /><BR />But what is really important, is that when working with TBB you should forget about process or thread IDs. The primary difference between MPI and TBB approaches results from the fact that the distributed systems have terrible communication overhead, and thus they have to use <I>coarse-grained</I> work splitting (a chunk per CPU node) to minimize the number of message passing roundtrips. In shared memory parallelizm (which TBB is targeted to), the cost of communication between CPUs/cores is relatively small. This allows to achieve very good load balance by using <I>fine-grained</I> work splitting.<BR /><BR />Thus the number of subgraphs you need to partition the source matrix to should be such that useful work at step 3.1 took approximately 10-20 microseconds (on modern CPUs), but was not (much) less than auxiliary operations overhead (step 2 is such an auxiliary operation in this case, as well as partitioning cost). The number of subgraphs should not depend on the number of CPUs/cores in your system, and normally it should be much bigger (an order of thousands would be fine for TBB).<BR /><BR />Advanced TBB partitioners working with TBB algorithms (auto_partitioner and affinity_partitioner) dinamically aggregate several subgraphs in one transaction where possible (to decrease the parallel book-keeping overhead), while falling back to the smallest grain size where it is necessary for the sake of good load balancing.<BR /><BR />Mon, 21 Jul 2008 08:10:44 GMTAndrey_Marochko2008-07-21T08:10:44ZHow to use TBB for solving sparse linear systems?
https://community.intel.com/t5/Intel-oneAPI-Threading-Building/How-to-use-TBB-for-solving-sparse-linear-systems/m-p/859544#M5311
Hi,<BR /><BR />I used to use MPI based packages to iteratively solve sparse linear systems. The basic procedure is:<BR /><BR />1. partition the graph/hypergraph based on the matrix A (metis/hmetis).<BR /><BR />2. construct local matrix and vector based on the partitioning results obtained.<BR /><BR />3. solve the given linear system in parallel.<BR /><BR />There is a process ID which determines the data to deal with. There is no such ID available in TBB. I figured it <BR />out that I could call<BR /><BR />parallel_for(blocked_range<INT>(0,nthread, 1), ApplySolve)<BR /><BR />to get thread ID. But how can I put all three steps above in a BIG class ApplySolve? Should I use pipeline instead? If so, how?<BR /><BR />Thanks,<BR />Zhongze<BR /></INT>Thu, 10 Jul 2008 21:01:19 GMThttps://community.intel.com/t5/Intel-oneAPI-Threading-Building/How-to-use-TBB-for-solving-sparse-linear-systems/m-p/859544#M5311Zhongze_L_2008-07-10T21:01:19ZRe: How to use TBB for solving sparse linear systems?
https://community.intel.com/t5/Intel-oneAPI-Threading-Building/How-to-use-TBB-for-solving-sparse-linear-systems/m-p/859545#M5312
Hi, Zhongze<BR /><BR />Unfortunately I am not an expert in the modern scientific algorithms, so I may be wrong in some of my assumptions. First I suppose that algorithms of the METIS family are serial, and thus the stage 1 is serial too. Then I assume that the stage 3 actually consists of two sub-stages: <BR />3.1. Process local matrices (actually sub-matrices of the matrix A). This can be done in parallel.<BR />3.2. Perform reduction of the results obtained at the step 3.1. This probably can also be done in parallel.<BR /><BR />Depending on the specific algorithm used at the step 3.2, two variants are possible. The first one: you use parallel_reduce algorithm where body::operator() executes steps 2 and 3.1 (paired together for each graph partition), and the body::join() method executes step 3.2.<BR /><BR />If the the step 3.2 does not fit the reduction model, then you use parallel_for to execute steps 2 and 3.1, and then what is appropriate for the step 3.2.<BR /><BR />But what is really important, is that when working with TBB you should forget about process or thread IDs. The primary difference between MPI and TBB approaches results from the fact that the distributed systems have terrible communication overhead, and thus they have to use <I>coarse-grained</I> work splitting (a chunk per CPU node) to minimize the number of message passing roundtrips. In shared memory parallelizm (which TBB is targeted to), the cost of communication between CPUs/cores is relatively small. This allows to achieve very good load balance by using <I>fine-grained</I> work splitting.<BR /><BR />Thus the number of subgraphs you need to partition the source matrix to should be such that useful work at step 3.1 took approximately 10-20 microseconds (on modern CPUs), but was not (much) less than auxiliary operations overhead (step 2 is such an auxiliary operation in this case, as well as partitioning cost). The number of subgraphs should not depend on the number of CPUs/cores in your system, and normally it should be much bigger (an order of thousands would be fine for TBB).<BR /><BR />Advanced TBB partitioners working with TBB algorithms (auto_partitioner and affinity_partitioner) dinamically aggregate several subgraphs in one transaction where possible (to decrease the parallel book-keeping overhead), while falling back to the smallest grain size where it is necessary for the sake of good load balancing.<BR /><BR />Mon, 21 Jul 2008 08:10:44 GMThttps://community.intel.com/t5/Intel-oneAPI-Threading-Building/How-to-use-TBB-for-solving-sparse-linear-systems/m-p/859545#M5312Andrey_Marochko2008-07-21T08:10:44Z