sched_ctx_delete.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2018-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), 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. */
  16. #include <starpu.h>
  17. #include <stdlib.h>
  18. int main(void)
  19. {
  20. int ret;
  21. int nprocs = 0;
  22. int procs[STARPU_NMAXWORKERS];
  23. unsigned sched_ctx1, sched_ctx2;
  24. ret = starpu_init(NULL);
  25. if (ret == -ENODEV) return 77;
  26. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  27. if (starpu_worker_get_count_by_type(STARPU_CPU_WORKER) == 0)
  28. {
  29. // Needs at least 1 CPU worker
  30. starpu_shutdown();
  31. return 77;
  32. }
  33. nprocs = starpu_worker_get_count_by_type(STARPU_CPU_WORKER);
  34. starpu_worker_get_ids_by_type(STARPU_CPU_WORKER, procs, nprocs);
  35. sched_ctx1 = starpu_sched_ctx_create(procs, nprocs, "ctx1", 0);
  36. sched_ctx2 = starpu_sched_ctx_create(procs, nprocs, "ctx2", 0);
  37. starpu_sched_ctx_set_inheritor(sched_ctx2, sched_ctx1);
  38. starpu_sched_ctx_delete(sched_ctx1);
  39. starpu_sched_ctx_delete(sched_ctx2);
  40. starpu_shutdown();
  41. return 0;
  42. }