cbc2paje.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 Université de Bordeaux 1
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <assert.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. struct task {
  21. double start;
  22. double stop;
  23. int worker;
  24. };
  25. int main(int argc, char *argv[]) {
  26. int nw, nt;
  27. double tmax;
  28. int i, w, t, t2;
  29. int foo;
  30. double bar;
  31. unsigned long num;
  32. int b;
  33. unsigned long next = 1;
  34. if (argc != 3) {
  35. fprintf(stderr,"usage: %s nb_workers nb_tasks\n", argv[0]);
  36. exit(1);
  37. }
  38. nw = atoi(argv[1]);
  39. nt = atoi(argv[2]);
  40. fprintf(stderr,"%d workers, %d tasks\n", nw, nt);
  41. assert(scanf("Optimal - objective value %lf", &tmax) == 1);
  42. printf(
  43. "%%EventDef PajeDefineContainerType 1\n"
  44. "%% Alias string\n"
  45. "%% ContainerType string\n"
  46. "%% Name string\n"
  47. "%%EndEventDef\n"
  48. "%%EventDef PajeCreateContainer 2\n"
  49. "%% Time date\n"
  50. "%% Alias string\n"
  51. "%% Type string\n"
  52. "%% Container string\n"
  53. "%% Name string\n"
  54. "%%EndEventDef\n"
  55. "%%EventDef PajeDefineStateType 3\n"
  56. "%% Alias string\n"
  57. "%% ContainerType string\n"
  58. "%% Name string\n"
  59. "%%EndEventDef\n"
  60. "%%EventDef PajeDestroyContainer 4\n"
  61. "%% Time date\n"
  62. "%% Name string\n"
  63. "%% Type string\n"
  64. "%%EndEventDef\n"
  65. "%%EventDef PajeDefineEntityValue 5\n"
  66. "%% Alias string\n"
  67. "%% EntityType string\n"
  68. "%% Name string\n"
  69. "%% Color color\n"
  70. "%%EndEventDef\n"
  71. "%%EventDef PajeSetState 6\n"
  72. "%% Time date\n"
  73. "%% Type string\n"
  74. "%% Container string\n"
  75. "%% Value string\n"
  76. "%%EndEventDef\n"
  77. "1 W 0 Worker\n"
  78. );
  79. printf("3 S W \"Worker State\"\n");
  80. printf("5 S S Running \"0.0 1.0 0.0\"\n");
  81. printf("5 F S Idle \"1.0 0.0 0.0\"\n");
  82. for (i = 0; i < nw; i++)
  83. printf("2 0 W%d W 0 \"%d\"\n", i, i);
  84. for (w = 0; w < nw; w++)
  85. printf("4 %f W%d W\n", tmax, w);
  86. assert(scanf("%d C%d %lf %lf", &foo, &foo, &tmax, &bar) == 4);
  87. next++;
  88. {
  89. struct task task[nt];
  90. memset(&task, 0, sizeof(task));
  91. for (t = 0; t < nt; t++) {
  92. assert(scanf("%d C%d %lf %lf", &foo, &foo, &task[t].stop, &bar) == 4);
  93. next++;
  94. }
  95. while (1) {
  96. assert(scanf("%d C%lu", &foo, &num) == 2);
  97. if (num >= next +
  98. /* FIXME */
  99. //nw*nt
  100. 8*20 + 5*16
  101. ) {
  102. next+= 8*20+5*16;
  103. break;
  104. }
  105. /* FIXME */
  106. if (num-next < 8*20) {
  107. t = (num - next) / nw;
  108. w = (num - next) % nw;
  109. } else {
  110. unsigned long nnum = (num-next)-8*20;
  111. t = (nnum / 5) + 20;
  112. w = (nnum % 5)+3;
  113. }
  114. assert(scanf("%d %lf", &b, &bar) == 2);
  115. if (b) {
  116. task[t].worker = w;
  117. fprintf(stderr,"%lu: task %d on %d: %f\n", num, t, w, task[t].stop);
  118. }
  119. }
  120. while(1) {
  121. t = num - next;
  122. if (t > nt)
  123. break;
  124. assert(scanf("%lf %lf", &task[t].start, &bar) == 2);
  125. assert(scanf("%d C%lu", &foo, &num) == 2);
  126. }
  127. for (t = 0; t < nt; t++) {
  128. printf("6 %f S W%d S\n", task[t].start, task[t].worker);
  129. printf("6 %f S W%d F\n", task[t].stop, task[t].worker);
  130. }
  131. for (t = 0; t < nt; t++) {
  132. for (t2 = 0; t2 < nt; t2++) {
  133. if (t != t2 && task[t].worker == task[t2].worker) {
  134. if (!(task[t].start >= task[t2].stop
  135. || task[t2].start >= task[t].stop)) {
  136. fprintf(stderr,"oops, %d and %d sharing worker %d !!\n", t, t2, task[t].worker);
  137. }
  138. }
  139. }
  140. }
  141. }
  142. return 0;
  143. }