restart.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010, 2013-2014, 2016 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012 CNRS
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <stdio.h>
  18. #include <unistd.h>
  19. #include <errno.h>
  20. #include <starpu.h>
  21. #include <stdlib.h>
  22. #include "../helper.h"
  23. /*
  24. * Try initializing/shutting down starpu several times
  25. */
  26. #ifdef STARPU_QUICK_CHECK
  27. #define N 2
  28. #else
  29. #define N 10
  30. #endif
  31. static double start;
  32. static double end;
  33. int main(int argc, char **argv)
  34. {
  35. unsigned iter;
  36. double init_timing = 0.0;
  37. double shutdown_timing = 0.0;
  38. int ret;
  39. for (iter = 0; iter < N; iter++)
  40. {
  41. start = starpu_timing_now();
  42. /* Initialize StarPU */
  43. ret = starpu_initialize(NULL, &argc, &argv);
  44. end = starpu_timing_now();
  45. if (ret == -ENODEV)
  46. goto enodev;
  47. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  48. init_timing += end - start;
  49. start = starpu_timing_now();
  50. /* Shutdown StarPU */
  51. starpu_shutdown();
  52. end = starpu_timing_now();
  53. shutdown_timing += end - start;
  54. }
  55. FPRINTF(stderr, "starpu_init: %2.2f seconds\n", init_timing/(N*1000000));
  56. FPRINTF(stderr, "starpu_shutdown: %2.2f seconds\n", shutdown_timing/(N*1000000));
  57. return EXIT_SUCCESS;
  58. enodev:
  59. return STARPU_TEST_SKIPPED;
  60. }