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.

c_xerbla.c 3.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <stdarg.h>
  4. #include <string.h>
  5. #include "common.h"
  6. #include "cblas_test.h"
  7. void cblas_xerbla(blasint info, char *rout, char *form, ...)
  8. {
  9. extern int cblas_lerr, cblas_info, cblas_ok;
  10. extern int link_xerbla;
  11. extern int RowMajorStrg;
  12. extern char *cblas_rout;
  13. /* Initially, c__3chke will call this routine with
  14. * global variable link_xerbla=1, and F77_xerbla will set link_xerbla=0.
  15. * This is done to fool the linker into loading these subroutines first
  16. * instead of ones in the CBLAS or the legacy BLAS library.
  17. */
  18. if (link_xerbla) return;
  19. if (cblas_rout != NULL && strcmp(cblas_rout, rout) != 0){
  20. printf("***** XERBLA WAS CALLED WITH SRNAME = <%s> INSTEAD OF <%s> *******\n", rout, cblas_rout);
  21. cblas_ok = FALSE;
  22. }
  23. if (RowMajorStrg)
  24. {
  25. /* To properly check leading dimension problems in cblas__gemm, we
  26. * need to do the following trick. When cblas__gemm is called with
  27. * CblasRowMajor, the arguments A and B switch places in the call to
  28. * f77__gemm. Thus when we test for bad leading dimension problems
  29. * for A and B, lda is in position 11 instead of 9, and ldb is in
  30. * position 9 instead of 11.
  31. */
  32. if (strstr(rout,"gemm") != 0)
  33. {
  34. if (info == 5 ) info = 4;
  35. else if (info == 4 ) info = 5;
  36. else if (info == 11) info = 9;
  37. else if (info == 9 ) info = 11;
  38. }
  39. else if (strstr(rout,"symm") != 0 || strstr(rout,"hemm") != 0)
  40. {
  41. if (info == 5 ) info = 4;
  42. else if (info == 4 ) info = 5;
  43. }
  44. else if (strstr(rout,"trmm") != 0 || strstr(rout,"trsm") != 0)
  45. {
  46. if (info == 7 ) info = 6;
  47. else if (info == 6 ) info = 7;
  48. }
  49. else if (strstr(rout,"gemv") != 0)
  50. {
  51. if (info == 4) info = 3;
  52. else if (info == 3) info = 4;
  53. }
  54. else if (strstr(rout,"gbmv") != 0)
  55. {
  56. if (info == 4) info = 3;
  57. else if (info == 3) info = 4;
  58. else if (info == 6) info = 5;
  59. else if (info == 5) info = 6;
  60. }
  61. else if (strstr(rout,"ger") != 0)
  62. {
  63. if (info == 3) info = 2;
  64. else if (info == 2) info = 3;
  65. else if (info == 8) info = 6;
  66. else if (info == 6) info = 8;
  67. }
  68. else if ( ( strstr(rout,"her2") != 0 || strstr(rout,"hpr2") != 0 )
  69. && strstr(rout,"her2k") == 0 )
  70. {
  71. if (info == 8) info = 6;
  72. else if (info == 6) info = 8;
  73. }
  74. }
  75. if (info != cblas_info){
  76. printf("***** XERBLA WAS CALLED WITH INFO = %d INSTEAD OF %d in %s *******\n",info, cblas_info, rout);
  77. cblas_lerr = PASSED;
  78. cblas_ok = FALSE;
  79. } else cblas_lerr = FAILED;
  80. }
  81. #ifdef F77_Char
  82. void F77_xerbla(F77_Char F77_srname, void *vinfo)
  83. #else
  84. void F77_xerbla(char *srname, void *vinfo)
  85. #endif
  86. {
  87. #ifdef F77_Char
  88. char *srname;
  89. #endif
  90. char rout[] = {'c','b','l','a','s','_','\0','\0','\0','\0','\0','\0','\0'};
  91. #ifdef F77_Integer
  92. F77_Integer *info=vinfo;
  93. F77_Integer i;
  94. extern F77_Integer link_xerbla;
  95. #else
  96. int *info=vinfo;
  97. int i;
  98. extern int link_xerbla;
  99. #endif
  100. #ifdef F77_Char
  101. srname = F2C_STR(F77_srname, XerblaStrLen);
  102. #endif
  103. /* See the comment in cblas_xerbla() above */
  104. if (link_xerbla)
  105. {
  106. link_xerbla = 0;
  107. return;
  108. }
  109. for(i=0; i < 6; i++) rout[i+6] = tolower(srname[i]);
  110. for(i=11; i >= 9; i--) if (rout[i] == ' ') rout[i] = '\0';
  111. /* We increment *info by 1 since the CBLAS interface adds one more
  112. * argument to all level 2 and 3 routines.
  113. */
  114. cblas_xerbla(*info+1,rout,"");
  115. }
  116. #ifdef USE64BITINT
  117. #undef int
  118. #endif
  119. int BLASFUNC(xerbla)(char *name, blasint *info, blasint length) {
  120. F77_xerbla(name, info);
  121. return 0;
  122. };