[Linux-hls-cvs] hls/simul sim.c,1.10,1.11 sim_events.c,1.14,1.15 sim_os.c,1.9,1.10 workload.c,1.3,1.
Status: Pre-Alpha
Brought to you by:
lucabe
|
From: <lu...@us...> - 2003-12-05 21:48:44
|
Update of /cvsroot/linux-hls/hls/simul
In directory sc8-pr-cvs1:/tmp/cvs-serv5866/simul
Modified Files:
sim.c sim_events.c sim_os.c workload.c
Log Message:
- Some simulator work
- Unbreak the PS scheduler (share was 0 by default)
- Add a filter to convert the simulator output in a .fig file
Index: sim.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/sim.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** sim.c 29 Nov 2003 09:11:35 -0000 1.10
--- sim.c 5 Dec 2003 21:48:39 -0000 1.11
***************
*** 11,14 ****
--- 11,15 ----
#include <stdio.h>
#include <stdlib.h>
+ #include <unistd.h>
#include <time.h>
***************
*** 34,38 ****
}
! static void sim_init(void)
{
--- 35,39 ----
}
! static void sim_init(char *name)
{
***************
*** 56,63 ****
#endif
! outfile = fopen (OUTFILE, "w");
if (!outfile) {
perror("Error");
! printf("while opening data file %s\n", OUTFILE);
sim_die();
}
--- 57,64 ----
#endif
! outfile = fopen(name, "w");
if (!outfile) {
perror("Error");
! printf("while opening data file %s\n", name);
sim_die();
}
***************
*** 94,110 ****
int seed;
int finished;
! printf("Blah!\n");
switch (argc) {
case 2:
! seed = atoi(argv[1]);
break;
default:
seed = (unsigned)time(NULL);
}
!
strcpy(CurrentDefaultSched, "rr2");
! sim_init();
event_init(seed);
--- 95,143 ----
int seed;
int finished;
+ char *fname;
+ int c, done;
! done = 0;
! seed = (unsigned)time(NULL);
! fname = OUTFILE;
! while(!done) {
! c = getopt(argc, argv, "hf:s:");
! if (c == -1) {
! done = 1;
! } else {
! switch(c) {
! case 'h':
! fprintf(stderr, "Usage: %s [-h] [-f <filename>] [-s <seed>]\n", argv[0]);
! exit(0);
! case 'f':
! fname = optarg;
! break;
! case 's':
! seed = atoi(optarg);
! break;
! default:
! fprintf(stderr, "Unknown option %c\n", c);
! exit(-1);
! }
! }
! }
! #if 0
switch (argc) {
+ case 3:
+ seed = atoi(argv[2]);
+ fname = argv[1];
+ break;
case 2:
! fname = argv[1];
! seed = (unsigned)time(NULL);
break;
default:
+ fname = OUTFILE;
seed = (unsigned)time(NULL);
}
! #endif
strcpy(CurrentDefaultSched, "rr2");
! sim_init(fname);
event_init(seed);
Index: sim_events.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/sim_events.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** sim_events.c 29 Nov 2003 09:11:35 -0000 1.14
--- sim_events.c 5 Dec 2003 21:48:39 -0000 1.15
***************
*** 453,473 ****
static int DoEventMoveToPS(struct sim_event *ev, long long int time)
{
- int r = sim_rand() % 100;
- char *mstr;
struct sim_event *e;
! if (r < 33) {
! mstr = "ps1";
! } else if (r < 66) {
! mstr = "rr1";
! } else {
! mstr = "foo";
! }
!
! scheduler_set_default(mstr);
!
! e = new_event(EVENT_TYPE_MOVETOPS, 0);
! insert_event(e, time + (long long int)(sim_rand() % 1000000));
return 0;
}
--- 453,467 ----
static int DoEventMoveToPS(struct sim_event *ev, long long int time)
{
struct sim_event *e;
+ struct sim_task_struct *t;
+ int start, status;
! start = 1;
! t = ev->u.ps.t;
! sim_printf("(nt) DoEventPS\n");
+ fprintf(stderr, "Share: %d\t Warp: %d\n", ev->u.ps.share, 0);
+ status = thread_move_to_ps(t, ev->u.ps.share, /*ev->u.ps.warp*/ 0, start);
+
return 0;
}
***************
*** 480,484 ****
}
- /* TODO: This!!! */
static int DoEventRes(struct sim_event *ev, long long int time)
--- 474,477 ----
***************
*** 492,534 ****
t = ev->u.res.t;
! start = ev->u.res.BeginRes;
sim_printf("(nt) DoEventRes\n");
! /*
! if (HLS_DATA(t)) {
! printf("(nt) Hmm: thread seems to have exited\n");
!
! return 0;
! }
! */
!
! if (sim_rand() % 100 < 50) {
! soft = 1;
! // res.Soft = HLS_FALSE;
! } else {
! soft = 0;
! }
!
! if (sim_rand() % 100 < 15) {
! start = 1;
! }
! if (sim_rand() % 100 < 15) {
! start = 0;
! }
!
! /* TODO: Fix these values... */
! res_period = sim_rand() % (200 * 10000);
! res_amount = sim_rand() % (10 * 10000);
status = thread_reserve(t, res_amount, res_period, start, soft);
/*
status = NtHLSCtl (HLS_CMD_RES, &res, sizeof (struct CPU_RESERVATION));
HLSDbgPrint (3, ("(nt) status of %s res is %ld\n",
! res.BeginRes ? "BEGIN" : "END", status));
*/
sim_printf("Res Number: %d\n", res_number);
if (res_number++ < NUM_RSV) {
sim_printf("Going to set...\n");
e = new_event(EVENT_TYPE_RES, sim_rand() % sim_nr_cpus());
e->u.res.t = t;
--- 485,509 ----
t = ev->u.res.t;
! res_period = ev->u.res.period;
! res_amount = ev->u.res.amount;
! start = ev->u.res.start;
sim_printf("(nt) DoEventRes\n");
! soft = 0;
status = thread_reserve(t, res_amount, res_period, start, soft);
+ /* TODO: Move back to RR after some time
+ * (EVENT_TYPE_RES withstart = 0)
+ */
/*
status = NtHLSCtl (HLS_CMD_RES, &res, sizeof (struct CPU_RESERVATION));
HLSDbgPrint (3, ("(nt) status of %s res is %ld\n",
! res.start ? "BEGIN" : "END", status));
*/
sim_printf("Res Number: %d\n", res_number);
if (res_number++ < NUM_RSV) {
sim_printf("Going to set...\n");
+ #if 0
e = new_event(EVENT_TYPE_RES, sim_rand() % sim_nr_cpus());
e->u.res.t = t;
***************
*** 536,552 ****
if (!start) {
// HLS_ASSERT (status == STATUS_SUCCESS);
! e->u.res.BeginRes = 1;
sim_printf("(nt) ending the res worked; next time we'll start one\n");
} else {
if (status == 0) {
if (sim_rand() % 100 < 50) {
! e->u.res.BeginRes = 0;
sim_printf("(nt) starting the res worked; next time we'll end one\n");
} else {
! e->u.res.BeginRes = 1;
sim_printf("(nt) starting the res worked; next time we'll start a new one\n");
}
} else {
! e->u.res.BeginRes = 1;
sim_printf("(nt) starting the res didn't work; next time we'll start one\n");
}
--- 511,527 ----
if (!start) {
// HLS_ASSERT (status == STATUS_SUCCESS);
! e->u.res.start = 1;
sim_printf("(nt) ending the res worked; next time we'll start one\n");
} else {
if (status == 0) {
if (sim_rand() % 100 < 50) {
! e->u.res.start = 0;
sim_printf("(nt) starting the res worked; next time we'll end one\n");
} else {
! e->u.res.start = 1;
sim_printf("(nt) starting the res worked; next time we'll start a new one\n");
}
} else {
! e->u.res.start = 1;
sim_printf("(nt) starting the res didn't work; next time we'll start one\n");
}
***************
*** 554,557 ****
--- 529,533 ----
insert_event (e, (long long int)time + max_res_time + (sim_rand() % max_res_time));
+ #endif
}
Index: sim_os.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/sim_os.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** sim_os.c 29 Nov 2003 09:11:35 -0000 1.9
--- sim_os.c 5 Dec 2003 21:48:40 -0000 1.10
***************
*** 18,21 ****
--- 18,22 ----
#include "thr.h"
#include "rsv.h"
+ #include "ps.h"
#include "sim.h"
***************
*** 134,138 ****
e = new_event(EVENT_TYPE_RES, sim_rand() % sim_nr_cpus()); /* TODO: Check this "NR_CPUS" thing */
e->u.res.t = t;
! e->u.res.BeginRes = TRUE;
insert_event(e, (long long int)((sim_rand() % (max_res_time / 100)) + create_time));
}
--- 135,139 ----
e = new_event(EVENT_TYPE_RES, sim_rand() % sim_nr_cpus()); /* TODO: Check this "NR_CPUS" thing */
e->u.res.t = t;
! e->u.res.start = TRUE;
insert_event(e, (long long int)((sim_rand() % (max_res_time / 100)) + create_time));
}
***************
*** 305,308 ****
--- 306,374 ----
}
+ int thread_move_to_ps(struct sim_task_struct *t, int share, int warp, int start)
+ {
+ char *schedname;
+ struct HLS_SCHED_INSTANCE *target_sched;
+ struct TH_INSTANCE_DATA *th;
+ int status;
+ int st;
+
+ if (start) {
+ schedname = "ps1";
+ } else {
+ schedname = "rr1";
+ }
+
+ target_sched = HLSFindInstByName(schedname);
+ if (target_sched == NULL) {
+ printf("Cannot find %s scheduler!!!\n", schedname);
+
+ exit(-1);
+ }
+ th = HLS_DATA(t);
+
+ if (th == NULL) {
+ printf("Cannot find TH_INSTANCE_DATA...\n");
+
+ exit(-1);
+ }
+
+ st = th->vp->State;
+
+ status = hls_thread_move(t, target_sched);
+ if (status != HLS_SUCCESS) {
+ printf("hls_thread_move() failed!!!\n");
+
+ exit(-1);
+ }
+
+ if (start == 0) {
+ HLSSetPri(th->Thread, HLS_DEFAULT_PRIORITY);
+ } else {
+ struct ps_msg_body body;
+ struct hls_message msg;
+
+ #ifdef HLS_DEBUG
+ msg.ObjType = RRMsgValue;
+ #endif
+ msg.type = MSG_SETPARAMS;
+ msg.body = &body;
+ body.warp = warp;
+ body.share = share;
+
+ /* Prepare s_p */
+ status = th->vp->TopSched->CB->B_Msg(NULL, th->vp, (MsgHandle)&msg);
+ sim_printf("status: %d\n", status);
+ if (status != HLS_SUCCESS) {
+ printf("hls_setparam() failed!!!\n");
+
+ exit(-1);
+ }
+ }
+
+ thread_set_state(th, st);
+
+ return 0;
+ }
int thread_reserve(struct sim_task_struct *t, long long int q, long long int p, int start, int soft)
Index: workload.c
===================================================================
RCS file: /cvsroot/linux-hls/hls/simul/workload.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** workload.c 25 Feb 2003 09:18:57 -0000 1.3
--- workload.c 5 Dec 2003 21:48:40 -0000 1.4
***************
*** 2,10 ****
* Copyright (c) 2002 Luca Abeni
*
! * Module Name: loads/periodic.c
* Abstract: Workload generator for the Simulator Backend.
! * Task set composed of ``periodic tasks'', that
! * execute for a fixed time C and then block until the
! * beginning of the next period.
* Author: Luca Abeni 2-Feb-2002
*
--- 2,9 ----
* Copyright (c) 2002 Luca Abeni
*
! * Module Name: loads/continuous.c
* Abstract: Workload generator for the Simulator Backend.
! * Task set composed of ``continuous tasks'', that
! * are always backlogged (never block or unblock).
* Author: Luca Abeni 2-Feb-2002
*
***************
*** 27,30 ****
--- 26,30 ----
extern long long int max_res_time;
+ extern long long int max_run_time_until_blocking;
extern long long int cpu_time_per_thread;
extern long long int max_blocking_time;
***************
*** 32,41 ****
long long int execution_time(void)
{
! return 2000000;
! }
!
! long long int period(void)
! {
! return 100000000;
}
--- 32,36 ----
long long int execution_time(void)
{
! return 10000;
}
***************
*** 54,57 ****
--- 49,53 ----
#if 0
+ max_run_time_until_blocking = ((long long int)(sim_rand()%1000000))+500;
max_blocking_time = ((long long int)(sim_rand()%100000))+500;
max_res_time = 100000000;
***************
*** 60,64 ****
for(i = 0; i < threads; i++) {
! make_new_thread(100, 0, execution_time, period, TH_FIXED_PRIO);
}
--- 56,60 ----
for(i = 0; i < threads; i++) {
! make_new_thread(100, 0, /*execution_time*/ NULL, NULL, TH_FIXED_PRIO);
}
***************
*** 85,88 ****
#endif
! return 1000000000;
}
--- 81,84 ----
#endif
! return 100000000;
}
|