cpu_func_to_cpu_funcs.cocci 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // $ spatch -sp_file cpu_func_to_cpu_funcs.cocci cpu_func_to_cpu_funcs_test.c
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // There is no need to specify STARPU_MULTIPLE_CPU_IMPLEMENTATIONS any more. //
  4. // XXX : We must find a way to make sure cpu_funcs is NULL-terminated. //
  5. ///////////////////////////////////////////////////////////////////////////////
  6. @@
  7. identifier cl;
  8. @@
  9. struct starpu_codelet cl = {
  10. - .cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS,
  11. .cpu_funcs = { ...
  12. - }
  13. + ,NULL}
  14. };
  15. ////////////////////////////////////////////////////////////////////////////////
  16. // The previous rule may have added "NULL" twice in the initialization of the //
  17. // cpu_funcs field. Let's take care of that. //
  18. ////////////////////////////////////////////////////////////////////////////////
  19. @@
  20. identifier cl;
  21. @@
  22. struct starpu_codelet cl = {
  23. .cpu_funcs = { ..., NULL
  24. - ,NULL
  25. }
  26. };
  27. ////////////////////////////////////////////////////
  28. // Find all the codelets using the cpu_func field //
  29. ////////////////////////////////////////////////////
  30. @cpu_func@
  31. expression f;
  32. identifier cl;
  33. @@
  34. struct starpu_codelet cl = {
  35. .cpu_func = f
  36. };
  37. ///////////////////////////////////////////////////////////////////
  38. // Find all the codelets that define both cpu_func and cpu_funcs //
  39. ///////////////////////////////////////////////////////////////////
  40. @cpu_funcs depends on cpu_func@
  41. expression cpu_func.f;
  42. identifier cpu_func.cl;
  43. @@
  44. struct starpu_codelet cl = {
  45. .cpu_funcs = { f, NULL }
  46. };
  47. //////////////////////////////////////////////////////////////////////////////
  48. // For codelets that define cpu_func but not cpu_funcs, remove cpu_func and //
  49. // add cpu_funcs //
  50. //////////////////////////////////////////////////////////////////////////////
  51. @depends on !cpu_funcs@
  52. identifier cpu_func.cl;
  53. expression cpu_func.f;
  54. @@
  55. struct starpu_codelet cl = {
  56. - .cpu_func = f
  57. + .cpu_funcs = { f, NULL }
  58. };
  59. /////////////////////////////////////////////////////////////////
  60. // If both cpu_func and cpu_funcs are defined, remove cpu_func //
  61. /////////////////////////////////////////////////////////////////
  62. @depends on cpu_funcs@
  63. identifier cpu_func.cl;
  64. expression cpu_func.f;
  65. @@
  66. struct starpu_codelet cl = {
  67. - .cpu_func = f
  68. };