cpu_func_to_cpu_funcs.cocci 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011,2012 Inria
  4. * Copyright (C) 2011,2012,2015,2017 CNRS
  5. * Copyright (C) 2014 Université de Bordeaux
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. // $ spatch -sp_file cpu_func_to_cpu_funcs.cocci cpu_func_to_cpu_funcs_test.c
  19. ///////////////////////////////////////////////////////////////////////////////
  20. // There is no need to specify STARPU_MULTIPLE_CPU_IMPLEMENTATIONS any more. //
  21. ///////////////////////////////////////////////////////////////////////////////
  22. @@
  23. identifier cl;
  24. @@
  25. struct starpu_codelet cl = {
  26. - .cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS,
  27. .cpu_funcs = { ... }
  28. };
  29. ////////////////////////////////////////////////////
  30. // Find all the codelets using the cpu_func field //
  31. ////////////////////////////////////////////////////
  32. @cpu_func@
  33. expression f;
  34. identifier cl;
  35. @@
  36. struct starpu_codelet cl = {
  37. .cpu_func = f
  38. };
  39. ///////////////////////////////////////////////////////////////////
  40. // Find all the codelets that define both cpu_func and cpu_funcs //
  41. ///////////////////////////////////////////////////////////////////
  42. @cpu_funcs depends on cpu_func@
  43. expression cpu_func.f;
  44. identifier cpu_func.cl;
  45. @@
  46. struct starpu_codelet cl = {
  47. .cpu_funcs = { f }
  48. };
  49. //////////////////////////////////////////////////////////////////////////////
  50. // For codelets that define cpu_func but not cpu_funcs, remove cpu_func and //
  51. // add cpu_funcs //
  52. //////////////////////////////////////////////////////////////////////////////
  53. @depends on !cpu_funcs@
  54. identifier cpu_func.cl;
  55. expression cpu_func.f;
  56. @@
  57. struct starpu_codelet cl = {
  58. - .cpu_func = f
  59. + .cpu_funcs = { f }
  60. };
  61. /////////////////////////////////////////////////////////////////
  62. // If both cpu_func and cpu_funcs are defined, remove cpu_func //
  63. /////////////////////////////////////////////////////////////////
  64. @depends on cpu_funcs@
  65. identifier cpu_func.cl;
  66. expression cpu_func.f;
  67. @@
  68. struct starpu_codelet cl = {
  69. - .cpu_func = f
  70. };