xgemm_kernels.c 1.9 KB

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