xgemm_kernels.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <starpu.h>
  17. #include <starpu_cuda.h>
  18. #include <common/blas.h>
  19. #define COMMON_CODE \
  20. uint32_t nxC, nyC, nyA; \
  21. uint32_t ldA, ldB, ldC; \
  22. \
  23. TYPE *subA; \
  24. TYPE *subB; \
  25. TYPE *subC; \
  26. \
  27. subA = (TYPE *)STARPU_MATRIX_GET_PTR(descr[0]); \
  28. subB = (TYPE *)STARPU_MATRIX_GET_PTR(descr[1]); \
  29. subC = (TYPE *)STARPU_MATRIX_GET_PTR(descr[2]); \
  30. \
  31. nxC = STARPU_MATRIX_GET_NX(descr[2]); \
  32. nyC = STARPU_MATRIX_GET_NY(descr[2]); \
  33. nyA = STARPU_MATRIX_GET_NY(descr[0]); \
  34. \
  35. ldA = STARPU_MATRIX_GET_LD(descr[0]); \
  36. ldB = STARPU_MATRIX_GET_LD(descr[1]); \
  37. ldC = STARPU_MATRIX_GET_LD(descr[2]);
  38. #ifdef STARPU_USE_CUDA
  39. void STARPU_GEMM(cublas_mult)(void *descr[], __attribute__((unused)) void *arg)
  40. {
  41. COMMON_CODE
  42. starpu_trace_user_event(0x42);
  43. CUBLAS_GEMM('n', 'n', nxC, nyC, nyA, (TYPE)1.0, subA, ldA, subB, ldB,
  44. (TYPE)0.0, subC, ldC);
  45. cublasStatus st;
  46. st = cublasGetError();
  47. if (st != CUBLAS_STATUS_SUCCESS)
  48. STARPU_ABORT();
  49. cudaThreadSynchronize();
  50. starpu_trace_user_event(0x42);
  51. }
  52. #endif
  53. void STARPU_GEMM(cpu_mult)(void *descr[], __attribute__((unused)) void *arg)
  54. {
  55. COMMON_CODE
  56. starpu_trace_user_event(0x42);
  57. CPU_GEMM("N", "N", nxC, nyC, nyA, (TYPE)1.0, subA, ldA, subB, ldB,
  58. (TYPE)0.0, subC, ldC);
  59. starpu_trace_user_event(0x43);
  60. }