File: new_test_loadstore_b.c

package info (click to toggle)
gxemul 0.7.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,152 kB
  • sloc: ansic: 111,065; sh: 972; exp: 354; makefile: 118
file content (71 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *  Experimenting with dynamic-but-not-binary-translation load/store.
 */

#include <stdio.h>
#include <stdlib.h>

#include "new_test_loadstore.h"

/*  These are in new_test_loadstore_a.c:  */
void x(struct cpu *cpu, struct ic *ic);
void y(struct cpu *cpu, struct ic *ic);

int main(int argc, char *argv[])
{
	int x1 = 72, x2 = 1234;
	struct ic ic = { 0, &x1, 5, &x2 };
	struct ic ic2 = { 0, &x2, 9, &x1 };
	struct cpu cpu;
	int i;
	char *page = malloc(4096);

#ifdef AAA
/*	cpu.table0 = malloc(sizeof(void *) * 1048576);  */
	for (i=0; i<1048576; i++)
		cpu.table0[i] = page;
#else
	cpu.table0[0] = malloc(sizeof(void *) * 2 * 1024);
	for (i=0; i<1024; i++) {
		cpu.table0[0][i*2+0] = page;
		cpu.table0[0][i*2+1] = page;
	}
#endif
	printf("A: 100 Million loads + 100 Million stores\n");
	printf("y=%i\n", x2);
	for (i=0; i<10000000; i++) {
		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);

		x(&cpu, &ic);
		y(&cpu, &ic2);
	}
	printf("y=%i\n", x2);
	printf("B\n");

	return 0;
}