cublas_init.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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 <sys/time.h>
  17. #include <stdio.h>
  18. #include <unistd.h>
  19. #include <errno.h>
  20. #include <starpu.h>
  21. #include <stdlib.h>
  22. struct timeval start;
  23. struct timeval end;
  24. static float *data = NULL;
  25. int main(int argc, char **argv)
  26. {
  27. starpu_init(NULL);
  28. unsigned ngpus = starpu_cuda_worker_get_count();
  29. double init_timing;
  30. double shutdown_timing;
  31. gettimeofday(&start, NULL);
  32. starpu_helper_cublas_init();
  33. gettimeofday(&end, NULL);
  34. init_timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
  35. gettimeofday(&start, NULL);
  36. starpu_helper_cublas_shutdown();
  37. gettimeofday(&end, NULL);
  38. shutdown_timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
  39. fprintf(stderr, "Total:\n");
  40. fprintf(stderr, "\tinit: %2.2f us\n", init_timing/(1000));
  41. fprintf(stderr, "\tshutdown: %2.2f us\n", shutdown_timing/(1000));
  42. if (ngpus != 0)
  43. {
  44. fprintf(stderr, "per-GPU (#gpu = %d):\n", ngpus);
  45. fprintf(stderr, "\tinit: %2.2f us\n", init_timing/(1000*ngpus));
  46. fprintf(stderr, "\tshutdown: %2.2f us\n", shutdown_timing/(1000*ngpus));
  47. }
  48. starpu_shutdown();
  49. return 0;
  50. }