MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / randomGemmxMatrices

Function randomGemmxMatrices

src/tests/include/blas-random.h:30–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29template <typename T>
30static void
31randomGemmxMatrices(
32 clblasOrder order,
33 clblasTranspose transA,
34 clblasTranspose transB,
35 clblasTranspose transC,
36 size_t M,
37 size_t N,
38 size_t K,
39 bool useAlpha,
40 T *alpha,
41 T *A,
42 size_t lda,
43 T *B,
44 size_t ldb,
45 bool useBeta,
46 T *beta,
47 T *C,
48 size_t ldc)
49{
50 size_t m, n, k;
51 cl_double bound;
52
53 if (!useAlpha) {
54 *alpha = random<T>(100);
55 if (module(*alpha) == 0.0) {
56 *alpha = ONE<T>();
57 }
58 }
59
60 bound = UPPER_BOUND<T>();
61 bound = sqrt(((K - 1) * bound) / (module(*alpha) * K * K));
62
63 for (m = 0; m < M; m++) {
64 for (k = 0; k < K; k++) {
65 setElement<T>(order, transA, m, k, A, lda, random<T>(bound));
66 }
67 }
68
69 if (B != NULL) {
70 for (k = 0; k < K; k++) {
71 for (n = 0; n < N; n++) {
72 setElement<T>(order, transB, k, n, B, ldb, random<T>(bound));
73 }
74 }
75 }
76
77 if ((!useBeta) && (beta != NULL)) {
78 *beta = random<T>(100);
79 }
80
81 if (C != NULL) {
82 // if C is not NULL, then beta must not be NULL.
83 bound = UPPER_BOUND<T>();
84 if (module(*beta) != 0.0) {
85 bound = sqrt(bound / (module(*beta) * K));
86 }
87

Callers

nothing calls this directly

Calls 1

moduleFunction · 0.70

Tested by

no test coverage detected