Parallel computing for integrals

I want to reduce the computation time for a time consuming integral by dividing the integration range. I am using C ++, Windows and an Intel i7 quad core processor.

How can I split it into 4 parallel computations?

+2


a source to share


7 replies


What's your integration algorithm?



Mathematically, a range integral is a sum of integrals by parts, so parallelization seems trivial.

+3


a source


Use OpenMP . gcc supports it. Visual C ++ supports it.



+2


a source


As others have said, and I'm sure you know that integration is a summation, parellization should be easy. I know you are using C ++, but are you using go capability? It is very easy to use goroutines to do this type of work . But I understand if this code will go to a client that you wouldn't want to use as it is still untested in the wild. If this is a personal project, go for it (no pun intended).

+1


a source


Grab this in 2 parts:

1) What approach to parallelization are you going to take: MPI, OpenMP, streams, anything? and

2) How to change the algorithm.

On a windows quad core machine, I suggest OpenMP as my answer to the first part of this. The answer to the second part depends on which algorithm you are using. If, for example, you use the Monte Carlo technique, parallelization is trivial. If you are using some sort of digital quadrature, it is much less trivial to ensure that none of the corner cases that others have identified become a major issue. However, if you can rule out pathological integrals, this shouldn't be overly difficult.

+1


a source


I suggest you take a look at the building blocks of information flows.

http://www.threadingbuildingblocks.org/

and especially parallel_reduce

.

0


a source


The problem you will have is boundary conditions.

It is easy to think that numerical squaring can be split into multiple domains, but you don't know what internal boundary conditions are.

The breaking of an integral upward along subdomains begins as a finite element, finite difference, or solution of boundary elements. You took a tricky region, broken into pieces, turned it into a matrix, and solved it given the boundary conditions you know.

I don't think it's as easy as splitting a domain into subdomains and assigning each processor, but I could be wrong.

0


a source


You can calculate the integral using the Trapezoidal Rule (or any other Newton-Cotes formula). For best results, you can segment the interval and use the Trapezoid rule for each segment. The formula can be found in the linked article.

Since each calculation is independent of the other, you can run them in parallel. The easiest way to do this is through OpenMP (as mentioned above).

0


a source







All Articles