Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > PRDSL > PRDSL__Test_App
changeset 0:1cb25216938b tip
Initial add -- working
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 19 Sep 2013 18:08:07 -0700 |
| parents | |
| children | |
| files | .hgeol .hgignore PRDSL__Test_App/PRDSL__Test_App.h PRDSL__Test_App/SeedVP.c PRDSL__Test_App/Task.c PR_defs__turn_on_and_off.h __brch__PRDSL_Dev main.c |
| diffstat | 8 files changed, 300 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgeol Thu Sep 19 18:08:07 2013 -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 Thu Sep 19 18:08:07 2013 -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/PRDSL__Test_App/PRDSL__Test_App.h Thu Sep 19 18:08:07 2013 -0700 3.3 @@ -0,0 +1,44 @@ 3.4 +/* 3.5 + * Copyright Oct 24, 2009 OpenSourceResearchInstitute.org 3.6 + * Licensed under GNU General Public License version 2 3.7 + */ 3.8 + 3.9 +#ifndef _PRDSL_TEST_APP_H_ 3.10 +#define _PRDSL_TEST_APP_H_ 3.11 + 3.12 +#include <stdio.h> 3.13 + 3.14 +#include "../PR_defs__turn_on_and_off.h" 3.15 +#include <PR__include/prmalloc.h> 3.16 +#include <PR__include/langlets/prdsl_wrapper_library.h> 3.17 + 3.18 +//=============================== Defines ============================== 3.19 + 3.20 +//============================== Structures ============================== 3.21 + 3.22 +typedef struct 3.23 + { 3.24 + int32 *data; 3.25 + } 3.26 +SeedParams; 3.27 + 3.28 +typedef struct 3.29 + { 3.30 + int32 start; 3.31 + int32 end; 3.32 + int32 *data; 3.33 + } 3.34 +TaskParams; 3.35 + 3.36 +//============================= Processor Functions ========================= 3.37 +void test_app_seed_Fn( void *data, SlaveVP *animatingSlv ); //seed VP function 3.38 +void task_birthFn( void *_params, SlaveVP *animVP ); 3.39 + 3.40 + 3.41 +//================================ Entry Point ============================== 3.42 +void 3.43 +PRDSL__Test_App( ); 3.44 + 3.45 +//================================ Global Vars ============================== 3.46 + 3.47 +#endif /*_SSR_MATRIX_MULT_H_*/
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/PRDSL__Test_App/SeedVP.c Thu Sep 19 18:08:07 2013 -0700 4.3 @@ -0,0 +1,60 @@ 4.4 +/* 4.5 + * Copyright 2009 OpenSourceResearchInstitute.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 +#include <string.h> 4.14 +#include "PRDSL__Test_App.h" 4.15 + 4.16 + 4.17 +/* 4.18 + ------- Original Source, using custom DSL syntax ------- 4.19 + int size = 1000; 4.20 + int data[]; 4.21 + data = makeArray( size ); 4.22 + 4.23 + IterateIndependently i in 1:size 4.24 + { data[i] = square( i ); 4.25 + } 4.26 + */ 4.27 + 4.28 +void 4.29 +test_app_seed_Fn( void *_params, SlaveVP *seedVP ) 4.30 + { PRDSLTaskStub *newTask; 4.31 + int size = 1000; 4.32 + int *data = (int *) PR__malloc (size * sizeof(int)) ; 4.33 + SeedParams *seedParams = (SeedParams *)_params; //used to comm with main() 4.34 + 4.35 + PRDSL__start( seedVP ); //starts the PR_DSL langlet -- does internal stuff inside proto-runtime.. 4.36 + //can start additional languages here, and then freely mix "constructs" from them 4.37 + 4.38 + int i ; 4.39 + TaskParams *params; 4.40 + int chunkSize = 100; //for portability, lang would choose this dynamically at run time 4.41 + for (i=0; i < size; i += chunkSize) 4.42 + { params = PR__malloc(sizeof(TaskParams)); //these define work the task performs 4.43 + params->start = i; 4.44 + params->end = i + chunkSize -1; 4.45 + params->data = data; 4.46 + newTask = 4.47 + PRDSL__create_task_ready_to_run( &task_birthFn, params, seedVP ); 4.48 + } 4.49 + 4.50 + //PRDSL__wait_for_all_children_to_end( animSlv ); //bug prone -- children must do same 4.51 + PRDSL__wait_for_all_PRDSL_created_work_to_end( seedVP ); 4.52 + 4.53 + seedParams->data = data; //sends results back to main() 4.54 + 4.55 + PRDSL__shutdown( seedVP ); //Shuts down PRDSL within the process 4.56 + 4.57 + //This ends the last live entity capable of work, in a process 4.58 + // that has no external input ports.. hence, no activity can take place 4.59 + // past that point.. PR detects that, and then automatically ends the 4.60 + // process. 4.61 + PR__end_seedVP( seedVP ); 4.62 + } 4.63 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/PRDSL__Test_App/Task.c Thu Sep 19 18:08:07 2013 -0700 5.3 @@ -0,0 +1,29 @@ 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 "PRDSL__Test_App.h" 5.16 + 5.17 +int 5.18 +square( int x ) 5.19 + { return x*x; 5.20 + } 5.21 + 5.22 +void task_birthFn( void *_params, SlaveVP *animVP ) 5.23 + { int32 i; 5.24 + TaskParams *params = (TaskParams *)_params; 5.25 + int32 *data = params->data; 5.26 + DEBUG__printf(TRUE, "Task %d", params->start); 5.27 + for( i=params->start; i < params->end; ++i ) 5.28 + { data[i] = square(i); 5.29 + } 5.30 + PRDSL__end_task( animVP ); 5.31 + } 5.32 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/PR_defs__turn_on_and_off.h Thu Sep 19 18:08:07 2013 -0700 6.3 @@ -0,0 +1,90 @@ 6.4 +/* 6.5 + * Copyright 2009 OpenSourceResearchInstitute.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 +#ifndef _PR_DEFS_TURN_ON_AND_OFF_H 6.13 +#define _PR_DEFS_TURN_ON_AND_OFF_H 6.14 +#define _GNU_SOURCE 6.15 + 6.16 + 6.17 +#define MODE__MULTI_LANG 6.18 + 6.19 +//====================== Turn Debug things on and off ===================== 6.20 +/*When DEBUG__TURN_ON_SEQUENTIAL_MODE is defined, PR does sequential exe in the main thread 6.21 + * It still does co-routines and all the mechanisms are the same, it just 6.22 + * has only a single thread and animates Slvs one at a time 6.23 + */ 6.24 +//#define DEBUG__TURN_ON_SEQUENTIAL_MODE 6.25 + //check for sequential mode and redefine num cores to be 1 so that lang 6.26 + // code doesn't have to do special #ifdef for sequential mode 6.27 +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 6.28 + #ifdef NUM_CORES 6.29 + #undef NUM_CORES 6.30 + #define NUM_CORES 1 6.31 + #endif 6.32 +#endif 6.33 + 6.34 +/*turns on the probe-instrumentation in the application -- when not 6.35 + * defined, the calls to the probe functions turn into comments 6.36 + */ 6.37 +#define DEBUG__TURN_ON_DEBUG_PRINT 6.38 + 6.39 +/*These defines turn types of bug messages on and off 6.40 + */ 6.41 +#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ 6.42 +#define dbgProbes FALSE /* for issues inside probes themselves*/ 6.43 +#define dbgMaster FALSE /* obsolete*/ 6.44 +#define dbgRqstHdlr TRUE /* in request handler code*/ 6.45 +#define dbgSS FALSE /* in request handler code*/ 6.46 +#define dbgInfra FALSE /* in request handler code*/ 6.47 + 6.48 +//#define DEBUG__TURN_ON_ERROR_MSGS 6.49 + 6.50 +//================== Turn Probe Things on and off ==================== 6.51 +/*Probes are used in the application as a cheap, convenient, and fast way 6.52 + * to collect statistics. Define this to enable them, else the probe 6.53 + * statements in the application code all turn into empty whitespace 6.54 + * in the pre-processor 6.55 + */ 6.56 +//#define PROBES__TURN_ON_STATS_PROBES 6.57 + 6.58 +/*When PROBES__TURN_ON_STATS_PROBES is defined, turn on one of these to choose 6.59 + * what kind of measurement the probes store 6.60 + */ 6.61 +//#define PROBES__USE_TSC_PROBES 6.62 +#define PROBES__USE_TIME_OF_DAY_PROBES 6.63 +//#define PROBES__USE_PERF_CTR_PROBES 6.64 + 6.65 + 6.66 +//============== Turn Internal Measurement Things on and off =============== 6.67 + 6.68 +//#define MEAS__TURN_ON_SUSP_MEAS 6.69 +//#define MEAS__TURN_ON_MASTER_MEAS 6.70 +//#define MEAS__TURN_ON_MASTER_LOCK_MEAS 6.71 +//#define MEAS__TURN_ON_MALLOC_MEAS 6.72 +//#define MEAS__TURN_ON_PLUGIN_MEAS 6.73 +//#define MEAS__TURN_ON_SYSTEM_MEAS 6.74 + /*turn on/off subtraction of create measurements from plugin meas*/ 6.75 +//#define MEAS__TURN_ON_EXCLUDE_CREATION_TIME 6.76 + 6.77 + 6.78 +//#define HOLISTIC__TURN_ON_PERF_COUNTERS 6.79 +//#define HOLISTIC__TURN_ON_OBSERVE_UCC 6.80 +//#define HOLISTIC__TURN_ON_DETECT_CONSTRAINT_GRAPH 6.81 + 6.82 +//=================== Turn on or off system options ======================= 6.83 +// 6.84 +/*Defining SYS__TURN_ON_WORK_STEALING causes the core controller behavior 6.85 + * to change. When it detects too many back-to-back masters, then it 6.86 + * searches the other core controllers, looking for work it can steal from 6.87 + * them. 6.88 + */ 6.89 +//#define SYS__TURN_ON_WORK_STEALING 6.90 + 6.91 +//=========================================================================== 6.92 +#endif /* */ 6.93 +
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/__brch__PRDSL_Dev Thu Sep 19 18:08:07 2013 -0700 7.3 @@ -0,0 +1,1 @@ 7.4 +Applications normally have only the default branch -- they shouldn't be affected by any choices in VMS or language..
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/main.c Thu Sep 19 18:08:07 2013 -0700 8.3 @@ -0,0 +1,50 @@ 8.4 +/* 8.5 + * Copyright 2012 OpenSourceResearchInstitute.org 8.6 + * Licensed under GNU General Public License version 2 8.7 + * 8.8 + * author seanhalle@yahoo.com 8.9 + */ 8.10 + 8.11 +#include <malloc.h> 8.12 +#include <stdlib.h> 8.13 + 8.14 +#include "PRDSL__Test_App/PRDSL__Test_App.h" 8.15 +#include <PR__include/PR__WL.h> //declares PR__create_process 8.16 + 8.17 + 8.18 +/*This demonstrates the use of the proto-runtime system. It allows multiple 8.19 + * languages to be mixed within a single sub-program. It also allows multiple 8.20 + * sub-programs to be started, where each uses its own set of languages. The 8.21 + * running sub-programs can then communicate with each other. 8.22 + * 8.23 + */ 8.24 +int main( int argc, char **argv ) 8.25 + { PRProcess *testProcess1, *testProcess2; 8.26 + 8.27 + DEBUG__printf(TRUE, "arguments: %s | %s", argv[0], argv[1] ); 8.28 + 8.29 + //A proto-runtime based language sits on top of the proto-runtime. So, 8.30 + // first start the proto-runtime system, then create processes (which 8.31 + // start languages inside themselves) 8.32 + PR__start(); 8.33 + 8.34 + //Now that PR is started, create processes. 8.35 + //Each process creates a seedVP and starts it running -- that then starts 8.36 + // the languages used inside the process.. 8.37 + //To get results from a process, it gets complicated.. simple soln is 8.38 + // just use PR's malloc and free, in the main thread, between PR__start 8.39 + // and PR__shutdown 8.40 + //The call returns a process struct (which has access to the seedVP) 8.41 + int32 *result = PR__malloc( 2 * sizeof(int32) ); 8.42 + testProcess1 = PR__create_process( &test_app_seed_Fn, result ); 8.43 + 8.44 + PR__wait_for_process_to_end( testProcess1 ); 8.45 + printf("\n\nresults: %d, %d\n\n", result[0], result[1] ); 8.46 + 8.47 + PR__free(result); 8.48 + 8.49 + PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown 8.50 + PR__shutdown(); 8.51 + 8.52 + exit(0); //cleans up 8.53 + }
