@@ -3974,7 +3974,6 @@ void kernel_mul_mm_impl(device const uchar * src0,
3974
3974
}
3975
3975
3976
3976
// same as kernel_mul_mm_impl, but src1 and dst are accessed via indices stored in src1ids
3977
- // TODO: simplify and optimize constants
3978
3977
template <typename block_q, short nl, void (*dequantize_func)(device const block_q *, short , thread half4x4 &)>
3979
3978
void kernel_mul_mm_id_impl (
3980
3979
device const uchar * src0,
@@ -4042,7 +4041,6 @@ void kernel_mul_mm_id_impl(
4042
4041
dequantize_func (x, il, temp_a);
4043
4042
threadgroup_barrier (mem_flags::mem_threadgroup);
4044
4043
4045
- #pragma unroll(16)
4046
4044
for (int i = 0 ; i < 16 ; i++) {
4047
4045
*(sa + SG_MAT_SIZE * ((tiitg / THREAD_PER_ROW / 8 ) \
4048
4046
+ (tiitg % THREAD_PER_ROW) * 16 + (i / 8 ) * 8 ) \
@@ -4061,38 +4059,25 @@ void kernel_mul_mm_id_impl(
4061
4059
threadgroup half * lsma = (sa + THREAD_MAT_M * SG_MAT_SIZE * (sgitg % 2 ));
4062
4060
threadgroup float * lsmb = (sb + THREAD_MAT_N * SG_MAT_SIZE * (sgitg / 2 ));
4063
4061
4064
- #pragma unroll(4)
4065
4062
for (int ik = 0 ; ik < BLOCK_SIZE_K / 8 ; ik++) {
4066
- #pragma unroll(4)
4067
4063
for (int i = 0 ; i < 4 ; i++) {
4068
4064
simdgroup_load (ma[i],lsma + SG_MAT_SIZE * i);
4069
4065
}
4070
4066
simdgroup_barrier (mem_flags::mem_none);
4071
- #pragma unroll(2)
4072
4067
for (int i = 0 ; i < 2 ; i++) {
4073
4068
simdgroup_load (mb[i],lsmb + SG_MAT_SIZE * i);
4074
4069
}
4075
4070
4076
4071
lsma += BLOCK_SIZE_M / SG_MAT_ROW * SG_MAT_SIZE;
4077
4072
lsmb += BLOCK_SIZE_N / SG_MAT_ROW * SG_MAT_SIZE;
4078
4073
4079
- #pragma unroll(8)
4080
4074
for (int i = 0 ; i < 8 ; i++){
4081
4075
simdgroup_multiply_accumulate (c_res[i], mb[i/4 ], ma[i%4 ], c_res[i]);
4082
4076
}
4083
4077
}
4084
4078
}
4085
4079
4086
- // TODO: this branch is invalid - need to fix it
4087
- // if ((r0 + 1) * BLOCK_SIZE_M <= ne0 && (r1 + 1) * BLOCK_SIZE_N <= ne1) {
4088
- // device float * C = dst + (BLOCK_SIZE_M * r0 + 32 * (sgitg & 1)) \
4089
- // + im*ne1*ne0;
4090
- // for (int i = 0; i < 8; i++) {
4091
- // simdgroup_store(c_res[i], C + 8 * (i%4) + ne0*src1ids[8*(i/4) + BLOCK_SIZE_N * r1 + 16 * (sgitg >> 1)], ne0);
4092
- // }
4093
- // } else {
4094
4080
{
4095
- // block is smaller than 64x32, we should avoid writing data outside of the matrix
4096
4081
threadgroup_barrier (mem_flags::mem_threadgroup);
4097
4082
threadgroup float * temp_str = ((threadgroup float *)shared_memory) \
4098
4083
+ 32 * (sgitg&1 ) + (16 * (sgitg>>1 )) * BLOCK_SIZE_M;
0 commit comments