broadcastCommand, a.k.a visualizing Kittens on a Cluster.

Picture1

When running your omegalib scripts in a cluster environment, you may need to execute some operation only on a specific node. That’s what the isMaster() and  getHostname() functions are for. Sometimes, after doing some node-specific work (especially on the master node) you want to notify all the other nodes you are done. A typical scenario is accessing some asset on the network and creating a copy on the local cache in the shared filesystem. As an example asset we’ll consider the canonical cute kitty picture.  You want the master node to perform the actual transfer, and notify all the other nodes of transfer completion, without blocking them. The nodes can then spam the displays with thousands of kitty-textured cubes (or spheres or cylinders. imagination is your limit).
The omegalib C++ API supported this for a while. In omegalib 3.7 the function is now available to python applications as well, through the broadcastCommand() call. BroadcastCommand accepts a python statement, and queues it for execution on all nodes of the cluster. Its typical use is at the end of an if(isMaster()) block, to notify nodes of work completion:
import urllib
        # On the master node, fetch an image somewhere on the internet
        if(isMaster())
                urllib.urlretrieve("http://www.digimouth.com/news/media/2011/09/google-logo.jpg", "local-image.jpg")
                # Call this when you are done
                broadcastCommand('onImageLoaded()')
        
        # This will be called on all nodes once the image is loaded. You can open the image here.
        # (Assuming use of a shared filesystem in your cluster installation)
        def onImageLoaded():
                img = loadImage("local-image.jpg")



For more information about the omegalib application control python API check this page!

Comments

Popular posts from this blog

Parallel Gaussian Elimination Using MPI

Parallel Beam Tracing and Visualization of 200 Million Sonar Points

Flickering 2D transform elements in Chrome: a simple fix