source: liacs/ca/opdr3/common.c@ 396

Last change on this file since 396 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 1.8 KB
Line 
1/* Author : Rick van der Zwet
2 * S-number : 0433373
3 * Version : $Id: memory.h 363 2007-12-03 06:07:31Z rick $
4 * Copyright : FreeBSD Licence
5 * Description : Small libary to include most common functions
6 * cycles
7 */
8#include <stdio.h>
9#include "common.h"
10
11
12/* Print of struct bus2_t mainly for debugging purposes */
13void
14fprintfbus2(FILE * output, struct bus2_t * line)
15{
16 fprintf(output, "type: %c, ", line->type);
17 fprintf(output, "size: %i, ", line->size);
18 fprintf(output, "address: %12i, ", line->address);
19 fprintf(output, "rcount: %i, ", line->rcount);
20 fprintf(output, "icount: %i, ", line->icount);
21 fprintf(output, "\n");
22}
23
24/* Push the bus2 lines into a bus2 struct */
25int
26fscanfbus2(struct bus2_t * line)
27{
28 return fscanf(stdin, "BUS2 %c %i %x %i %i\n",
29 &line->type,
30 &line->size,
31 &line->address,
32 &line->rcount,
33 &line->icount);
34}
35
36
37
38void
39setstats(struct bus2_t * line, struct result_t * output) {
40 /* Both calls are 'in cache calls' */
41 output->incache += line->rcount;
42 output->incache += line->icount;
43 /* Minus one, cause the current call is also included */
44 output->incache--;
45
46 /* Raise the cache miss counter */
47 output->misses++;
48}
49
50void
51printfresult(FILE * output, struct result_t * result)
52{
53 long bytes = result->incache * 4;
54 float bandwidth = (float)bytes / result->cycles;
55 fprintf(output, "Total cycles : %li\n", result->cycles);
56 fprintf(output, "Cache misses : %li\n", result->misses);
57 fprintf(output, "Cache bytes : %li\n", bytes);
58 fprintf(output, "Bandwidth [1] : %.2f\n", bandwidth);
59 fprintf(output, "Bankconflicts : %li\n", result->conflicts);
60 fprintf(output, "---\n");
61 fprintf(output, "[1] Bytes/cycle CPU <> Cache\n");
62}
Note: See TracBrowser for help on using the repository browser.