changeset 0:7a85919442f2

Initial add -- test application for use while developing VSs features
author Sean Halle <seanhalle@yahoo.com>
date Wed, 01 Aug 2012 01:08:02 -0700
parents
children ea293c5b31f6 6462b7a00386
files .hgeol .hgignore Design_Notes.txt VSs__Test_App/EntryPoint.c VSs__Test_App/SeedVP.c VSs__Test_App/Task.c VSs__Test_App/VSs__Test_App.h __brch__default main.c
diffstat 9 files changed, 265 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.hgeol	Wed Aug 01 01:08:02 2012 -0700
     1.3 @@ -0,0 +1,14 @@
     1.4 +
     1.5 +[patterns]
     1.6 +**.py = native
     1.7 +**.txt = native
     1.8 +**.c = native
     1.9 +**.h = native
    1.10 +**.cpp = native
    1.11 +**.java = native
    1.12 +**.class = bin
    1.13 +**.jar = bin
    1.14 +**.sh = native
    1.15 +**.pl = native
    1.16 +**.jpg = bin
    1.17 +**.gif = bin
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/.hgignore	Wed Aug 01 01:08:02 2012 -0700
     2.3 @@ -0,0 +1,12 @@
     2.4 +nbproject
     2.5 +Makefile
     2.6 +build
     2.7 +dist
     2.8 +src/Default
     2.9 +src/.settings
    2.10 +src/.cproject
    2.11 +src/.project
    2.12 +.dep.inc
    2.13 +glob:.cproject
    2.14 +glob:.project
    2.15 +glob:Debug
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/Design_Notes.txt	Wed Aug 01 01:08:02 2012 -0700
     3.3 @@ -0,0 +1,51 @@
     3.4 +
     3.5 +This test app has to exercise all the aspects of the request handling 
     3.6 +and the assigner code.
     3.7 +
     3.8 +The assigner has two different Qs, plus a set of currentTaskSlvs  check for tasks and also check for explicit VPs.
     3.9 +
    3.10 +So, in the app, make tasks, and also explicit VPs..  create such that they
    3.11 +interleave, cause assigner to switch between.
    3.12 +
    3.13 +So, when start, make some tasks, then make some explicit VPs, then some
    3.14 +tasks, back and forth..  second batch of tasks have inter-dependencies, so
    3.15 +some of the VPs should jump into the middle of them..
    3.16 +
    3.17 +Then, make it so that the last two tasks talk to each other, suspending
    3.18 +each other in turn, (which should cause the extra VPs to dissipate) and
    3.19 +after that they create a bunch more tasks.
    3.20 +
    3.21 +Okay..  what needs to be exercised?
    3.22 +-] create new slave when task suspends
    3.23 +-] dissipate extra slave when have a task one, and no free tasks
    3.24 +-] suspend a task -> no tasks in taskQ -> empty task slave in slaveQ -> 
    3.25 +   dissipate that task slave -> explicit slave next in slaveQ, animate that.
    3.26 +  Means: To get an empty task slave in slaveQ -> create a task that will
    3.27 +   suspend, then create a normal task, which will cause an extra task 
    3.28 +   slave to be created
    3.29 +
    3.30 +===================
    3.31 +To have explicit VPs as well tasks.. add a field to semantic data holds type
    3.32 +of VP: whether it's for running tasks, vs an explicit VP.  when an
    3.33 +explicit dissipates, then switch it to a task VP that has no suspended
    3.34 +tasks..
    3.35 +
    3.36 +So, in the semantic data, have:
    3.37 +-> taskVP vs explicitVP
    3.38 +-> has suspended task vs idle
    3.39 +
    3.40 +Then fix the assigner logic:
    3.41 +When task suspends, get next readyVP, 
    3.42 + check if it's an explicit
    3.43 + and if yes, resume it,
    3.44 + if no, then it's a taskVP, so get next task from taskQ and do it.
    3.45 + Check whether taskQ empty
    3.46 + if yes, then in the state: suspended taskVP, have empty taskVP, no tasks
    3.47 +   so, 
    3.48 +
    3.49 +If taskQ empty, and VP Q empty, return NULL, which will trigger the
    3.50 + back-to-back Master backoff.
    3.51 +
    3.52 +If assigner called and no suspended slaves and taskQ empty..  does it have
    3.53 +a "current task slave"?  If not, create one in the semantic Env.
    3.54 +==================================
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/VSs__Test_App/EntryPoint.c	Wed Aug 01 01:08:02 2012 -0700
     4.3 @@ -0,0 +1,37 @@
     4.4 +/*
     4.5 + *  Copyright 2009 OpenSourceStewardshipFoundation.org
     4.6 + *  Licensed under GNU General Public License version 2
     4.7 + *
     4.8 + * Author: seanhalle@yahoo.com
     4.9 + *
    4.10 + */
    4.11 +
    4.12 +#include <math.h>
    4.13 +
    4.14 +#include "VSs__Hello_World.h"
    4.15 +
    4.16 +
    4.17 +
    4.18 +/*This "entry point" function creates the first
    4.19 + * processor, which starts the chain of creating more processors..
    4.20 + * eventually all of the processors will dissipate themselves, and
    4.21 + * return.
    4.22 + *
    4.23 + *This entry-point function follows the same pattern as all entry-point
    4.24 + * functions do:
    4.25 + *1) it creates the params for the seed processor, from the
    4.26 + *    parameters passed into the entry-point function
    4.27 + *2) it calls SSR__create_seed_slave_and_do_work
    4.28 + *3) it gets the return value from the params struc, frees the params struc,
    4.29 + *    and returns the value from the function
    4.30 + *
    4.31 + */
    4.32 +void
    4.33 +VSs__Test_App( )
    4.34 + { 
    4.35 +      //create seed processor, start doing the work, and wait till done
    4.36 +      //This function is the "border crossing" between normal code and SSR
    4.37 +   VSs__create_seed_slave_and_do_work( &test_app, NULL );
    4.38 +  
    4.39 +   return;
    4.40 + }
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/VSs__Test_App/SeedVP.c	Wed Aug 01 01:08:02 2012 -0700
     5.3 @@ -0,0 +1,48 @@
     5.4 +/*
     5.5 + *  Copyright 2009 OpenSourceResearchInstitute.org
     5.6 + *  Licensed under GNU General Public License version 2
     5.7 + *
     5.8 + * Author: seanhalle@yahoo.com
     5.9 + *
    5.10 + */
    5.11 +
    5.12 +
    5.13 +#include <math.h>
    5.14 +#include <string.h>
    5.15 +#include "VSs__Hello_World.h"
    5.16 +
    5.17 +/*Global vars are part of the hello world task type..  ctld args MUST always
    5.18 + * be the first ones in the array*/
    5.19 +int32 testAppArgTypes[3] = {IN, NONCTLD, NONCTLD };
    5.20 +int32 testAppArgSizes[3] = {16*16*sizeof(float), sizeof(int32), sizeof(int32)};
    5.21 +
    5.22 +void test_app( void *_params, SlaveVP *animSlv )
    5.23 + { int32 i, *taskID;
    5.24 + 
    5.25 +         DEBUG__printf( dbgAppFlow, "start test_app");
    5.26 +
    5.27 +   //params = (VSsTestAppParams*)_params;
    5.28 +         
    5.29 +   // create all the task types
    5.30 +   testAppTaskType               = VMS_App__malloc( sizeof(VSsTaskType) );
    5.31 +   testAppTaskType->fn           = &test_app_task;
    5.32 +   testAppTaskType->numCtldArgs  = 1;
    5.33 +   testAppTaskType->numTotalArgs = 3;
    5.34 +   testAppTaskType->sizeOfArgs   = sizeof(TestAppArgs);
    5.35 +   testAppTaskType->argTypes     = testAppArgTypes;
    5.36 +   testAppTaskType->argSizes     = testAppArgSizes;
    5.37 +
    5.38 +   TestAppArgs args; //allocate on stack, VSs copies internally
    5.39 +   
    5.40 +   for( i = 0; i < 5; i++ )
    5.41 +    {
    5.42 +      args.controlledArg = VMS_App__malloc( testAppTaskType->argSizes[0] );
    5.43 +      args.taskNum       = i;
    5.44 +      args.numTasks      = 5;
    5.45 +      taskID             = VSs__create_taskID_of_size( 1, animSlv );
    5.46 +      taskID[1]          = i;
    5.47 +      VSs__submit_task_with_ID( testAppTaskType, &args, taskID, animSlv );
    5.48 +	 }
    5.49 +   VSs__dissipate_slave( animSlv );
    5.50 + }
    5.51 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/VSs__Test_App/Task.c	Wed Aug 01 01:08:02 2012 -0700
     6.3 @@ -0,0 +1,40 @@
     6.4 +/*
     6.5 + *  Copyright 2009 OpenSourceStewardshipFoundation.org
     6.6 + *  Licensed under GNU General Public License version 2
     6.7 + *
     6.8 + * Author: seanhalle@yahoo.com
     6.9 + *
    6.10 + */
    6.11 +
    6.12 +
    6.13 +#include <math.h>
    6.14 +#include <string.h>
    6.15 +#include "VSs__Hello_World.h"
    6.16 + 
    6.17 +void test_app_task( void  *_args, SlaveVP *animSlv )
    6.18 + { TestAppArgs *args;
    6.19 +   int32 *selfTaskID, *receiveFromTaskID, *sendToTaskID;
    6.20 +	int32  numTasks;
    6.21 +   
    6.22 +   args = (TestAppArgs *)_args;
    6.23 +   numTasks = args->numTasks;
    6.24 +   
    6.25 +   selfTaskID = VSs__give_self_taskID( animSlv );
    6.26 +
    6.27 +   receiveFromTaskID    = VSs__create_taskID_of_size( 1, animSlv );
    6.28 +   receiveFromTaskID[1] = selfTaskID[1] - 1;
    6.29 +
    6.30 +   sendToTaskID    = VSs__create_taskID_of_size( 1, animSlv );
    6.31 +   sendToTaskID[1] = selfTaskID[1] + 1;
    6.32 +   
    6.33 +   if( receiveFromTaskID[1] >= 0 )
    6.34 +      VSs__receive_from_to( receiveFromTaskID, selfTaskID, animSlv );
    6.35 +   if( sendToTaskID[1] < numTasks )
    6.36 +      VSs__send_from_to( NULL, selfTaskID, sendToTaskID, animSlv );
    6.37 +   printf("Hello World: %llu, %d", (uint64)args->controlledArg, args->taskNum);
    6.38 +   
    6.39 +   fflush(stdout);
    6.40 +   
    6.41 +   VSs__end_task( animSlv );
    6.42 + }
    6.43 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/VSs__Test_App/VSs__Test_App.h	Wed Aug 01 01:08:02 2012 -0700
     7.3 @@ -0,0 +1,38 @@
     7.4 +/*
     7.5 + *  Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org
     7.6 + *  Licensed under GNU General Public License version 2
     7.7 + */
     7.8 +
     7.9 +#ifndef _VSs_TEST_APP_H_
    7.10 +#define _VSs_TEST_APP_H_
    7.11 +
    7.12 +#include <stdio.h>
    7.13 +
    7.14 +#include "VSs_impl/VSs.h"
    7.15 +
    7.16 +
    7.17 +//===============================  Defines  ==============================
    7.18 +
    7.19 +//==============================  Structures  ==============================
    7.20 +
    7.21 +//NOTE: controlled args must come first, accessible as array of ptrs
    7.22 +typedef struct
    7.23 + { int32 *controlledArg;  //This is a controlled arg -- VSs uses to calc depenencies
    7.24 +   int32  taskNum;  //This is a normal arg, ignored by VSs
    7.25 +   int32  numTasks; //This is a normal arg, ignored by VSs
    7.26 + }
    7.27 +TestAppArgs;
    7.28 +
    7.29 +//============================= Processor Functions =========================
    7.30 +void test_app(      void *data, SlaveVP *animatingSlv ); //seed VP function
    7.31 +void test_app_task( void *data, SlaveVP *animatingSlv );
    7.32 +
    7.33 +
    7.34 +//================================ Entry Point ==============================
    7.35 +void
    7.36 +VSs__Test_App( );
    7.37 +
    7.38 +//================================ Global Vars ==============================
    7.39 +VSsTaskType *testAppTaskType;
    7.40 +
    7.41 +#endif /*_SSR_MATRIX_MULT_H_*/
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/__brch__default	Wed Aug 01 01:08:02 2012 -0700
     8.3 @@ -0,0 +1,1 @@
     8.4 +Applications normally have only the default branch -- they shouldn't be affected by any choices in VMS or language..
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/main.c	Wed Aug 01 01:08:02 2012 -0700
     9.3 @@ -0,0 +1,24 @@
     9.4 +/*
     9.5 + *  Copyright 2012 OpenSourceResearchInstitute.org
     9.6 + *  Licensed under GNU General Public License version 2
     9.7 + *
     9.8 + * author seanhalle@yahoo.com
     9.9 + */
    9.10 +
    9.11 +#include <malloc.h>
    9.12 +#include <stdlib.h>
    9.13 +
    9.14 +#include "VSs__Test_App/VSs__Test_App.h"
    9.15 +
    9.16 +/*
    9.17 + * 
    9.18 + */
    9.19 +int main( int argc, char **argv )
    9.20 + { 
    9.21 +   
    9.22 +   DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] );
    9.23 +   
    9.24 +   VSs__Test_App( );
    9.25 +   
    9.26 +   exit(0); //cleans up
    9.27 + }