PetaVision / OpenPV

PetaVision is a C++ library for designing and deploying large-scale neurally-inspired computational models.
http://petavision.github.io
Eclipse Public License 1.0
40 stars 13 forks source link

Simplifies communicate stage #278

Closed peteschultz closed 5 years ago

peteschultz commented 5 years ago

This pull request simplifies the task of searching for another object in the hierarchy during the CommunicateInitInfo stage.

Previously, the HyPerCol would broadcast its table of objects, which consisted only of the layers, connections, and probes. Frequently an object that needed this list would need to find a component within a layer or connection. This required objects to know details of the structure of the hierarchy.

With this pull request, the HyPerCol assembles a table of all objects in the heirarchy, including components within other objects. The objects are tagged by their name data member, not their description. Components within an object have the same name as their parent. HyPerCol broadcasts this table to all the objects in the table using the CommunicateInitObject message. The full table is only used during the CommunicateInitInfo stage; other messages are sent only to the layers, connections and probes, who are then responsible for passing the messages to their components as needed.

ObserverTable has two new function templates: findObject() and findObjects(). The first finds an object in the table with type T. It is an error if more than one object in the table dynamically casts to type T. The second, findObjects(), returns a vector of those objects that dynamically cast to type T. The second form is useful for the case where a layer has several buffers created as class RestrictedBuffer, and differ only in their labels. The vector can be retrieved using findObjects(), and then the buffers' labels can be examined to find the correct one. The function templates lookupByName, lookupByType, lookupByNameRecursive, and lookupByTypeRecursive, have been removed.

To allow searching component buffers by label, buffers should not have the empty label. Previously this was used to signal that a buffer should not be checkpointed. Now, this is indicated by setting the ComponentBuffer data member mCheckpointFlag to false.

Because multiple objects have the same tag (components have the same name as their parent) ObserverPattern now uses std::multimap instead of std::map.