-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexact_block_inc.c
66 lines (62 loc) · 1.92 KB
/
exact_block_inc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
static void LABEL (const double* A_T, const double* B, double* restrict C) {
int i, j, k;
register double acc_00, acc_01, acc_10, acc_11;
for (i = 0; i < LDA_; i+=2)
{
for (j = 0; j < LDA_; j+=2)
{
acc_00 = *(C + (i+0) + (j+0)*LDA);
acc_01 = *(C + (i+0) + (j+1)*LDA);
acc_10 = *(C + (i+1) + (j+0)*LDA);
acc_11 = *(C + (i+1) + (j+1)*LDA);
for (k = 0; k < LDA; k++)
{
acc_00 += (*(A_T + (i+0)*LDA_A + k)) * (*(B + k + (j+0)*LDA));
acc_01 += (*(A_T + (i+0)*LDA_A + k)) * (*(B + k + (j+1)*LDA));
acc_10 += (*(A_T + (i+1)*LDA_A + k)) * (*(B + k + (j+0)*LDA));
acc_11 += (*(A_T + (i+1)*LDA_A + k)) * (*(B + k + (j+1)*LDA));
}
*(C + (i+0) + (j+0)*LDA) = acc_00;
*(C + (i+0) + (j+1)*LDA) = acc_01;
*(C + (i+1) + (j+0)*LDA) = acc_10;
*(C + (i+1) + (j+1)*LDA) = acc_11;
}
}
// If dim is odd, work on borders
// note: LDA_ = LDA-1
#ifdef BORDER
// last row
for (j = 0; j < LDA_; j+=2)
{
acc_00 = *(C + (LDA_) + (j+0)*LDA);
acc_01 = *(C + (LDA_) + (j+1)*LDA);
for (k = 0; k < LDA; k++)
{
acc_00 += (*(A_T + (LDA_)*LDA_A + k)) * (*(B + k + (j+0)*LDA));
acc_01 += (*(A_T + (LDA_)*LDA_A + k)) * (*(B + k + (j+1)*LDA));
}
*(C + (LDA_) + (j+0)*LDA) = acc_00;
*(C + (LDA_) + (j+1)*LDA) = acc_01;
}
// last column
for (i = 0; i < LDA_; i+=2)
{
acc_00 = *(C + (i+0) + (LDA_)*LDA);
acc_10 = *(C + (i+1) + (LDA_)*LDA);
for (k = 0; k < LDA; k++)
{
acc_00 += (*(A_T + (i+0)*LDA_A + k)) * (*(B + k + (LDA_)*LDA));
acc_10 += (*(A_T + (i+1)*LDA_A + k)) * (*(B + k + (LDA_)*LDA));
}
*(C + (i+0) + (LDA_)*LDA) = acc_00;
*(C + (i+1) + (LDA_)*LDA) = acc_10;
}
// last element
acc_00 = *(C + (LDA_) + (LDA_)*LDA);
for (k = 0; k < LDA; k++)
{
acc_00 += (*(A_T + (LDA_)*LDA_A + k)) * (*(B + k + (LDA_)*LDA));
}
*(C + (LDA_) + (LDA_)*LDA) = acc_00;
#endif
}