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

  • Home
  • SEARCH
  • 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 978107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:00:36+00:00 2026-05-16T04:00:36+00:00

I have the code: float *mu_x_ptr; __m128 *tmp; __m128 *mm_mu_x; mu_x_ptr = _aligned_malloc(4*sizeof(float), 16);

  • 0

I have the code:

float *mu_x_ptr;
__m128 *tmp;
__m128 *mm_mu_x;

mu_x_ptr = _aligned_malloc(4*sizeof(float), 16);
mm_mu_x = (__m128*) mu_x_ptr;
for(row = 0; row < ker_size; row++) {
    tmp = (__m128*) &original[row*width + col];
    *mm_mu_x = _mm_add_ps(*tmp, *mm_mu_x);
}

From this I get:

First-chance exception at 0x00ad192e in SSIM.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00ad192e in SSIM.exe: 0xC0000005: Access violation reading location 0x00000000.
The program '[4452] SSIM.exe: Native' has exited with code -1073741819 (0xc0000005)

when running the program, the error occurs at the _mm_add_ps line.

original is allocated using _aligned_malloc(…, 16); as well and passed to the function, so it shouldn’t, as far as my understanding of sse goes, be that it’s not alligned.

I’m wondering if anyone can see why this crashes, since I can’t see why.

EDIT: Width and col is always multiples of 4. Col is 0 or 4, while width is always a multiple of 4.

EDIT2: Looks like my original array is not aligned. Wouldn’t:

function(float *original);
.
.
.
    orignal = _aligned_malloc(width*height*sizeof(float), 16);
    function(original);
    _aligned_free(original);
}

Make sure that original is alligned inside of function?

Edit3: This is actually really weird. When I do:

float *orig;
orig = _aligned_malloc(width*height*sizeof(float), 16);
assert(isAligned(orig));

The assert fails with

#define isAligned(p) (((unsigned long)(p)) & 15 == 0)
  • 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-05-16T04:00:36+00:00Added an answer on May 16, 2026 at 4:00 am

    I think you need to use

    __m128 tmp = _mm_load_ps( &original[row * width + col] );
    

    instead of

    tmp = (__m128 *)&original[row * width + col];
    

    EDIT: If you get access violation errors are after some offset then possibly your stride is not aligned. Either way allocate __m128 elements(which represent 4 floats). This takes care of the alignment.

    Also you can get some extra performance by eliminating the arithmetic [row * width + col].
    Determine your stride and increment your pointer accordingly.

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

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A byte value is signed, and you are using the… May 17, 2026 at 2:21 am
  • Editorial Team
    Editorial Team added an answer Page Blobs are the way to go for this need.… May 17, 2026 at 2:21 am
  • Editorial Team
    Editorial Team added an answer As you said, when you add a new field it… May 17, 2026 at 2:21 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following code: float valueCalculated = (val1 / val2) * 100; What
I currently have the following code: float a[4] = { 10, 20, 30, 40
Edit: original question below, but I revise it now that I have some code
I have some simple code that is comparing two float values to illustrate a
I have the following code (compiler: MSVC++ 10): std::vector<float> data; data.push_back(1.0f); data.push_back(1.0f); data.push_back(2.0f); //
I have code written in C which is intended for a 16-bit microcontroller. The
I have code that needs to render regions of my object differently depending on
I have code that boils down to the following: template <typename T> struct Foo
Can you not have code blocks in server tags? For example, I wish to
Here is my code float cpuLoad = 0; try{ MessageBox.Show(Running); //CPU Load PerformanceCounter cpuCounter

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.