drivers.c 2.0 KB

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