cublas_init.c 1.7 KB

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