changeset 5:8b7761919283 tip

Works -- with send-receive plus normal dependencies
author Sean Halle <seanhalle@yahoo.com>
date Thu, 14 Jun 2012 18:40:57 -0700
parents 6643a6f47050
children
files VSs__Hello_World/SeedVP.c VSs__Hello_World/Task.c VSs__Hello_World/VSs__Hello_World.h
diffstat 3 files changed, 39 insertions(+), 19 deletions(-) [+]
line diff
     1.1 --- a/VSs__Hello_World/SeedVP.c	Wed Jun 06 18:00:58 2012 -0700
     1.2 +++ b/VSs__Hello_World/SeedVP.c	Thu Jun 14 18:40:57 2012 -0700
     1.3 @@ -11,35 +11,38 @@
     1.4  #include <string.h>
     1.5  #include "VSs__Hello_World.h"
     1.6  
     1.7 -/*Global vars are part of the hello world task type.. NULL means not cntld
     1.8 -  ctld args MUST always be the first ones in the array*/
     1.9 -int32 helloWorldArgTypes[2] = {IN, (int32)NULL};
    1.10 -int32 helloWorldArgSizes[2] = {16*16*sizeof(float), sizeof(int32)};
    1.11 +/*Global vars are part of the hello world task type..  ctld args MUST always
    1.12 + * be the first ones in the array*/
    1.13 +int32 helloWorldArgTypes[3] = {IN, NONCTLD, NONCTLD };
    1.14 +int32 helloWorldArgSizes[3] = {16*16*sizeof(float), sizeof(int32), sizeof(int32)};
    1.15  
    1.16  void hello_world( void *_params, SlaveVP *animSlv )
    1.17 - { int32 i;
    1.18 + { int32 i, *taskID;
    1.19   
    1.20           DEBUG__printf( dbgAppFlow, "start hello_world");
    1.21  
    1.22 +   //params = (VSsHelloWorldParams*)_params;
    1.23 +         
    1.24     // create all the task types
    1.25 -   helloWorldTaskType = VMS_App__malloc( sizeof(VSsTaskType) );
    1.26 -   helloWorldTaskType->fn = &hello_world_task;
    1.27 +   helloWorldTaskType     = VMS_App__malloc( sizeof(VSsTaskType) );
    1.28 +   helloWorldTaskType->fn           = &hello_world_task;
    1.29     helloWorldTaskType->numCtldArgs  = 1;
    1.30 -   helloWorldTaskType->numTotalArgs = 2;
    1.31 +   helloWorldTaskType->numTotalArgs = 3;
    1.32     helloWorldTaskType->sizeOfArgs   = sizeof(HelloWorldArgs);
    1.33 -   helloWorldTaskType->argTypes = helloWorldArgTypes;
    1.34 -   helloWorldTaskType->argSizes = helloWorldArgSizes;
    1.35 +   helloWorldTaskType->argTypes     = helloWorldArgTypes;
    1.36 +   helloWorldTaskType->argSizes     = helloWorldArgSizes;
    1.37  
    1.38     HelloWorldArgs args; //allocate on stack, VSs copies internally
    1.39     
    1.40     for( i = 0; i < 5; i++ )
    1.41      {
    1.42 -      args.dummy1 = VMS_App__malloc( helloWorldTaskType->argSizes[0] );
    1.43 -      args.dummy2 = i;
    1.44 -      VSs__submit_task( helloWorldTaskType, &args, animSlv );
    1.45 +      args.controlledArg = VMS_App__malloc( helloWorldTaskType->argSizes[0] );
    1.46 +      args.taskNum = i;
    1.47 +      args.numTasks = 5;
    1.48 +      taskID = VSs__create_taskID_of_size( 1, animSlv );
    1.49 +      taskID[1] = i;
    1.50 +      VSs__submit_task_with_ID( helloWorldTaskType, &args, taskID, animSlv );
    1.51  	 }
    1.52 -//   VSs__wait_for_all_tasks_to_complete();
    1.53 -//   VSs__shutdown( animSlv );
    1.54     VSs__dissipate_slave( animSlv );
    1.55   }
    1.56  
     2.1 --- a/VSs__Hello_World/Task.c	Wed Jun 06 18:00:58 2012 -0700
     2.2 +++ b/VSs__Hello_World/Task.c	Thu Jun 14 18:40:57 2012 -0700
     2.3 @@ -13,10 +13,26 @@
     2.4   
     2.5  void hello_world_task( void  *_args, SlaveVP *animSlv )
     2.6   { HelloWorldArgs *args;
     2.7 -		 
     2.8 +   int32 *selfTaskID, *receiveFromTaskID, *sendToTaskID;
     2.9 +	int32  numTasks;
    2.10 +   
    2.11     args = (HelloWorldArgs *)_args;
    2.12 +   numTasks = args->numTasks;
    2.13     
    2.14 -   printf("Hello World: %llu, %d", (uint64)args->dummy1, args->dummy2);
    2.15 +   selfTaskID = VSs__give_self_taskID( animSlv );
    2.16 +
    2.17 +   receiveFromTaskID    = VSs__create_taskID_of_size( 1, animSlv );
    2.18 +   receiveFromTaskID[1] = selfTaskID[1] - 1;
    2.19 +
    2.20 +   sendToTaskID    = VSs__create_taskID_of_size( 1, animSlv );
    2.21 +   sendToTaskID[1] = selfTaskID[1] + 1;
    2.22 +   
    2.23 +   if( receiveFromTaskID[1] >= 0 )
    2.24 +      VSs__receive_from_to( receiveFromTaskID, selfTaskID, animSlv );
    2.25 +   if( sendToTaskID[1] < numTasks )
    2.26 +      VSs__send_from_to( NULL, selfTaskID, sendToTaskID, animSlv );
    2.27 +   printf("Hello World: %llu, %d", (uint64)args->controlledArg, args->taskNum);
    2.28 +   
    2.29     fflush(stdout);
    2.30     
    2.31     VSs__end_task( animSlv );
     3.1 --- a/VSs__Hello_World/VSs__Hello_World.h	Wed Jun 06 18:00:58 2012 -0700
     3.2 +++ b/VSs__Hello_World/VSs__Hello_World.h	Thu Jun 14 18:40:57 2012 -0700
     3.3 @@ -17,8 +17,9 @@
     3.4  
     3.5  //NOTE: controlled args must come first, accessible as array of ptrs
     3.6  typedef struct
     3.7 - { int32 *dummy1;  //This is a controlled arg -- VSs uses to calc depenencies
     3.8 -   int32  dummy2;  //This is a normal arg, ignored by VSs
     3.9 + { int32 *controlledArg;  //This is a controlled arg -- VSs uses to calc depenencies
    3.10 +   int32  taskNum;  //This is a normal arg, ignored by VSs
    3.11 +   int32  numTasks; //This is a normal arg, ignored by VSs
    3.12   }
    3.13  HelloWorldArgs;
    3.14