I have an array x[] containing data. Also there is an array of "system states" c[]. The process:
for(i = 1; i < N; i++)
{
a = f1(x[i] + c[i-1]);
b = f2(x[i] + c[i-1]);
c[i] = a + b;
}
Is there any efficient way to find the values of f1
and f2
on 2-core system using 2 parallel threads? I mean the following (in pseudo-code):
thread_1
{
for(i = 1; i < N; i++)
a = f1(x[i] + c[i-1]);
}
thread_2
{
for(i = 1; i < N; i++)
{
b = f2(x[i] + c[i-1]);
c[i] = a + b; //here we somehow get a{i} from thread_1
}
}
f1
and f2
are not time consumptive, but have to be calculated many times, so desired speedup is about x2. See the diagram for graphical representation:
Looking for code examples for Windows.