errorcheck.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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. #include <core/errorcheck.h>
  17. #include <core/workers.h>
  18. void _starpu_set_local_worker_status(starpu_worker_status st)
  19. {
  20. struct starpu_worker_s *worker = _starpu_get_local_worker_key();
  21. /* It is possible that we call this function from the application (and
  22. * thereforce outside a worker), for instance if we are executing the
  23. * callback function of a task with a "NULL" codelet. */
  24. if (worker)
  25. worker->status = st;
  26. }
  27. starpu_worker_status _starpu_get_local_worker_status(void)
  28. {
  29. struct starpu_worker_s *worker = _starpu_get_local_worker_key();
  30. if (STARPU_UNLIKELY(!worker))
  31. return STATUS_INVALID;
  32. return worker->status;
  33. }
  34. /* It is forbidden to call blocking operations with Callback and during the
  35. * execution of a task. */
  36. unsigned _starpu_worker_may_perform_blocking_calls(void)
  37. {
  38. starpu_worker_status st = _starpu_get_local_worker_status();
  39. return ( !(st == STATUS_CALLBACK) && !(st == STATUS_EXECUTING));
  40. }