# HG changeset patch # User Sean Halle # Date 1380037351 25200 # Node ID c6fc793f68a55890e885fe151ced597bda447a7b # Parent efca8e7ec576f61453426625451f10bdd0ad012f added rest of stuff diff -r efca8e7ec576 -r c6fc793f68a5 .hgeol --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgeol Tue Sep 24 08:42:31 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 efca8e7ec576 -r c6fc793f68a5 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Tue Sep 24 08:42:31 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 efca8e7ec576 -r c6fc793f68a5 DKU_Fns.c --- a/DKU_Fns.c Tue Sep 24 08:08:18 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - - -#include -#include -#include "DKU__Test_App.h" - -/*Bare smoke test of DKU wrapper library functions. - * Create one DKU instance, with a dummy kernel - * Bare bones divider and undivider - * simple root piece maker - * dummy serial kernel - */ - -int -square( int x ) - { return x*x; - } - - -DKUPiece * -rootPieceMakerFn( void *params, DKUInstance *dkuInstance ) - { DKUPiece *rootPiece; - - rootPiece = PRServ__DKU_make_empty_DKU_piece(); - rootPiece->parent = NULL; - rootPiece->payload = params; - rootPiece->dkuInstance = dkuInstance; - - return rootPiece; - } - -DKUPiece * -make_root_dku_piece_for_test_inst( int32 *data, int32 size, - DKUInstance *dkuInstance ) - { DKUPiece *rootPiece; - TestAppStruct *params; - - params = PR__malloc( sizeof(TestAppStruct) ); - params->startIter = 0; - params->endIter = size-1; - params->data = data; - params->size = size; - rootPiece = (*(dkuInstance->rootPieceMaker))( params, dkuInstance ); - return rootPiece; - } - - -void -kernelFn( void *_params, SlaveVP *animVP ) - { int32 i; - DKUPiece *piece = (DKUPiece *)_params; - TestAppStruct *params = (TestAppStruct *)piece->payload; - int32 *data = params->data; - - DEBUG__printf(dbgAppFlow, "Kernel %d", params->startIter); - - for( i=params->startIter; i <= params->endIter; ++i ) - { data[i] = square(i); - } - PRServ__DKU_end_kernel( piece, animVP ); - } - - -/*Serial kernel is called with bare app-defined struct, not DKUPiece - */ -void -serialKernelFn( void *_params, SlaveVP *animVP ) - { int32 i; - TestAppStruct *params = (TestAppStruct *)_params; - int32 *data = params->data; - - DEBUG__printf(dbgAppFlow, "SerialKernel %d", params->startIter); - - for( i=params->startIter; i < params->endIter; ++i ) - { data[i] = square(i); - } - PRServ__DKU_end_serial_kernel( animVP ); - } - -void -dividerFn( DKUPiece *pieceToDivide ) - { - int32 idx, childIdx, numChildren, size, *data; - DKUPiece *childPiece, **childrenArray; - TestAppStruct *params; - DEBUG__printf(dbgAppFlow, "divider %p", pieceToDivide) - - numChildren = pieceToDivide->numChildren; - childrenArray = PR__malloc( numChildren * sizeof(DKUPiece *) ); - size = ((TestAppStruct*)pieceToDivide->payload)->size; - data = ((TestAppStruct*)pieceToDivide->payload)->data; - int chunkSize = size/numChildren; //for portability, lang would choose this dynamically at run time - //note: should do processing to catch too small a chunksize and deal w/it - for( childIdx = 0; childIdx < numChildren; childIdx++ ) - { params = PR__malloc(sizeof(TestAppStruct)); //these define work the task performs - idx = childIdx * chunkSize; - params->startIter = idx; - params->endIter = idx + chunkSize -1; - params->data = data; - params->size = size; - childPiece = PRServ__DKU_make_child_piece_from( pieceToDivide ); - childPiece->payload = params; - childrenArray[childIdx] = childPiece; - } - params->endIter = size -1; //catch truncation error from chunkSize calc - - pieceToDivide->children = childrenArray; - } - -void undividerFn( DKUPiece *piece ) - { - //DEBUG__printf(dbgAppFlow, "Undivider %p", piece) - //nothing to do -- request handler does counting of completions - } - diff -r efca8e7ec576 -r c6fc793f68a5 DKU__Test_App.h --- a/DKU__Test_App.h Tue Sep 24 08:08:18 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright 2013 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - */ - -#ifndef _DKU_TEST_APP_H_ -#define _DKU_TEST_APP_H_ - -#include - -#include "../PR_defs__turn_on_and_off.h" -#include - -/*Bare smoke test of DKU wrapper library functions. - * Create one DKU instance, with a dummy kernel - * Bare bones divider and undivider - * simple root piece maker - * dummy serial kernel - */ - -//=============================== Defines ============================== - -//============================== Structures ============================== -typedef struct - { int32 *data; - } -SeedParams; - -typedef struct - { - int32 *data; - int32 size; - int32 startIter; - int32 endIter; - } -TestAppStruct; - -//============================= Processor Functions ========================= -void test_app_seed_Fn( void *data, SlaveVP *animatingVP ); //seed VP function - -DKUPiece *rootPieceMakerFn( void *data, DKUInstance *dkuInstance ); -void kernelFn( void *_params, SlaveVP *animVP ); //used as task birth Fn -void serialKernelFn( void *_params, SlaveVP *animVP ); //used as task birth Fn -void dividerFn( DKUPiece *piece ); -void undividerFn( DKUPiece *piece ); - -DKUPiece * -make_root_dku_piece_for_test_inst( int32 *data, int32 size, - DKUInstance *dkuInstance ); - -//================================ Global Vars ============================== - -#endif /*_SSR_MATRIX_MULT_H_*/ diff -r efca8e7ec576 -r c6fc793f68a5 DKU__Test_App/DKU_Fns.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DKU__Test_App/DKU_Fns.c Tue Sep 24 08:42:31 2013 -0700 @@ -0,0 +1,122 @@ +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + + +#include +#include +#include "DKU__Test_App.h" + +/*Bare smoke test of DKU wrapper library functions. + * Create one DKU instance, with a dummy kernel + * Bare bones divider and undivider + * simple root piece maker + * dummy serial kernel + */ + +int +square( int x ) + { return x*x; + } + + +DKUPiece * +rootPieceMakerFn( void *params, DKUInstance *dkuInstance ) + { DKUPiece *rootPiece; + + rootPiece = PRServ__DKU_make_empty_DKU_piece(); + rootPiece->parent = NULL; + rootPiece->payload = params; + rootPiece->dkuInstance = dkuInstance; + + return rootPiece; + } + +DKUPiece * +make_root_dku_piece_for_test_inst( int32 *data, int32 size, + DKUInstance *dkuInstance ) + { DKUPiece *rootPiece; + TestAppStruct *params; + + params = PR__malloc( sizeof(TestAppStruct) ); + params->startIter = 0; + params->endIter = size-1; + params->data = data; + params->size = size; + rootPiece = (*(dkuInstance->rootPieceMaker))( params, dkuInstance ); + return rootPiece; + } + + +void +kernelFn( void *_params, SlaveVP *animVP ) + { int32 i; + DKUPiece *piece = (DKUPiece *)_params; + TestAppStruct *params = (TestAppStruct *)piece->payload; + int32 *data = params->data; + + DEBUG__printf(dbgAppFlow, "Kernel %d", params->startIter); + + for( i=params->startIter; i <= params->endIter; ++i ) + { data[i] = square(i); + } + PRServ__DKU_end_kernel( piece, animVP ); + } + + +/*Serial kernel is called with bare app-defined struct, not DKUPiece + */ +void +serialKernelFn( void *_params, SlaveVP *animVP ) + { int32 i; + TestAppStruct *params = (TestAppStruct *)_params; + int32 *data = params->data; + + DEBUG__printf(dbgAppFlow, "SerialKernel %d", params->startIter); + + for( i=params->startIter; i < params->endIter; ++i ) + { data[i] = square(i); + } + PRServ__DKU_end_serial_kernel( animVP ); + } + +void +dividerFn( DKUPiece *pieceToDivide ) + { + int32 idx, childIdx, numChildren, size, *data; + DKUPiece *childPiece, **childrenArray; + TestAppStruct *params; + DEBUG__printf(dbgAppFlow, "divider %p", pieceToDivide) + + numChildren = pieceToDivide->numChildren; + childrenArray = PR__malloc( numChildren * sizeof(DKUPiece *) ); + size = ((TestAppStruct*)pieceToDivide->payload)->size; + data = ((TestAppStruct*)pieceToDivide->payload)->data; + int chunkSize = size/numChildren; //for portability, lang would choose this dynamically at run time + //note: should do processing to catch too small a chunksize and deal w/it + for( childIdx = 0; childIdx < numChildren; childIdx++ ) + { params = PR__malloc(sizeof(TestAppStruct)); //these define work the task performs + idx = childIdx * chunkSize; + params->startIter = idx; + params->endIter = idx + chunkSize -1; + params->data = data; + params->size = size; + childPiece = PRServ__DKU_make_child_piece_from( pieceToDivide ); + childPiece->payload = params; + childrenArray[childIdx] = childPiece; + } + params->endIter = size -1; //catch truncation error from chunkSize calc + + pieceToDivide->children = childrenArray; + } + +void undividerFn( DKUPiece *piece ) + { + //DEBUG__printf(dbgAppFlow, "Undivider %p", piece) + //nothing to do -- request handler does counting of completions + } + diff -r efca8e7ec576 -r c6fc793f68a5 DKU__Test_App/DKU__Test_App.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DKU__Test_App/DKU__Test_App.h Tue Sep 24 08:42:31 2013 -0700 @@ -0,0 +1,53 @@ +/* + * Copyright 2013 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + */ + +#ifndef _DKU_TEST_APP_H_ +#define _DKU_TEST_APP_H_ + +#include + +#include "../PR_defs__turn_on_and_off.h" +#include + +/*Bare smoke test of DKU wrapper library functions. + * Create one DKU instance, with a dummy kernel + * Bare bones divider and undivider + * simple root piece maker + * dummy serial kernel + */ + +//=============================== Defines ============================== + +//============================== Structures ============================== +typedef struct + { int32 *data; + } +SeedParams; + +typedef struct + { + int32 *data; + int32 size; + int32 startIter; + int32 endIter; + } +TestAppStruct; + +//============================= Processor Functions ========================= +void test_app_seed_Fn( void *data, SlaveVP *animatingVP ); //seed VP function + +DKUPiece *rootPieceMakerFn( void *data, DKUInstance *dkuInstance ); +void kernelFn( void *_params, SlaveVP *animVP ); //used as task birth Fn +void serialKernelFn( void *_params, SlaveVP *animVP ); //used as task birth Fn +void dividerFn( DKUPiece *piece ); +void undividerFn( DKUPiece *piece ); + +DKUPiece * +make_root_dku_piece_for_test_inst( int32 *data, int32 size, + DKUInstance *dkuInstance ); + +//================================ Global Vars ============================== + +#endif /*_SSR_MATRIX_MULT_H_*/ diff -r efca8e7ec576 -r c6fc793f68a5 DKU__Test_App/SeedVP.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DKU__Test_App/SeedVP.c Tue Sep 24 08:42:31 2013 -0700 @@ -0,0 +1,63 @@ +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + + +#include +#include +#include "DKU__Test_App.h" + +/*Bare smoke test of DKU wrapper library functions. + * Create one DKU instance, with a dummy kernel + * Bare bones divider and undivider + * simple root piece maker + * dummy serial kernel + */ + +//==================================================================== +#define NO_INPUT NULL + /*Just to get proto-runtime built and run, to test it.. + */ +void test_app_seed_Fn( void *_params, SlaveVP *seedVP ) + { DKUInstance *dkuInstance; + DKUPiece *rootPiece; + int32 size = 1000; + int32 *data = (int32 *) PR__malloc (size * sizeof(int32)) ; + + DEBUG__printf(dbgAppFlow, "In seed Fn") + + SeedParams *seedParams = (SeedParams *)_params; //used to comm with main() + + dkuInstance = PRServ__DKU_make_empty_DKU_instance( seedVP ); + PRServ__DKU_set_root_piece_maker( dkuInstance, &rootPieceMakerFn, seedVP ); + PRServ__DKU_set_kernel( dkuInstance, &kernelFn, seedVP ); + PRServ__DKU_set_serial_kernel( dkuInstance, &serialKernelFn, seedVP ); + PRServ__DKU_set_divider( dkuInstance, ÷rFn, seedVP ); + PRServ__DKU_set_undivider( dkuInstance, &undividerFn, seedVP ); + + rootPiece = + make_root_dku_piece_for_test_inst( data, size, dkuInstance ); +// rootPiece = PRServ__DKU_make_root_piece( dkuInstance, data, seedVP ); + + PRServ__DKU_perform_work_on( rootPiece, seedVP ); + + PRServ__DKU_wait_for_result_to_be_complete( rootPiece, seedVP ); + + seedParams->data = data; //sends results back to main() + + //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_process_from_inside( seedVP ); + + //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 efca8e7ec576 -r c6fc793f68a5 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 Tue Sep 24 08:42:31 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 efca8e7ec576 -r c6fc793f68a5 SeedVP.c --- a/SeedVP.c Tue Sep 24 08:08:18 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - - -#include -#include -#include "DKU__Test_App.h" - -/*Bare smoke test of DKU wrapper library functions. - * Create one DKU instance, with a dummy kernel - * Bare bones divider and undivider - * simple root piece maker - * dummy serial kernel - */ - -//==================================================================== -#define NO_INPUT NULL - /*Just to get proto-runtime built and run, to test it.. - */ -void test_app_seed_Fn( void *_params, SlaveVP *seedVP ) - { DKUInstance *dkuInstance; - DKUPiece *rootPiece; - int32 size = 1000; - int32 *data = (int32 *) PR__malloc (size * sizeof(int32)) ; - - DEBUG__printf(dbgAppFlow, "In seed Fn") - - SeedParams *seedParams = (SeedParams *)_params; //used to comm with main() - - dkuInstance = PRServ__DKU_make_empty_DKU_instance( seedVP ); - PRServ__DKU_set_root_piece_maker( dkuInstance, &rootPieceMakerFn, seedVP ); - PRServ__DKU_set_kernel( dkuInstance, &kernelFn, seedVP ); - PRServ__DKU_set_serial_kernel( dkuInstance, &serialKernelFn, seedVP ); - PRServ__DKU_set_divider( dkuInstance, ÷rFn, seedVP ); - PRServ__DKU_set_undivider( dkuInstance, &undividerFn, seedVP ); - - rootPiece = - make_root_dku_piece_for_test_inst( data, size, dkuInstance ); -// rootPiece = PRServ__DKU_make_root_piece( dkuInstance, data, seedVP ); - - PRServ__DKU_perform_work_on( rootPiece, seedVP ); - - PRServ__DKU_wait_for_result_to_be_complete( rootPiece, seedVP ); - - seedParams->data = data; //sends results back to main() - - //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_process_from_inside( seedVP ); - - //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 efca8e7ec576 -r c6fc793f68a5 __brch__default --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/__brch__default Tue Sep 24 08:42:31 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 efca8e7ec576 -r c6fc793f68a5 main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.c Tue Sep 24 08:42:31 2013 -0700 @@ -0,0 +1,57 @@ +/* + * Copyright 2012 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * author seanhalle@yahoo.com + */ + +#include +#include + +#include "DKU__Test_App/DKU__Test_App.h" +#include //declares PR__create_process -- else get integer return value + +#define NO_INPUT_OR_OUTPUT NULL + +/*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] ); + + //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 for developing VReo"); + 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 + SeedParams *params = PR__malloc( sizeof(SeedParams) ); + testProcess1 = PR__create_process( &test_app_seed_Fn, params ); + + PR__wait_for_process_to_end( testProcess1 ); + printf("\n\nresults: %d, %d\n\n", params->data[0], params->data[1] ); + + PR__free(params); + + PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown + PR__shutdown(); + + exit(0); //cleans up + }