lib/adarwin/nest.rb in bones-compiler-1.3.1 vs lib/adarwin/nest.rb in bones-compiler-1.6.0

- old
+ new

@@ -45,16 +45,19 @@ # Get all loops from the loop body and subtract the outer loops from all # loops to obtain the set of inner loops (loops in the body). @all_loops = @code.get_all_loops() @outer_loops = @code.get_direct_loops() @inner_loops = @all_loops - @outer_loops + + # Get all local variable declarations + @var_declarations = @code.get_var_declarations() # Process the read/write nodes in the loop body to obtain the array # reference characterisations. The references also need to be aware of all # loop data and of any if-statements in the loop body. @references = @code.clone.get_accesses().map do |reference| - Reference.new(reference,@id,@inner_loops,@outer_loops,@verbose) + Reference.new(reference,@id,@inner_loops,@outer_loops,@var_declarations,@verbose) end # Perform the dependence test. The result can be either true or false. # Proceed only if there are no dependences. # Don't perform the dependence test if this is a fused loopnest @@ -119,10 +122,23 @@ # Create a 'void' access pattern in case there is no read or no write. # Else, set the species for the individual accesses. read_names = (@reads.empty?) ? ['0:0|void'] : @reads.map{ |r| r.to_species } write_names = (@writes.empty?) ? ['0:0|void'] : @writes.map{ |r| r.to_species } + + # Remove a 'full' access pattern in case there is a same 'shared' write pattern + write_names.each do |write_name| + write_parts = write_name.split(PIPE) + if write_parts.last == 'shared' + read_names.each do |read_name| + read_parts = read_name.split(PIPE) + if read_parts.last == 'full' && read_parts.first == write_parts.first + read_names.delete(read_name) + end + end + end + end # Combine the descriptions (using Reference's +to_s+ method) into species species_in = read_names.uniq.join(' '+WEDGE+' ') species_out = write_names.uniq.join(' '+WEDGE+' ') @species = species_in+' '+ARROW+' '+species_out @@ -172,9 +188,10 @@ # formed from shared or full patterns. If so, there is no parallelism. def has_species? return false if @removed return false if @has_dependences return false if @species == '' + return false if (@writes) && (@writes.select{ |a| a.pattern == 'shared' }.length > 3) only_full = (@reads) ? @reads.select{ |a| a.pattern != 'full' }.empty? : false only_shared = (@writes) ? @writes.select{ |a| a.pattern != 'shared' }.empty? : false return !(only_full && only_shared) end \ No newline at end of file