drivers.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2017 CNRS
  4. * Copyright (C) 2009-2017 Université de Bordeaux
  5. * Copyright (C) 2010-2012,2016-2017 Inria
  6. * Copyright (C) 2011 Télécom-SudParis
  7. * Copyright (C) 2010-2012,2016-2017 Inria
  8. * Copyright (C) 2016 Uppsala University
  9. *
  10. * StarPU is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU Lesser General Public License as published by
  12. * the Free Software Foundation; either version 2.1 of the License, or (at
  13. * your option) any later version.
  14. *
  15. * StarPU is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. *
  19. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  20. */
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <common/config.h>
  24. #include <core/debug.h>
  25. int starpu_driver_init(struct starpu_driver *d)
  26. {
  27. STARPU_ASSERT(d);
  28. struct _starpu_worker *worker = _starpu_get_worker_from_driver(d);
  29. if (worker->driver_ops == NULL)
  30. return -EINVAL;
  31. else
  32. return worker->driver_ops->init(worker);
  33. }
  34. int starpu_driver_run(struct starpu_driver *d)
  35. {
  36. if (!d)
  37. {
  38. _STARPU_DEBUG("Invalid argument\n");
  39. return -EINVAL;
  40. }
  41. struct _starpu_worker *worker = _starpu_get_worker_from_driver(d);
  42. if (worker->driver_ops == NULL)
  43. return -EINVAL;
  44. else
  45. return worker->driver_ops->run(worker);
  46. }
  47. int starpu_driver_run_once(struct starpu_driver *d)
  48. {
  49. STARPU_ASSERT(d);
  50. struct _starpu_worker *worker = _starpu_get_worker_from_driver(d);
  51. if (worker->driver_ops == NULL)
  52. return -EINVAL;
  53. else
  54. return worker->driver_ops->run_once(worker);
  55. }
  56. int starpu_driver_deinit(struct starpu_driver *d)
  57. {
  58. STARPU_ASSERT(d);
  59. struct _starpu_worker *worker = _starpu_get_worker_from_driver(d);
  60. if (worker->driver_ops == NULL)
  61. return -EINVAL;
  62. else
  63. return worker->driver_ops->deinit(worker);
  64. }