changeset 6:1c9122bfd1c8 ML_dev

ML_dev -- Compiles and runs
author Sean Halle <seanhalle@yahoo.com>
date Sat, 02 Mar 2013 10:03:18 -0800
parents 2d955ed916ef
children eecb8b6c092d
files 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 main.c
diffstat 6 files changed, 82 insertions(+), 62 deletions(-) [+]
line diff
     1.1 --- a/Design_Notes.txt	Mon Sep 03 03:16:32 2012 -0700
     1.2 +++ b/Design_Notes.txt	Sat Mar 02 10:03:18 2013 -0800
     1.3 @@ -1,6 +1,3 @@
     1.4 -0x7ffff644ab60
     1.5 -0x7ffff64487f0
     1.6 -0x7ffff644b0a0
     1.7  
     1.8  This test app has to exercise all the aspects of the request handling 
     1.9  and the assigner code.
    1.10 @@ -50,5 +47,5 @@
    1.11   back-to-back Master backoff.
    1.12  
    1.13  If assigner called and no suspended slaves and taskQ empty..  does it have
    1.14 -a "current task slave"?  If not, create one in the semantic Env.
    1.15 +a "current task slave"?  If not, create one in the language env.
    1.16  ==================================
     2.1 --- a/VSs__Test_App/EntryPoint.c	Mon Sep 03 03:16:32 2012 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,37 +0,0 @@
     2.4 -/*
     2.5 - *  Copyright 2009 OpenSourceStewardshipFoundation.org
     2.6 - *  Licensed under GNU General Public License version 2
     2.7 - *
     2.8 - * Author: seanhalle@yahoo.com
     2.9 - *
    2.10 - */
    2.11 -
    2.12 -#include <math.h>
    2.13 -
    2.14 -#include "VSs__Test_App.h"
    2.15 -
    2.16 -
    2.17 -
    2.18 -/*This "entry point" function creates the first
    2.19 - * processor, which starts the chain of creating more processors..
    2.20 - * eventually all of the processors will dissipate themselves, and
    2.21 - * return.
    2.22 - *
    2.23 - *This entry-point function follows the same pattern as all entry-point
    2.24 - * functions do:
    2.25 - *1) it creates the params for the seed processor, from the
    2.26 - *    parameters passed into the entry-point function
    2.27 - *2) it calls SSR__create_seed_slave_and_do_work
    2.28 - *3) it gets the return value from the params struc, frees the params struc,
    2.29 - *    and returns the value from the function
    2.30 - *
    2.31 - */
    2.32 -void
    2.33 -VSs__Test_App( )
    2.34 - { 
    2.35 -      //create seed processor, start doing the work, and wait till done
    2.36 -      //This function is the "border crossing" between normal code and SSR
    2.37 -   VSs__create_seed_slave_and_do_work( &test_app, NULL );
    2.38 -  
    2.39 -   return;
    2.40 - }
     3.1 --- a/VSs__Test_App/SeedVP.c	Mon Sep 03 03:16:32 2012 -0700
     3.2 +++ b/VSs__Test_App/SeedVP.c	Sat Mar 02 10:03:18 2013 -0800
     3.3 @@ -17,15 +17,21 @@
     3.4  int32 testAppArgTypes[3] = {IN, NONCTLD, NONCTLD };
     3.5  int32 testAppArgSizes[3] = {16*16*sizeof(float), sizeof(int32), sizeof(int32)};
     3.6  
     3.7 -void test_app( void *_params, SlaveVP *animSlv )
     3.8 +void test_app_seed_Fn( void *_params, SlaveVP *seedSlv )
     3.9   { int32 i, *taskID;
    3.10 +   int32 *results = (int32 *)_params; //array to hold results was passed in
    3.11   
    3.12           DEBUG__printf( dbgAppFlow, "start test_app");
    3.13  
    3.14 -   //params = (VSsTestAppParams*)_params;
    3.15 -         
    3.16 +      //first thing to do is start the langlets going to use in this
    3.17 +      // proglet (AKA process).
    3.18 +   VSs__start( seedSlv );
    3.19 +   //Vthread__start( animSlv );
    3.20 +   //VCilk__start( animSlv );
    3.21 +
    3.22 +            
    3.23     // create all the task types
    3.24 -   testAppTaskType               = VMS_App__malloc( sizeof(VSsTaskType) );
    3.25 +   testAppTaskType               = PR__malloc( sizeof(VSsTaskType) );
    3.26     testAppTaskType->fn           = &test_app_task;
    3.27     testAppTaskType->numCtldArgs  = 1;
    3.28     testAppTaskType->numTotalArgs = 3;
    3.29 @@ -37,14 +43,34 @@
    3.30     
    3.31     for( i = 0; i < 5; i++ )
    3.32      {
    3.33 -      args.controlledArg = VMS_App__malloc( testAppTaskType->argSizes[0] );
    3.34 +      args.controlledArg = PR__malloc( testAppTaskType->argSizes[0] );
    3.35        args.controlledArg[0] = (float)i;
    3.36        args.taskNum       = i;
    3.37        args.numTasks      = 5;
    3.38 -      taskID             = VSs__create_taskID_of_size( 1, animSlv );
    3.39 +      taskID             = PR__create_taskID_of_size( 1 );
    3.40        taskID[1]          = i;
    3.41 -      VSs__submit_task_with_ID( testAppTaskType, &args, taskID, animSlv );
    3.42 -	 }
    3.43 -   VSs__end_thread( animSlv );
    3.44 +      VSs__submit_task_with_ID( testAppTaskType, &args, taskID, seedSlv );
    3.45 +    }
    3.46 +   
    3.47 +   //VSs__wait_for_all_children_to_end( animSlv ); //bug prone -- children must do same
    3.48 +   VSs__wait_for_all_VSs_created_work_to_end( seedSlv );
    3.49 +   //VSs__wait_until_all_activity_done( seedSlv ); //difficult to detect
    3.50 +
    3.51 +      //fake results, just to test basic PR functionality
    3.52 +   results[0] = 0;
    3.53 +   results[1] = 1;
    3.54 +   
    3.55 +   VSs__shutdown( seedSlv ); //Shuts down VSs within the process
    3.56 +
    3.57 +      //These are two of the ways to end a process, from inside itself..
    3.58 +      //The first ends the last live entity capable of work, in a process
    3.59 +      // that has no external input ports.. hence, no activity can take place
    3.60 +      // past that point..  PR detects that, and then automatically ends the
    3.61 +      // process.
    3.62 +      //The second explicitly tells PR to end the process, which it will do even
    3.63 +      // if work is active, or suspended work entities are still live, or the
    3.64 +      // process has input ports that could trigger future work.
    3.65 +   PR__end_seedVP( seedSlv );
    3.66 +   PR__end_process_from_inside( seedSlv );
    3.67   }
    3.68  
     4.1 --- a/VSs__Test_App/Task.c	Mon Sep 03 03:16:32 2012 -0700
     4.2 +++ b/VSs__Test_App/Task.c	Sat Mar 02 10:03:18 2013 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - *  Copyright 2009 OpenSourceStewardshipFoundation.org
     4.6 + *  Copyright 2009 OpenSourceResearchInstitute.org
     4.7   *  Licensed under GNU General Public License version 2
     4.8   *
     4.9   * Author: seanhalle@yahoo.com
    4.10 @@ -21,19 +21,19 @@
    4.11     
    4.12     selfTaskID = VSs__give_self_taskID( animSlv );
    4.13  
    4.14 -   receiveFromTaskID    = VSs__create_taskID_of_size( 1, animSlv );
    4.15 +   receiveFromTaskID    = PR__create_taskID_of_size( 1 );
    4.16     receiveFromTaskID[1] = selfTaskID[1] - 1;
    4.17  
    4.18 -   sendToTaskID    = VSs__create_taskID_of_size( 1, animSlv );
    4.19 +   sendToTaskID    = PR__create_taskID_of_size( 1 );
    4.20     sendToTaskID[1] = selfTaskID[1] + 1;
    4.21     
    4.22     if( receiveFromTaskID[1] >= 0 )
    4.23        VSs__receive_from_to( receiveFromTaskID, selfTaskID, animSlv );
    4.24 -   printf("Hello World: %f, %d\n", args->controlledArg[0], selfTaskID[1]);
    4.25 +   printf("Hello World: %d, %d\n", (int32)args->controlledArg[0], selfTaskID[1]);
    4.26     fflush(stdout);
    4.27     if( sendToTaskID[1] < numTasks )
    4.28        VSs__send_from_to( NULL, selfTaskID, sendToTaskID, animSlv );
    4.29 -   
    4.30 +    
    4.31     VSs__end_task( animSlv );
    4.32   }
    4.33  
     5.1 --- a/VSs__Test_App/VSs__Test_App.h	Mon Sep 03 03:16:32 2012 -0700
     5.2 +++ b/VSs__Test_App/VSs__Test_App.h	Sat Mar 02 10:03:18 2013 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - *  Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org
     5.6 + *  Copyright Oct 24, 2009 OpenSourceResearchInstitute.org
     5.7   *  Licensed under GNU General Public License version 2
     5.8   */
     5.9  
    5.10 @@ -17,14 +17,14 @@
    5.11  
    5.12  //NOTE: controlled args must come first, accessible as array of ptrs
    5.13  typedef struct
    5.14 - { int32 *controlledArg;  //This is a controlled arg -- VSs uses to calc depenencies
    5.15 + { float32 *controlledArg;  //This is a controlled arg -- VSs uses to calc depenencies
    5.16     int32  taskNum;  //This is a normal arg, ignored by VSs
    5.17     int32  numTasks; //This is a normal arg, ignored by VSs
    5.18   }
    5.19  TestAppArgs;
    5.20  
    5.21  //============================= Processor Functions =========================
    5.22 -void test_app(      void *data, SlaveVP *animatingSlv ); //seed VP function
    5.23 +void test_app_seed_Fn(      void *data, SlaveVP *animatingSlv ); //seed VP function
    5.24  void test_app_task( void *data, SlaveVP *animatingSlv );
    5.25  
    5.26  
     6.1 --- a/main.c	Mon Sep 03 03:16:32 2012 -0700
     6.2 +++ b/main.c	Sat Mar 02 10:03:18 2013 -0800
     6.3 @@ -10,15 +10,49 @@
     6.4  
     6.5  #include "VSs__Test_App/VSs__Test_App.h"
     6.6  
     6.7 -/*
     6.8 +/*This demonstrates the use of the proto-runtime system.  It allows multiple
     6.9 + * languages to be mixed within a single sub-program.  It also allows multiple
    6.10 + * sub-programs to be started, where each uses its own set of languages. The
    6.11 + * running sub-programs can then communicate with each other.
    6.12   * 
    6.13   */
    6.14  int main( int argc, char **argv )
    6.15 - { 
    6.16 -   
    6.17 + { PRProcess *testProcess1, *testProcess2;
    6.18 + 
    6.19     DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] );
    6.20     
    6.21 -   VSs__Test_App( );
    6.22 +      //A proto-runtime based language sits on top of the proto-runtime. So, 
    6.23 +      // first start the proto-runtime system, then create processes (which
    6.24 +      // start languages inside themselves)
    6.25 +   PR__start();
    6.26 +   
    6.27 +      //This info shows up in the header of output files holding measurements
    6.28 +      //These calls MUST be made after PR__start and before creating a process
    6.29 +   PR__set_app_info("test of multi-lang functionality");
    6.30 +   PR__set_input_info("no input");
    6.31 +   
    6.32 +  
    6.33 +      //Now that PR is started, create processes.  
    6.34 +      //Each process creates a seedVP and starts it running -- that then starts
    6.35 +      // the languages used inside the process..
    6.36 +      //To get results from a process, it gets complicated..  simple soln is 
    6.37 +      // just use PR's malloc and free, in the main thread, between PR__start
    6.38 +      // and PR__shutdown
    6.39 +      //The call returns a process struct (which has access to the seedVP)
    6.40 +   int32 *result = PR__malloc( 2 * sizeof(int32) );
    6.41 +   testProcess1 = PR__create_process( &test_app_seed_Fn, result );
    6.42 +   
    6.43 +   //testProcessor2 = PR__create_processor( &test_app2, NULL );
    6.44 +   //PR__connect_processors(testProcess1, OUT, testProcess2, IN); 
    6.45 +   //PR__connect_processors(testProcess2, OUT, testProcess1, IN); 
    6.46 +      
    6.47 +   PR__wait_for_process_to_end( testProcess1 );
    6.48 +   printf("results: %d, %d\n", result[0], result[1] );
    6.49 +   
    6.50 +   PR__free(result);
    6.51 +   
    6.52 +   //PR__wait_for_all_activity_to_end();  //equivalent of detecting shutdown
    6.53 +   PR__shutdown();
    6.54     
    6.55     exit(0); //cleans up
    6.56   }