cg.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2011 Université de Bordeaux 1
  4. *
  5. * StarPU 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. * StarPU 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. #ifndef __STARPU_EXAMPLE_CG_H__
  17. #define __STARPU_EXAMPLE_CG_H__
  18. #include <starpu.h>
  19. #include <math.h>
  20. #include <common/blas.h>
  21. #ifdef STARPU_USE_CUDA
  22. #include <cuda.h>
  23. #include <cublas.h>
  24. #include <starpu_cuda.h>
  25. #endif
  26. #include <starpu.h>
  27. #define DOUBLE
  28. #ifdef DOUBLE
  29. #define TYPE double
  30. #define GEMV DGEMV
  31. #define DOT DDOT
  32. #define GEMV DGEMV
  33. #define AXPY DAXPY
  34. #define SCAL DSCAL
  35. #define cublasdot cublasDdot
  36. #define cublasscal cublasDscal
  37. #define cublasaxpy cublasDaxpy
  38. #define cublasgemv cublasDgemv
  39. #define cublasscal cublasDscal
  40. #else
  41. #define TYPE float
  42. #define GEMV SGEMV
  43. #define DOT SDOT
  44. #define GEMV SGEMV
  45. #define AXPY SAXPY
  46. #define SCAL SSCAL
  47. #define cublasdot cublasSdot
  48. #define cublasscal cublasSscal
  49. #define cublasaxpy cublasSaxpy
  50. #define cublasgemv cublasSgemv
  51. #define cublasscal cublasSscal
  52. #endif
  53. void dot_kernel(starpu_data_handle v1,
  54. starpu_data_handle v2,
  55. starpu_data_handle s,
  56. unsigned nblocks,
  57. int use_reduction);
  58. void gemv_kernel(starpu_data_handle v1,
  59. starpu_data_handle matrix,
  60. starpu_data_handle v2,
  61. TYPE p1, TYPE p2,
  62. unsigned nblocks,
  63. int use_reduction);
  64. void axpy_kernel(starpu_data_handle v1,
  65. starpu_data_handle v2, TYPE p1,
  66. unsigned nblocks);
  67. void scal_axpy_kernel(starpu_data_handle v1, TYPE p1,
  68. starpu_data_handle v2, TYPE p2,
  69. unsigned nblocks);
  70. void copy_handle(starpu_data_handle dst,
  71. starpu_data_handle src,
  72. unsigned nblocks);
  73. #endif /* __STARPU_EXAMPLE_CG_H__ */