cg.h 2.3 KB

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