Skip to content

FIX: Improve cutout speed #845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pyedb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys
import warnings

if os.name == "nt":
os.environ["PYTHONMALLOC"] = "malloc"
# if os.name == "nt":
# os.environ["PYTHONMALLOC"] = "malloc"

# By default we use pyedb legacy implementation
if "PYEDB_USE_DOTNET" not in os.environ:
Expand Down
73 changes: 44 additions & 29 deletions src/pyedb/dotnet/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2244,7 +2244,7 @@ def _create_cutout_multithread(
pins_to_preserve = []
nets_to_preserve = []
if preserve_components_with_model:
for el in self.components.instances.values():
for el in self.layout.groups:
if el.model_type in [
"SPICEModel",
"SParameterModel",
Expand Down Expand Up @@ -2273,23 +2273,41 @@ def _create_cutout_multithread(
reference_pinsts = []
reference_prims = []
reference_paths = []
for i in self.padstacks.instances.values():
net_name = i.net_name
id = i.id
pins_to_delete = []

def check_instances(item):
net_name = item.net_name
id = item.id
if net_name not in all_list and id not in pins_to_preserve:
i.delete()
pins_to_delete.append(item)
elif net_name in reference_list and id not in pins_to_preserve:
reference_pinsts.append(i)
for i in self.modeler.primitives:
if i:
net_name = i.net_name
reference_pinsts.append(item)

with ThreadPoolExecutor(number_of_threads) as pool:
pool.map(lambda item: check_instances(item), self.layout.padstack_instances)

for i in pins_to_delete:
i.delete()

prim_to_delete = []

def check_prims(item):
if item:
net_name = item.net_name
if net_name not in all_list:
i.delete()
elif net_name in reference_list and not i.is_void:
if keep_lines_as_path and i.type == "Path":
reference_paths.append(i)
prim_to_delete.append(item)
elif net_name in reference_list and not item.is_void:
if keep_lines_as_path and item.type == "Path":
reference_paths.append(item)
else:
reference_prims.append(i)
reference_prims.append(item)

with ThreadPoolExecutor(number_of_threads) as pool:
pool.map(lambda item: check_prims(item), self.modeler.primitives)

for i in prim_to_delete:
i.delete()

self.logger.info_timer("Net clean up")
self.logger.reset_timer()

Expand Down Expand Up @@ -2334,7 +2352,7 @@ def _create_cutout_multithread(
if not _poly or _poly.IsNull():
self._logger.error("Failed to create Extent.")
return []
self.logger.info_timer("Expanded Net Polygon Creation")
self.logger.info_timer("Extent Creation")
self.logger.reset_timer()
_poly_list = convert_py_list_to_net_list([_poly])
prims_to_delete = []
Expand Down Expand Up @@ -2417,28 +2435,25 @@ def pins_clean(pinst):
for pin in pins_to_delete:
pin.delete()

self.logger.info_timer(
"Padstack Instances removal completed. {} instances removed.".format(len(pins_to_delete))
)
self.logger.info_timer("{} Padstack Instances deleted.".format(len(pins_to_delete)))
self.logger.reset_timer()

# with ThreadPoolExecutor(number_of_threads) as pool:
# pool.map(lambda item: clip_path(item), reference_paths)

for item in reference_paths:
clip_path(item)
for prim in reference_prims: # removing multithreading as failing with new layer from primitive
clean_prim(prim)
# with ThreadPoolExecutor(number_of_threads) as pool:
# pool.map(lambda item: clean_prim(item), reference_prims)
with ThreadPoolExecutor(number_of_threads) as pool:
pool.map(lambda item: clip_path(item), reference_paths)
with ThreadPoolExecutor(number_of_threads) as pool:
pool.map(lambda item: clean_prim(item), reference_prims)
# for item in reference_paths:
# clip_path(item)
# for prim in reference_prims: # removing multithreading as failing with new layer from primitive
# clean_prim(prim)

for el in poly_to_create:
self.modeler.create_polygon(el[0], el[1], net_name=el[2], voids=el[3])

for prim in prims_to_delete:
prim.delete()

self.logger.info_timer("Primitives cleanup completed. {} primitives deleted.".format(len(prims_to_delete)))
self.logger.info_timer("{} Primitives deleted.".format(len(prims_to_delete)))
self.logger.reset_timer()

i = 0
Expand All @@ -2447,7 +2462,7 @@ def pins_clean(pinst):
val.edbcomponent.Delete()
i += 1
i += 1
self.logger.info("Deleted {} additional components".format(i))
self.logger.info("{} components deleted".format(i))
if remove_single_pin_components:
self.components.delete_single_pin_rlc()
self.logger.info_timer("Single Pins components deleted")
Expand Down
15 changes: 2 additions & 13 deletions src/pyedb/dotnet/edb_core/cell/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ def primitives(self):
-------
list of :class:`dotnet.edb_core.dotnet.primitive.PrimitiveDotNet` cast objects.
"""
prims = []
for p in self._edb_object.Primitives:
obj = primitive_cast(self._pedb, p)
prims.append(obj)
return prims
return [primitive_cast(self._pedb, p) for p in self._edb_object.Primitives]

@property
def bondwires(self):
Expand All @@ -249,14 +245,7 @@ def bondwires(self):

@property
def groups(self):
temp = []
for i in list(self._edb_object.Groups):
group_type = i.ToString().split(".")[-1].lower()
if group_type == "component":
temp.append(EDBComponent(self._pedb, i))
else:
pass
return temp
return [EDBComponent(self._pedb, i) for i in self._edb_object.Groups if i.ToString().endswith(".Component")]

@property
def pin_groups(self):
Expand Down
10 changes: 8 additions & 2 deletions src/pyedb/dotnet/edb_core/cell/primitive/primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class Primitive(Connectable):
def __init__(self, pedb, edb_object):
super().__init__(pedb, edb_object)
self._app = self._pedb
self._core_stackup = pedb.stackup
self._core_net = pedb.nets
self.primitive_object = self._edb_object

bondwire_type = self._pedb._edb.Cell.Primitive.BondwireType
Expand All @@ -62,6 +60,14 @@ def __init__(self, pedb, edb_object):
"rectangle": bondwire_cross_section_type.BondwireRectangle,
}

@property
def _core_stackup(self):
return self._app.stackup

@property
def _core_net(self):
return self._app.nets

@property
def type(self):
"""Return the type of the primitive.
Expand Down
3 changes: 1 addition & 2 deletions src/pyedb/dotnet/edb_core/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ def refresh_components(self):
# self._logger.info("Refreshing the Components dictionary.")
self._cmp = {}
for i in self._pedb.layout.groups:
if i.group_type == "component":
self._cmp[i.name] = i
self._cmp[i.name] = i
return True

@property
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/dotnet/edb_core/layout_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def disjoint_nets(
_objects_list[n_name].append(prim)
else:
_objects_list[n_name] = [prim]
for pad in list(self._pedb.padstacks.instances.values()):
for pad in list(self._pedb.layout.padstack_instances):
n_name = pad.net_name
if n_name in _padstacks_list:
_padstacks_list[n_name].append(pad)
Expand Down
1 change: 0 additions & 1 deletion src/pyedb/dotnet/edb_core/padstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def instances(self):
List of padstack instances.

"""

edb_padstack_inst_list = self._pedb.layout.padstack_instances
if len(self._instances) == len(edb_padstack_inst_list):
return self._instances
Expand Down
Loading