dw_block_spmv_kernels.c 1.8 KB

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