Thursday, June 14, 2012

Apache Airavata ForEach construct

This post will introduce the ForEach construct and what are it's uses. Then we'll look at how to ForEach samples shipped in with Apache Airavata [1]. 

Introduction
Airavata supports parametric sweeps through a construct called Foreach. Given an array of inputs of size n and an application service, it is possible to run the application service n times for each of the input values in the input array. There are two modes of ForEach;
  1. Cartesian product of inputs: Inputs of array sizes n1 ,n2 , .. nk will yield:  
    • n1 ∗ n2 ∗ ... ∗ nk invocations.
  2. Dot product of inputs. Inputs of equal size arrays of size n will yield n computations.
Executing a simple workflow which uses ForEach
Apache Airavata is shipped with a workflow named SimpleForEach.xwf. As the name suggests, it contains a simple workflow which demonstrates the use of ForEach construct. Following are the steps to running the sample workflow.

Instructions to run the sample
  1. Download the latest Airavata release pack from downloads link and extract, for future explanation lets assume the path to extracted directory is AIRAVATA_HOME.

    NOTE: The above mentioned workflow samples are committed to the trunk. Therefore, you are better off using a trunk build.

  2. Now Run the following scripts in the given order below to start the components of Airavata.

    AIRAVATA_HOME/bin/jackrabbit-server.sh - This will start Jackrabbit repository on port 8081.

    AIRAVATA_HOME/bin/airavata-server.sh - This will start SimpleAxis2Server on port 8080

    AIRAVATA_HOME/bin/xbaya-gui.sh - This will start XBaya GUI application.
  3. Click the Xbaya tab and open up an Airavata workflow configuration (.xwf) from file system (sample workflows shipped in with Airavata can be found in AIRAVATA_HOME/samples/workflows) eg. Assume that you selected the SimpleForEach workflow
    • Now Click on the run button (red colored play).
    • Then the workflow will get executed.
    • Finally the result of the workflow will get displayed.
The workflow which we ran early looks like following (Figure 1.)  

Figure 1 : SimpleForEach sample
When running the workflow if you tick the "Execute in cross product" condition in the "Execute Workflow" dialog box; the workflow will be run in cross product. Otherwise, by default a given ForeEach will run in dot product. "Execute Workflow" dialog box is shown in Figure 2.

Figure 2 : Execute Workflow Dialog Box
Results
As you might have noticed in Figure 2, we have given two arrays (containing 1,2 and 3,4) as input to the ForEach construct.

If we ran the dot product, there will be 2 resulting outputs. It can be seen in Figure 3.

Figure 3: Dot product result

If we ran the cross product, there will be 4 resulting outputs. It can be seen in Figure 4. 

Figure 4: Cross product result
Apache Airavata contains another sample named ComplexForEach.xwf, which demonstrates the use of multiple ForEach constructs inside one workflow. Have fun running the ComplexForEach sample

Figure 5: ComplexForEach sample



REFERNCES
[1] - airavata.org

No comments: