cg.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  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. #endif
  25. #define DOUBLE
  26. #ifdef DOUBLE
  27. #define TYPE double
  28. #define GEMV STARPU_DGEMV
  29. #define DOT STARPU_DDOT
  30. #define GEMV STARPU_DGEMV
  31. #define AXPY STARPU_DAXPY
  32. #define SCAL STARPU_DSCAL
  33. #define cublasdot cublasDdot
  34. #define cublasscal cublasDscal
  35. #define cublasaxpy cublasDaxpy
  36. #define cublasgemv cublasDgemv
  37. #define cublasscal cublasDscal
  38. #else
  39. #define TYPE float
  40. #define GEMV STARPU_SGEMV
  41. #define DOT STARPU_SDOT
  42. #define GEMV STARPU_SGEMV
  43. #define AXPY STARPU_SAXPY
  44. #define SCAL STARPU_SSCAL
  45. #define cublasdot cublasSdot
  46. #define cublasscal cublasSscal
  47. #define cublasaxpy cublasSaxpy
  48. #define cublasgemv cublasSgemv
  49. #define cublasscal cublasSscal
  50. #endif
  51. int dot_kernel(starpu_data_handle_t v1,
  52. starpu_data_handle_t v2,
  53. starpu_data_handle_t s,
  54. unsigned nblocks,
  55. int use_reduction);
  56. int gemv_kernel(starpu_data_handle_t v1,
  57. starpu_data_handle_t matrix,
  58. starpu_data_handle_t v2,
  59. TYPE p1, TYPE p2,
  60. unsigned nblocks,
  61. int use_reduction);
  62. int axpy_kernel(starpu_data_handle_t v1,
  63. starpu_data_handle_t v2, TYPE p1,
  64. unsigned nblocks);
  65. int scal_axpy_kernel(starpu_data_handle_t v1, TYPE p1,
  66. starpu_data_handle_t v2, TYPE p2,
  67. unsigned nblocks);
  68. int copy_handle(starpu_data_handle_t dst,
  69. starpu_data_handle_t src,
  70. unsigned nblocks);
  71. #endif /* __STARPU_EXAMPLE_CG_H__ */