# HG changeset patch # User Sean Halle # Date 1362247398 28800 # Node ID 1c9122bfd1c8ac0e6647220ed3a8e7f013a970f0 # Parent 2d955ed916effc0e065c6da2f8d824ad68e068ce ML_dev -- Compiles and runs diff -r 2d955ed916ef -r 1c9122bfd1c8 Design_Notes.txt --- a/Design_Notes.txt Mon Sep 03 03:16:32 2012 -0700 +++ b/Design_Notes.txt Sat Mar 02 10:03:18 2013 -0800 @@ -1,6 +1,3 @@ -0x7ffff644ab60 -0x7ffff64487f0 -0x7ffff644b0a0 This test app has to exercise all the aspects of the request handling and the assigner code. @@ -50,5 +47,5 @@ back-to-back Master backoff. If assigner called and no suspended slaves and taskQ empty.. does it have -a "current task slave"? If not, create one in the semantic Env. +a "current task slave"? If not, create one in the language env. ================================== diff -r 2d955ed916ef -r 1c9122bfd1c8 VSs__Test_App/EntryPoint.c --- a/VSs__Test_App/EntryPoint.c Mon Sep 03 03:16:32 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright 2009 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#include - -#include "VSs__Test_App.h" - - - -/*This "entry point" function creates the first - * processor, which starts the chain of creating more processors.. - * eventually all of the processors will dissipate themselves, and - * return. - * - *This entry-point function follows the same pattern as all entry-point - * functions do: - *1) it creates the params for the seed processor, from the - * parameters passed into the entry-point function - *2) it calls SSR__create_seed_slave_and_do_work - *3) it gets the return value from the params struc, frees the params struc, - * and returns the value from the function - * - */ -void -VSs__Test_App( ) - { - //create seed processor, start doing the work, and wait till done - //This function is the "border crossing" between normal code and SSR - VSs__create_seed_slave_and_do_work( &test_app, NULL ); - - return; - } diff -r 2d955ed916ef -r 1c9122bfd1c8 VSs__Test_App/SeedVP.c --- a/VSs__Test_App/SeedVP.c Mon Sep 03 03:16:32 2012 -0700 +++ b/VSs__Test_App/SeedVP.c Sat Mar 02 10:03:18 2013 -0800 @@ -17,15 +17,21 @@ int32 testAppArgTypes[3] = {IN, NONCTLD, NONCTLD }; int32 testAppArgSizes[3] = {16*16*sizeof(float), sizeof(int32), sizeof(int32)}; -void test_app( void *_params, SlaveVP *animSlv ) +void test_app_seed_Fn( void *_params, SlaveVP *seedSlv ) { int32 i, *taskID; + int32 *results = (int32 *)_params; //array to hold results was passed in DEBUG__printf( dbgAppFlow, "start test_app"); - //params = (VSsTestAppParams*)_params; - + //first thing to do is start the langlets going to use in this + // proglet (AKA process). + VSs__start( seedSlv ); + //Vthread__start( animSlv ); + //VCilk__start( animSlv ); + + // create all the task types - testAppTaskType = VMS_App__malloc( sizeof(VSsTaskType) ); + testAppTaskType = PR__malloc( sizeof(VSsTaskType) ); testAppTaskType->fn = &test_app_task; testAppTaskType->numCtldArgs = 1; testAppTaskType->numTotalArgs = 3; @@ -37,14 +43,34 @@ for( i = 0; i < 5; i++ ) { - args.controlledArg = VMS_App__malloc( testAppTaskType->argSizes[0] ); + args.controlledArg = PR__malloc( testAppTaskType->argSizes[0] ); args.controlledArg[0] = (float)i; args.taskNum = i; args.numTasks = 5; - taskID = VSs__create_taskID_of_size( 1, animSlv ); + taskID = PR__create_taskID_of_size( 1 ); taskID[1] = i; - VSs__submit_task_with_ID( testAppTaskType, &args, taskID, animSlv ); - } - VSs__end_thread( animSlv ); + VSs__submit_task_with_ID( testAppTaskType, &args, taskID, seedSlv ); + } + + //VSs__wait_for_all_children_to_end( animSlv ); //bug prone -- children must do same + VSs__wait_for_all_VSs_created_work_to_end( seedSlv ); + //VSs__wait_until_all_activity_done( seedSlv ); //difficult to detect + + //fake results, just to test basic PR functionality + results[0] = 0; + results[1] = 1; + + VSs__shutdown( seedSlv ); //Shuts down VSs within the process + + //These are two of the ways to end a process, from inside itself.. + //The first ends the last live entity capable of work, in a process + // that has no external input ports.. hence, no activity can take place + // past that point.. PR detects that, and then automatically ends the + // process. + //The second explicitly tells PR to end the process, which it will do even + // if work is active, or suspended work entities are still live, or the + // process has input ports that could trigger future work. + PR__end_seedVP( seedSlv ); + PR__end_process_from_inside( seedSlv ); } diff -r 2d955ed916ef -r 1c9122bfd1c8 VSs__Test_App/Task.c --- a/VSs__Test_App/Task.c Mon Sep 03 03:16:32 2012 -0700 +++ b/VSs__Test_App/Task.c Sat Mar 02 10:03:18 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright 2009 OpenSourceStewardshipFoundation.org + * Copyright 2009 OpenSourceResearchInstitute.org * Licensed under GNU General Public License version 2 * * Author: seanhalle@yahoo.com @@ -21,19 +21,19 @@ selfTaskID = VSs__give_self_taskID( animSlv ); - receiveFromTaskID = VSs__create_taskID_of_size( 1, animSlv ); + receiveFromTaskID = PR__create_taskID_of_size( 1 ); receiveFromTaskID[1] = selfTaskID[1] - 1; - sendToTaskID = VSs__create_taskID_of_size( 1, animSlv ); + sendToTaskID = PR__create_taskID_of_size( 1 ); sendToTaskID[1] = selfTaskID[1] + 1; if( receiveFromTaskID[1] >= 0 ) VSs__receive_from_to( receiveFromTaskID, selfTaskID, animSlv ); - printf("Hello World: %f, %d\n", args->controlledArg[0], selfTaskID[1]); + printf("Hello World: %d, %d\n", (int32)args->controlledArg[0], selfTaskID[1]); fflush(stdout); if( sendToTaskID[1] < numTasks ) VSs__send_from_to( NULL, selfTaskID, sendToTaskID, animSlv ); - + VSs__end_task( animSlv ); } diff -r 2d955ed916ef -r 1c9122bfd1c8 VSs__Test_App/VSs__Test_App.h --- a/VSs__Test_App/VSs__Test_App.h Mon Sep 03 03:16:32 2012 -0700 +++ b/VSs__Test_App/VSs__Test_App.h Sat Mar 02 10:03:18 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org + * Copyright Oct 24, 2009 OpenSourceResearchInstitute.org * Licensed under GNU General Public License version 2 */ @@ -17,14 +17,14 @@ //NOTE: controlled args must come first, accessible as array of ptrs typedef struct - { int32 *controlledArg; //This is a controlled arg -- VSs uses to calc depenencies + { float32 *controlledArg; //This is a controlled arg -- VSs uses to calc depenencies int32 taskNum; //This is a normal arg, ignored by VSs int32 numTasks; //This is a normal arg, ignored by VSs } TestAppArgs; //============================= Processor Functions ========================= -void test_app( void *data, SlaveVP *animatingSlv ); //seed VP function +void test_app_seed_Fn( void *data, SlaveVP *animatingSlv ); //seed VP function void test_app_task( void *data, SlaveVP *animatingSlv ); diff -r 2d955ed916ef -r 1c9122bfd1c8 main.c --- a/main.c Mon Sep 03 03:16:32 2012 -0700 +++ b/main.c Sat Mar 02 10:03:18 2013 -0800 @@ -10,15 +10,49 @@ #include "VSs__Test_App/VSs__Test_App.h" -/* +/*This demonstrates the use of the proto-runtime system. It allows multiple + * languages to be mixed within a single sub-program. It also allows multiple + * sub-programs to be started, where each uses its own set of languages. The + * running sub-programs can then communicate with each other. * */ int main( int argc, char **argv ) - { - + { PRProcess *testProcess1, *testProcess2; + DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] ); - VSs__Test_App( ); + //A proto-runtime based language sits on top of the proto-runtime. So, + // first start the proto-runtime system, then create processes (which + // start languages inside themselves) + PR__start(); + + //This info shows up in the header of output files holding measurements + //These calls MUST be made after PR__start and before creating a process + PR__set_app_info("test of multi-lang functionality"); + PR__set_input_info("no input"); + + + //Now that PR is started, create processes. + //Each process creates a seedVP and starts it running -- that then starts + // the languages used inside the process.. + //To get results from a process, it gets complicated.. simple soln is + // just use PR's malloc and free, in the main thread, between PR__start + // and PR__shutdown + //The call returns a process struct (which has access to the seedVP) + int32 *result = PR__malloc( 2 * sizeof(int32) ); + testProcess1 = PR__create_process( &test_app_seed_Fn, result ); + + //testProcessor2 = PR__create_processor( &test_app2, NULL ); + //PR__connect_processors(testProcess1, OUT, testProcess2, IN); + //PR__connect_processors(testProcess2, OUT, testProcess1, IN); + + PR__wait_for_process_to_end( testProcess1 ); + printf("results: %d, %d\n", result[0], result[1] ); + + PR__free(result); + + //PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown + PR__shutdown(); exit(0); //cleans up }