starpu_check_register.cocci 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2012 Inria
  4. * Copyright (C) 2012,2015,2017 CNRS
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. @initialize:python@
  18. handles = {}
  19. @select@
  20. position p;
  21. identifier f =~ "^starpu_.*_data_register$";
  22. identifier e;
  23. @@
  24. <...
  25. f@p( &e, ... );
  26. ...>
  27. @script:python@
  28. p << select.p;
  29. f << select.f;
  30. e << select.e;
  31. @@
  32. s = "%s(%s),%s:%s" % (f,e,p[0].file,p[0].line)
  33. # hack: 'clean' the string e from unwanted non printing characters, otherwise 'e' in select rule does not match 'e' in check rule
  34. e = "%s" % e
  35. handles[e]=s
  36. @check@
  37. position p;
  38. identifier select.e;
  39. @@
  40. <...
  41. starpu_data_unregister@p( e );
  42. ...>
  43. @script:python@
  44. e << select.e;
  45. p << check.p;
  46. @@
  47. # hack: position p must be defined in the check rule even though it is not used, otherwise the 'check' python script is not run
  48. e = "%s" % e
  49. if e in handles:
  50. del handles[e]
  51. @finalize:python@
  52. for s in handles.values():
  53. print s