use_starpu_cublas_report_error.cocci 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // StarPU --- Runtime system for heterogeneous multicore architectures.
  2. //
  3. // Copyright (C) 2012 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. // When using the CUBLAS library, we call cublasGetError() from times to times.
  16. // If it does not return CUBLAS_STATUS_SUCCESS, we should not immediatly abort:
  17. // first, we need to print a useful piece of information to make it easier to
  18. // debug the program.
  19. virtual context
  20. virtual org
  21. virtual patch
  22. virtual report
  23. // Pattern:
  24. // status = cubalsGetError();
  25. // if (status != CUBLAS_STATUS_SUCCESS)
  26. // STARPU_ABORT();
  27. //
  28. @starpu_abort@
  29. cublasStatus status;
  30. position p;
  31. @@
  32. status = cublasGetError();
  33. (
  34. if (status != CUBLAS_STATUS_SUCCESS)
  35. STARPU_ABORT@p();
  36. |
  37. if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
  38. STARPU_ABORT@p();
  39. )
  40. @depends on starpu_abort && context@
  41. position starpu_abort.p;
  42. @@
  43. * STARPU_ABORT@p();
  44. @script:python depends on starpu_abort && org@
  45. p << starpu_abort.p;
  46. @@
  47. coccilib.org.print_todo(p[0], "Use STARPU_CUBLAS_REPORT_ERROR() instead of STARPU_ABORT().")
  48. @depends on starpu_abort && patch@
  49. cublasStatus starpu_abort.status;
  50. position starpu_abort.p;
  51. @@
  52. - STARPU_ABORT@p();
  53. + STARPU_CUBLAS_REPORT_ERROR(status);
  54. @script:python depends on starpu_abort && report@
  55. p << starpu_abort.p;
  56. @@
  57. coccilib.report.print_report(p[0], "Use STARPU_CUBLAS_REPORT_ERROR() instead of STARPU_ABORT().")
  58. // Pattern:
  59. // status = cublasGetError();
  60. // STARPU_ASSERT(!status);
  61. @starpu_assert@
  62. cublasStatus status;
  63. position p;
  64. @@
  65. status = cublasGetError();
  66. STARPU_ASSERT@p(!status);
  67. @depends on starpu_assert && context@
  68. position starpu_assert.p;
  69. @@
  70. * STARPU_ASSERT@p(...);
  71. @script:python depends on starpu_assert && org@
  72. p << starpu_assert.p;
  73. @@
  74. coccilib.org.print_todo(p[0], "Use STARPU_CUBLAS_REPORT_ERROR() instead of STARPU_ASSERT().")
  75. @depends on starpu_assert && patch@
  76. position starpu_assert.p;
  77. cublasStatus starpu_assert.status;
  78. @@
  79. - STARPU_ASSERT@p(!status);
  80. + if (STARPU_UNLIKELY(status != CUBLAS_STATUS_SUCCESS))
  81. + STARPU_CUBLAS_REPORT_ERROR(status);
  82. @script:python depends on starpu_assert && report@
  83. p << starpu_assert.p;
  84. @@
  85. coccilib.report.print_report(p[0], "Use STARPU_CUBLAS_REPORT_ERROR() instead of STARPU_ASSERT().")