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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:41:14+00:00 2026-06-10T11:41:14+00:00

I am trying to compare SSE float[4] addition to standard float[4] addition. I tried

  • 0

I am trying to compare SSE float[4] addition to standard float[4] addition. I tried this:

#include <iostream>
#include <vector>

struct Point4
{
  Point4()
  {
    data[0] = 0;
    data[1] = 0;
    data[2] = 0;
    data[3] = 0;
  }

  float data[4];
};

static float SumOfDifferences(const Point4& a, const Point4& b)
{
  // This function only returns the sum of the sum of the components
  float sumValues = 0.0f;
  for(unsigned int i = 0; i < 4; ++i)
  {
    sumValues += a.data[i] + b.data[i];
  }
  return sumValues;
}

void Standard()
{
  Point4 a;
  a.data[0] = 1;
  a.data[1] = 2;
  a.data[2] = 3;
  a.data[3] = 4;

  Point4 b;
  b.data[0] = 1;
  b.data[1] = 6;
  b.data[2] = 3;
  b.data[3] = 5;

  float total = 0.0f;
  for(unsigned int i = 0; i < 1e6; ++i)
  {
    total += SumOfDifferences(a, b);
  }

  std::cout << "total: " << total << std::endl;
}

void Vectorized()
{
  typedef int v4sf __attribute__ (( vector_size(4*sizeof(float)) ));

  v4sf a;
  float* aPointer = (float*)&a;
  aPointer[0] = 1; aPointer[1] = 2; aPointer[2] = 3; aPointer[3] = 4;

  v4sf b;
  float* bPointer = (float*)&b;
  bPointer[0] = 1; bPointer[1] = 2; bPointer[2] = 3; bPointer[3] = 4;

  float total = 0.0f;
  v4sf result;
  float* resultPointer = (float*)&result;

  for(unsigned int i = 0; i < 1e6; ++i)
  {
    result = a + b; // Vectorized operation

    // Sum the components of the result (this is done with the "total += " in the Standard() loop
    for(unsigned int component = 0; component < 4; ++component)
    {
      total += resultPointer[component];
    }
  }

  std::cout << "total: " << total << std::endl;
}

int main()
{

//  Standard();

  Vectorized();

  return 0;
}

but the output is ‘inf’ for the Vectorized() function. When I stepped through with a debugger, the values of ‘result’ seem to be garbage (i’d expect them to be (0, 4, 0, 1) ). Where am I going wrong here?

  • 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-10T11:41:15+00:00Added an answer on June 10, 2026 at 11:41 am

    Try typedef float v4sf __attribute__ (( vector_size(4*sizeof(float)) ));
    I get 2e+07 as the result.

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

Sidebar

Related Questions

I am trying to compare values on data frame rows, and removing all the
I'm trying to compare a character string with the argv argument. I have this
I'm trying to compare two images using: [DllImport(msvcrt.dll)] private static extern int memcmp(IntPtr b1,
I'm basicly trying to compare a token(string) with a hex-datatype! Example: #include<stdio.h> #include<string.h> int
im trying to compare two dates like this ICriteria criteria = base.DataStore.TransactionScope.NHibernateSession.CreateCriteria<CcCorte>(); criteria.Add(Restrictions.Ge(Start, init.Date));
I'm trying to compare the value of some data from an ajax request (json)
Trying to compare and print only members with Inactive status. The problem is that
When trying to compare software versions 5.12 to 5.8, version 5.12 is newer, however
Im trying to compare these two chars but on win 32 Visual Studio 2008:
I am trying to compare a date against the first of next month from

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.