sipeed/TinyMaix

Question: Why do we need to add eight to a loop?

Opened this issue · 2 comments

TinyMaix/src/arch_cpu.h

Lines 21 to 41 in 9487854

TM_INLINE void tm_dot_prod(mtype_t* sptr, mtype_t* kptr,uint32_t size, sumtype_t* result)
{
sumtype_t sum=0;
uint32_t i = 0;
uint32_t cnt = (size>>3)<<3; //8
for(; i+8-1 <cnt; ){
sum += sptr[i]*kptr[i];i++;
sum += sptr[i]*kptr[i];i++;
sum += sptr[i]*kptr[i];i++;
sum += sptr[i]*kptr[i];i++;
sum += sptr[i]*kptr[i];i++;
sum += sptr[i]*kptr[i];i++;
sum += sptr[i]*kptr[i];i++;
sum += sptr[i]*kptr[i];i++;
}
for(; i <size; i++){
sum += sptr[i]*kptr[i];
}
*result = sum;
return;
}

Is there any skills?

Zepan commented

it is unroll to speedup

Answered. Issue can be closed