Skip to content

Commit d0d6882

Browse files
committed
config: Support read/write mode
This commit allow users specify required type of access in the config file. Users can specify what type of the access they want for each access of each phase by adding one more field. The filed can have value of ro, wo, or rw for read only, write only, or read-write, respectively. Signed-off-by: SeongJae Park <[email protected]>
1 parent eb7d394 commit d0d6882

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

masim.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ int parse_phase(char *lines[], int nr_lines, struct phase *p,
364364
p->patterns = patterns;
365365
for (j = 0; j < p->nr_patterns; j++) {
366366
nr_fields = astr_split(lines[0], ',', &fields);
367-
if (nr_fields != 4)
367+
if (nr_fields != 4 && nr_fields != 5)
368368
err(1, "Wrong number of fields! %s\n",
369369
lines[0]);
370370
a = &patterns[j];
@@ -380,6 +380,16 @@ int parse_phase(char *lines[], int nr_lines, struct phase *p,
380380
a->random_access = atoi(fields[1]);
381381
a->stride = atoi(fields[2]);
382382
a->probability = atoi(fields[3]);
383+
if (nr_fields == 5) {
384+
if (!strncmp(fields[4], "ro", 2))
385+
a->rw_mode = READ_ONLY;
386+
else if (!strncmp(fields[4], "wo", 2))
387+
a->rw_mode = WRITE_ONLY;
388+
else if (!strncmp(fields[4], "rw", 2))
389+
a->rw_mode = READ_WRITE;
390+
} else {
391+
a->rw_mode = WRITE_ONLY;
392+
}
383393
a->prob_start = p->total_probability;
384394
a->last_offset = 0;
385395
lines++;

masim.h

+7
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ struct mregion {
77
char *region;
88
};
99

10+
enum rw_mode {
11+
READ_ONLY,
12+
WRITE_ONLY,
13+
READ_WRITE,
14+
};
15+
1016
struct access {
1117
struct mregion *mregion;
1218
int random_access;
1319
size_t stride;
1420
int probability;
21+
enum rw_mode rw_mode;
1522

1623
/* For runtime only */
1724
int prob_start;

0 commit comments

Comments
 (0)