4

タイトルが示すように、私は並列コンピューター ビジョン技術に関するちょっとした個人研究に取り組んでいます。CUDA を使用して、ハフ変換の GPGPU バージョンを実装しようとしています。私が遭遇した唯一の問題は、投票プロセス中です。複数の同時書き込み操作を防ぐためにatomicAdd()を呼び出していますが、パフォーマンス効率があまり向上していないようです。Web を検索しましたが、投票プロセスのパフォーマンスを著しく向上させる方法は見つかりませんでした。

投票プロセスに関してご提供いただけるご支援をいただければ幸いです。

4

2 に答える 2

1

私はハフ変換に慣れていないので、疑似コードを投稿するとここに役立つかもしれません。ただし、投票に関心がある場合は、CUDA 投票組み込み命令を使用して投票を加速することを検討してください。

これには 2.0 以降のコンピューティング機能 (Fermi 以降) が必要であることに注意してください。

特定の条件が真であるブロック内のスレッドの数を数えたい場合は、単に を使用できます__syncthreads_count()

bool condition = ...; // compute the condition
int blockCount = __syncthreads_count(condition); // must be in non-divergent code

条件が真であるグリッド内のスレッドの数を数えたい場合は、次のように実行できます。atomicAdd

bool condition = ...; // compute the condition
int blockCount = __syncthreads_count(condition); // must be in non-divergent code
atomicAdd(totalCount, blockCount);

条件が true であるブロックよりも小さいグループ内のスレッドの数をカウントする必要がある場合は、__ballot()and __popc()(population count) を使用できます。

// get the count of threads within each warp for which the condition is true
bool condition = ...; // compute the condition in each thread
int warpCount = __popc(__ballot()); // see the CUDA programming guide for details

お役に立てれば。

于 2012-06-27T12:57:58.830 に答える