dw_block_spmv_kernels.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010-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 "dw_block_spmv.h"
  18. /*
  19. * U22
  20. */
  21. static inline void common_block_spmv(void *descr[], int s, STARPU_ATTRIBUTE_UNUSED void *_args)
  22. {
  23. /* printf("22\n"); */
  24. float *block = (float *)STARPU_MATRIX_GET_PTR(descr[0]);
  25. float *in = (float *)STARPU_VECTOR_GET_PTR(descr[1]);
  26. float *out = (float *)STARPU_VECTOR_GET_PTR(descr[2]);
  27. unsigned dx = STARPU_MATRIX_GET_NX(descr[0]);
  28. unsigned dy = STARPU_MATRIX_GET_NY(descr[0]);
  29. unsigned ld = STARPU_MATRIX_GET_LD(descr[0]);
  30. switch (s)
  31. {
  32. case 0:
  33. cblas_sgemv(CblasRowMajor, CblasNoTrans, dx, dy, 1.0f, block, ld, in, 1, 1.0f, out, 1);
  34. break;
  35. #ifdef STARPU_USE_CUDA
  36. case 1:
  37. cublasSgemv ('t', dx, dy, 1.0f, block, ld, in, 1, 1.0f, out, 1);
  38. break;
  39. #endif
  40. default:
  41. STARPU_ABORT();
  42. break;
  43. }
  44. }
  45. void cpu_block_spmv(void *descr[], void *_args)
  46. {
  47. /* printf("CPU CODELET \n"); */
  48. common_block_spmv(descr, 0, _args);
  49. }
  50. #ifdef STARPU_USE_CUDA
  51. void cublas_block_spmv(void *descr[], void *_args)
  52. {
  53. /* printf("CUBLAS CODELET \n"); */
  54. common_block_spmv(descr, 1, _args);
  55. }
  56. #endif /* STARPU_USE_CUDA */