pwrake 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/pwrake/branch/communicator_set.rb +4 -0
- data/lib/pwrake/master/master.rb +58 -38
- data/lib/pwrake/master/master_application.rb +11 -6
- data/lib/pwrake/nbio.rb +21 -2
- data/lib/pwrake/option/host_map.rb +13 -18
- data/lib/pwrake/queue/locality_aware_queue.rb +14 -3
- data/lib/pwrake/queue/task_queue.rb +24 -14
- data/lib/pwrake/report/report.rb +11 -8
- data/lib/pwrake/task/task_property.rb +20 -30
- data/lib/pwrake/task/task_wrapper.rb +6 -10
- data/lib/pwrake/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c3bfd1d1e40600085dbe880e57230260fa81b4f
|
4
|
+
data.tar.gz: 84a151198f3d200792e84fbe17715092b33abc15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1db1ccc6ce750393100155219a6b86c012c9126b6dfe77ed7bc2f8e4d8ec7baa113741b51a43765e16513554cae8a077bd005706290b2f139d0e960a21d0d4c2
|
7
|
+
data.tar.gz: c2d49f2af43611bda75f92f74726bd5c7045ea2d85604b480231b5d0e5729d2d90b60f9c58b89aa12ea1e513eb8f3fa4c38a87b1beab485f266a0c759271383e
|
data/README.md
CHANGED
@@ -170,6 +170,7 @@ Properties (The leftmost item is default):
|
|
170
170
|
|
171
171
|
ncore=integer - The number of cores used by this task.
|
172
172
|
exclusive=no|yes - Exclusively execute this task in a single node.
|
173
|
+
reserve=no|yes - Gives higher priority to this task if ncore>1. (reserve a host)
|
173
174
|
allow=hostname - Allow this host to execute this task. (accepts wild card)
|
174
175
|
deny=hostname - Deny this host to execute this task. (accepts wild card)
|
175
176
|
order=deny,allow|allow,deny - The order of evaluation.
|
@@ -201,12 +202,12 @@ Properties (The leftmost item is default):
|
|
201
202
|
|
202
203
|
## Current version
|
203
204
|
|
204
|
-
* Pwrake version 2.2.
|
205
|
+
* Pwrake version 2.2.3
|
205
206
|
|
206
207
|
## Tested Platform
|
207
208
|
|
208
209
|
|
209
|
-
* Ruby 2.4.
|
210
|
+
* Ruby 2.4.1
|
210
211
|
* Rake 12.0.0
|
211
212
|
* CentOS 7.3
|
212
213
|
|
@@ -95,11 +95,15 @@ class CommunicatorSet
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def kill(sig)
|
98
|
+
@selector.clear
|
98
99
|
NBIO::Handler.kill(handler_set,sig)
|
100
|
+
@selector.run
|
99
101
|
end
|
100
102
|
|
101
103
|
def exit
|
104
|
+
@selector.clear
|
102
105
|
NBIO::Handler.exit(handler_set)
|
106
|
+
@selector.run
|
103
107
|
end
|
104
108
|
|
105
109
|
end
|
data/lib/pwrake/master/master.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "fileutils"
|
2
|
+
require "timeout"
|
2
3
|
require "pwrake/logger"
|
3
4
|
require "pwrake/nbio"
|
4
5
|
require "pwrake/option/option"
|
@@ -22,6 +23,7 @@ module Pwrake
|
|
22
23
|
@option = Option.new
|
23
24
|
Log.set_logger(@option)
|
24
25
|
TaskWrapper.init_task_logger(@option)
|
26
|
+
at_exit{TaskWrapper.close_task_logger}
|
25
27
|
# moved from Option#init
|
26
28
|
@option.put_log
|
27
29
|
if @option['LOG_DIR'] && @option['GC_LOG_FILE']
|
@@ -63,31 +65,33 @@ module Pwrake
|
|
63
65
|
end
|
64
66
|
|
65
67
|
def signal_trap(sig)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
$stderr.puts
|
70
|
-
if
|
71
|
-
$stderr.puts "in
|
72
|
-
$stderr.puts
|
73
|
-
if @thread
|
74
|
-
$stderr.puts "in branch thread #{@thread}:"
|
75
|
-
$stderr.puts @thread.backtrace.join("\n")
|
76
|
-
end
|
68
|
+
$stderr.puts "\nSignal trapped. (sig=#{sig} pid=#{Process.pid})"
|
69
|
+
if Rake.application.options.debug
|
70
|
+
$stderr.puts "in master thread #{Thread.current}:"
|
71
|
+
$stderr.puts caller
|
72
|
+
if @thread
|
73
|
+
$stderr.puts "in branch thread #{@thread}:"
|
74
|
+
$stderr.puts @thread.backtrace.join("\n")
|
77
75
|
end
|
78
|
-
$stderr.puts "Exiting..."
|
79
|
-
@no_more_run = true
|
80
|
-
@failed = true
|
81
|
-
NBIO::Handler.kill(@hdl_set,sig)
|
82
|
-
# @selector.run : not required here
|
83
|
-
when 1
|
84
|
-
$stderr.puts "\nOnce more Ctrl-C (SIGINT) for exit."
|
85
|
-
when 2
|
86
|
-
@thread.kill if @thread
|
87
|
-
else
|
88
|
-
Kernel.exit(false) # must wait for nomral exit
|
89
76
|
end
|
90
|
-
|
77
|
+
kill_end(sig)
|
78
|
+
end
|
79
|
+
|
80
|
+
def kill_end(sig)
|
81
|
+
# log writing failed. can't be called from trap context
|
82
|
+
$stderr.puts "Exiting..."
|
83
|
+
@no_more_run = true
|
84
|
+
@failed = true
|
85
|
+
@selector.clear
|
86
|
+
NBIO::Handler.kill(@hdl_set,sig)
|
87
|
+
begin
|
88
|
+
Timeout.timeout(30) do
|
89
|
+
@selector.run
|
90
|
+
@thread.join if @thread
|
91
|
+
end
|
92
|
+
rescue
|
93
|
+
end
|
94
|
+
Kernel.exit(false)
|
91
95
|
end
|
92
96
|
|
93
97
|
def setup_branches
|
@@ -167,12 +171,14 @@ module Pwrake
|
|
167
171
|
host_info = @hostinfo_by_id[hid.to_i]
|
168
172
|
if host_info && host_info.decrease(1)
|
169
173
|
# all retired
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
174
|
+
if !@exited
|
175
|
+
m = "retired: host #{host_info.name}"
|
176
|
+
Log.warn(m)
|
177
|
+
$stderr.puts(m)
|
178
|
+
drop_host(host_info) # delete from hostinfo_by_id
|
179
|
+
if @hostinfo_by_id.empty?
|
180
|
+
raise RuntimeError,"no worker host"
|
181
|
+
end
|
176
182
|
end
|
177
183
|
end
|
178
184
|
end
|
@@ -208,7 +214,6 @@ module Pwrake
|
|
208
214
|
|
209
215
|
setup_postprocess1
|
210
216
|
@branch_setup_thread.join
|
211
|
-
@killed = 0
|
212
217
|
[:TERM,:INT].each do |sig|
|
213
218
|
Signal.trap(sig) do
|
214
219
|
signal_trap(sig)
|
@@ -374,12 +379,18 @@ module Pwrake
|
|
374
379
|
end
|
375
380
|
|
376
381
|
def ending?
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
+
if @no_more_run || @task_queue.empty? || @hostinfo_by_id.empty?
|
383
|
+
case @hostinfo_by_taskname.size
|
384
|
+
when 1..2
|
385
|
+
Log.debug " @no_more_run=#{@no_more_run.inspect}" if @no_more_run
|
386
|
+
Log.debug " @task_queue.empty?=#{@task_queue.empty?}" if @task_queue.empty?
|
387
|
+
Log.debug " @hostinfo_by_id.empty?=#{@hostinfo_by_id.empty?}" if @hostinfo_by_id.empty?
|
388
|
+
Log.debug " @hostinfo_by_taskname.keys=#{@hostinfo_by_taskname.keys.inspect}"
|
389
|
+
end
|
382
390
|
@hostinfo_by_taskname.empty?
|
391
|
+
else
|
392
|
+
false
|
393
|
+
end
|
383
394
|
end
|
384
395
|
|
385
396
|
def handle_failed_target(name)
|
@@ -427,16 +438,25 @@ module Pwrake
|
|
427
438
|
@branch_setup_thread.join
|
428
439
|
# continues running fibers
|
429
440
|
Log.debug "Master#finish @selector.run begin"
|
430
|
-
|
441
|
+
begin
|
442
|
+
Timeout.timeout(30){@selector.run}
|
443
|
+
rescue
|
444
|
+
end
|
431
445
|
Log.debug "Master#finish @selector.run end"
|
432
446
|
if !@exited
|
433
447
|
@exited = true
|
434
448
|
Log.debug "Master#finish Handler.exit begin"
|
449
|
+
@selector.clear
|
435
450
|
NBIO::Handler.exit(@hdl_set)
|
436
|
-
|
451
|
+
begin
|
452
|
+
Timeout.timeout(30) do
|
453
|
+
@selector.run
|
454
|
+
@thread.join if @thread
|
455
|
+
end
|
456
|
+
rescue
|
457
|
+
end
|
437
458
|
Log.debug "Master#finish Handler.exit end"
|
438
459
|
end
|
439
|
-
TaskWrapper.close_task_logger
|
440
460
|
Log.debug "Master#finish end"
|
441
461
|
@failed
|
442
462
|
end
|
@@ -31,21 +31,25 @@ module Pwrake
|
|
31
31
|
top_level
|
32
32
|
Log.debug "main: #{Time.now-t} sec"
|
33
33
|
t = Time.now
|
34
|
+
@failed = @master.finish
|
35
|
+
Log.debug "finish: #{Time.now-t} sec"
|
36
|
+
rescue SystemExit => e
|
37
|
+
@failed = true
|
34
38
|
rescue Exception => e
|
35
39
|
# Exit with error message
|
36
40
|
m = Log.bt(e)
|
37
41
|
if @master.thread
|
38
42
|
m += "\nIn branch thread #{@master.thread}:\n "
|
39
|
-
|
43
|
+
if @master.thread.backtrace
|
44
|
+
m += @master.thread.backtrace.join("\n ")
|
45
|
+
end
|
40
46
|
end
|
41
47
|
Log.fatal m
|
42
48
|
$stderr.puts m
|
43
|
-
@master.
|
44
|
-
|
45
|
-
@failed = @master.finish
|
46
|
-
Log.debug "finish: #{Time.now-t} sec"
|
47
|
-
Log.info "pwrake elapsed time: #{Time.now-START_TIME} sec"
|
49
|
+
@master.kill_end("INT")
|
50
|
+
@failed = true
|
48
51
|
end
|
52
|
+
Log.info "pwrake elapsed time: #{Time.now-START_TIME} sec"
|
49
53
|
Kernel.exit(false) if @failed
|
50
54
|
end
|
51
55
|
end
|
@@ -183,6 +187,7 @@ module Pwrake
|
|
183
187
|
],
|
184
188
|
['--clear-gfarm2fs',"[Pw] Clear gfarm2fs mountpoints left after failure.",
|
185
189
|
lambda { |value|
|
190
|
+
require "pwrake/option/option_gfarm2fs"
|
186
191
|
Option.new.clear_gfarm2fs
|
187
192
|
exit
|
188
193
|
}
|
data/lib/pwrake/nbio.rb
CHANGED
@@ -39,6 +39,11 @@ module NBIO
|
|
39
39
|
@reader.empty? && @writer.empty?
|
40
40
|
end
|
41
41
|
|
42
|
+
def clear
|
43
|
+
@reader.clear
|
44
|
+
@writer.clear
|
45
|
+
end
|
46
|
+
|
42
47
|
def halt
|
43
48
|
@running = false
|
44
49
|
@writer.each_value{|w| w.halt}
|
@@ -101,12 +106,22 @@ module NBIO
|
|
101
106
|
|
102
107
|
def init_heartbeat
|
103
108
|
t = Time.now
|
109
|
+
@hb_check_time = t
|
104
110
|
@hb_time = {}
|
105
111
|
@reader.each_key{|io| @hb_time[io] = t}
|
106
112
|
end
|
107
113
|
|
108
114
|
def check_heartbeat(ios,timeout)
|
109
115
|
t = Time.now
|
116
|
+
if t - @hb_check_time < 3
|
117
|
+
if ios
|
118
|
+
ios.each do |io|
|
119
|
+
@hb_time[io] = t
|
120
|
+
end
|
121
|
+
end
|
122
|
+
return
|
123
|
+
end
|
124
|
+
@hb_check_time = t
|
110
125
|
rds = @reader.dup
|
111
126
|
if ios
|
112
127
|
ios.each do |io|
|
@@ -119,7 +134,8 @@ module NBIO
|
|
119
134
|
tdif = t - @hb_time[io]
|
120
135
|
if tdif > timeout
|
121
136
|
m = "Heartbeat Timeout: no response during #{tdif}s "+
|
122
|
-
"> timeout #{timeout}s from host=#{get_host(io)}"
|
137
|
+
"> timeout #{timeout}s from host=#{get_host(io)} " +
|
138
|
+
"@hb_time[io=#{io.inspect}]=#{@hb_time[io].strftime('%FT%T.%6N')}"
|
123
139
|
hdl.error(TimeoutError.new(m))
|
124
140
|
end
|
125
141
|
end
|
@@ -138,6 +154,7 @@ module NBIO
|
|
138
154
|
@pool = []
|
139
155
|
end
|
140
156
|
attr_reader :io
|
157
|
+
attr_accessor :host
|
141
158
|
|
142
159
|
# call from Selector
|
143
160
|
def call
|
@@ -237,7 +254,7 @@ module NBIO
|
|
237
254
|
@chunk_size = 8192
|
238
255
|
end
|
239
256
|
attr_reader :io, :waiter
|
240
|
-
attr_accessor :check_timeout
|
257
|
+
attr_accessor :check_timeout, :host
|
241
258
|
|
242
259
|
# call from Selector#run
|
243
260
|
def call
|
@@ -455,6 +472,8 @@ module NBIO
|
|
455
472
|
@writer = writer
|
456
473
|
@reader = reader
|
457
474
|
@host = hostname
|
475
|
+
@reader.host = @host
|
476
|
+
@writer.host = @host
|
458
477
|
@exited = false
|
459
478
|
end
|
460
479
|
attr_reader :reader, :writer, :host
|
@@ -87,25 +87,20 @@ module Pwrake
|
|
87
87
|
@continuous_fail
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
@reserved_task = nil
|
96
|
-
return :ok
|
97
|
-
end
|
98
|
-
end
|
99
|
-
else
|
100
|
-
if use_cores <= @idle_cores
|
101
|
-
return :ok
|
102
|
-
elsif use_cores > 1
|
103
|
-
@reserved_task = task_name
|
104
|
-
Log.info "reserve host: #{@name} for #{task_name} (#{use_cores} cores)"
|
105
|
-
return :reserve
|
106
|
-
end
|
90
|
+
def check_cores(use_cores)
|
91
|
+
unless (1-@ncore..@ncore) === use_cores
|
92
|
+
m = "use_cores=#{use_cores} is invalid for @ncore=#{@ncore}"
|
93
|
+
Log.fatal m
|
94
|
+
raise RuntimeError,m
|
107
95
|
end
|
108
|
-
|
96
|
+
if use_cores < 1
|
97
|
+
use_cores += @ncore
|
98
|
+
end
|
99
|
+
use_cores
|
100
|
+
end
|
101
|
+
|
102
|
+
def accept_core(use_cores)
|
103
|
+
check_cores(use_cores) <= @idle_cores
|
109
104
|
end
|
110
105
|
end
|
111
106
|
|
@@ -37,7 +37,12 @@ module Pwrake
|
|
37
37
|
if !kv.empty?
|
38
38
|
kv.each_key do |id|
|
39
39
|
t.assigned.push(id)
|
40
|
-
@q[id]
|
40
|
+
q = @q[id]
|
41
|
+
if q
|
42
|
+
q.push(t)
|
43
|
+
else
|
44
|
+
Log.warn("@q[id]=#{q.inspect} : @q.keys=#{@q.keys.inspect} id=#{id.inspect}")
|
45
|
+
end
|
41
46
|
end
|
42
47
|
@size_q += 1
|
43
48
|
else
|
@@ -116,10 +121,13 @@ module Pwrake
|
|
116
121
|
end
|
117
122
|
if max_num > 0
|
118
123
|
max_info = @hostinfo_by_id[max_host]
|
119
|
-
Log.debug "deq_steal max_host=#{max_info.name} max_num=#{max_num}"
|
124
|
+
#Log.debug "deq_steal max_host=#{max_info.name} max_num=#{max_num}"
|
120
125
|
t = host_info.steal_phase{|h| deq_locate(max_info,h)}
|
121
126
|
#Log.debug "deq_steal task=#{t.inspect}"
|
122
|
-
|
127
|
+
if t
|
128
|
+
Log.debug "deq_steal max_host=#{max_info.name} max_num=#{max_num}"
|
129
|
+
return t
|
130
|
+
end
|
123
131
|
end
|
124
132
|
end
|
125
133
|
nil
|
@@ -152,13 +160,16 @@ module Pwrake
|
|
152
160
|
|
153
161
|
def clear
|
154
162
|
@q_no_action.clear
|
163
|
+
@q_reserved.clear
|
155
164
|
@q.each{|h,q| q.clear}
|
165
|
+
@size_q = 0
|
156
166
|
@q_remote.clear
|
157
167
|
end
|
158
168
|
|
159
169
|
def empty?
|
160
170
|
@size_q == 0 &&
|
161
171
|
@q_no_action.empty? &&
|
172
|
+
@q_reserved.empty? &&
|
162
173
|
@q_remote.empty?
|
163
174
|
end
|
164
175
|
|
@@ -8,6 +8,7 @@ module Pwrake
|
|
8
8
|
def initialize(hostinfo_by_id, group_map=nil)
|
9
9
|
@enable_steal = true
|
10
10
|
@q_no_action = NoActionQueue.new
|
11
|
+
@q_reserved = Hash.new
|
11
12
|
|
12
13
|
@hostinfo_by_id = hostinfo_by_id
|
13
14
|
|
@@ -84,22 +85,29 @@ module Pwrake
|
|
84
85
|
count = 0
|
85
86
|
@hostinfo_by_id.each_value do |host_info|
|
86
87
|
#Log.debug "TaskQueue#deq_turn host_info=#{host_info.name}"
|
87
|
-
if (
|
88
|
-
|
89
|
-
|
88
|
+
if turn_empty?(turn)
|
89
|
+
return queued
|
90
|
+
elsif (n_idle = host_info.idle_cores) && n_idle > 0
|
91
|
+
if tw = @q_reserved[host_info]
|
92
|
+
n_use = tw.n_used_cores(host_info)
|
93
|
+
if n_idle < n_use
|
94
|
+
next
|
95
|
+
end
|
96
|
+
@q_reserved.delete(host_info)
|
97
|
+
Log.debug "deq_reserve: #{tw.name} n_use_cores=#{n_use}"
|
90
98
|
elsif tw = deq_impl(host_info,turn)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
Log.fatal m
|
97
|
-
raise RuntimeError,m
|
98
|
-
else
|
99
|
-
yield(tw,host_info,n_task_cores)
|
100
|
-
count += 1
|
101
|
-
queued += 1
|
99
|
+
n_use = tw.n_used_cores(host_info)
|
100
|
+
if n_idle < n_use
|
101
|
+
@q_reserved[host_info] = tw
|
102
|
+
Log.debug "reserve host: #{host_info.name} for #{tw.name} (#{n_use} cores)"
|
103
|
+
next
|
102
104
|
end
|
105
|
+
Log.debug "deq: #{tw.name} n_use_cores=#{n_use}"
|
106
|
+
end
|
107
|
+
if tw
|
108
|
+
yield(tw,host_info,n_use)
|
109
|
+
count += 1
|
110
|
+
queued += 1
|
103
111
|
end
|
104
112
|
end
|
105
113
|
end
|
@@ -120,12 +128,14 @@ module Pwrake
|
|
120
128
|
|
121
129
|
def clear
|
122
130
|
@q_no_action.clear
|
131
|
+
@q_reserved.clear
|
123
132
|
@q_input.clear
|
124
133
|
@q_no_input.clear
|
125
134
|
end
|
126
135
|
|
127
136
|
def empty?
|
128
137
|
@q_no_action.empty? &&
|
138
|
+
@q_reserved.empty? &&
|
129
139
|
@q_input.empty? &&
|
130
140
|
@q_no_input.empty?
|
131
141
|
end
|
data/lib/pwrake/report/report.rb
CHANGED
@@ -59,11 +59,14 @@ EOL
|
|
59
59
|
|
60
60
|
h = {}
|
61
61
|
@elap_sum = 0
|
62
|
+
@elap_core_sum = 0
|
62
63
|
@sh_table.each do |row|
|
63
64
|
if host = row['host']
|
64
65
|
h[host] = true
|
65
66
|
end
|
66
|
-
|
67
|
+
t = row['elap_time'].to_f
|
68
|
+
@elap_sum += t
|
69
|
+
@elap_core_sum += t * row['ncore'].to_f
|
67
70
|
end
|
68
71
|
@hosts = h.keys.sort
|
69
72
|
@start_time = Time.parse(@sh_table[0]["start_time"])
|
@@ -207,18 +210,18 @@ EOL
|
|
207
210
|
html = HTML_HEAD + "<body><h1>Pwrake Statistics</h1>\n"
|
208
211
|
html << "<h2>Workflow</h2>\n"
|
209
212
|
html << "<table>\n"
|
210
|
-
html << "<tr><th>log
|
213
|
+
html << "<tr><th>log directory</th><td>#{@base}</td><tr>\n"
|
211
214
|
html << "<tr><th>ncore</th><td>#{@ncore}</td><tr>\n"
|
212
215
|
html << "<tr><th>elapsed time</th><td>%.3f sec</td><tr>\n"%[@elap]
|
213
|
-
html << "<tr><th>
|
214
|
-
html << "<tr><th>occupancy</th><td>%.3f %%</td><tr>\n"%[@
|
216
|
+
html << "<tr><th>accumulated process time</th><td>%.3f sec</td><tr>\n"%[@elap_sum]
|
217
|
+
html << "<tr><th>occupancy</th><td>%.3f %%</td><tr>\n"%[@elap_core_sum/@elap/@ncore*100]
|
215
218
|
html << "<tr><th>start time</th><td>#{@start_time}</td><tr>\n"
|
216
219
|
html << "<tr><th>end time</th><td>#{@end_time}</td><tr>\n"
|
217
|
-
html << "</table
|
220
|
+
html << "</table><br/>\n"
|
218
221
|
html << "<table>\n"
|
219
|
-
html << "<tr><th
|
220
|
-
@hosts.
|
221
|
-
html << "<tr
|
222
|
+
html << "<tr><th colspan=5>#{@hosts.size} hosts × #{@ncore.fdiv @hosts.size} cores/host</th><tr>\n"
|
223
|
+
@hosts.each_slice(5) do |a|
|
224
|
+
html << "<tr>"+a.map{|h|"<td>#{h}</td>"}.join("")+"<tr>\n"
|
222
225
|
end
|
223
226
|
html << "</table>\n"
|
224
227
|
html << "<h2>Parallelism</h2>\n"
|
@@ -3,7 +3,7 @@ module Pwrake
|
|
3
3
|
class TaskProperty
|
4
4
|
|
5
5
|
attr_reader :ncore, :exclusive, :allow, :deny, :order_allow_deny,
|
6
|
-
:retry, :disable_steal
|
6
|
+
:retry, :disable_steal, :reserve
|
7
7
|
attr_accessor :subflow
|
8
8
|
|
9
9
|
def parse_description(description)
|
@@ -18,6 +18,11 @@ module Pwrake
|
|
18
18
|
@exclusive = true
|
19
19
|
end
|
20
20
|
end
|
21
|
+
if /\breserve[=:]\s*(\S+)/i =~ description
|
22
|
+
if /^(y|t)/i =~ $1
|
23
|
+
@reserve = true
|
24
|
+
end
|
25
|
+
end
|
21
26
|
if /\ballow[=:]\s*(\S+)/i =~ description
|
22
27
|
@allow = $1
|
23
28
|
end
|
@@ -37,25 +42,24 @@ module Pwrake
|
|
37
42
|
@disable_steal = true
|
38
43
|
end
|
39
44
|
end
|
45
|
+
@use_cores = nil
|
40
46
|
end
|
41
47
|
|
42
48
|
def merge(prop)
|
43
49
|
@ncore = prop.ncore if prop.ncore
|
44
50
|
@exclusive = prop.exclusive if prop.exclusive
|
51
|
+
@reserve = prop.reserve if prop.reserve
|
45
52
|
@allow = prop.allow if prop.allow
|
46
53
|
@deny = prop.deny if prop.deny
|
47
54
|
@order_allow_deny = prop.order_allow_deny if prop.order_allow_deny
|
48
55
|
@retry = prop.retry if prop.retry
|
49
56
|
@disable_steal = prop.disable_steal if prop.disable_steal
|
50
57
|
@subflow = prop.subflow if prop.subflow
|
58
|
+
@use_cores = nil
|
51
59
|
end
|
52
60
|
|
53
|
-
def use_cores
|
54
|
-
|
55
|
-
if nc < 1
|
56
|
-
nc += host_info.ncore
|
57
|
-
end
|
58
|
-
return nc
|
61
|
+
def use_cores
|
62
|
+
@use_cores ||= (@exclusive) ? 0 : (@ncore || 1)
|
59
63
|
end
|
60
64
|
|
61
65
|
def accept_host(host_info)
|
@@ -84,31 +88,17 @@ module Pwrake
|
|
84
88
|
end
|
85
89
|
|
86
90
|
def n_used_cores(host_info=nil)
|
87
|
-
|
88
|
-
if
|
91
|
+
n = use_cores
|
92
|
+
if n == 1
|
89
93
|
return 1
|
90
|
-
elsif
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
return @ncore
|
97
|
-
else
|
98
|
-
if nc_node.nil?
|
99
|
-
m = "host_info.ncore is not set"
|
100
|
-
Log.fatal m
|
101
|
-
raise RuntimeError,m
|
102
|
-
end
|
103
|
-
n = @ncore + nc_node
|
104
|
-
if n > 0
|
105
|
-
return n
|
106
|
-
else
|
107
|
-
m = "ncore+nc_node=#{n} must be > 0"
|
108
|
-
Log.fatal m
|
109
|
-
raise RuntimeError,m
|
110
|
-
end
|
94
|
+
elsif host_info
|
95
|
+
return host_info.check_cores(n)
|
96
|
+
elsif n < 1
|
97
|
+
m = "invalid for use_cores=#{n}"
|
98
|
+
Log.fatal m
|
99
|
+
raise RuntimeError,m
|
111
100
|
end
|
101
|
+
return n
|
112
102
|
end
|
113
103
|
|
114
104
|
end
|
@@ -343,20 +343,16 @@ module Pwrake
|
|
343
343
|
end
|
344
344
|
|
345
345
|
def acceptable_for(host_info)
|
346
|
+
unless host_info
|
347
|
+
return true
|
348
|
+
end
|
346
349
|
unless @property.accept_host(host_info)
|
347
350
|
return false
|
348
351
|
end
|
349
|
-
|
350
|
-
|
351
|
-
case host_info.accept_core(name,use_cores)
|
352
|
-
when :ok
|
353
|
-
@reserved_host = nil
|
354
|
-
return true
|
355
|
-
when :reserve
|
356
|
-
@reserved_host = host_info
|
357
|
-
end
|
352
|
+
if @property.reserve
|
353
|
+
return true
|
358
354
|
end
|
359
|
-
|
355
|
+
host_info.accept_core(@property.use_cores)
|
360
356
|
end
|
361
357
|
|
362
358
|
def tried_host?(host_info)
|
data/lib/pwrake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwrake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro TANAKA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|