My C++ code evaluates very large integrals on timeseries data (t2 >> t1). The integrals are fixed length and currently stored in [m x 2] column array of doubles. Column 1 is time. Column 2 is the signal that's being integrated. The code is running on a quadcore or 8 core machine.
For a machine with k cores, I want to:
- Spin off k-1 worker processes (one for each of the remaining cores) to evaluate portions of the integral (trapezoidal integrations) and return their results to the waiting master thread.
- Achieve the above without deep copying portions of the original array.
- Implement C++11 async template for portability
How can I achieve the above without hardcoding the number of available cores?
I am Currently using VS 2012.
Update for Clarity:
For example, here's the rough psuedo-code
data is [100000,2] double
result = MyIntegrator(data[1:50000,1:2]) + MyIntegrator(data[50001:100000, 1:2]);
I need the MyIntegrator()
functions to be evaluated in separate threads. The master thread waits for the two results.