# encoding: UTF-8 # KLayout Layout Viewer # Copyright (C) 2006-2024 Matthias Koefferlein # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA if !$:.member?(File::dirname($0)) $:.push(File::dirname($0)) end load("test_prologue.rb") class StringCollectingOutputReceiver < RBA::TileOutputReceiver attr_accessor :data def begin(nx, ny, p0, dx, dy, frame) @data = [] @data.push("begin nx=#{nx} ny=#{ny} p0=#{p0.to_s} dx=#{dx} dy=#{dy}") end def put(ix, iy, tile, obj, dbu, clip) GC.start # makes Ruby crash if started from a non-ruby thread @data ||= [] @data.push("put ix=#{ix} iy=#{iy} tile=#{tile.to_s} obj=#{obj.to_s} dbu=#{dbu} clip=#{clip.to_s}") end def finish(success) @data.push("finish") end end class DBTilingProcessor_TestClass < TestBase def test_1 rin = RBA::Region::new rin.insert(RBA::Box::new(0, 0, 100, 200)) rin.insert(RBA::Box::new(9900, 9800, 10000, 10000)) rall = RBA::Region::new rall.insert(RBA::Box::new(0, 0, 10000, 10000)) tp = RBA::TilingProcessor::new tp.input("in", rin) tp.input("all", rall) rout = RBA::Region::new tp.output("out", rout) tp.dbu = 0.1 tp.tile_size(200.0, 500.0) tp.queue("_output(out, all-in)") tp.execute("A job") rout.merged_semantics = false assert_equal(rout.size, 10) assert_equal(rout.area, 100000000-20000*2) assert_equal(rout.to_s, "(100,0;100,200;0,200;0,5000;2000,5000;2000,0);(0,5000;0,10000;2000,10000;2000,5000);(2000,0;2000,5000;4000,5000;4000,0);(2000,5000;2000,10000;4000,10000;4000,5000);(4000,0;4000,5000;6000,5000;6000,0);(4000,5000;4000,10000;6000,10000;6000,5000);(6000,0;6000,5000;8000,5000;8000,0);(6000,5000;6000,10000;8000,10000;8000,5000);(8000,0;8000,5000;10000,5000;10000,0);(8000,5000;8000,10000;9900,10000;9900,9800;10000,9800;10000,5000)") end def test_2 rin = RBA::Region::new rin.insert(RBA::Box::new(0, 0, 100, 200)) rin.insert(RBA::Box::new(9900, 9800, 10000, 10000)) rall = RBA::Region::new rall.insert(RBA::Box::new(0, 0, 10000, 10000)) tp = RBA::TilingProcessor::new tp.input("in", rin) tp.input("all", rall) rout = RBA::Region::new tp.output("out", rout) tp.dbu = 0.1 tp.tile_size(20.0, 50.0) tp.queue("_output(out, all-in)") tp.execute("A job") tp.threads = 4 rout.merged_semantics = false assert_equal(rout.size, 1000) assert_equal(rout.area, 100000000-20000*2) end def test_3 rin = RBA::Region::new rin.insert(RBA::Box::new(0, 0, 100, 200)) rin.insert(RBA::Box::new(9900, 9800, 10000, 10000)) tp = RBA::TilingProcessor::new tp.input("in", rin) out = StringCollectingOutputReceiver::new tp.output("out", out) tp.dbu = 0.1 tp.tile_size(200.0, 500.0) tp.queue("_output(out, _tile.to_s)") tp.execute("A job") assert_equal(out.data.join("\n") + "\n", <