use_starpu_macros.cocci 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // StarPU --- Runtime system for heterogeneous multicore architectures.
  2. //
  3. // Copyright (C) 2011-2012 inria
  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. virtual context
  16. virtual org
  17. virtual patch
  18. virtual report
  19. //
  20. // General stuff for org and report modes.
  21. //
  22. @initialize:python depends on report || org@
  23. d = { 'abort':'STARPU_ABORT', 'assert':'STARPU_ASSERT'}
  24. msg = "Please use %s rather than %s."
  25. from re import sub
  26. orgmsg = sub(r'(%[a-z])', r'=\1=', msg)
  27. @r@
  28. identifier f =~ "abort|assert";
  29. position p;
  30. @@
  31. f@p(...);
  32. @min@
  33. expression E1,E2;
  34. identifier i;
  35. position p;
  36. @@
  37. (
  38. return@p E1<E2?E1:E2;
  39. |
  40. i =@p E1<E2?E1:E2
  41. )
  42. @max@
  43. expression E1, E2;
  44. identifier i;
  45. position p;
  46. @@
  47. (
  48. return@p E1>E2?E1:E2;
  49. |
  50. i =@p E1>E2?E1:E2
  51. )
  52. //
  53. // Context mode.
  54. //
  55. @depends on context@
  56. @@
  57. * abort();
  58. @depends on context@
  59. @@
  60. * assert(...);
  61. @depends on context@
  62. identifier i;
  63. expression E1, E2;
  64. @@
  65. (
  66. * return E1<E2?E1:E2;
  67. |
  68. * i = E1<E2?E1:E2 // No semi-colon at the end, so that it
  69. |
  70. * return E1>E2?E1:E2;
  71. |
  72. * i = E1>E2?E1:E2 // No semi-colon at the end, so that it
  73. )
  74. //
  75. // Org mode.
  76. //
  77. @script:python depends on r && org@
  78. p << r.p;
  79. f << r.f;
  80. @@
  81. coccilib.org.print_todo(p[0], orgmsg % (d[str(f)], f))
  82. @script:python depends on min && org@
  83. p << min.p;
  84. @@
  85. coccilib.org.print_todo(p[0], "Please use STARPU_MIN")
  86. @script:python depends on max && org@
  87. p << max.p;
  88. @@
  89. coccilib.org.print_todo(p[0], "Please use STARPU_MAX")
  90. //
  91. // Patch mode.
  92. //
  93. @depends on patch@
  94. @@
  95. - abort();
  96. + STARPU_ABORT();
  97. @depends on patch@
  98. @@
  99. - assert(
  100. + STARPU_ASSERT(
  101. ...)
  102. @depends on patch@
  103. identifier i;
  104. expression E1, E2;
  105. @@
  106. (
  107. - return E1<E2?E1:E2;
  108. + return STARPU_MIN(E1, E2);
  109. |
  110. - i = E1<E2?E1:E2 // No semi-colon at the end, so that it
  111. + i = STARPU_MIN(E1, E2) // matches both "i = ..." and "t i = ..."
  112. |
  113. - return E1>E2?E1:E2;
  114. + return STAPU_MAX(E1, E2);
  115. |
  116. - i = E1>E2?E1:E2 // No semi-colon at the end, so that it
  117. + i = STARPU_MAX(E1, E2) // matches both "i = ..." and "t i = ..."
  118. )
  119. //
  120. // Report mode.
  121. //
  122. @script:python depends on r && report@
  123. p << r.p;
  124. f << r.f;
  125. @@
  126. coccilib.report.print_report(p[0], msg % (d[str(f)], f))
  127. @script:python depends on min && report@
  128. p << min.p;
  129. @@
  130. coccilib.report.print_report(p[0], "Please use STARPU_MIN")
  131. @script:python depends on max && report@
  132. p << max.p;
  133. @@
  134. coccilib.report.print_report(p[0], "Please use STARPU_MAX")