prio.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013-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. #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
  18. int main(void)
  19. {
  20. int ret;
  21. ret = starpu_init(NULL);
  22. if (ret == -ENODEV) return 77;
  23. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  24. unsigned sched_ctx1 = starpu_sched_ctx_create(NULL, -1, "ctx1", STARPU_SCHED_CTX_POLICY_NAME, "prio", 0);
  25. FPRINTF(stderr, "min prio %d\n", starpu_sched_ctx_get_min_priority(sched_ctx1));
  26. FPRINTF(stderr, "max prio %d\n", starpu_sched_ctx_get_max_priority(sched_ctx1));
  27. unsigned sched_ctx2 = starpu_sched_ctx_create(NULL, -1, "ctx2",
  28. STARPU_SCHED_CTX_POLICY_NAME, "prio",
  29. STARPU_SCHED_CTX_POLICY_MIN_PRIO, -12,
  30. STARPU_SCHED_CTX_POLICY_MAX_PRIO, 32,
  31. 0);
  32. FPRINTF(stderr, "min prio %d\n", starpu_sched_ctx_get_min_priority(sched_ctx2));
  33. FPRINTF(stderr, "max prio %d\n", starpu_sched_ctx_get_max_priority(sched_ctx2));
  34. if (starpu_sched_ctx_get_min_priority(sched_ctx2) != -12)
  35. {
  36. FPRINTF(stderr, "Error with min priority: %d != %d\n", starpu_sched_ctx_get_min_priority(sched_ctx2), -12);
  37. ret = 1;
  38. }
  39. if (starpu_sched_ctx_get_max_priority(sched_ctx2) != 32)
  40. {
  41. FPRINTF(stderr, "Error with max priority: %d != %d\n", starpu_sched_ctx_get_max_priority(sched_ctx2), 32);
  42. ret = 1;
  43. }
  44. starpu_sched_ctx_delete(sched_ctx1);
  45. starpu_sched_ctx_delete(sched_ctx2);
  46. starpu_shutdown();
  47. return ret;
  48. }