2013-06-24 86 views
1

假設您有一個圖表表示在make文件中定義的依賴關係。什麼是(an?)算法,用於確定構建依賴性的順序以及可並行化的內容(使用-jX標誌時)。什麼是「make -jX」算法

E.g.如果你有以下DEPS:

A: B C 
B: D 
C: D 
D: 

「d」顯然需要先建,但一旦建成,B和C可以建在並行,而當他們都完成後,可建。

+1

請參見[拓撲排序](http://en.wikipedia.org/wiki/Topological_sorting),其中「圖的頂點可以表示要執行的任務,並且邊可以表示必須先執行一個任務之前必須執行的約束另一個「 –

+0

@ jwpat7:我想真正的問題是如何將頂點分配給線程。 –

回答

2

通過使用make -d可以精確地看到使用的算法打印調試信息。對於你的榜樣(我加echo命令實際上會導致一些事情發生):

$ make -r -d -j 
GNU Make 3.81 
Copyright (C) 2006 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. 
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE. 

This program built for i386-apple-darwin11.3.0 
Reading makefiles... 
Reading makefile `Makefile'... 
Updating makefiles.... 
Considering target file `Makefile'. 
    Looking for an implicit rule for `Makefile'. 
    No implicit rule found for `Makefile'. 
    Finished prerequisites of target file `Makefile'. 
No need to remake target `Makefile'. 
Updating goal targets.... 
Considering target file `A'. 
File `A' does not exist. 
    Considering target file `B'. 
    File `B' does not exist. 
    Considering target file `D'. 
    File `D' does not exist. 
    Finished prerequisites of target file `D'. 
    Must remake target `D'. 
Putting child 0x7fdae2c08110 (D) PID 71724 on the chain. 
    Commands of `D' are being run. 
    Finished prerequisites of target file `B'. 
    The prerequisites of `B' are being made. 
    Considering target file `C'. 
    File `C' does not exist. 
    Pruning file `D'. 
    Finished prerequisites of target file `C'. 
    The prerequisites of `C' are being made. 
Finished prerequisites of target file `A'. 
The prerequisites of `A' are being made. 
Live child 0x7fdae2c08110 (D) PID 71724 
D 
Reaping winning child 0x7fdae2c08110 PID 71724 
Removing child 0x7fdae2c08110 PID 71724 from chain. 
Considering target file `A'. 
File `A' does not exist. 
    Considering target file `B'. 
    File `B' does not exist. 
    Considering target file `D'. 
    File `D' was considered already. 
    Finished prerequisites of target file `B'. 
    Must remake target `B'. 
Putting child 0x7fdae2c083c0 (B) PID 71729 on the chain. 
    Commands of `B' are being run. 
    Considering target file `C'. 
    File `C' does not exist. 
    Pruning file `D'. 
    Finished prerequisites of target file `C'. 
    Must remake target `C'. 
Live child 0x7fdae2c083c0 (B) PID 71729 
Putting child 0x7fdae2c09020 (C) PID 71734 on the chain. 
    Commands of `C' are being run. 
Finished prerequisites of target file `A'. 
The prerequisites of `A' are being made. 
Live child 0x7fdae2c09020 (C) PID 71734 
Live child 0x7fdae2c083c0 (B) PID 71729 
B 
Reaping winning child 0x7fdae2c083c0 PID 71729 
Removing child 0x7fdae2c083c0 PID 71729 from chain. 
Live child 0x7fdae2c09020 (C) PID 71734 
Considering target file `A'. 
File `A' does not exist. 
    Considering target file `B'. 
    File `B' was considered already. 
    Considering target file `C'. 
    Still updating file `C'. 
Finished prerequisites of target file `A'. 
The prerequisites of `A' are being made. 
Live child 0x7fdae2c09020 (C) PID 71734 
C 
Reaping winning child 0x7fdae2c09020 PID 71734 
Removing child 0x7fdae2c09020 PID 71734 from chain. 
Considering target file `A'. 
File `A' does not exist. 
    Considering target file `B'. 
    File `B' was considered already. 
    Considering target file `C'. 
    File `C' was considered already. 
Finished prerequisites of target file `A'. 
Must remake target `A'. 
Putting child 0x7fdae2c090c0 (A) PID 71739 on the chain. 
Commands of `A' are being run. 
Live child 0x7fdae2c090c0 (A) PID 71739 
A 
Reaping winning child 0x7fdae2c090c0 PID 71739 
Removing child 0x7fdae2c090c0 PID 71739 from chain. 
Considering target file `A'. 
File `A' was considered already. 

注意下面兩行一起:

Live child 0x7fdae2c09020 (C) PID 71734 
Live child 0x7fdae2c083c0 (B) PID 71729 

顯示兩者BC食譜在同一時間運行。