dw_block_spmv_kernels.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010-2011 Université de Bordeaux 1
  4. * Copyright (C) 2010 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, __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. case 0:
  32. cblas_sgemv(CblasRowMajor, CblasNoTrans, dx, dy, 1.0f, block, ld, in, 1, 1.0f, out, 1);
  33. break;
  34. #ifdef STARPU_USE_CUDA
  35. case 1:
  36. cublasSgemv ('t', dx, dy, 1.0f, block, ld, in, 1, 1.0f, out, 1);
  37. break;
  38. #endif
  39. default:
  40. STARPU_ABORT();
  41. break;
  42. }
  43. }
  44. void cpu_block_spmv(void *descr[], void *_args)
  45. {
  46. /* printf("CPU CODELET \n"); */
  47. common_block_spmv(descr, 0, _args);
  48. }
  49. #ifdef STARPU_USE_CUDA
  50. void cublas_block_spmv(void *descr[], void *_args)
  51. {
  52. /* printf("CUBLAS CODELET \n"); */
  53. common_block_spmv(descr, 1, _args);
  54. }
  55. #endif /* STARPU_USE_CUDA */