cusparse_init.c 1.8 KB

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