view Reo__Matrix_Mult/SeedVP.c @ 2:96deb7b4502e

working, k=4
author Sean Halle <seanhalle@yahoo.com>
date Sat, 29 Mar 2014 06:02:18 -0700
parents 1b61e0c00512
children
line source
1 /*
2 * Copyright 2014 OpenSourceResearchInstitute.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 *
7 */
9 #include <math.h>
10 #include <string.h>
12 #include "Reo__Matrix_Mult.h"
14 #define NO_INPUT NULL
16 #include "MeasurementStuff.c"
18 // =============================================================================
20 /*The _params was passed into the create_process call inside main.
21 *
22 * the seed first starts up VReo, then it calls the create circuit Fn,
23 which returns a pointer to the circuit, then it calls create_VP three
24 times. The first, it hands it the pointer to the producer Fn, along with
25 a pointer to the circuit and an integer that indicates that it connects to
26 bridge 1 of the circuit. Second, it creates another producer, but connected
27 to bridge 2, then it creates a consumer connected to bridge 3.
29 Then, it waits for the computation to end.
31 A producer puts out 5 items, doing a print for each. The consumer consumes
32 10 items, doing a print for each.
34 Then each of them call "end_VP".
36 That ends the computation, and the seed comes back, and calls "end_seed_VP"
38 */
39 void matrix_mult__seed_Fn(void *_params, SlaveVP *seedVP)
40 {
41 /* Declare variables. */
42 VReoCircuit *circuit;
43 //MatrixMultPiece **workPieces;
45 //MatrixMultParams *params = (MatrixMultParams *)_params;
47 /* Log. */
48 DEBUG__printf(dbgAppFlow, "start app");
50 /* Start Reo plug-in. */
51 VReo__start(seedVP);
54 //take measurement before creation of threads, to get total exetime
55 MeasStruct benchStartMeas, benchEndMeas;
56 takeAMeas(0, benchStartMeas);
58 /* Create circuit. */
59 circuit = (VReoCircuit *) create_circuit(seedVP);
61 /* Create VPs -- pass along the array of work units*/
62 create_VPs_w_init_and_connect(circuit, _params, seedVP);
64 /* Wait for work to end. */
65 VReo__wait_for_all_VReo_created_work_to_end(seedVP);
67 /* Log. */
68 DEBUG__printf(TRUE, "work done");
70 //work is all done, so take a measurement snapshot at end
71 takeAMeas(0, benchEndMeas);
73 #ifdef MEASURE_PERF
74 uint64_t totalExeCycles = ( benchEndMeas.cycles - benchStartMeas.cycles);
75 printf("Total Execution: %lu\n", totalExeCycles);
76 #else
77 uint64_t totalExeCycles = (benchEndMeas.total - benchStartMeas.total);
78 printf("Total Cycles of Execution: %lu\n", totalExeCycles);
79 #endif
81 fflush(stdout);
82 // exit(0);
84 /* Stop Reo plug-in. */
85 VReo__shutdown(seedVP);
87 /* Stop PR. */
88 PR__end_process_from_inside(seedVP);
89 }