Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:02:31+00:00 2026-06-09T07:02:31+00:00

I need to implement the following loop in Neon. int jump=4,c[8],i; //c[8] may be

  • 0

I need to implement the following loop in Neon.

int jump=4,c[8],i;  //c[8] may be declared here
int *src,sum=0; //**EDIT:** src points to a 256 element array

for (i = 0; i < 4; i++)
{
  sum  = src[ i + 0 * jump] * c[0];//1
  sum += src[ i + 1 * jump] * c[1];//2
  sum += src[ i + 2 * jump] * c[2];//3
  sum += src[ i + 3 * jump] * c[3];//4
  sum += src[ i + 4 * jump] * c[4];//5
  sum += src[ i + 5 * jump] * c[5];//6
  sum += src[ i + 6 * jump] * c[6];//7
  sum += src[ i + 7 * jump] * c[7];//8


  src += 2;                       //9
}

**EDIT:**
 The code can be shortened as-

int jump=4,c[8],i,j; //initialize array c
int *src,sum,a[256];//initialize array a
src=a;
for (i = 0; i < 4; i++)
{
        sum=0;
        for (j = 0; j < 8; j++)
        {
                  int *p=src+ i + (j * jump);  
                  sum  += (*p)* c[j];    //sum  += src[ i + j* jump] * c[j]
        }
        printf("Sum:%d\n",sum);
        src += 2;                       
}


Just need to know a way to implement something like [%0]=[%0]+4 rather than [%0]!

The main optimization will come by running the instructions numbered 1-8 in parallel using VMLA instruction in NEON.

  1. We may do that by loading array c[8] into registers q0 and q1 and loading array src[256] into registers q2 and q3.After this we use VMLA,VADD,VPADD to get the result in the variable sum.
  2. The problem being faced is how to load the elements of array src (as src[0],src[4],src[8] and so on)since the only way i know how to load an array is by [%1]! which only loads an array sequentially(as src[0],src[1],src[2] and so on).

Also how may the pointer src be incremented by 2 in instruction 9?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:02:32+00:00Added an answer on June 9, 2026 at 7:02 am

    Instead of computing the sums one after another, compute them at the same time. Then you don’t need to skip source values, since every source value (presumably) affects some sum. Basically, what you do is computing (* means dot product).

    sum0 = source * (c0 0 0  0 c1 0  0  0 c2 0  0  0 ... c7  0 0  0 )
    sum1 = source * ( 0 0 0 c0  0 0  0 c1  0 0  0 c2 ...  0  0 0 c7 )
    sum2 = source * ( 0 0 0  0  0 0 c0  0  0 0 c1  0 ...  0  0 c6 0 )
    sum3 = source * ( 0 0 0  0  0 0  0  0  0 c0 0  0 ...  0 c5  0 0 )
    

    You can do that instead by doing

    sum0 = sum1 = sum2 = sum3 = 0
    
    sum0 += (s0 s1 s2 s3) * (c0  0  0  0)
    sum1 += (s0 s1 s2 s3) * ( 0  0  0 c0)
    sum2 += (s0 s1 s2 s3) * ( 0  0  0  0)
    sum3 += (s0 s1 s2 s3) * ( 0  0  0  0)
    
    sum0 += (s0 s1 s2 s3) * (c1  0  0  0)
    sum1 += (s0 s1 s2 s3) * ( 0  0  0 c1)
    sum2 += (s0 s1 s2 s3) * ( 0  0 c0  0)
    sum3 += (s0 s1 s2 s3) * ( 0  0  0  0)
    
    ...
    
    sum0 += (s0 s1 s2 s3) * (c7  0  0  0)
    sum1 += (s0 s1 s2 s3) * ( 0  0  0 c7)
    sum2 += (s0 s1 s2 s3) * ( 0  0 c6  0)
    sum3 += (s0 s1 s2 s3) * ( 0 c5  0  0)
    

    You don’t actually need a horizontal summing during the individual steps, you can just use vmul.32 (or maybe it’s accumuated form, if there is one) to compute the dot-products, then sum them horizontally at the end. You’ll just have to figure out a way to compute the coefficient vectors, but since they all have only a single non-zero element, you can simply use vset_lane.

    Or, even better, you can exploit that fact that each coefficient vector contains only one non-zero entry, and do one multipyl instead of four, then use vdup_lane extract each lane and add it to the sum. You’ll need to generate the coefficient vectors

    (c0  0  0  0)
    (c1  0 c0 c1)
    (c2 c0 c1 c2)
    ...
    (c7 c5 c6 c7)
    

    which should be easy if your coefficients are already stored consecutively – you just need to fixup the first element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning and using Web API and need to implement following Authentication mechanism
I need to implement the following: There is a table A which is supposed
we need to implement the following query in such a way that we should
I have an iPhone application and I need to implement the following method: +(UITextView
I'm new to WPF but I need to implement following functionality: I have a
I need to implement the following flow in my application: the user can click
I need to implement multi-tenancy and i like the way it is solved here
I need to implement the following custom action filter: Action filter, when applied to
I need to implement the following expression in a tablix: 1. NewRetail < cost
I need to implement following categorization in SQL: group can contain multiple tests or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.