debug.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2012 Inria
  4. * Copyright (C) 2012-2013,2017 CNRS
  5. * Copyright (C) 2010-2011,2013,2015 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. #ifndef SOCL_DEBUG_H
  19. #define SOCL_DEBUG_H
  20. #include <../src/common/config.h>
  21. #ifdef STARPU_VERBOSE
  22. #define DEBUG
  23. #include <stdio.h>
  24. #define DEBUG_MSG(...) do { if (!getenv("STARPU_SILENT")) { fprintf(stderr, "[SOCL] [%s] ", __starpu_func__); fprintf(stderr, __VA_ARGS__);}} while (0)
  25. #define DEBUG_MSG_NOHEAD(...) do { if (!getenv("STARPU_SILENT")) { fprintf(stderr, __VA_ARGS__);}} while (0);
  26. #define DEBUG_ERROR(...) do { if (!getenv("STARPU_SILENT")) { fprintf(stderr, "[SOCL] ERROR: "__VA_ARGS__); } exit(1); } while (0)
  27. #else
  28. #define DEBUG_MSG(...) while(0)
  29. #define DEBUG_MSG_NOHEAD(...) while(0)
  30. #define DEBUG_ERROR(...) while(0)
  31. #endif
  32. #define ERROR_MSG(...) do { fprintf(stderr, "[SOCL] [%s] ERROR: ", __starpu_func__); fprintf(stderr, __VA_ARGS__); } while (0)
  33. #define ERROR_MSG_NOHEAD(...) fprintf(stderr, __VA_ARGS__)
  34. #define ERROR_STOP(...) do { ERROR_MSG(__VA_ARGS__); exit(1); } while(0)
  35. void ERROR_CL(char *s, cl_int err);
  36. #ifdef STARPU_VERBOSE
  37. #define DEBUG_CL(args...) ERROR_CL(args)
  38. #else
  39. #define DEBUG_CL(...) while(0)
  40. #endif
  41. #ifdef DEBUG
  42. #define DEBUG_PARAM(p) p
  43. #else
  44. #define DEBUG_PARAM(p) UNUSED(p)
  45. #endif
  46. #endif /* SOCL_DEBUG_H */