cublas_init.c 1.8 KB

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