数値積分関数を並列化したい。計算の途中でこの関数を使いたいです。前の作業はルートプロセスで行う必要があります。これはMPIで行うことができますか?
double integral_count_MPI(double (*function)(double) , double beginX, double endX, int count)
{
double step, result;
int i;
if (endX - beginX <= 0) return 0;
step = (endX - beginX) / count;
result = 0;
double *input = (double*)malloc((count+1) *sizeof(double));
for (i = 0; i <= count; i ++)
{
input[i] = beginX + i*step;
}
// Calculate and gather
}
編集
アルゴリズム:
1 process calculation;
while:
1 process calculation;
integration very complex function with many processes;
1 process calculation;
end while;
1 process calculation;