Class: Pwrake::NonLocalityQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/queue/non_locality_queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostinfo_by_id, array_class, median_core, group_map = nil) ⇒ NonLocalityQueue

Returns a new instance of NonLocalityQueue.



9
10
11
12
13
14
15
16
17
18
# File 'lib/pwrake/queue/non_locality_queue.rb', line 9

def initialize(hostinfo_by_id, array_class, median_core, group_map=nil)
  @hostinfo_by_id = hostinfo_by_id
  @array_class = array_class
  @median_core = median_core
  @disable_rank = Rake.application.pwrake_options['DISABLE_RANK_PRIORITY']
  Log.debug "#{self.class}: @disable_rank=#{@disable_rank.inspect}"
  @q_input = @array_class.new(@median_core)
  @q_no_input = FifoQueueArray.new(@median_core)
  @turns = [0]
end

Instance Attribute Details

#turnsObject (readonly)

Returns the value of attribute turns.



20
21
22
# File 'lib/pwrake/queue/non_locality_queue.rb', line 20

def turns
  @turns
end

Instance Method Details

#clearObject



53
54
55
56
# File 'lib/pwrake/queue/non_locality_queue.rb', line 53

def clear
  @q_input.clear
  @q_no_input.clear
end

#deq_impl(host_info, turn) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/pwrake/queue/non_locality_queue.rb', line 38

def deq_impl(host_info, turn)
  case turn
  when 0
    @q_input.shift(host_info,@rank) ||
      @q_no_input.shift(host_info,@rank)
  else
    raise "invalid turn: #{turn}"
  end
end

#deq_startObject



34
35
36
# File 'lib/pwrake/queue/non_locality_queue.rb', line 34

def deq_start
  @rank = @disable_rank ? 0 : @q_input.find_rank(@median_core)
end

#drop_host(host_info) ⇒ Object



68
69
# File 'lib/pwrake/queue/non_locality_queue.rb', line 68

def drop_host(host_info)
end

#empty?Boolean

Returns:

  • (Boolean)


58
59
60
61
# File 'lib/pwrake/queue/non_locality_queue.rb', line 58

def empty?
  @q_input.empty? &&
  @q_no_input.empty?
end

#enq_impl(tw) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/pwrake/queue/non_locality_queue.rb', line 22

def enq_impl(tw)
  if tw.has_input_file?
    @q_input.push(tw)
  else
    @q_no_input.push(tw)
  end
end

#inspect_qObject



63
64
65
66
# File 'lib/pwrake/queue/non_locality_queue.rb', line 63

def inspect_q
  TaskQueue._qstr("input",   @q_input) +
  TaskQueue._qstr("no_input",@q_no_input)
end

#sizeObject



48
49
50
51
# File 'lib/pwrake/queue/non_locality_queue.rb', line 48

def size
  @q_input.size +
  @q_no_input.size
end

#turn_empty?(turn) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/pwrake/queue/non_locality_queue.rb', line 30

def turn_empty?(turn)
  empty?
end