You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cblas_sgemm.c 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. *
  3. * cblas_sgemm.c
  4. * This program is a C interface to sgemm.
  5. * Written by Keita Teranishi
  6. * 4/8/1998
  7. *
  8. */
  9. #include "cblas.h"
  10. #include "cblas_f77.h"
  11. void cblas_sgemm(const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE TransA,
  12. const CBLAS_TRANSPOSE TransB, const int M, const int N,
  13. const int K, const float alpha, const float *A,
  14. const int lda, const float *B, const int ldb,
  15. const float beta, float *C, const int ldc)
  16. {
  17. char TA, TB;
  18. #ifdef F77_CHAR
  19. F77_CHAR F77_TA, F77_TB;
  20. #else
  21. #define F77_TA &TA
  22. #define F77_TB &TB
  23. #endif
  24. #ifdef F77_INT
  25. F77_INT F77_M=M, F77_N=N, F77_K=K, F77_lda=lda, F77_ldb=ldb;
  26. F77_INT F77_ldc=ldc;
  27. #else
  28. #define F77_M M
  29. #define F77_N N
  30. #define F77_K K
  31. #define F77_lda lda
  32. #define F77_ldb ldb
  33. #define F77_ldc ldc
  34. #endif
  35. extern int CBLAS_CallFromC;
  36. extern int RowMajorStrg;
  37. RowMajorStrg = 0;
  38. CBLAS_CallFromC = 1;
  39. if( layout == CblasColMajor )
  40. {
  41. if(TransA == CblasTrans) TA='T';
  42. else if ( TransA == CblasConjTrans ) TA='C';
  43. else if ( TransA == CblasNoTrans ) TA='N';
  44. else
  45. {
  46. cblas_xerbla(2, "cblas_sgemm",
  47. "Illegal TransA setting, %d\n", TransA);
  48. CBLAS_CallFromC = 0;
  49. RowMajorStrg = 0;
  50. return;
  51. }
  52. if(TransB == CblasTrans) TB='T';
  53. else if ( TransB == CblasConjTrans ) TB='C';
  54. else if ( TransB == CblasNoTrans ) TB='N';
  55. else
  56. {
  57. cblas_xerbla(3, "cblas_sgemm",
  58. "Illegal TransB setting, %d\n", TransB);
  59. CBLAS_CallFromC = 0;
  60. RowMajorStrg = 0;
  61. return;
  62. }
  63. #ifdef F77_CHAR
  64. F77_TA = C2F_CHAR(&TA);
  65. F77_TB = C2F_CHAR(&TB);
  66. #endif
  67. F77_sgemm(F77_TA, F77_TB, &F77_M, &F77_N, &F77_K, &alpha, A, &F77_lda, B, &F77_ldb, &beta, C, &F77_ldc);
  68. } else if (layout == CblasRowMajor)
  69. {
  70. RowMajorStrg = 1;
  71. if(TransA == CblasTrans) TB='T';
  72. else if ( TransA == CblasConjTrans ) TB='C';
  73. else if ( TransA == CblasNoTrans ) TB='N';
  74. else
  75. {
  76. cblas_xerbla(2, "cblas_sgemm",
  77. "Illegal TransA setting, %d\n", TransA);
  78. CBLAS_CallFromC = 0;
  79. RowMajorStrg = 0;
  80. return;
  81. }
  82. if(TransB == CblasTrans) TA='T';
  83. else if ( TransB == CblasConjTrans ) TA='C';
  84. else if ( TransB == CblasNoTrans ) TA='N';
  85. else
  86. {
  87. cblas_xerbla(2, "cblas_sgemm",
  88. "Illegal TransB setting, %d\n", TransB);
  89. CBLAS_CallFromC = 0;
  90. RowMajorStrg = 0;
  91. return;
  92. }
  93. #ifdef F77_CHAR
  94. F77_TA = C2F_CHAR(&TA);
  95. F77_TB = C2F_CHAR(&TB);
  96. #endif
  97. F77_sgemm(F77_TA, F77_TB, &F77_N, &F77_M, &F77_K, &alpha, B, &F77_ldb, A, &F77_lda, &beta, C, &F77_ldc);
  98. } else
  99. cblas_xerbla(1, "cblas_sgemm",
  100. "Illegal layout setting, %d\n", layout);
  101. CBLAS_CallFromC = 0;
  102. RowMajorStrg = 0;
  103. }