それぞれが隣接するプロセッサを備えた4つのスレッドで4つのチームを作成する必要があります。
私が期待している結果は、たとえば次のとおりです。
Team 0 Thread 0 Processor: 0
Team 0 Thread 1 Processor: 1
Team 0 Thread 2 Processor: 2
Team 0 Thread 3 Processor: 3
Team 1 Thread 0 Processor: 4
Team 1 Thread 1 Processor: 5
Team 1 Thread 2 Processor: 6
Team 1 Thread 3 Processor: 7
Team 2 Thread 0 Processor: 8
Team 2 Thread 1 Processor: 9
Team 2 Thread 2 Processor: 10
Team 2 Thread 3 Processor: 11
Team 3 Thread 0 Processor: 12
Team 3 Thread 1 Processor: 13
Team 3 Thread 2 Processor: 14
Team 3 Thread 3 Processor: 15
GOMP_CPU_AFFINITY変数を使用して、GCCでプロセッサ親和性を処理できます。
私が使用しているもの:
#pragma omp parallel num_threads(4)
2つのフォークレベルを取得するために2回。
現在、GOMP_CPU_AFFINITYで次の順序になっています。
0 4 8 12 1 2 3 5 6 7 9 10 11 13 14 15
したがって、最初のフォークである「父親のフォーク」は次のようになります。
Team 0 Thread 0 Processor: 0
Team 1 Thread 0 Processor: 4
Team 2 Thread 0 Processor: 8
Team 3 Thread 0 Processor: 12
私が抱えている問題は、フォークの2番目のグループが順序なしで作成されるため、たとえば、この状況が発生する可能性があることです(#pragma ompアトミックを使用しているため、いつでも1人の「父」だけがより多くのプロセッサを要求できます) :
Team 0 Thread 0 Processor: 0
Team 0 Thread 1 Processor: 5
Team 0 Thread 2 Processor: 6
Team 0 Thread 3 Processor: 7
Team 1 Thread 0 Processor: 4
Team 1 Thread 1 Processor: 13
Team 1 Thread 2 Processor: 14
Team 1 Thread 3 Processor: 15
Team 2 Thread 0 Processor: 8
Team 2 Thread 1 Processor: 1
Team 2 Thread 2 Processor: 2
Team 2 Thread 3 Processor: 3
Team 3 Thread 0 Processor: 12
Team 3 Thread 1 Processor: 9
Team 3 Thread 2 Processor: 10
Team 3 Thread 3 Processor: 11
問題は、この2番目の請願を順番に行う方法はありますか?
私はロックか何かで同期方法を作らなければならないと思います...
前もって感謝します!
- ハビエル