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 8733611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:41:01+00:00 2026-06-13T09:41:01+00:00

I’m trying to code a neon version of Sum of Absolute Difference of a

  • 0

I’m trying to code a neon version of Sum of Absolute Difference of a 16 uint8_t sized inputs:

inline static int f_sad_16(const uint8_t* a, const uint8_t* b)
{
  int sad = 0;
  for (int i = 0; i < 16; i++) {
    sad += abs(static_cast<int>(a[i]) - static_cast<int>(b[i]));
  }
  return sad;
}

The neon code I wrote:

inline static int f_sad_16_neon(const uint8_t* a, const uint8_t* b)
{
  int32_t r[4] = { 0, 0, 0, 0 };
  uint8x16_t va, vb, vr;

  va = vld1q_u8(a);
  vb = vld1q_u8(b);

  vr = vabdq_u8(va, vb);

  uint16x8_t vr1 = vpaddlq_u8 (vr );
  uint32x4_t vr2 = vpaddlq_u16(vr1);
  uint64x2_t vr3 = vpaddlq_u32(vr2);

  vst1q_u64 (reinterpret_cast<uint64_t*>(r), vr3);

  return r[0] + r[2];
}

For some reason I get a bus error. My test program uses the __attribute__ ((aligned (16))) gcc directive for the two inputs, and I can see by the memory addresses assigned to them that the inputs are 16-byte aligned.

What can be the source of the problem?

  • 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-13T09:41:03+00:00Added an answer on June 13, 2026 at 9:41 am

    You need to make sure that r is properly aligned – change:

    int32_t r[4] = { 0, 0, 0, 0 };
    

    to:

    int32_t r[4] = { 0, 0, 0, 0 } __attribute__ ((aligned(16)));
    

    Note however that it’s unlikely that this routine will be beneficial, as it uses a significant number of both scalar and NEON instructions, which means it will most likely have performance similar to that of your original scalar implementation.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.