This file is indexed.

/usr/share/starpu/gdbinit is in starpu-tools 1.2.3+dfsg-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
# StarPU --- Runtime system for heterogeneous multicore architectures.
#
# Copyright (C) 2010-2016  Université de Bordeaux
# Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
#
# StarPU is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# StarPU is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU Lesser General Public License in COPYING.LGPL for more details.

# To set a breakpoint when starting gdb with option "-ex run",
# here what you need to do:
#set breakpoint pending on
#break starpu_mpi.c:419

define starpu-print-job
  set language c
  set $job = (struct _starpu_job *)$arg0

  printf "StarPU Job (%p)\n", $job
  if ($job != 0)
    printf "\ttask:\t\t\t\t<%p>\n", $job->task
    printf "\tsubmitted:\t\t\t<%d>\n", $job->submitted
    printf "\tterminated:\t\t\t<%d>\n", $job->terminated
    printf "\tjob_id:\t\t\t\t<%d>\n", $job->job_id
    if $job->task && $job->task->name
        printf "\tname:\t\t\t\t<%s>\n", $job->task->name
    end
  end
end

document starpu-print-job
Prints a StarPU job
end

define starpu-print-task
  set language c
  set $task = (struct starpu_task *)$arg0
  set $job = (struct _starpu_job *)$task->starpu_private
  set $status=0
  if $task->status == 0
    set $status="STARPU_TASK_INVALID"
  end
  if $task->status == 1
    set $status="STARPU_TASK_BLOCKED"
  end
  if $task->status == 2
    set $status="STARPU_TASK_READY"
  end
  if $task->status == 3
    set $status="STARPU_TASK_RUNNING"
  end
  if $task->status == 4
    set $status="STARPU_TASK_FINISHED"
  end
  if $task->status == 5
    set $status="STARPU_TASK_BLOCKED_ON_TAG"
  end
  if $task->status == 6
    set $status="STARPU_TASK_BLOCKED_ON_TASK"
  end
  if $task->status == 7
    set $status="STARPU_TASK_BLOCKED_ON_DATA"
  end
  if $task->status == 8
    set $status="STARPU_TASK_STOPPED"
  end

  printf "StarPU Task (%p)\n", $task
  if $task->name
    printf "\tname:\t\t\t\t<%s>\n", $task->name
  end
  printf "\tcodelet:\t\t\t<%p>\n", $task->cl
  printf "\tcallback:\t\t\t<%p>\n", $task->callback_func
  printf "\tsynchronous:\t\t\t<%d>\n", $task->synchronous
  printf "\texecute_on_a_specific_worker:\t<%d>\n", $task->execute_on_a_specific_worker
  printf "\tworkerid:\t\t\t<%d>\n", $task->workerid
  printf "\tdetach:\t\t\t\t<%d>\n", $task->detach
  printf "\tdestroy:\t\t\t<%d>\n", $task->destroy
  printf "\tregenerate:\t\t\t<%d>\n", $task->regenerate
  printf "\tstatus:\t\t\t\t<%s>\n", $status
  printf "\tjob:\t\t\t\t<%p>\n", $job
  printf "\tndeps:\t\t\t\t<%u>\n", $job->job_successors->ndeps
  printf "\tndeps_completed:\t\t<%u>\n", $job->job_successors->ndeps_completed
  printf "\tnsuccs:\t\t\t\t<%u>\n", $job->job_successors->nsuccs
  if $job
    starpu-print-job $job
  end
end

define starpu-print-task-and-successor
  set language c
  set $t = (struct starpu_task *) ($arg0)
  starpu-print-task $t
  set $j = (struct _starpu_job *) $t->starpu_private
  set $nsuccs = $j->job_successors.nsuccs
  set $i = 0
  while $i < $nsuccs
    set $cg = $j->job_successors.succ[$i]
    if ($cg->cg_type == 1)
      # STARPU_CG_APPS
      printf "waited for by application"
    end
    if ($cg->cg_type == 2)
      # STARPU_CG_TAG
      printf "will produce tag %x\n", $cg->succ.tag
    end
    if ($cg->cg_type == 4)
      # STARPU_CG_TASK
      printf "dep of task %p\n", $cg->succ.job
      starpu-print-task $cg->succ.job->task
    end
    set $i = $i + 1
  end
end

document starpu-print-task
Prints a StarPU task
end

define starpu-tasks-on-worker
  set language c
  set $worker=_starpu_config->workers[$arg0]
  set $task=$worker.local_tasks.head
  while $task != 0x0
    starpu-print-task $task
    set $task=$task->next
  end
end

define starpu-tasks-on-workers
  set language c
  set $num=0
  while $num<_starpu_config->topology->nworkers
    printf "Worker %s\n", _starpu_config->workers[$num].name
    starpu-tasks-on-worker $num
    set $num = $num + 1
  end
end

define starpu-workers
  set language c
  set $num=0
  printf "[Id] Name                                     Arch Mask Devid Bindid Workerid Isrunning Isinitialized Status\n"
  while $num<_starpu_config->topology->nworkers
    set $worker=&_starpu_config->workers[$num]
    if $worker->status == STATUS_INVALID
      set $status="INVALID"
    end
    if $worker->status == STATUS_UNKNOWN
      set $status="UNKNOWN"
    end
    if $worker->status == STATUS_INITIALIZING
      set $status="INITIALIZING"
    end
    if $worker->status == STATUS_EXECUTING
      set $status="EXECUTING"
    end
    if $worker->status == STATUS_CALLBACK
      set $status="CALLBACK"
    end
    if $worker->status == STATUS_SCHEDULING
      set $status="SCHEDULING"
    end
    if $worker->status == STATUS_WAITING
      set $status="WAITING"
    end
    if $worker->status == STATUS_SLEEPING
      set $status="SLEEPING"
    end
    if $worker->status == STATUS_WAKING_UP
      set $status="WAKING_UP"
    end
    printf "[%2d] %-40s %-4d %-4d %-5d %-6d %-8d %-9d %-13d %s\n", $num, $worker->name, $worker->arch, $worker->worker_mask, \
          $worker->devid, $worker->bindid, $worker->workerid, $worker->worker_is_running, $worker->worker_is_initialized, $status
    set $num = $num + 1
  end
end

document starpu-workers
Prints a list of the StarPU workers
end

define starpu-tags
  printf "tags htbl %p\n", tag_htbl
  printf "TODO\n"
end

define starpu-tasks
  set language c
  set $num=0
  set $nsubmitted=0
  set $nready=0
  while $num<_starpu_config->topology->nsched_ctxs
  	set $nsubmitted = $nsubmitted + _starpu_config->sched_ctxs[$num]->tasks_barrier->barrier->reached_start
  	set $nready = $nready + _starpu_config->sched_ctxs[$num]->ready_tasks_barrier->barrier->reached_start
	set $num = $num + 1
  end
  printf "%d submitted tasks\n", $nsubmitted
  printf "%d ready tasks\n", $nready
  printf "Tasks being run:\n"
  set $n = 0
  while $n < _starpu_config.topology.nworkers
    printf "worker %d %s:\n", $n, _starpu_config.workers[$n].short_name
    if _starpu_config.workers[$n].pipeline_length > 0
      set $m = 0
      while $m < _starpu_config.workers[$n].ntasks
        set $t = _starpu_config.workers[$n].current_tasks[(_starpu_config.workers[$n].first_task + $m) % (sizeof(_starpu_config.workers[$n].current_tasks)/sizeof(_starpu_config.workers[$n].current_tasks[0]))]
        printf "  task %p\n", $t
        set $m = $m + 1
      end
    end
    set $task = _starpu_config.workers[$n].current_task
    if ($task)
      printf "  task %p\n", $task
    end
    set $n = $n + 1
  end
  if (tag_htbl)
    printf "TODO: tags\n"
  end
  print "TODO: complete\n"
end

define starpu-print-all-tasks
  set language c
  set $l = all_jobs_list->next
  while $l != &all_jobs_list
    set $j = (struct _starpu_job*) (((unsigned long) $l) - ((unsigned long) &((struct _starpu_job *)0)->all_submitted))
    printf "task %p\n", $j->task
    starpu-print-task $j->task
    set $l = $l->next
  end
end

define starpu-all-tasks
  set language c
  set $l = all_jobs_list->next
  while $l != &all_jobs_list
    set $j = (struct _starpu_job*) (((unsigned long) $l) - ((unsigned long) &((struct _starpu_job *)0)->all_submitted))
    printf "task %p\n", $j->task
    set $l = $l->next
  end
end

define starpu
  printf "Here I am...\n"
end

define starpu-print-mode
  if ($arg0 & 1)
    printf "R"
  end
  if ($arg0 & 2)
    printf "W"
  end
  if ($arg0 & 4)
    printf " SCRATCH"
  end
  if ($arg0 & 8)
    printf " REDUX"
  end
end

define starpu-print-data
  set language c
  set $data = (starpu_data_handle_t) $arg0
  printf "Data handle %p\n", $data
  if $data->ops->interfaceid == 0
    printf "Matrix\n"
  end
  if $data->ops->interfaceid == 1
    printf "Block\n"
  end
  if $data->ops->interfaceid == 2
    printf "Vector\n"
  end
  if $data->ops->interfaceid == 3
    printf "CSR\n"
  end
  if $data->ops->interfaceid == 4
    printf "BCSR\n"
  end
  if $data->ops->interfaceid == 5
    printf "Variable\n"
  end
  if $data->ops->interfaceid == 6
    printf "Void\n"
  end
  if $data->ops->interfaceid == 7
    printf "Multiformat\n"
  end
  if $data->ops->interfaceid == 8
    printf "COO\n"
  end
  if $data->ops->interfaceid > 8
    printf "Interface id %d\n", $data->ops->interfaceid
  end
  printf "Home node %d\n", $data->home_node
  printf "RWlock refs %d\n", $data->refcnt
  printf "Busy count %d\n", $data->busy_count
  printf "Current mode "
  starpu-print-mode $data->current_mode
  printf "\n"
  if $data->current_mode & (4|8)
    set $n = 0
    while $n < _starpu_config.topology.nworkers
      set $replicate = $data->per_worker[$n]
      printf "Worker %2d %10s:", $n, _starpu_config->workers[$n]->name
      if $replicate.state == 0
        printf " OWNER"
      end
      if $replicate.state == 1
        printf " SHARED"
      end
      if $replicate.state == 2
        printf " INVALID"
      end
      if $replicate.initialized
        printf " initialized"
      end
      printf "\n"
      set $n = $n + 1
    end
  else
    set $n = 0
    while $n < _starpu_descr.nnodes
      set $replicate = &$data->per_node[$n]
      printf "Node %2d (%2d):", $n, $replicate->refcnt
      if $replicate.state == 0
        printf " OWNER"
      end
      if $replicate.state == 1
        printf " SHARED"
      end
      if $replicate.state == 2
        printf " INVALID"
      end
      if $replicate.initialized
        printf " initialized"
      end
      printf "\n"
      set $m = 0
      while $m < _starpu_descr.nnodes
        if $replicate->request[$m]
	  printf " request %p from %d\n", $replicate->request[$m], $m
	end
        set $m = $m + 1
      end
      set $n = $n + 1
    end
    set $r = $data->write_invalidation_req
    if $r
      printf "w_req %p for %d\n", $r, $r->dst_replicate->memory_node
    end
  end
  printf "Post sync tasks\n"
  set $tasklist = $data->post_sync_tasks
  while $tasklist != 0x0
    starpu-print-task $tasklist->task
    set $tasklist = $tasklist->next
  end
  printf "Requester tasks\n"
  set $requesterlist = $data->req_list._head
  while $requesterlist != 0x0
    printf "mode: "
    starpu-print-mode $requesterlist->mode
    printf "\n"
    starpu-print-job $requesterlist->j
    set $requesterlist = $requesterlist->_next
  end
  printf "Arbitered requester tasks\n"
  set $requesterlist = $data->arbitered_req_list._head
  while $requesterlist != 0x0
    printf "mode: "
    starpu-print-mode $requesterlist->mode
    printf "\n"
    starpu-print-job $requesterlist->j
    set $requesterlist = $requesterlist->_next
  end
  if ($data->nchildren)
    printf "%d children\n", $data->nchildren
  end
end

define starpu-print-datas
  set $entry = registered_handles
  while $entry
    starpu-print-data $entry->handle
    printf "\n"
    set $entry = (struct handle_entry *) $entry.hh.next
  end
end

define starpu-print-datas-summary
  set language c
  set $entry = registered_handles

  set $data_n = 0
  set $pw_data_n = 0
  set $data_n_allocated = 0
  set $replicate_n_owners = 0
  set $replicate_n_shared = 0
  set $replicate_n_invalid = 0
  set $replicate_n_initialized = 0
  set $replicate_n_allocated = 0
  set $pw_replicate_n_owners = 0
  set $pw_replicate_n_shared = 0
  set $pw_replicate_n_invalid = 0
  set $pw_replicate_n_initialized = 0
  set $pw_replicate_n_allocated = 0

  while $entry
    set $data = (starpu_data_handle_t) $entry->handle

    if $data->current_mode & (4|8)
      set $pw_data_n = $pw_data_n + 1
      set $n = 0
      while $n < _starpu_config.topology.nworkers
        set $replicate = $data->per_worker[$n]
        if $replicate.state == 0
          set $pw_replicate_n_owners = $pw_replicate_n_owners + 1
        end
        if $replicate.state == 1
          set $pw_replicate_n_shared = $pw_replicate_n_shared + 1
        end
        if $replicate.state == 2
          set $pw_replicate_n_invalid = $pw_replicate_n_invalid + 1
        end
        if $replicate.initialized
          set $pw_replicate_n_initialized = $pw_replicate_n_initialized + 1
        end
        if $replicate.allocated
          set $pw_replicate_n_allocated = $pw_replicate_n_allocated + 1
        end
        set $n = $n + 1
      end
    else
      set $data_n = $data_n + 1
      set $n = 0
      while $n < _starpu_descr.nnodes
        set $replicate = &$data->per_node[$n]
        if $replicate.state == 0
          set $replicate_n_owners = $replicate_n_owners + 1
        end
        if $replicate.state == 1
          set $replicate_n_shared = $replicate_n_shared + 1
        end
        if $replicate.state == 2
          set $replicate_n_invalid = $replicate_n_invalid + 1
        end
        if $replicate.initialized
          set $replicate_n_initialized = $replicate_n_initialized + 1
        end
        if $replicate.allocated
          set $replicate_n_allocated = $replicate_n_allocated + 1
	  set $data_allocated = 1
        end
        set $n = $n + 1
      end
      if $data_allocated
        set $data_n_allocated = $data_n_allocated + 1
      end
    end
    set $entry = (struct handle_entry *) $entry.hh.next
  end
  printf "Number of handles: %d\n", $data_n
  printf "Number of allocated handles: %d\n", $data_n_allocated
  printf "Number of OWNER replicates: %d\n", $replicate_n_owners
  printf "Number of SHARED replicates: %d\n", $replicate_n_shared
  printf "Number of INVALID replicates: %d\n", $replicate_n_invalid
  printf "Number of initialized replicates: %d\n", $replicate_n_initialized
  printf "Number of allocated replicates: %d\n", $replicate_n_allocated

  printf "Number of per-worker handles: %d\n", $pw_data_n
  printf "Number of OWNER per-worker replicates: %d\n", $pw_replicate_n_owners
  printf "Number of SHARED per-worker replicates: %d\n", $pw_replicate_n_shared
  printf "Number of INVALID per-worker replicates: %d\n", $pw_replicate_n_invalid
  printf "Number of initialized per-worker replicates: %d\n", $pw_replicate_n_initialized
  printf "Number of allocated per-worker replicates: %d\n", $pw_replicate_n_allocated
end

define starpu-print-request
  set $r = (struct _starpu_data_request *)$arg0
  printf "Request %p\n", $r
  printf "Refcnt %d\n", $r->refcnt
  printf "Handle %p\n", $r->handle
  printf "src_replicate %p\n", $r->src_replicate
  printf "dst_replicate %p\n", $r->dst_replicate
  printf "handling_node %d\n", $r->handling_node
  if ($r->mode & 1)
    printf "R"
  end
  if ($r->mode & 2)
    printf "W"
  end
  if ($r->mode & 4)
    printf "S"
  end
  if ($r->mode & 8)
    printf "X"
  end
  printf "\n"
  printf "completed: %d\n", $r->completed
  printf "prefetch: %d\n", $r->prefetch
  printf "retval: %d\n", $r->retval
  printf "ndeps: %d\n", $r->ndeps
  printf "next_req_count: %d\n", $r->next_req_count
  printf "comid: %u\n", $r->com_id
  set $c = $r->callbacks
  while $c != 0
    printf "callback: %p %p\n", $c->callback_func, $c->callback_arg
    set $c = $c->next
  end
end

define starpu-print-requests
  set $node = 0
  while $node < _starpu_descr.nnodes
    printf "Node %u:\n", $node
    set $request = data_requests[$node]._head
    while $request != 0
      printf " Request %p: handle %p ", $request, $request->handle
      starpu-print-mode $request->mode
      printf "\n"
      set $request = $request->_next
    end
    set $node = $node + 1
  end
end

define starpu-print-prequests
  set $node = 0
  while $node < _starpu_descr.nnodes
    printf "Node %u:\n", $node
    printf "%u pending requests\n", data_requests_npending[$node]
    set $request = data_requests_pending[$node]._head
    while $request != 0
      printf " Request %p: handle %p ", $request, $request->handle
      starpu-print-mode $request->mode
      printf "\n"
      set $request = $request->_next
    end
    set $node = $node + 1
  end
end

define starpu-print-arch
  set $arch = (struct starpu_perfmodel_arch *)$arg0
  set $device = 0
  while $device < $arch->ndevices
    printf "  Device type %d - devid: %d - ncores: %d\n", $arch->devices[$device].type, $arch->devices[$device].devid, $arch->devices[$device].ncores
    set $device = $device + 1
  end
end

define starpu-print-archs
  set $comb = 0
  while $comb < current_arch_comb
    printf "Combination %d with %d devices\n", $comb, arch_combs[$comb]->ndevices
    starpu-print-arch arch_combs[$comb]
    set $comb = $comb + 1
  end
end

define starpu-print-frequests
  set $node = 0
  while $node < _starpu_descr.nnodes
    printf "Node %u:\n", $node
    set $request = prefetch_requests[$node]._head
    while $request != 0
      printf " Request %p: handle %p ", $request, $request->handle
      starpu-print-mode $request->mode
      printf "\n"
      set $request = $request->_next
    end
    set $node = $node + 1
  end
end

define starpu-print-irequests
  set $node = 0
  while $node < _starpu_descr.nnodes
    printf "Node %u:\n", $node
    set $request = idle_requests[$node]._head
    while $request != 0
      printf " Request %p: handle %p ", $request, $request->handle
      starpu-print-mode $request->mode
      printf "\n"
      set $request = $request->_next
    end
    set $node = $node + 1
  end
end

define starpu-memusage
  set scheduler-locking on
  set $node = 0
  while $node < _starpu_descr.nnodes
    printf "\n\nNode %u:\n", $node
    set $total = 0
    set $total_b = 0
    set $wt = 0
    set $wt_b = 0
    set $home = 0
    set $home_b = 0
    set $redux = 0
    set $redux_b = 0
    set $relax = 0
    set $relax_b = 0
    set $noref = 0
    set $noref_b = 0
    set $nodataref = 0
    set $nodataref_b = 0
    set $nosubdataref = 0
    set $nosubdataref_b = 0
    set $mc = mc_list[$node]->_head
    while $mc != 0
      set $handle = $mc->data
      set $size = _starpu_data_get_size($handle)
      set $total = $total + 1
      set $total_b = $total_b + $size
      if $handle->wt_mask & (1 << $node)
        set $wt = $wt + 1
	set $wt_b = $wt_b + $size
      end
      if $node == $handle->home_node
        set $home = $home + 1
	set $home_b = $home_b + $size
      end
      if $mc->relaxed_coherency == 2
        set $redux = $redux + 1
	set $redux_b = $redux_b + $size
      end
      if $mc->relaxed_coherency == 1
        set $relax = $relax + 1
	set $relax_b = $relax_b + $size
        if $mc->replicate
          if $mc->replicate->refcnt == 0
            set $noref = $noref + 1
	    set $noref_b = $noref_b + $size
          end
        end
      end
      if $mc->relaxed_coherency == 0
        if (may_free_subtree($handle,$node))
	  set $nosubdataref = $nosubdataref + 1
	  set $nosubdataref_b = $nosubdataref_b + $size
	end
        if $handle->per_node[$node].refcnt == 0
          set $nodataref = $nodataref + 1
	  set $nodataref_b = $nodataref_b + $size
        end
      end
      set $mc = $mc->_next
    end
    printf "  Total used: %u, %uMiB\n", $total, $total_b / 1048576
    printf "  WT: %u, %uMiB\n", $wt, $wt_b / 1048576
    printf "  home: %u, %uMiB\n", $home, $home_b / 1048576
    printf "  redux: %u, %uMiB\n", $redux, $redux_b / 1048576
    printf "  relax: %u, %uMiB\n", $relax, $relax_b / 1048576
    printf "  noref: %u, %uMiB\n", $noref, $noref_b / 1048576
    printf "  nosubdataref: %u, %uMiB\n", $nosubdataref, $nosubdataref_b / 1048576
    printf "  nodataref: %u, %uMiB\n", $nodataref, $nodataref_b / 1048576
    printf "\n  cached: %u, %uMiB\n", mc_cache_nb[$node], mc_cache_size[$node] / 1048576
    set $node = $node + 1
  end
end

define starpu-print-model
    set $model = (struct starpu_perfmodel *)$arg0
    printf "Model %p type %d symbol ", $model, $model->type
    if $model->symbol
       printf "%s", $model->symbol
    else
       printf "NULL"
    end
    printf "\n"
end

define starpu-print-registered-models
    set $node = registered_models
    while $node
    	  starpu-print-model $node->model
	  set $node = $node->next
    end
end

define starpu-mpi-print-request
    set $request = (struct _starpu_mpi_req *)$arg0
    set $request_type = "unknown_type"
    if $request->request_type == SEND_REQ
       set $request_type = "SEND_REQ"
    end
    if $request->request_type == RECV_REQ
       set $request_type = "RECV_REQ"
    end
    if $request->request_type == WAIT_REQ
       set $request_type = "WAIT_REQ"
    end
    if $request->request_type == TEST_REQ
       set $request_type = "TEST_REQ"
    end
    if $request->request_type == BARRIER_REQ
       set $request_type = "BARRIER_REQ"
    end
    if $request->request_type == PROBE_REQ
       set $request_type = "PROBE_REQ"
    end
    if $request->request_type == UNKNOWN_REQ
       set $request_type = "UNKNOWN_REQ"
    end
    printf "Request (struct _starpu_mpi_req *) %p data %p tag %d to MPI node %d type %s submitted %d completed %d posted %d detached %d is_internal_req %d\n", $request, $request->data_handle, $request->data_handle ? ((struct _starpu_mpi_node_tag *) ($request->data_handle->mpi_data))->data_tag : -1, $request->node_tag.rank, $request_type, $request->submitted, $request->completed, $request->posted, $request->detached, $request->is_internal_req
end

define starpu-mpi-print-ready-requests
    set $list = (struct _starpu_mpi_req_list *) ready_requests
    if $list
	set $request = $list->_head
        while $request
            starpu-mpi-print-request $request
	    set $request = $request->_next
	end
    else
	printf "No ready requests\n"
    end
end

define starpu-mpi-print-detached-requests
    set $list = (struct _starpu_mpi_req_list *) detached_requests
    if $list
	set $request = $list->_head
        while $request
            starpu-mpi-print-request $request
	    set $request = $request->_next
	end
    else
	printf "No detached requests\n"
    end
end

define starpu-mpi-print-early-data
  set $hash = (struct _starpu_mpi_early_data_handle_hashlist *)_starpu_mpi_early_data_handle_hashmap
  if $hash
     while $hash
       printf "Communicator %p Rank %d Data_tag %d\n", $hash->node_tag->comm, $hash->node_tag->rank, $hash->node_tag->data_tag
       set $list = (struct _starpu_mpi_early_data_handle_list *) $hash->list
       if $list
  	  set $data = (struct _starpu_mpi_early_data_handle *)$list->_head
          while $data
             starpu-mpi-print-request $data->req
	     set $data = $data->_next
	  end
       end
       set $hash = (struct _starpu_mpi_early_data_handle_hashlist *) $hash->hh.next
     end
  else
     printf "No early data\n"
  end
end

define starpu-mpi-print-early-requests
  set $hash = (struct _starpu_mpi_early_request_hashlist *)_starpu_mpi_early_request_hash
  if $hash
     while $hash
       printf "Communicator %p Rank %d Data_tag %d\n", $hash->node_tag->comm, $hash->node_tag->rank, $hash->node_tag->data_tag
       set $list = (struct _starpu_mpi_req_list*) $hash->list
       if $list
  	  set $request = $list->_head
          while $request
             starpu-mpi-print-request $request
	     set $request = $request->_next
	  end
       end
       set $hash = (struct _starpu_mpi_early_request_hashlist *) $hash->hh.next
     end
  else
     printf "No early request\n"
  end
end

define starpu-mpi-print-sync-data
  set $hash = (struct _starpu_mpi_sync_data_handle_hashlist *)_starpu_mpi_sync_data_handle_hashmap
  if $hash
     while $hash
       printf "Communicator %p Rank %d Data_tag %d\n", $hash->node_tag->comm, $hash->node_tag->rank, $hash->node_tag->data_tag
       set $list = (struct _starpu_mpi_req_list *) $hash->list
       if $list
  	  set $request = $list->_head
          while $request
             starpu-mpi-print-request $request
	     set $request = $request->_next
	  end
       end
       set $hash = (struct _starpu_mpi_sync_data_handle_hashlist *) $hash->hh.next
     end
  else
     printf "No sync data\n"
  end
end

document starpu
List of StarPU-specific gdb functions:
starpu-workers                     prints a list of the StarPU workers
starpu-tasks-on-workers            prints a list of the tasks queued on workers
starpu-tasks-on-worker             prints a list of the tasks queued on the given worker
starpu-print-job                   prints a StarPU job
starpu-print-task                  prints a StarPU task
starpu-print-all-tasks             prints all StarPU tasks
starpu-print-task-and-successor    prints a StarPU task and its successors
starpu-print-data                  prints a StarPU data handle
starpu-print-datas                 prints all StarPU data handles
starpu-print-datas-summary         prints a summary of data handles
starpu-print-request               prints a StarPU data request
starpu-print-prequests             prints all pending StarPU data requests
starpu-print-requests              prints all queued StarPU data requests
starpu-print-frequests             prints all queued StarPU prefetch data requests
starpu-print-irequests             prints all queued StarPU idle data requests
starpu-tasks                       prints a summary of the tasks flowing in StarPU
starpu-all-tasks                   prints a list of all the tasks flowing in StarPU
starpu-tags                        prints a list of the tags known to StarPU
starpu-memusage                    prints the memory node usage
starpu-print-archs                 prints all known arch combinations
starpu-print-arch                  prints a given arch combination
starpu-print-registered-models     prints all registered performance models
starpu-print-model                 prints a given performance model
starpu-mpi-print-ready-requests    prints all MPI ready requests
starpu-mpi-print-detached-requests prints all MPI detached requests
starpu-mpi-print-early-data        prints all MPI early received data
starpu-mpi-print-early-requests    prints all MPI early requests
starpu-mpi-print-sync-data         prints all MPI sync data
end