xor tile optimization

Hello, thank you for the great tool!

I've been running through an issue where I'm trying to optimize an xor script used for huge layouts using TilingProcessor I used the script in the documentation and it is really fast, but I was wondering how I could output these layers into a new gds file (I added a loop that gets all layers from the 2 layouts and queues them to do the xor). I tried using this function and then doing a simple layout.write("output.gds") after the loop but it ends up with an empty layout.

Any suggestions on how to write the output one by one? maybe from inside the queue script itself?

Comments

  • edited August 2021

    @marwaneltoukhy The script inside the tiling processor should not write anything. In order to receive something on the output, you need to call the "_output" function inside the script.

    The TilingProcessor description gives an example.

    Maybe this discussion is easier if you paste code.

    Matthias

  • @Matthias The code for xor:

    # set up input a
    a = source($a, $top_cell)
    lay_a = a.layout
    
    # set up input b
    b = source($b, $top_cell)
    lay_b = b.layout
    
    o = RBA::Layout::new
    cell = o.create_cell($top_cell.to_s)
    cell_ind = cell.cell_index()
    
    # collect all common layers
    layers = {}
    [ a.layout, b.layout ].each do |ly|
      ly.layer_indices.each do |li|
        i = ly.get_info(li)
        layers[i.to_s] = i
      end
    end
    
    tp = RBA::TilingProcessor::new
    tp.tile_size(500, 500)
    tp.threads = $thr.to_i
    tp.dbu = layout.dbu
    
    layers.keys.sort.each do |l|
      i = layers[l]
      tp.input("a1", lay_a, lay_a.top_cell().cell_index, i )
      tp.input("a2", lay_b, lay_b.top_cell().cell_index, i )
      tp.output("o1", o, cell_ind, i)
      tp.queue("_output(o1, a1 ^ a2)")
    end
    
    
    tp.execute("XOR")
    o.write("output.gds")
    
  • edited August 2021

    @marwaneltoukhy The script is basically correct, but it's a bit weird: are you trying to use DRC or is that a basic Ruby API script?

    When I rewrite it to Ruby, the script looks like this:

    # set up input a
    a = source($a, $top_cell)
    lay_a = a.layout
    
    # set up input b
    b = source($b, $top_cell)
    lay_b = b.layout
    
    o = RBA::Layout::new
    cell = o.create_cell($top_cell.to_s)
    cell_ind = cell.cell_index()
    
    # collect all common layers
    layers = {}
    [ a.layout, b.layout ].each do |ly|
      ly.layer_indices.each do |li|
        i = ly.get_info(li)
        layers[i.to_s] = i
      end
    end
    
    tp = RBA::TilingProcessor::new
    tp.tile_size(500, 500)
    tp.threads = $thr.to_i
    tp.dbu = layout.dbu
    
    layers.keys.sort.each do |l|
      i = layers[l]
      tp.input("a1", lay_a, lay_a.top_cell().cell_index, i )
      tp.input("a2", lay_b, lay_b.top_cell().cell_index, i )
      tp.output("o1", o, cell_ind, i)
      tp.queue("_output(o1, a1 ^ a2)")
    end
    
    
    tp.execute("XOR")
    o.write("output.gds")
    

    And for me it seems to work.

    Inside DRC you don't need to implement the tiling yourself. DRC wraps it for you. Just say:

    # set up input a
    a = source($a, $top_cell)
    
    # set up input b
    b = source($b, $top_cell)
    
    # set up the output
    target("output.gds")
    
    # enable tiling with 4 cores:
    tiles(500.0)
    threads(4)
    
    # collect all common layers
    layers = {}
    [ a.layout, b.layout ].each do |ly|
      ly.layer_indices.each do |li|
        i = ly.get_info(li)
        (a.input(i) ^ b.input(i)).output(i)
      end
    end
    

    Matthias

  • @Matthias Thanks for your clarification, but the o.write("output.gds") in the first script actually doesn't output anything in the output.gds file

  • @marwaneltoukhy No, sorry, I just confirmed that the Ruby script I showed works (I added the missing '#' at the beginning).

    But maybe your input files are identical? In this case the XOR output is empty. That's how XOR says the files are the same.

    Matthias

Sign In or Register to comment.