starpu_cublas.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2011 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011 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. #if CUDA_VERSION >= 3010
  27. cublasSetKernelStream(starpu_cuda_get_local_stream());
  28. #endif
  29. }
  30. static void shutdown_cublas_func(void *args STARPU_ATTRIBUTE_UNUSED)
  31. {
  32. cublasShutdown();
  33. }
  34. #endif
  35. void starpu_helper_cublas_init(void)
  36. {
  37. #ifdef STARPU_USE_CUDA
  38. starpu_execute_on_each_worker(init_cublas_func, NULL, STARPU_CUDA);
  39. #endif
  40. }
  41. void starpu_helper_cublas_shutdown(void)
  42. {
  43. #ifdef STARPU_USE_CUDA
  44. starpu_execute_on_each_worker(shutdown_cublas_func, NULL, STARPU_CUDA);
  45. #endif
  46. }