restart.c 1.8 KB

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