10 #ifndef EIGEN_SPARSELU_GEMM_KERNEL_H
11 #define EIGEN_SPARSELU_GEMM_KERNEL_H
24 template<
typename Scalar>
36 RK = NumberOfRegisters>=16 ? 4 : 2,
60 Index actual_b = std::min<Index>(BM,
m-ib);
61 Index actual_b_end1 = (actual_b/SM)*SM;
62 Index actual_b_end2 = (actual_b/PacketSize)*PacketSize;
70 for(
Index k=0; k<d_end; k+=RK)
74 Packet b00, b10, b20, b30, b01, b11, b21, b31;
75 { b00 = pset1<Packet>(Bc0[0]); }
76 { b10 = pset1<Packet>(Bc0[1]); }
77 if(RK==4) { b20 = pset1<Packet>(Bc0[2]); }
78 if(RK==4) { b30 = pset1<Packet>(Bc0[3]); }
79 { b01 = pset1<Packet>(Bc1[0]); }
80 { b11 = pset1<Packet>(Bc1[1]); }
81 if(RK==4) { b21 = pset1<Packet>(Bc1[2]); }
82 if(RK==4) { b31 = pset1<Packet>(Bc1[3]); }
94 a0 = pload<Packet>(
A0);
95 a1 = pload<Packet>(
A1);
98 a2 = pload<Packet>(
A2);
99 a3 = pload<Packet>(
A3);
107 #define KMADD(c, a, b, tmp) {tmp = b; tmp = pmul(a,tmp); c = padd(c,tmp);}
109 c0 = pload<Packet>(C0+i+(I)*PacketSize); \
110 c1 = pload<Packet>(C1+i+(I)*PacketSize); \
111 KMADD(c0, a0, b00, t0) \
112 KMADD(c1, a0, b01, t1) \
113 a0 = pload<Packet>(A0+i+(I+1)*PacketSize); \
114 KMADD(c0, a1, b10, t0) \
115 KMADD(c1, a1, b11, t1) \
116 a1 = pload<Packet>(A1+i+(I+1)*PacketSize); \
117 if(RK==4){ KMADD(c0, a2, b20, t0) }\
118 if(RK==4){ KMADD(c1, a2, b21, t1) }\
119 if(RK==4){ a2 = pload<Packet>(A2+i+(I+1)*PacketSize); }\
120 if(RK==4){ KMADD(c0, a3, b30, t0) }\
121 if(RK==4){ KMADD(c1, a3, b31, t1) }\
122 if(RK==4){ a3 = pload<Packet>(A3+i+(I+1)*PacketSize); }\
123 pstore(C0+i+(I)*PacketSize, c0); \
124 pstore(C1+i+(I)*PacketSize, c1)
127 for(
Index i=0;
i<actual_b_end1;
i+=PacketSize*8)
145 for(
Index i=actual_b_end1;
i<actual_b_end2;
i+=PacketSize)
151 for(
Index i=actual_b_end2;
i<actual_b; ++
i)
155 C0[
i] +=
A0[
i]*Bc0[0]+
A1[
i]*Bc0[1]+
A2[
i]*Bc0[2]+
A3[
i]*Bc0[3];
160 C0[
i] +=
A0[
i]*Bc0[0]+
A1[
i]*Bc0[1];
174 for(
Index k=0; k<d_end; k+=RK)
178 Packet b00, b10, b20, b30;
179 b00 = pset1<Packet>(Bc0[0]);
180 b10 = pset1<Packet>(Bc0[1]);
181 if(RK==4) b20 = pset1<Packet>(Bc0[2]);
182 if(RK==4) b30 = pset1<Packet>(Bc0[3]);
193 a0 = pload<Packet>(
A0);
194 a1 = pload<Packet>(
A1);
197 a2 = pload<Packet>(
A2);
198 a3 = pload<Packet>(
A3);
207 c0 = pload<Packet>(C0+i+(I)*PacketSize); \
208 KMADD(c0, a0, b00, t0) \
209 a0 = pload<Packet>(A0+i+(I+1)*PacketSize); \
210 KMADD(c0, a1, b10, t0) \
211 a1 = pload<Packet>(A1+i+(I+1)*PacketSize); \
212 if(RK==4){ KMADD(c0, a2, b20, t0) }\
213 if(RK==4){ a2 = pload<Packet>(A2+i+(I+1)*PacketSize); }\
214 if(RK==4){ KMADD(c0, a3, b30, t0) }\
215 if(RK==4){ a3 = pload<Packet>(A3+i+(I+1)*PacketSize); }\
216 pstore(C0+i+(I)*PacketSize, c0);
219 for(
Index i=0;
i<actual_b_end1;
i+=PacketSize*8)
232 for(
Index i=actual_b_end1;
i<actual_b_end2;
i+=PacketSize)
237 for(
Index i=actual_b_end2;
i<actual_b; ++
i)
240 C0[
i] +=
A0[
i]*Bc0[0]+
A1[
i]*Bc0[1]+
A2[
i]*Bc0[2]+
A3[
i]*Bc0[3];
242 C0[
i] +=
A0[
i]*Bc0[0]+
A1[
i]*Bc0[1];
257 Alignment = PacketSize>1 ?
Aligned : 0
261 if(rd==1) MapVector(
C+
j*ldc+ib,actual_b) +=
B[0+d_end+
j*ldb] * ConstMapVector(
A+(d_end+0)*
lda+ib, actual_b);
263 else if(rd==2) MapVector(
C+
j*ldc+ib,actual_b) +=
B[0+d_end+
j*ldb] * ConstMapVector(
A+(d_end+0)*
lda+ib, actual_b)
264 +
B[1+d_end+
j*ldb] * ConstMapVector(
A+(d_end+1)*
lda+ib, actual_b);
266 else MapVector(
C+
j*ldc+ib,actual_b) +=
B[0+d_end+
j*ldb] * ConstMapVector(
A+(d_end+0)*
lda+ib, actual_b)
267 +
B[1+d_end+
j*ldb] * ConstMapVector(
A+(d_end+1)*
lda+ib, actual_b)
268 +
B[2+d_end+
j*ldb] * ConstMapVector(
A+(d_end+2)*
lda+ib, actual_b);
280 #endif // EIGEN_SPARSELU_GEMM_KERNEL_H