我有一個c應用程序處理用於Radix4計算的浮點表。現在,我希望它以多核系統上運行它被分成兩個線程,首先,這是功能結構:將c函數拆分爲線程
void radix4(float* x, float* y, N)
{
for (l = 1; l <= PMAX; l++)
{
n = pow_4[l];//LUT for power of 4
for (c =0; c < n; c=c+4)
{
//Loading some parameters from a look-up table
n2 =LUT_n2[l][c];
N2 =LUT_n2[l][c+1];
N2_2=LUT_n2[l][c+2];
N2_3=LUT_n2[l][c+3];
factor = TWIDDLE_LIMIT/(range*4);
while ((k < range) && (range > 7))
{//loading data from input tables
//Computing butterflies
//Loading twiddles
//Computing final values
//Store result in the same table
}
while ((k<range) && (range<=7))
{
//loading data from input tables
//Computing butterflies
//Loading twiddles
//Computing final values
//Store result in the same table
}
}
}
}
的while循環展開。 現在我想了解的是如何知道哪些部分可以拆分成線程,並且可以給出一些關於如何去做的提示,因爲我正在閱讀很多讓我有點困惑的東西。
問題是針對C而不是C++。 – sendaran
改爲使用pthreads庫,工作原理相同 – baliman
1)這不是C! 2)純代碼答案3)爲什麼兩個函數? 4)不,它不「工作相同」!不同的語言! – Olaf