source: doc/theses/mike_brooks_MMath/benchmarks/list/observation.c@ ac9c0ee8

Last change on this file since ac9c0ee8 was 9d3dc40, checked in by Michael Brooks <mlbrooks@…>, 3 months ago

Various changes motivated by improving CFA score on len-1 queues.

No such CFA score improvement achieved. Each change helped only on stripped-down, "try to isolate an important factor" tests. Generally, the changes are benign refactorings. (Results substantiating "don't hurt" are forthcoming.)

Libcfa changes are

  • move a read action from between the memory breaks to before them
  • make the memory breaks conditionally excluded (default included, as before)

Harness changes are

  • add width, a compiled-in number of lists to use in round-robin order; defaults to 1, which is what was happening all along
  • make the analysis scripts tolerate (so far, ignore) the width column
  • rename CLI arg NumNodes to Length (now NumNodes is Length * Width)
  • factor core testing loops into helper function runtest
  • switch to signal-based termination (and add uC++ work-around)
  • put "iterator threading" into ITERS_SAVE, joining preexisting "save iter into elem's self ref"; make iterator threading conditional on iterators-active
  • disable insertion loop counter and obs_*-variable declarations (and thus writes) when observation disabled
  • generalize observation to work on multiple lists
  • make observation and assertion-check-enabled mode work on stripped CFA list implementations like tagging-disabled
  • through this observation, ensure correctness of multi-list versions
  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include <assert.h>
2
3#ifdef __needExternC
4#error Only compile observation.c (once) in plain C
5#endif
6
7#include <stdio.h>
8#include <stddef.h>
9
10#include "observation.h"
11
12static size_t NumNodes;
13
14void bobs_init(size_t NumNodes_) {
15 // printf("at bobs_init; bobs_ops_completed = %zd\n", bobs_ops_completed);
16
17 // todo: register a signal handler that prints progress info
18 // note function bobs_XXX in driver.c are untested until that's working
19 // to be driven as:
20 // ./a.out & # then, very quickly
21 // kill -s USR2 $!
22
23 NumNodes = NumNodes_;
24}
25
26#ifdef BOBS_SHOW_ADDRESSES
27#define SNAP \
28 void * userAddr = bobs_getCurrentLoc(); \
29 size_t userValue = bobs_getCurrentVal();
30#define SHOW(pfx, sfx) \
31 printf(" " pfx "%d@%p" sfx, userValue, userAddr);
32#else
33#define SNAP \
34 size_t userValue = bobs_getCurrentVal();
35#define SHOW(pfx, sfx) \
36 printf(" " pfx "%zd" sfx, userValue);
37#endif
38
39static void printPreds(size_t leash) {
40 if (leash==0)
41 return;
42 if (!bobs_hasCurrent()) {
43 printf(" |");
44 return;
45 }
46 SNAP
47 bobs_movePrev();
48 printPreds(leash - 1);
49 SHOW("", "")
50}
51static void printSuccs(size_t leash) {
52 if (leash==0)
53 return;
54 if (!bobs_hasCurrent()) {
55 printf(" |");
56 return;
57 }
58 SNAP
59 SHOW("", "")
60 bobs_moveNext();
61 printSuccs(leash - 1);
62}
63static void explore(size_t here, size_t leash) {
64 bobs_seek(here);
65 if (!bobs_hasCurrent()) {
66 printf(" <X>");
67 return;
68 }
69 bobs_movePrev();
70 printPreds(leash);
71
72 bobs_seek(here);
73 SNAP
74 SHOW("<", ">")
75
76 bobs_moveNext();
77 printSuccs(leash);
78}
79static void exploreRange(size_t validFrom, size_t validTo) {
80 size_t gapsize = validTo - validFrom;
81 size_t midpoint = (validTo + validFrom) / 2;
82
83 size_t listFirstmost, listLastmost;
84 switch(bobs_op_polarity) {
85 case insfirst:
86 listFirstmost = validTo;
87 listLastmost = validFrom;
88 break;
89 case inslast:
90 listFirstmost = validFrom;
91 listLastmost = validTo;
92 break;
93 default:
94 assert(0 && "unsupported bobs_op_movement value");
95 }
96
97 printf(" v%zd..%zd ", listFirstmost, listLastmost);
98
99 explore(listFirstmost, 6);
100 printf(" ...");
101 // if (gapsize > 5) {
102 // explore(midpoint);
103 // printf(" ...");
104 // }
105 explore(listLastmost, 6);
106}
107
108void bobs_report(void) {
109 if (bobs_prog_rollover_flag) {
110 printf("%8zd + ? (rolling over)\n", bobs_ops_completed);
111 } else {
112 printf("%8zd + %6zd/2 + %6zd/2, %6zd@e %6zd_u", bobs_ops_completed, bobs_prog_inserting, bobs_prog_removing, bobs_prog_removing_end, *bobs_prog_rem_pos);
113
114 ptrdiff_t validFrom = bobs_first_valid();
115 ptrdiff_t validTo = bobs_last_valid();
116
117 printf(" ");
118
119 if (validTo < validFrom) {
120 printf(" (list is empty)");
121 } else {
122 exploreRange(validFrom, validTo);
123 }
124
125 printf("\n");
126 }
127}
Note: See TracBrowser for help on using the repository browser.