restart.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 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 <stdio.h>
  17. #include <unistd.h>
  18. #include <errno.h>
  19. #include <starpu.h>
  20. #include <stdlib.h>
  21. #include "../helper.h"
  22. /*
  23. * Try initializing/shutting down starpu several times
  24. */
  25. #ifdef STARPU_QUICK_CHECK
  26. #define N 2
  27. #else
  28. #define N 10
  29. #endif
  30. static double start;
  31. static double end;
  32. int main(int argc, char **argv)
  33. {
  34. unsigned iter;
  35. double init_timing = 0.0;
  36. double shutdown_timing = 0.0;
  37. int ret;
  38. for (iter = 0; iter < N; iter++)
  39. {
  40. start = starpu_timing_now();
  41. /* Initialize StarPU */
  42. ret = starpu_initialize(NULL, &argc, &argv);
  43. end = starpu_timing_now();
  44. if (ret == -ENODEV)
  45. goto enodev;
  46. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  47. init_timing += end - start;
  48. start = starpu_timing_now();
  49. /* Shutdown StarPU */
  50. starpu_shutdown();
  51. end = starpu_timing_now();
  52. shutdown_timing += end - start;
  53. }
  54. FPRINTF(stderr, "starpu_init: %2.2f seconds\n", init_timing/(N*1000000));
  55. FPRINTF(stderr, "starpu_shutdown: %2.2f seconds\n", shutdown_timing/(N*1000000));
  56. return EXIT_SUCCESS;
  57. enodev:
  58. return STARPU_TEST_SKIPPED;
  59. }