Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
peter5232 opened this issue Dec 2, 2023 · 1 comment
Open

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

peter5232 opened this issue Dec 2, 2023 · 1 comment

Comments

@peter5232
Copy link

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
Copy link
Contributor

Zepan commented Dec 22, 2023

it is unroll to speedup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants