use_starpu_macros.cocci 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. @r@
  26. identifier f =~ "abort|assert";
  27. position p;
  28. @@
  29. f@p(...);
  30. @min@
  31. expression E1,E2;
  32. identifier i;
  33. position p;
  34. @@
  35. (
  36. return@p E1<E2?E1:E2;
  37. |
  38. i =@p E1<E2?E1:E2
  39. )
  40. @max@
  41. expression E1, E2;
  42. identifier i;
  43. position p;
  44. @@
  45. (
  46. return@p E1>E2?E1:E2;
  47. |
  48. i =@p E1>E2?E1:E2
  49. )
  50. //
  51. // Context mode.
  52. //
  53. @depends on context@
  54. @@
  55. * abort();
  56. @depends on context@
  57. @@
  58. * assert(...);
  59. @depends on context@
  60. identifier i;
  61. expression E1, E2;
  62. @@
  63. (
  64. * return E1<E2?E1:E2;
  65. |
  66. * i = E1<E2?E1:E2 // No semi-colon at the end, so that it
  67. |
  68. * return E1>E2?E1:E2;
  69. |
  70. * i = E1>E2?E1:E2 // No semi-colon at the end, so that it
  71. )
  72. //
  73. // Org mode.
  74. //
  75. @script:python depends on r && org@
  76. p << r.p;
  77. f << r.f;
  78. @@
  79. coccilib.org.print_todo(p[0], msg % (d[str(f)], f))
  80. @script:python depends on min && org@
  81. p << min.p;
  82. @@
  83. coccilib.org.print_todo(p[0], "Please use STARPU_MIN")
  84. @script:python depends on max && org@
  85. p << max.p;
  86. @@
  87. coccilib.org.print_todo(p[0], "Please use STARPU_MAX")
  88. //
  89. // Patch mode.
  90. //
  91. @depends on patch@
  92. @@
  93. - abort();
  94. + STARPU_ABORT();
  95. @depends on patch@
  96. @@
  97. - assert(
  98. + STARPU_ASSERT(
  99. ...)
  100. @depends on patch@
  101. identifier i;
  102. expression E1, E2;
  103. @@
  104. (
  105. - return E1<E2?E1:E2;
  106. + return STARPU_MIN(E1, E2);
  107. |
  108. - i = E1<E2?E1:E2 // No semi-colon at the end, so that it
  109. + i = STARPU_MIN(E1, E2) // matches both "i = ..." and "t i = ..."
  110. |
  111. - return E1>E2?E1:E2;
  112. + return STAPU_MAX(E1, E2);
  113. |
  114. - i = E1>E2?E1:E2 // No semi-colon at the end, so that it
  115. + i = STARPU_MAX(E1, E2) // matches both "i = ..." and "t i = ..."
  116. )
  117. //
  118. // Report mode.
  119. //
  120. @script:python depends on r && report@
  121. p << r.p;
  122. f << r.f;
  123. @@
  124. coccilib.report.print_report(p[0], msg % (d[str(f)], f))
  125. @script:python depends on min && report@
  126. p << min.p;
  127. @@
  128. coccilib.report.print_report(p[0], "Please use STARPU_MIN")
  129. @script:python depends on max && report@
  130. p << max.p;
  131. @@
  132. coccilib.report.print_report(p[0], "Please use STARPU_MAX")