blas.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2021 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. #include <ctype.h>
  17. #include <stdio.h>
  18. #include "blas.h"
  19. inline void STARPU_SGEMM(char *transa, char *transb, BLASINT M, BLASINT N, BLASINT K,
  20. float alpha, const float *A, BLASINT lda, const float *B, BLASINT ldb,
  21. float beta, float *C, BLASINT ldc)
  22. {
  23. sgemm_64_(transa, transb, &M, &N, &K, &alpha,
  24. A, &lda, B, &ldb,
  25. &beta, C, &ldc);
  26. }
  27. inline void STARPU_DGEMM(char *transa, char *transb, BLASINT M, BLASINT N, BLASINT K,
  28. double alpha, double *A, BLASINT lda, double *B, BLASINT ldb,
  29. double beta, double *C, BLASINT ldc)
  30. {
  31. dgemm_64_(transa, transb, &M, &N, &K, &alpha,
  32. A, &lda, B, &ldb,
  33. &beta, C, &ldc);
  34. }
  35. inline void STARPU_SGEMV(char *transa, BLASINT M, BLASINT N, float alpha, float *A, BLASINT lda,
  36. float *X, BLASINT incX, float beta, float *Y, BLASINT incY)
  37. {
  38. sgemv_64_(transa, &M, &N, &alpha, A, &lda, X, &incX, &beta, Y, &incY);
  39. }
  40. inline void STARPU_DGEMV(char *transa, BLASINT M, BLASINT N, double alpha, double *A, BLASINT lda,
  41. double *X, BLASINT incX, double beta, double *Y, BLASINT incY)
  42. {
  43. dgemv_64_(transa, &M, &N, &alpha, A, &lda, X, &incX, &beta, Y, &incY);
  44. }
  45. inline float STARPU_SASUM(BLASINT N, float *X, BLASINT incX)
  46. {
  47. return sasum_64_(&N, X, &incX);
  48. }
  49. inline double STARPU_DASUM(BLASINT N, double *X, BLASINT incX)
  50. {
  51. return dasum_64_(&N, X, &incX);
  52. }
  53. void STARPU_SSCAL(BLASINT N, float alpha, float *X, BLASINT incX)
  54. {
  55. sscal_64_(&N, &alpha, X, &incX);
  56. }
  57. void STARPU_DSCAL(BLASINT N, double alpha, double *X, BLASINT incX)
  58. {
  59. dscal_64_(&N, &alpha, X, &incX);
  60. }
  61. void STARPU_STRSM (const char *side, const char *uplo, const char *transa,
  62. const char *diag, const BLASINT m, const BLASINT n,
  63. const float alpha, const float *A, const BLASINT lda,
  64. float *B, const BLASINT ldb)
  65. {
  66. strsm_64_(side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
  67. }
  68. void STARPU_DTRSM (const char *side, const char *uplo, const char *transa,
  69. const char *diag, const BLASINT m, const BLASINT n,
  70. const double alpha, const double *A, const BLASINT lda,
  71. double *B, const BLASINT ldb)
  72. {
  73. dtrsm_64_(side, uplo, transa, diag, &m, &n, &alpha, A, &lda, B, &ldb);
  74. }
  75. void STARPU_SSYR (const char *uplo, const BLASINT n, const float alpha,
  76. const float *x, const BLASINT incx, float *A, const BLASINT lda)
  77. {
  78. ssyr_64_(uplo, &n, &alpha, x, &incx, A, &lda);
  79. }
  80. void STARPU_SSYRK (const char *uplo, const char *trans, const BLASINT n,
  81. const BLASINT k, const float alpha, const float *A,
  82. const BLASINT lda, const float beta, float *C,
  83. const BLASINT ldc)
  84. {
  85. ssyrk_64_(uplo, trans, &n, &k, &alpha, A, &lda, &beta, C, &ldc);
  86. }
  87. void STARPU_SGER(const BLASINT m, const BLASINT n, const float alpha,
  88. const float *x, const BLASINT incx, const float *y,
  89. const BLASINT incy, float *A, const BLASINT lda)
  90. {
  91. sger_64_(&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
  92. }
  93. void STARPU_DGER(const BLASINT m, const BLASINT n, const double alpha,
  94. const double *x, const BLASINT incx, const double *y,
  95. const BLASINT incy, double *A, const BLASINT lda)
  96. {
  97. dger_64_(&m, &n, &alpha, x, &incx, y, &incy, A, &lda);
  98. }
  99. void STARPU_STRSV (const char *uplo, const char *trans, const char *diag,
  100. const BLASINT n, const float *A, const BLASINT lda, float *x,
  101. const BLASINT incx)
  102. {
  103. strsv_64_(uplo, trans, diag, &n, A, &lda, x, &incx);
  104. }
  105. void STARPU_STRMM(const char *side, const char *uplo, const char *transA,
  106. const char *diag, const BLASINT m, const BLASINT n,
  107. const float alpha, const float *A, const BLASINT lda,
  108. float *B, const BLASINT ldb)
  109. {
  110. strmm_64_(side, uplo, transA, diag, &m, &n, &alpha, A, &lda, B, &ldb);
  111. }
  112. void STARPU_DTRMM(const char *side, const char *uplo, const char *transA,
  113. const char *diag, const BLASINT m, const BLASINT n,
  114. const double alpha, const double *A, const BLASINT lda,
  115. double *B, const BLASINT ldb)
  116. {
  117. dtrmm_64_(side, uplo, transA, diag, &m, &n, &alpha, A, &lda, B, &ldb);
  118. }
  119. void STARPU_STRMV(const char *uplo, const char *transA, const char *diag,
  120. const BLASINT n, const float *A, const BLASINT lda, float *X,
  121. const BLASINT incX)
  122. {
  123. strmv_64_(uplo, transA, diag, &n, A, &lda, X, &incX);
  124. }
  125. void STARPU_SAXPY(const BLASINT n, const float alpha, float *X, const BLASINT incX, float *Y, const BLASINT incY)
  126. {
  127. saxpy_64_(&n, &alpha, X, &incX, Y, &incY);
  128. }
  129. void STARPU_DAXPY(const BLASINT n, const double alpha, double *X, const BLASINT incX, double *Y, const BLASINT incY)
  130. {
  131. daxpy_64_(&n, &alpha, X, &incX, Y, &incY);
  132. }
  133. BLASINT STARPU_ISAMAX (const BLASINT n, float *X, const BLASINT incX)
  134. {
  135. BLASINT retVal;
  136. retVal = isamax_64_ (&n, X, &incX);
  137. return retVal;
  138. }
  139. BLASINT STARPU_IDAMAX (const BLASINT n, double *X, const BLASINT incX)
  140. {
  141. BLASINT retVal;
  142. retVal = idamax_64_ (&n, X, &incX);
  143. return retVal;
  144. }
  145. float STARPU_SDOT(const BLASINT n, const float *x, const BLASINT incx, const float *y, const BLASINT incy)
  146. {
  147. float retVal = 0;
  148. /* GOTOBLAS will return a FLOATRET which is a double, not a float */
  149. retVal = (float)sdot_64_(&n, x, &incx, y, &incy);
  150. return retVal;
  151. }
  152. double STARPU_DDOT(const BLASINT n, const double *x, const BLASINT incx, const double *y, const BLASINT incy)
  153. {
  154. return ddot_64_(&n, x, &incx, y, &incy);
  155. }
  156. void STARPU_SSWAP(const BLASINT n, float *X, const BLASINT incX, float *Y, const BLASINT incY)
  157. {
  158. sswap_64_(&n, X, &incX, Y, &incY);
  159. }
  160. void STARPU_DSWAP(const BLASINT n, double *X, const BLASINT incX, double *Y, const BLASINT incY)
  161. {
  162. dswap_64_(&n, X, &incX, Y, &incY);
  163. }