7 #include <cdsannotate.h>
8 #include <specannotation.h>
9 #include <model_memory.h>
12 template <typename t_element, size_t t_size>
13 struct mpmc_boundq_1_alt
19 t_element m_array[t_size];
21 atomic<unsigned int> m_rdwr;
22 atomic<unsigned int> m_read;
23 atomic<unsigned int> m_written;
37 /* All other user-defined structs */
38 /* All other user-defined functions */
39 /* Definition of interface info struct: Publish */
40 typedef struct Publish_info {
43 /* End of info struct definition: Publish */
45 /* ID function of interface: Publish */
46 inline static call_id_t Publish_id(void *info, thread_id_t __TID__) {
47 Publish_info* theInfo = (Publish_info*)info;
48 t_element * bin = theInfo->bin;
50 call_id_t __ID__ = ( call_id_t ) bin;
53 /* End of ID function: Publish */
55 /* Check action function of interface: Publish */
56 inline static bool Publish_check_action(void *info, call_id_t __ID__, thread_id_t __TID__) {
58 Publish_info* theInfo = (Publish_info*)info;
59 t_element * bin = theInfo->bin;
63 /* End of check action function: Publish */
65 /* Definition of interface info struct: Fetch */
66 typedef struct Fetch_info {
69 /* End of info struct definition: Fetch */
71 /* ID function of interface: Fetch */
72 inline static call_id_t Fetch_id(void *info, thread_id_t __TID__) {
73 Fetch_info* theInfo = (Fetch_info*)info;
74 t_element * __RET__ = theInfo->__RET__;
76 call_id_t __ID__ = ( call_id_t ) __RET__;
79 /* End of ID function: Fetch */
81 /* Check action function of interface: Fetch */
82 inline static bool Fetch_check_action(void *info, call_id_t __ID__, thread_id_t __TID__) {
84 Fetch_info* theInfo = (Fetch_info*)info;
85 t_element * __RET__ = theInfo->__RET__;
89 /* End of check action function: Fetch */
91 /* Definition of interface info struct: Prepare */
92 typedef struct Prepare_info {
95 /* End of info struct definition: Prepare */
97 /* ID function of interface: Prepare */
98 inline static call_id_t Prepare_id(void *info, thread_id_t __TID__) {
99 Prepare_info* theInfo = (Prepare_info*)info;
100 t_element * __RET__ = theInfo->__RET__;
102 call_id_t __ID__ = ( call_id_t ) __RET__;
105 /* End of ID function: Prepare */
107 /* Check action function of interface: Prepare */
108 inline static bool Prepare_check_action(void *info, call_id_t __ID__, thread_id_t __TID__) {
110 Prepare_info* theInfo = (Prepare_info*)info;
111 t_element * __RET__ = theInfo->__RET__;
115 /* End of check action function: Prepare */
117 /* Definition of interface info struct: Consume */
118 typedef struct Consume_info {
121 /* End of info struct definition: Consume */
123 /* ID function of interface: Consume */
124 inline static call_id_t Consume_id(void *info, thread_id_t __TID__) {
125 Consume_info* theInfo = (Consume_info*)info;
126 t_element * bin = theInfo->bin;
128 call_id_t __ID__ = ( call_id_t ) bin;
131 /* End of ID function: Consume */
133 /* Check action function of interface: Consume */
134 inline static bool Consume_check_action(void *info, call_id_t __ID__, thread_id_t __TID__) {
136 Consume_info* theInfo = (Consume_info*)info;
137 t_element * bin = theInfo->bin;
141 /* End of check action function: Consume */
143 #define INTERFACE_SIZE 4
144 static void** func_ptr_table;
145 static hb_rule** hb_rule_table;
146 static commutativity_rule** commutativity_rule_table;
147 inline static bool CommutativityCondition0(void *info1, void *info2) {
148 Prepare_info *_info1 = (Prepare_info*) info1;
149 Prepare_info *_info2 = (Prepare_info*) info2;
150 return _info1-> __RET__ != _info2-> __RET__ || ! _info1-> __RET__ || ! _info2-> __RET__;
152 inline static bool CommutativityCondition1(void *info1, void *info2) {
153 Prepare_info *_info1 = (Prepare_info*) info1;
154 Publish_info *_info2 = (Publish_info*) info2;
155 return _info1-> __RET__ != _info2-> bin || ! _info1-> __RET__;
157 inline static bool CommutativityCondition2(void *info1, void *info2) {
158 Prepare_info *_info1 = (Prepare_info*) info1;
159 Fetch_info *_info2 = (Fetch_info*) info2;
160 return _info1-> __RET__ != _info2-> __RET__ || ! _info1-> __RET__ || ! _info2-> __RET__;
162 inline static bool CommutativityCondition3(void *info1, void *info2) {
163 Prepare_info *_info1 = (Prepare_info*) info1;
164 Consume_info *_info2 = (Consume_info*) info2;
165 return _info1-> __RET__ != _info2-> bin || ! _info1-> __RET__;
167 inline static bool CommutativityCondition4(void *info1, void *info2) {
168 Publish_info *_info1 = (Publish_info*) info1;
169 Publish_info *_info2 = (Publish_info*) info2;
170 return _info1-> bin != _info2-> bin;
172 inline static bool CommutativityCondition5(void *info1, void *info2) {
173 Publish_info *_info1 = (Publish_info*) info1;
174 Fetch_info *_info2 = (Fetch_info*) info2;
175 return _info1-> bin != _info2-> __RET__ || ! _info2-> __RET__;
177 inline static bool CommutativityCondition6(void *info1, void *info2) {
178 Publish_info *_info1 = (Publish_info*) info1;
179 Consume_info *_info2 = (Consume_info*) info2;
180 return _info1-> bin != _info2-> bin;
182 inline static bool CommutativityCondition7(void *info1, void *info2) {
183 Fetch_info *_info1 = (Fetch_info*) info1;
184 Fetch_info *_info2 = (Fetch_info*) info2;
185 return _info1-> __RET__ != _info2-> __RET__ || ! _info1-> __RET__ || ! _info2-> __RET__;
187 inline static bool CommutativityCondition8(void *info1, void *info2) {
188 Fetch_info *_info1 = (Fetch_info*) info1;
189 Consume_info *_info2 = (Consume_info*) info2;
190 return _info1-> __RET__ != _info2-> bin || ! _info1-> __RET__;
192 inline static bool CommutativityCondition9(void *info1, void *info2) {
193 Consume_info *_info1 = (Consume_info*) info1;
194 Consume_info *_info2 = (Consume_info*) info2;
195 return _info1-> bin != _info2-> bin;
198 /* Initialization of sequential varialbes */
199 static void __SPEC_INIT__() {
202 /* Cleanup routine of sequential variables */
203 static bool __SPEC_CLEANUP__() {
207 /* Define function for sequential code initialization */
208 inline static void __sequential_init() {
209 /* Init func_ptr_table */
210 func_ptr_table = (void**) malloc(sizeof(void*) * 4 * 2);
211 func_ptr_table[2 * 3] = (void*) &Publish_id;
212 func_ptr_table[2 * 3 + 1] = (void*) &Publish_check_action;
213 func_ptr_table[2 * 0] = (void*) &Fetch_id;
214 func_ptr_table[2 * 0 + 1] = (void*) &Fetch_check_action;
215 func_ptr_table[2 * 2] = (void*) &Prepare_id;
216 func_ptr_table[2 * 2 + 1] = (void*) &Prepare_check_action;
217 func_ptr_table[2 * 1] = (void*) &Consume_id;
218 func_ptr_table[2 * 1 + 1] = (void*) &Consume_check_action;
219 /* Consume(true) -> Prepare(true) */
220 struct hb_rule *hbConditionInit0 = (struct hb_rule*) malloc(sizeof(struct hb_rule));
221 hbConditionInit0->interface_num_before = 1; // Consume
222 hbConditionInit0->hb_condition_num_before = 0; //
223 hbConditionInit0->interface_num_after = 2; // Prepare
224 hbConditionInit0->hb_condition_num_after = 0; //
225 /* Publish(true) -> Fetch(true) */
226 struct hb_rule *hbConditionInit1 = (struct hb_rule*) malloc(sizeof(struct hb_rule));
227 hbConditionInit1->interface_num_before = 3; // Publish
228 hbConditionInit1->hb_condition_num_before = 0; //
229 hbConditionInit1->interface_num_after = 0; // Fetch
230 hbConditionInit1->hb_condition_num_after = 0; //
231 /* Init hb_rule_table */
232 hb_rule_table = (hb_rule**) malloc(sizeof(hb_rule*) * 2);
233 #define HB_RULE_TABLE_SIZE 2
234 hb_rule_table[0] = hbConditionInit0;
235 hb_rule_table[1] = hbConditionInit1;
236 /* Init commutativity_rule_table */
237 commutativity_rule_table = (commutativity_rule**) malloc(sizeof(commutativity_rule*) * 10);
238 commutativity_rule* rule;
239 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
240 rule->interface_num_before = 2;
241 rule->interface_num_after = 2;
242 rule->rule = "_Method1 . __RET__ != _Method2 . __RET__ || ! _Method1 . __RET__ || ! _Method2 . __RET__";
243 rule->condition = CommutativityCondition0;
244 commutativity_rule_table[0] = rule;
245 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
246 rule->interface_num_before = 2;
247 rule->interface_num_after = 3;
248 rule->rule = "_Method1 . __RET__ != _Method2 . bin || ! _Method1 . __RET__";
249 rule->condition = CommutativityCondition1;
250 commutativity_rule_table[1] = rule;
251 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
252 rule->interface_num_before = 2;
253 rule->interface_num_after = 0;
254 rule->rule = "_Method1 . __RET__ != _Method2 . __RET__ || ! _Method1 . __RET__ || ! _Method2 . __RET__";
255 rule->condition = CommutativityCondition2;
256 commutativity_rule_table[2] = rule;
257 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
258 rule->interface_num_before = 2;
259 rule->interface_num_after = 1;
260 rule->rule = "_Method1 . __RET__ != _Method2 . bin || ! _Method1 . __RET__";
261 rule->condition = CommutativityCondition3;
262 commutativity_rule_table[3] = rule;
263 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
264 rule->interface_num_before = 3;
265 rule->interface_num_after = 3;
266 rule->rule = "_Method1 . bin != _Method2 . bin";
267 rule->condition = CommutativityCondition4;
268 commutativity_rule_table[4] = rule;
269 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
270 rule->interface_num_before = 3;
271 rule->interface_num_after = 0;
272 rule->rule = "_Method1 . bin != _Method2 . __RET__ || ! _Method2 . __RET__";
273 rule->condition = CommutativityCondition5;
274 commutativity_rule_table[5] = rule;
275 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
276 rule->interface_num_before = 3;
277 rule->interface_num_after = 1;
278 rule->rule = "_Method1 . bin != _Method2 . bin";
279 rule->condition = CommutativityCondition6;
280 commutativity_rule_table[6] = rule;
281 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
282 rule->interface_num_before = 0;
283 rule->interface_num_after = 0;
284 rule->rule = "_Method1 . __RET__ != _Method2 . __RET__ || ! _Method1 . __RET__ || ! _Method2 . __RET__";
285 rule->condition = CommutativityCondition7;
286 commutativity_rule_table[7] = rule;
287 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
288 rule->interface_num_before = 0;
289 rule->interface_num_after = 1;
290 rule->rule = "_Method1 . __RET__ != _Method2 . bin || ! _Method1 . __RET__";
291 rule->condition = CommutativityCondition8;
292 commutativity_rule_table[8] = rule;
293 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
294 rule->interface_num_before = 1;
295 rule->interface_num_after = 1;
296 rule->rule = "_Method1 . bin != _Method2 . bin";
297 rule->condition = CommutativityCondition9;
298 commutativity_rule_table[9] = rule;
299 /* Pass init info, including function table info & HB rules & Commutativity Rules */
300 struct anno_init *anno_init = (struct anno_init*) malloc(sizeof(struct anno_init));
301 anno_init->init_func = (void_func_t) __SPEC_INIT__;
302 anno_init->cleanup_func = (cleanup_func_t) __SPEC_CLEANUP__;
303 anno_init->func_table = func_ptr_table;
304 anno_init->func_table_size = INTERFACE_SIZE;
305 anno_init->hb_rule_table = hb_rule_table;
306 anno_init->hb_rule_table_size = HB_RULE_TABLE_SIZE;
307 anno_init->commutativity_rule_table = commutativity_rule_table;
308 anno_init->commutativity_rule_table_size = 10;
309 struct spec_annotation *init = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
311 init->annotation = anno_init;
312 cdsannotate(SPEC_ANALYSIS, init);
316 /* End of Global construct generation in class */
321 t_element * read_fetch() {
322 /* Interface begins */
323 struct anno_interface_begin *interface_begin = (struct anno_interface_begin*) malloc(sizeof(struct anno_interface_begin));
324 interface_begin->interface_num = 0; // Fetch
325 interface_begin->interface_name = "Fetch";
326 struct spec_annotation *annotation_interface_begin = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
327 annotation_interface_begin->type = INTERFACE_BEGIN;
328 annotation_interface_begin->annotation = interface_begin;
329 cdsannotate(SPEC_ANALYSIS, annotation_interface_begin);
330 t_element * __RET__ = __wrapper__read_fetch();
331 struct anno_hb_condition *hb_condition = (struct anno_hb_condition*) malloc(sizeof(struct anno_hb_condition));
332 hb_condition->interface_num = 0; // Fetch
333 hb_condition->hb_condition_num = 0;
334 struct spec_annotation *annotation_hb_condition = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
335 annotation_hb_condition->type = HB_CONDITION;
336 annotation_hb_condition->annotation = hb_condition;
337 cdsannotate(SPEC_ANALYSIS, annotation_hb_condition);
339 Fetch_info* info = (Fetch_info*) malloc(sizeof(Fetch_info));
340 info->__RET__ = __RET__;
341 struct anno_interface_end *interface_end = (struct anno_interface_end*) malloc(sizeof(struct anno_interface_end));
342 interface_end->interface_num = 0; // Fetch
343 interface_end->info = info;
344 struct spec_annotation *annoation_interface_end = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
345 annoation_interface_end->type = INTERFACE_END;
346 annoation_interface_end->annotation = interface_end;
347 cdsannotate(SPEC_ANALYSIS, annoation_interface_end);
351 t_element * __wrapper__read_fetch() {
352 unsigned int rdwr = m_rdwr.load(mo_acquire);
353 /* Automatically generated code for potential commit point: Fetch_Potential_RW_Load */
356 struct anno_potential_cp_define *potential_cp_define = (struct anno_potential_cp_define*) malloc(sizeof(struct anno_potential_cp_define));
357 potential_cp_define->label_num = 0;
358 potential_cp_define->label_name = "Fetch_Potential_RW_Load";
359 struct spec_annotation *annotation_potential_cp_define = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
360 annotation_potential_cp_define->type = POTENTIAL_CP_DEFINE;
361 annotation_potential_cp_define->annotation = potential_cp_define;
362 cdsannotate(SPEC_ANALYSIS, annotation_potential_cp_define);
367 rd = (rdwr>>16) & MASK;
371 /* Automatically generated code for commit point define: Fetch_RW_Load_Empty */
374 struct anno_cp_define *cp_define = (struct anno_cp_define*) malloc(sizeof(struct anno_cp_define));
375 cp_define->label_num = 1;
376 cp_define->label_name = "Fetch_RW_Load_Empty";
377 cp_define->potential_cp_label_num = 0;
378 cp_define->potential_label_name = "Fetch_Potential_RW_Load";
379 cp_define->interface_num = 0;
380 struct spec_annotation *annotation_cp_define = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
381 annotation_cp_define->type = CP_DEFINE;
382 annotation_cp_define->annotation = cp_define;
383 cdsannotate(SPEC_ANALYSIS, annotation_cp_define);
392 m_rdwr.compare_exchange_weak(rdwr,rdwr+(1<<16),mo_acq_rel);
393 /* Automatically generated code for commit point define check: Fetch_RW_RMW */
396 struct anno_cp_define_check *cp_define_check = (struct anno_cp_define_check*) malloc(sizeof(struct anno_cp_define_check));
397 cp_define_check->label_num = 2;
398 cp_define_check->label_name = "Fetch_RW_RMW";
399 cp_define_check->interface_num = 0;
400 struct spec_annotation *annotation_cp_define_check = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
401 annotation_cp_define_check->type = CP_DEFINE_CHECK;
402 annotation_cp_define_check->annotation = cp_define_check;
403 cdsannotate(SPEC_ANALYSIS, annotation_cp_define_check);
415 int written = m_written.load(mo_acquire);
416 /* Automatically generated code for potential commit point: Fetch_Potential_W_Load */
419 struct anno_potential_cp_define *potential_cp_define = (struct anno_potential_cp_define*) malloc(sizeof(struct anno_potential_cp_define));
420 potential_cp_define->label_num = 3;
421 potential_cp_define->label_name = "Fetch_Potential_W_Load";
422 struct spec_annotation *annotation_potential_cp_define = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
423 annotation_potential_cp_define->type = POTENTIAL_CP_DEFINE;
424 annotation_potential_cp_define->annotation = potential_cp_define;
425 cdsannotate(SPEC_ANALYSIS, annotation_potential_cp_define);
428 if ((written & MASK) != wr) {
431 printf("Fetch: m_written=%d\n", written);
436 /* Automatically generated code for commit point define: Fetch_W_Load */
439 struct anno_cp_define *cp_define = (struct anno_cp_define*) malloc(sizeof(struct anno_cp_define));
440 cp_define->label_num = 4;
441 cp_define->label_name = "Fetch_W_Load";
442 cp_define->potential_cp_label_num = 3;
443 cp_define->potential_label_name = "Fetch_Potential_W_Load";
444 cp_define->interface_num = 0;
445 struct spec_annotation *annotation_cp_define = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
446 annotation_cp_define->type = CP_DEFINE;
447 annotation_cp_define->annotation = cp_define;
448 cdsannotate(SPEC_ANALYSIS, annotation_cp_define);
452 t_element * p = & ( m_array[ rd % t_size ] );
458 void read_consume(t_element * bin) {
459 /* Interface begins */
460 struct anno_interface_begin *interface_begin = (struct anno_interface_begin*) malloc(sizeof(struct anno_interface_begin));
461 interface_begin->interface_num = 1; // Consume
462 interface_begin->interface_name = "Consume";
463 struct spec_annotation *annotation_interface_begin = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
464 annotation_interface_begin->type = INTERFACE_BEGIN;
465 annotation_interface_begin->annotation = interface_begin;
466 cdsannotate(SPEC_ANALYSIS, annotation_interface_begin);
467 __wrapper__read_consume(bin);
468 struct anno_hb_condition *hb_condition = (struct anno_hb_condition*) malloc(sizeof(struct anno_hb_condition));
469 hb_condition->interface_num = 1; // Consume
470 hb_condition->hb_condition_num = 0;
471 struct spec_annotation *annotation_hb_condition = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
472 annotation_hb_condition->type = HB_CONDITION;
473 annotation_hb_condition->annotation = hb_condition;
474 cdsannotate(SPEC_ANALYSIS, annotation_hb_condition);
476 Consume_info* info = (Consume_info*) malloc(sizeof(Consume_info));
478 struct anno_interface_end *interface_end = (struct anno_interface_end*) malloc(sizeof(struct anno_interface_end));
479 interface_end->interface_num = 1; // Consume
480 interface_end->info = info;
481 struct spec_annotation *annoation_interface_end = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
482 annoation_interface_end->type = INTERFACE_END;
483 annoation_interface_end->annotation = interface_end;
484 cdsannotate(SPEC_ANALYSIS, annoation_interface_end);
487 void __wrapper__read_consume(t_element * bin) {
489 m_read.fetch_add(1,mo_release);
490 /* Automatically generated code for commit point define check: Consume_R_RMW */
493 struct anno_cp_define_check *cp_define_check = (struct anno_cp_define_check*) malloc(sizeof(struct anno_cp_define_check));
494 cp_define_check->label_num = 5;
495 cp_define_check->label_name = "Consume_R_RMW";
496 cp_define_check->interface_num = 1;
497 struct spec_annotation *annotation_cp_define_check = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
498 annotation_cp_define_check->type = CP_DEFINE_CHECK;
499 annotation_cp_define_check->annotation = cp_define_check;
500 cdsannotate(SPEC_ANALYSIS, annotation_cp_define_check);
507 t_element * write_prepare() {
508 /* Interface begins */
509 struct anno_interface_begin *interface_begin = (struct anno_interface_begin*) malloc(sizeof(struct anno_interface_begin));
510 interface_begin->interface_num = 2; // Prepare
511 interface_begin->interface_name = "Prepare";
512 struct spec_annotation *annotation_interface_begin = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
513 annotation_interface_begin->type = INTERFACE_BEGIN;
514 annotation_interface_begin->annotation = interface_begin;
515 cdsannotate(SPEC_ANALYSIS, annotation_interface_begin);
516 t_element * __RET__ = __wrapper__write_prepare();
517 struct anno_hb_condition *hb_condition = (struct anno_hb_condition*) malloc(sizeof(struct anno_hb_condition));
518 hb_condition->interface_num = 2; // Prepare
519 hb_condition->hb_condition_num = 0;
520 struct spec_annotation *annotation_hb_condition = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
521 annotation_hb_condition->type = HB_CONDITION;
522 annotation_hb_condition->annotation = hb_condition;
523 cdsannotate(SPEC_ANALYSIS, annotation_hb_condition);
525 Prepare_info* info = (Prepare_info*) malloc(sizeof(Prepare_info));
526 info->__RET__ = __RET__;
527 struct anno_interface_end *interface_end = (struct anno_interface_end*) malloc(sizeof(struct anno_interface_end));
528 interface_end->interface_num = 2; // Prepare
529 interface_end->info = info;
530 struct spec_annotation *annoation_interface_end = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
531 annoation_interface_end->type = INTERFACE_END;
532 annoation_interface_end->annotation = interface_end;
533 cdsannotate(SPEC_ANALYSIS, annoation_interface_end);
537 t_element * __wrapper__write_prepare() {
538 unsigned int rdwr = m_rdwr.load(mo_acquire);
539 /* Automatically generated code for potential commit point: Prepare_Potential_RW_Load */
542 struct anno_potential_cp_define *potential_cp_define = (struct anno_potential_cp_define*) malloc(sizeof(struct anno_potential_cp_define));
543 potential_cp_define->label_num = 6;
544 potential_cp_define->label_name = "Prepare_Potential_RW_Load";
545 struct spec_annotation *annotation_potential_cp_define = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
546 annotation_potential_cp_define->type = POTENTIAL_CP_DEFINE;
547 annotation_potential_cp_define->annotation = potential_cp_define;
548 cdsannotate(SPEC_ANALYSIS, annotation_potential_cp_define);
553 rd = (rdwr>>16) & MASK;
556 if ( wr == ((rd + t_size)&MASK) ) {
557 /* Automatically generated code for commit point define: Prepare_RW_Load_Full */
560 struct anno_cp_define *cp_define = (struct anno_cp_define*) malloc(sizeof(struct anno_cp_define));
561 cp_define->label_num = 7;
562 cp_define->label_name = "Prepare_RW_Load_Full";
563 cp_define->potential_cp_label_num = 6;
564 cp_define->potential_label_name = "Prepare_Potential_RW_Load";
565 cp_define->interface_num = 2;
566 struct spec_annotation *annotation_cp_define = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
567 annotation_cp_define->type = CP_DEFINE;
568 annotation_cp_define->annotation = cp_define;
569 cdsannotate(SPEC_ANALYSIS, annotation_cp_define);
576 bool succ = m_rdwr.compare_exchange_weak(rdwr,(rd<<16) |
577 ((wr+1)&MASK),mo_acq_rel);
578 /* Automatically generated code for commit point define check: Prepare_RW_RMW */
581 struct anno_cp_define_check *cp_define_check = (struct anno_cp_define_check*) malloc(sizeof(struct anno_cp_define_check));
582 cp_define_check->label_num = 8;
583 cp_define_check->label_name = "Prepare_RW_RMW";
584 cp_define_check->interface_num = 2;
585 struct spec_annotation *annotation_cp_define_check = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
586 annotation_cp_define_check->type = CP_DEFINE_CHECK;
587 annotation_cp_define_check->annotation = cp_define_check;
588 cdsannotate(SPEC_ANALYSIS, annotation_cp_define_check);
600 int read = m_read.load(mo_acquire);
601 /* Automatically generated code for potential commit point: Prepare_Potential_R_Load */
604 struct anno_potential_cp_define *potential_cp_define = (struct anno_potential_cp_define*) malloc(sizeof(struct anno_potential_cp_define));
605 potential_cp_define->label_num = 9;
606 potential_cp_define->label_name = "Prepare_Potential_R_Load";
607 struct spec_annotation *annotation_potential_cp_define = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
608 annotation_potential_cp_define->type = POTENTIAL_CP_DEFINE;
609 annotation_potential_cp_define->annotation = potential_cp_define;
610 cdsannotate(SPEC_ANALYSIS, annotation_potential_cp_define);
613 if ((read & MASK) != rd)
619 /* Automatically generated code for commit point define: Prepare_R_Load */
622 struct anno_cp_define *cp_define = (struct anno_cp_define*) malloc(sizeof(struct anno_cp_define));
623 cp_define->label_num = 10;
624 cp_define->label_name = "Prepare_R_Load";
625 cp_define->potential_cp_label_num = 9;
626 cp_define->potential_label_name = "Prepare_Potential_R_Load";
627 cp_define->interface_num = 2;
628 struct spec_annotation *annotation_cp_define = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
629 annotation_cp_define->type = CP_DEFINE;
630 annotation_cp_define->annotation = cp_define;
631 cdsannotate(SPEC_ANALYSIS, annotation_cp_define);
635 t_element * p = & ( m_array[ wr % t_size ] );
641 void write_publish(t_element * bin) {
642 /* Interface begins */
643 struct anno_interface_begin *interface_begin = (struct anno_interface_begin*) malloc(sizeof(struct anno_interface_begin));
644 interface_begin->interface_num = 3; // Publish
645 interface_begin->interface_name = "Publish";
646 struct spec_annotation *annotation_interface_begin = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
647 annotation_interface_begin->type = INTERFACE_BEGIN;
648 annotation_interface_begin->annotation = interface_begin;
649 cdsannotate(SPEC_ANALYSIS, annotation_interface_begin);
650 __wrapper__write_publish(bin);
651 struct anno_hb_condition *hb_condition = (struct anno_hb_condition*) malloc(sizeof(struct anno_hb_condition));
652 hb_condition->interface_num = 3; // Publish
653 hb_condition->hb_condition_num = 0;
654 struct spec_annotation *annotation_hb_condition = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
655 annotation_hb_condition->type = HB_CONDITION;
656 annotation_hb_condition->annotation = hb_condition;
657 cdsannotate(SPEC_ANALYSIS, annotation_hb_condition);
659 Publish_info* info = (Publish_info*) malloc(sizeof(Publish_info));
661 struct anno_interface_end *interface_end = (struct anno_interface_end*) malloc(sizeof(struct anno_interface_end));
662 interface_end->interface_num = 3; // Publish
663 interface_end->info = info;
664 struct spec_annotation *annoation_interface_end = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
665 annoation_interface_end->type = INTERFACE_END;
666 annoation_interface_end->annotation = interface_end;
667 cdsannotate(SPEC_ANALYSIS, annoation_interface_end);
670 void __wrapper__write_publish(t_element * bin)
673 int tmp = m_written.fetch_add(1,mo_release);
674 /* Automatically generated code for commit point define check: Publish_W_RMW */
677 struct anno_cp_define_check *cp_define_check = (struct anno_cp_define_check*) malloc(sizeof(struct anno_cp_define_check));
678 cp_define_check->label_num = 11;
679 cp_define_check->label_name = "Publish_W_RMW";
680 cp_define_check->interface_num = 3;
681 struct spec_annotation *annotation_cp_define_check = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
682 annotation_cp_define_check->type = CP_DEFINE_CHECK;
683 annotation_cp_define_check->annotation = cp_define_check;
684 cdsannotate(SPEC_ANALYSIS, annotation_cp_define_check);
687 printf("publish: m_written=%d\n", tmp + 1);
693 template <typename t_element, size_t t_size>
694 void** mpmc_boundq_1_alt<t_element, t_size>::func_ptr_table;
695 template <typename t_element, size_t t_size>
696 hb_rule** mpmc_boundq_1_alt<t_element, t_size>::hb_rule_table;
697 template <typename t_element, size_t t_size>
698 commutativity_rule** mpmc_boundq_1_alt<t_element, t_size>::commutativity_rule_table;