6 #ifndef TPZStructMatrixTBB_H 7 #define TPZStructMatrixTBB_H 11 #include <semaphore.h> 23 class TPZStructMatrixTBB;
27 #include "tbb/flow_graph.h" 46 TPZStructMatrixTBB(
TPZCompMesh *,
bool onlyrhs =
false);
50 TPZStructMatrixTBB(
const TPZStructMatrixTBB ©);
52 virtual ~TPZStructMatrixTBB();
58 unsigned numthreads_assemble,
unsigned numthreads_decompose) {
65 virtual TPZStructMatrixTBB *
Clone()
override;
70 unsigned numthreads_assemble,
unsigned numthreads_decompose) {
71 std::cout <<
"Nothing to do." << std::endl;
106 TPZPointers() : fEk(0), fEf(0){}
110 TPZFlowGraph(TPZStructMatrixTBB *strmat,
bool onlyrhs);
112 TPZFlowGraph(TPZFlowGraph
const ©);
129 tbb::flow::graph fGraph;
132 std::vector<tbb::flow::continue_node<tbb::flow::continue_msg> *> fNodes;
145 void OrderElements();
146 void ElementColoring();
150 void CreateGraphRhs();
156 friend class TPZStructMatrixTBB;
160 TPZStructMatrixTBB *fStruct;
173 class TPZAssembleTask {
175 TPZAssembleTask() : fOrigin(0), fElMat(0), fIel(-1){
178 TPZAssembleTask(int64_t iel, TPZFlowGraph *origin) : fOrigin(origin), fIel(iel)
180 fElMat = &origin->fElMatPointers[iel];
183 ~TPZAssembleTask() {}
185 TPZAssembleTask(
const TPZAssembleTask ©) : fOrigin(copy.fOrigin), fElMat(copy.fElMat), fIel(copy.fIel)
190 void operator=(
const TPZAssembleTask ©)
192 fOrigin = copy.fOrigin;
193 fElMat = copy.fElMat;
197 tbb::flow::continue_msg operator()(
const tbb::flow::continue_msg &msg);
200 TPZFlowGraph *fOrigin;
212 TPZCalcTask(TPZFlowGraph *flowgraph) : fFlowGraph(flowgraph) {}
214 void operator()(
const tbb::blocked_range<int64_t>& range)
const;
218 TPZFlowGraph *fFlowGraph;
221 class TAssembleOneColor {
223 TAssembleOneColor(TPZFlowGraph *graph) : fFlowGraph(graph)
227 void operator()(
const tbb::blocked_range<int64_t> &range)
const;
230 TPZFlowGraph *fFlowGraph;
233 class TComputeElementRange {
236 TComputeElementRange(TPZFlowGraph *graph, int64_t color) : fFlowGraph(graph), fColor(color)
240 void operator()(
const tbb::blocked_range<int64_t> &range)
const;
242 TPZFlowGraph *fFlowGraph;
250 TSumTwoColors(int64_t firstcolumn, int64_t secondcolumn,
TPZFMatrix<STATE> *rhs) : fFirstColumn(firstcolumn), fSecondColumn(secondcolumn), fRhs(rhs)
254 tbb::flow::continue_msg operator()(
const tbb::flow::continue_msg &msg)
const 256 int64_t nrow = fRhs->Rows();
257 for (int64_t ir=0; ir<nrow; ir++) {
258 (*fRhs)(ir,fFirstColumn) += (*fRhs)(ir,fSecondColumn);
260 return tbb::flow::continue_msg();
264 int64_t fFirstColumn;
265 int64_t fSecondColumn;
278 TPZFlowGraph *fFlowGraph;
virtual TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
Contains declaration of the TPZSemaphore class which implements semaphore to threads.
Templated vector implementation.
Contains declaration of TPZGuiInterface class.
virtual TPZStructMatrixBase * Clone()=0
int ClassId() const override
Define the class id associated with the class.
TPZSkylMatrix< REAL > matrix
virtual void Assemble(TPZMatrix< STATE > &stiffness, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)=0
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
Contains TPZMatrixclass which implements full matrix (using column major representation).
virtual void SetNumThreads(int n)
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
Contains declaration of TPZCompMesh class which is a repository for computational elements...
Contains TPZMatrix<TVar>class, root matrix class.
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
virtual TPZMatrix< STATE > * Create()=0
Implements computational mesh. Computational Mesh.
Defines the interface for saving and reading data. Persistency.
void Read(TPZStream &buf, void *context) override
read objects from the stream