starpu_check_register.cocci 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. @initialize:python@
  17. handles = {}
  18. @select@
  19. position p;
  20. identifier f =~ "^starpu_.*_data_register$";
  21. identifier e;
  22. @@
  23. <...
  24. f@p( &e, ... );
  25. ...>
  26. @script:python@
  27. p << select.p;
  28. f << select.f;
  29. e << select.e;
  30. @@
  31. s = "%s(%s),%s:%s" % (f,e,p[0].file,p[0].line)
  32. # hack: 'clean' the string e from unwanted non printing characters, otherwise 'e' in select rule does not match 'e' in check rule
  33. e = "%s" % e
  34. handles[e]=s
  35. @check@
  36. position p;
  37. identifier select.e;
  38. @@
  39. <...
  40. starpu_data_unregister@p( e );
  41. ...>
  42. @script:python@
  43. e << select.e;
  44. p << check.p;
  45. @@
  46. # hack: position p must be defined in the check rule even though it is not used, otherwise the 'check' python script is not run
  47. e = "%s" % e
  48. if e in handles:
  49. del handles[e]
  50. @finalize:python@
  51. for s in handles.values():
  52. print s