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.

xgemmt.c 2.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "test.h"
  2. datatype *A[2], *B[2], *C[2], *Ctmp;
  3. int info;
  4. void pre() {
  5. x2matgen(n, n, A[0], A[1]);
  6. x2matgen(n, n, B[0], B[1]);
  7. x2matgen(n, n, C[0], C[1]);
  8. }
  9. void post() {
  10. error = x2vecerr(n * n, C[0], C[1]);
  11. }
  12. #define ROUTINE XPREF(gemmt)
  13. #define xlacpy XPREF(LAPACK(lacpy))
  14. #define xgemm XPREF(BLAS(gemm))
  15. extern void xlacpy(const char *, const int *, const int *, const datatype *, const int *, datatype *, const int *);
  16. extern void xgemm(const char *, const char *, const int *, const int *, const int *, const datatype *, const datatype *, const int *, const datatype *, const int *, const datatype *, const datatype *, const int*);
  17. void XLAPACK(ROUTINE)(
  18. const char *uplo, const char *transA, const char *transB,
  19. const int *n, const int *k,
  20. const datatype *alpha, const datatype *A, const int *ldA,
  21. const datatype *B, const int *ldB,
  22. const datatype *beta, datatype *C, const int *ldC
  23. ) {
  24. xlacpy(uplo, n, n, C, ldC, Ctmp, n);
  25. xgemm(transA, transB, n, n, k, alpha, A, ldA, B, ldB, beta, Ctmp, n);
  26. xlacpy(uplo, n, n, Ctmp, ldC, C, n);
  27. }
  28. void tests() {
  29. A[0] = xmalloc(n * n);
  30. A[1] = xmalloc(n * n);
  31. B[0] = xmalloc(n * n);
  32. B[1] = xmalloc(n * n);
  33. C[0] = xmalloc(n * n);
  34. C[1] = xmalloc(n * n);
  35. Ctmp = xmalloc(n * n);
  36. TEST("L", "N", "N", &n, &n, ONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  37. TEST("L", "N", "N", &n, &n, ONE, A[i], &n, B[i], &n, MONE, C[i], &n);
  38. TEST("L", "N", "N", &n, &n, MONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  39. TEST("L", "N", "T", &n, &n, ONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  40. TEST("L", "T", "N", &n, &n, ONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  41. TEST("L", "N", "N", &n, &n2, ONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  42. TEST("U", "N", "N", &n, &n, ONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  43. TEST("U", "N", "N", &n, &n, ONE, A[i], &n, B[i], &n, MONE, C[i], &n);
  44. TEST("U", "N", "N", &n, &n, MONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  45. TEST("U", "N", "T", &n, &n, ONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  46. TEST("U", "T", "N", &n, &n, ONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  47. TEST("U", "N", "N", &n, &n2, ONE, A[i], &n, B[i], &n, ONE, C[i], &n);
  48. free(A[0]);
  49. free(A[1]);
  50. free(B[0]);
  51. free(B[1]);
  52. free(C[0]);
  53. free(C[1]);
  54. free(Ctmp);
  55. }