starpu_cublas.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2012 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012 Centre National de la Recherche Scientifique
  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 <starpu.h>
  18. #include <starpu_cuda.h>
  19. #include <common/config.h>
  20. #ifdef STARPU_USE_CUDA
  21. static void init_cublas_func(void *args STARPU_ATTRIBUTE_UNUSED)
  22. {
  23. cublasStatus cublasst = cublasInit();
  24. if (STARPU_UNLIKELY(cublasst))
  25. STARPU_CUBLAS_REPORT_ERROR(cublasst);
  26. cublasSetKernelStream(starpu_cuda_get_local_stream());
  27. }
  28. static void shutdown_cublas_func(void *args STARPU_ATTRIBUTE_UNUSED)
  29. {
  30. cublasShutdown();
  31. }
  32. #endif
  33. void starpu_helper_cublas_init(void)
  34. {
  35. #ifdef STARPU_USE_CUDA
  36. starpu_execute_on_each_worker(init_cublas_func, NULL, STARPU_CUDA);
  37. #endif
  38. }
  39. void starpu_helper_cublas_shutdown(void)
  40. {
  41. #ifdef STARPU_USE_CUDA
  42. starpu_execute_on_each_worker(shutdown_cublas_func, NULL, STARPU_CUDA);
  43. #endif
  44. }