cpu_func_to_cpu_funcs.cocci 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), 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. */
  16. // $ spatch -sp_file cpu_func_to_cpu_funcs.cocci cpu_func_to_cpu_funcs_test.c
  17. ///////////////////////////////////////////////////////////////////////////////
  18. // There is no need to specify STARPU_MULTIPLE_CPU_IMPLEMENTATIONS any more. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20. @@
  21. identifier cl;
  22. @@
  23. struct starpu_codelet cl = {
  24. - .cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS,
  25. .cpu_funcs = { ... }
  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 }
  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 }
  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. };