大きなデータセットに対して多くの操作を必要とするプログラムがあり、各データ要素の操作が独立している場合、OpenCLは高速化のための良い選択の1つになります。ここ反復問題のためのOpenCLの最良の汎用コンピューティングプラクティスは何ですか?
while(function(b,c)!=TRUE)
{
[X,Y] = function1(BigData);
M = functionA(X);
b = function2(M);
N = functionB(Y);
c = function3(N);
}
はfunction1はBigDataの要素のそれぞれに適用され、別の二つの大きなデータセット(X、Y)を生成される:私は次のようなプログラムを有しています。 function2およびfunction3は、それぞれ、これらのX、Yデータ上の各要素に個別に適用されます。
すべての機能の操作がデータセットの各要素に個別に適用されるため、GPUを使用すると処理が高速になる場合があります。だから私は、次の思い付く:
while(function(b,c)!=TRUE)
{
//[X,Y] = function1(BigData);
1. load kernel1 and BigData on the GPU. each of the thread will work on one of the data
element and save the result on X and Y on GPU.
//M = functionA(X);
2a. load kernel2 on GPU. Each of the threads will work on one of the
data elements of X and save the result on M on GPU.
(workItems=n1, workgroup size=y1)
//b = function2(M);
2b. load kernel2 (Same kernel) on GPU. Each of the threads will work on
one of the data elements of M and save the result on B on GPU
(workItems=n2, workgroup size=y2)
3. read the data B on host variable b
//N = functionB(Y);
4a. load kernel3 on GPU. Each of the threads will work on one of the
data element of Y and save the result on N on GPU.
(workItems=n1, workgroup size=y1)
//c = function2(M);
4b. load kernel3 (Same kernel) on GPU. Each of the threads will work
on one of the data element of M and save the result on C on GPU
(workItems=n2, workgroup size=y2)
5. read the data C on host variable c
}
しかし、このコードに関わるオーバーヘッドは(私がテストプログラムを実装し、GPU上で実行している)私には重要なようです。また、カーネルに何らかの同期があると、速度が遅くなってしまうかもしれません。
また、私はワークフローが一般的であると考えています。では、このようなプログラムの高速化にOpenCLを使うのがベストプラクティスです。
カードは、+ write + computeを同時に読み取ることができるため、可能な場合はそれらを同時に使用する必要があります。 –
情報ありがとうございます。しかし、ループ内のすべての操作が以前の操作の結果に依存することがわかります。だから、あなたが示唆しているように並行性は考えられません。それを改善する他の方法はありますか?それ以外の場合は、ベストプラクティスは何ですか? –
opencl 2.0では、デバイス側のカーネルエンキューが行われるため、カーネルのinitごとにホストを待つのではなく、より高速になる可能性があります。 –