# HG changeset patch # User Sean Halle # Date 1379639287 25200 # Node ID 1cb25216938b18993d5041c4e96f5e5d2522a5cf Initial add -- working diff -r 000000000000 -r 1cb25216938b .hgeol --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgeol Thu Sep 19 18:08:07 2013 -0700 @@ -0,0 +1,14 @@ + +[patterns] +**.py = native +**.txt = native +**.c = native +**.h = native +**.cpp = native +**.java = native +**.class = bin +**.jar = bin +**.sh = native +**.pl = native +**.jpg = bin +**.gif = bin diff -r 000000000000 -r 1cb25216938b .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Sep 19 18:08:07 2013 -0700 @@ -0,0 +1,12 @@ +nbproject +Makefile +build +dist +src/Default +src/.settings +src/.cproject +src/.project +.dep.inc +glob:.cproject +glob:.project +glob:Debug diff -r 000000000000 -r 1cb25216938b PRDSL__Test_App/PRDSL__Test_App.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PRDSL__Test_App/PRDSL__Test_App.h Thu Sep 19 18:08:07 2013 -0700 @@ -0,0 +1,44 @@ +/* + * Copyright Oct 24, 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + */ + +#ifndef _PRDSL_TEST_APP_H_ +#define _PRDSL_TEST_APP_H_ + +#include + +#include "../PR_defs__turn_on_and_off.h" +#include +#include + +//=============================== Defines ============================== + +//============================== Structures ============================== + +typedef struct + { + int32 *data; + } +SeedParams; + +typedef struct + { + int32 start; + int32 end; + int32 *data; + } +TaskParams; + +//============================= Processor Functions ========================= +void test_app_seed_Fn( void *data, SlaveVP *animatingSlv ); //seed VP function +void task_birthFn( void *_params, SlaveVP *animVP ); + + +//================================ Entry Point ============================== +void +PRDSL__Test_App( ); + +//================================ Global Vars ============================== + +#endif /*_SSR_MATRIX_MULT_H_*/ diff -r 000000000000 -r 1cb25216938b PRDSL__Test_App/SeedVP.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PRDSL__Test_App/SeedVP.c Thu Sep 19 18:08:07 2013 -0700 @@ -0,0 +1,60 @@ +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#include +#include +#include "PRDSL__Test_App.h" + + +/* + ------- Original Source, using custom DSL syntax ------- + int size = 1000; + int data[]; + data = makeArray( size ); + + IterateIndependently i in 1:size + { data[i] = square( i ); + } + */ + +void +test_app_seed_Fn( void *_params, SlaveVP *seedVP ) + { PRDSLTaskStub *newTask; + int size = 1000; + int *data = (int *) PR__malloc (size * sizeof(int)) ; + SeedParams *seedParams = (SeedParams *)_params; //used to comm with main() + + PRDSL__start( seedVP ); //starts the PR_DSL langlet -- does internal stuff inside proto-runtime.. + //can start additional languages here, and then freely mix "constructs" from them + + int i ; + TaskParams *params; + int chunkSize = 100; //for portability, lang would choose this dynamically at run time + for (i=0; i < size; i += chunkSize) + { params = PR__malloc(sizeof(TaskParams)); //these define work the task performs + params->start = i; + params->end = i + chunkSize -1; + params->data = data; + newTask = + PRDSL__create_task_ready_to_run( &task_birthFn, params, seedVP ); + } + + //PRDSL__wait_for_all_children_to_end( animSlv ); //bug prone -- children must do same + PRDSL__wait_for_all_PRDSL_created_work_to_end( seedVP ); + + seedParams->data = data; //sends results back to main() + + PRDSL__shutdown( seedVP ); //Shuts down PRDSL within the process + + //This 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. + PR__end_seedVP( seedVP ); + } + diff -r 000000000000 -r 1cb25216938b PRDSL__Test_App/Task.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PRDSL__Test_App/Task.c Thu Sep 19 18:08:07 2013 -0700 @@ -0,0 +1,29 @@ +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + + +#include +#include +#include "PRDSL__Test_App.h" + +int +square( int x ) + { return x*x; + } + +void task_birthFn( void *_params, SlaveVP *animVP ) + { int32 i; + TaskParams *params = (TaskParams *)_params; + int32 *data = params->data; + DEBUG__printf(TRUE, "Task %d", params->start); + for( i=params->start; i < params->end; ++i ) + { data[i] = square(i); + } + PRDSL__end_task( animVP ); + } + diff -r 000000000000 -r 1cb25216938b PR_defs__turn_on_and_off.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PR_defs__turn_on_and_off.h Thu Sep 19 18:08:07 2013 -0700 @@ -0,0 +1,90 @@ +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PR_DEFS_TURN_ON_AND_OFF_H +#define _PR_DEFS_TURN_ON_AND_OFF_H +#define _GNU_SOURCE + + +#define MODE__MULTI_LANG + +//====================== Turn Debug things on and off ===================== +/*When DEBUG__TURN_ON_SEQUENTIAL_MODE is defined, PR does sequential exe in the main thread + * It still does co-routines and all the mechanisms are the same, it just + * has only a single thread and animates Slvs one at a time + */ +//#define DEBUG__TURN_ON_SEQUENTIAL_MODE + //check for sequential mode and redefine num cores to be 1 so that lang + // code doesn't have to do special #ifdef for sequential mode +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE + #ifdef NUM_CORES + #undef NUM_CORES + #define NUM_CORES 1 + #endif +#endif + +/*turns on the probe-instrumentation in the application -- when not + * defined, the calls to the probe functions turn into comments + */ +#define DEBUG__TURN_ON_DEBUG_PRINT + +/*These defines turn types of bug messages on and off + */ +#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ +#define dbgProbes FALSE /* for issues inside probes themselves*/ +#define dbgMaster FALSE /* obsolete*/ +#define dbgRqstHdlr TRUE /* in request handler code*/ +#define dbgSS FALSE /* in request handler code*/ +#define dbgInfra FALSE /* in request handler code*/ + +//#define DEBUG__TURN_ON_ERROR_MSGS + +//================== Turn Probe Things on and off ==================== +/*Probes are used in the application as a cheap, convenient, and fast way + * to collect statistics. Define this to enable them, else the probe + * statements in the application code all turn into empty whitespace + * in the pre-processor + */ +//#define PROBES__TURN_ON_STATS_PROBES + +/*When PROBES__TURN_ON_STATS_PROBES is defined, turn on one of these to choose + * what kind of measurement the probes store + */ +//#define PROBES__USE_TSC_PROBES +#define PROBES__USE_TIME_OF_DAY_PROBES +//#define PROBES__USE_PERF_CTR_PROBES + + +//============== Turn Internal Measurement Things on and off =============== + +//#define MEAS__TURN_ON_SUSP_MEAS +//#define MEAS__TURN_ON_MASTER_MEAS +//#define MEAS__TURN_ON_MASTER_LOCK_MEAS +//#define MEAS__TURN_ON_MALLOC_MEAS +//#define MEAS__TURN_ON_PLUGIN_MEAS +//#define MEAS__TURN_ON_SYSTEM_MEAS + /*turn on/off subtraction of create measurements from plugin meas*/ +//#define MEAS__TURN_ON_EXCLUDE_CREATION_TIME + + +//#define HOLISTIC__TURN_ON_PERF_COUNTERS +//#define HOLISTIC__TURN_ON_OBSERVE_UCC +//#define HOLISTIC__TURN_ON_DETECT_CONSTRAINT_GRAPH + +//=================== Turn on or off system options ======================= +// +/*Defining SYS__TURN_ON_WORK_STEALING causes the core controller behavior + * to change. When it detects too many back-to-back masters, then it + * searches the other core controllers, looking for work it can steal from + * them. + */ +//#define SYS__TURN_ON_WORK_STEALING + +//=========================================================================== +#endif /* */ + diff -r 000000000000 -r 1cb25216938b __brch__PRDSL_Dev --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/__brch__PRDSL_Dev Thu Sep 19 18:08:07 2013 -0700 @@ -0,0 +1,1 @@ +Applications normally have only the default branch -- they shouldn't be affected by any choices in VMS or language.. diff -r 000000000000 -r 1cb25216938b main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.c Thu Sep 19 18:08:07 2013 -0700 @@ -0,0 +1,50 @@ +/* + * Copyright 2012 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * author seanhalle@yahoo.com + */ + +#include +#include + +#include "PRDSL__Test_App/PRDSL__Test_App.h" +#include //declares PR__create_process + + +/*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__printf(TRUE, "arguments: %s | %s", argv[0], argv[1] ); + + //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(); + + //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 ); + + PR__wait_for_process_to_end( testProcess1 ); + printf("\n\nresults: %d, %d\n\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 + }