cublas_init.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2011,2013,2014,2016 Université de Bordeaux
  4. * Copyright (C) 2010-2013,2015,2017 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. * Test initializing cublas, and how much time that takes
  25. */
  26. static double start;
  27. static double end;
  28. //static float *data = NULL;
  29. int main(int argc, char **argv)
  30. {
  31. int ret;
  32. ret = starpu_initialize(NULL, &argc, &argv);
  33. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  34. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  35. unsigned ngpus = starpu_cuda_worker_get_count();
  36. double init_timing;
  37. double shutdown_timing;
  38. start = starpu_timing_now();
  39. starpu_cublas_init();
  40. end = starpu_timing_now();
  41. init_timing = end - start;
  42. start = starpu_timing_now();
  43. starpu_cublas_shutdown();
  44. end = starpu_timing_now();
  45. shutdown_timing = end - start;
  46. FPRINTF(stderr, "Total:\n");
  47. FPRINTF(stderr, "\tinit: %2.2f us\n", init_timing/(1000));
  48. FPRINTF(stderr, "\tshutdown: %2.2f us\n", shutdown_timing/(1000));
  49. if (ngpus != 0)
  50. {
  51. FPRINTF(stderr, "per-GPU (#gpu = %u):\n", ngpus);
  52. FPRINTF(stderr, "\tinit: %2.2f us\n", init_timing/(1000*ngpus));
  53. FPRINTF(stderr, "\tshutdown: %2.2f us\n", shutdown_timing/(1000*ngpus));
  54. }
  55. starpu_shutdown();
  56. return EXIT_SUCCESS;
  57. }