cpu_func_to_cpu_funcs.cocci 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // StarPU --- Runtime system for heterogeneous multicore architectures.
  2. //
  3. // Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
  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. // $ spatch -sp_file cpu_func_to_cpu_funcs.cocci cpu_func_to_cpu_funcs_test.c
  16. ///////////////////////////////////////////////////////////////////////////////
  17. // There is no need to specify STARPU_MULTIPLE_CPU_IMPLEMENTATIONS any more. //
  18. // XXX : We must find a way to make sure cpu_funcs is NULL-terminated. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20. @@
  21. identifier cl;
  22. @@
  23. struct starpu_codelet cl = {
  24. - .cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS,
  25. .cpu_funcs = { ...
  26. - }
  27. + ,NULL}
  28. };
  29. ////////////////////////////////////////////////////////////////////////////////
  30. // The previous rule may have added "NULL" twice in the initialization of the //
  31. // cpu_funcs field. Let's take care of that. //
  32. ////////////////////////////////////////////////////////////////////////////////
  33. @@
  34. identifier cl;
  35. @@
  36. struct starpu_codelet cl = {
  37. .cpu_funcs = { ..., NULL
  38. - ,NULL
  39. }
  40. };
  41. ////////////////////////////////////////////////////
  42. // Find all the codelets using the cpu_func field //
  43. ////////////////////////////////////////////////////
  44. @cpu_func@
  45. expression f;
  46. identifier cl;
  47. @@
  48. struct starpu_codelet cl = {
  49. .cpu_func = f
  50. };
  51. ///////////////////////////////////////////////////////////////////
  52. // Find all the codelets that define both cpu_func and cpu_funcs //
  53. ///////////////////////////////////////////////////////////////////
  54. @cpu_funcs depends on cpu_func@
  55. expression cpu_func.f;
  56. identifier cpu_func.cl;
  57. @@
  58. struct starpu_codelet cl = {
  59. .cpu_funcs = { f, NULL }
  60. };
  61. //////////////////////////////////////////////////////////////////////////////
  62. // For codelets that define cpu_func but not cpu_funcs, remove cpu_func and //
  63. // add cpu_funcs //
  64. //////////////////////////////////////////////////////////////////////////////
  65. @depends on !cpu_funcs@
  66. identifier cpu_func.cl;
  67. expression cpu_func.f;
  68. @@
  69. struct starpu_codelet cl = {
  70. - .cpu_func = f
  71. + .cpu_funcs = { f, NULL }
  72. };
  73. /////////////////////////////////////////////////////////////////
  74. // If both cpu_func and cpu_funcs are defined, remove cpu_func //
  75. /////////////////////////////////////////////////////////////////
  76. @depends on cpu_funcs@
  77. identifier cpu_func.cl;
  78. expression cpu_func.f;
  79. @@
  80. struct starpu_codelet cl = {
  81. - .cpu_func = f
  82. };