dw_block_spmv_kernels.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 "dw_block_spmv.h"
  17. /*
  18. * U22
  19. */
  20. static inline void common_block_spmv(void *descr[], int s, __attribute__((unused)) void *_args)
  21. {
  22. //printf("22\n");
  23. float *block = (float *)STARPU_GET_MATRIX_PTR(descr[0]);
  24. float *in = (float *)STARPU_GET_VECTOR_PTR(descr[1]);
  25. float *out = (float *)STARPU_GET_VECTOR_PTR(descr[2]);
  26. unsigned dx = STARPU_GET_MATRIX_NX(descr[0]);
  27. unsigned dy = STARPU_GET_MATRIX_NY(descr[0]);
  28. unsigned ld = STARPU_GET_MATRIX_LD(descr[0]);
  29. switch (s) {
  30. case 0:
  31. cblas_sgemv(CblasRowMajor, CblasNoTrans, dx, dy, 1.0f, block, ld, in, 1, 1.0f, out, 1);
  32. break;
  33. #ifdef STARPU_USE_CUDA
  34. case 1:
  35. cublasSgemv ('t', dx, dy, 1.0f, block, ld, in, 1, 1.0f, out, 1);
  36. break;
  37. #endif
  38. default:
  39. STARPU_ABORT();
  40. break;
  41. }
  42. }
  43. void cpu_block_spmv(void *descr[], void *_args)
  44. {
  45. // printf("CPU CODELET \n");
  46. common_block_spmv(descr, 0, _args);
  47. }
  48. #ifdef STARPU_USE_CUDA
  49. void cublas_block_spmv(void *descr[], void *_args)
  50. {
  51. // printf("CUBLAS CODELET \n");
  52. common_block_spmv(descr, 1, _args);
  53. }
  54. #endif// STARPU_USE_CUDA