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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:24:01+00:00 2026-05-26T20:24:01+00:00

So I’m having a little trouble figuring out the best way parallelizing these for

  • 0

So I’m having a little trouble figuring out the best way parallelizing these for loops using openmp. I’m guessing that biggest speed up would come from parallelizing the middle loop like I do here:

for(i = 0; i < m/16*16; i+=16){
    #pragma omp parallel for
        for(j = 0; j < m; j++){

            C_column_start = C+i+j*m;

            c_1 = _mm_loadu_ps(C_column_start);
            c_2 = _mm_loadu_ps(C_column_start+4);
            c_3 = _mm_loadu_ps(C_column_start+8);
            c_4 = _mm_loadu_ps(C_column_start+12);

            for (k=0; k < n; k+=2){

                A_column_start = A+k*m;

                a_1 = _mm_loadu_ps(A_column_start+i);
                a_2 = _mm_loadu_ps(A_column_start+i+4);
                a_3 = _mm_loadu_ps(A_column_start+i+8);
                a_4 = _mm_loadu_ps(A_column_start+i+12);

                b_1 = _mm_load1_ps(A_column_start+j);

                mul_1 = _mm_mul_ps(a_1, b_1);
                mul_2 = _mm_mul_ps(a_2, b_1);
                mul_3 = _mm_mul_ps(a_3, b_1);
                mul_4 = _mm_mul_ps(a_4, b_1);

                c_4 = _mm_add_ps(c_4, mul_4);
                c_3 = _mm_add_ps(c_3, mul_3);
                c_2 = _mm_add_ps(c_2, mul_2);
                c_1 = _mm_add_ps(c_1, mul_1);

                A_column_start+=m;

                a_1 = _mm_loadu_ps(A_column_start+i);
                a_2 = _mm_loadu_ps(A_column_start+i+4);
                a_3 = _mm_loadu_ps(A_column_start+i+8);
                a_4 = _mm_loadu_ps(A_column_start+i+12);

                b_1 = _mm_load1_ps(A_column_start+j);

                mul_1 = _mm_mul_ps(a_1, b_1);
                mul_2 = _mm_mul_ps(a_2, b_1);
                mul_3 = _mm_mul_ps(a_3, b_1);
                mul_4 = _mm_mul_ps(a_4, b_1);

                c_4 = _mm_add_ps(c_4, mul_4);
                c_3 = _mm_add_ps(c_3, mul_3);
                c_2 = _mm_add_ps(c_2, mul_2);
                c_1 = _mm_add_ps(c_1, mul_1);

            }


            _mm_storeu_ps(C_column_start, c_1);
            _mm_storeu_ps(C_column_start+4, c_2);
            _mm_storeu_ps(C_column_start+8, c_3);
            _mm_storeu_ps(C_column_start+12, c_4);

        }

    }

However, this is currently giving me almost no speed up. Any tips would be awesome. I’ve been stuck for quite a while now.

  • 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-26T20:24:01+00:00Added an answer on May 26, 2026 at 8:24 pm

    First of all, are you sure the loops are parallelizable? What is the range of the value m?

    When all three nested loops are parallelizable and m is sufficiently large (say at least 16 or so), then parallelizing the outer most loop will be most beneficial. Parallelizaing inner loops may have severe forking-joining overhead from omp parallel for.

    For the low speedup, here is some checklist:

    1. Are you sure all cores are utilized? Check a sort of task manager. Since no synchronization except for the implicit barrier of omp parallel for, all cores are should be utilized.
    2. Is m a huge number? And, what is the computation length? If m is huge while the computation is small, the parallel overhead due to omp parallel for may offset the benefit of the parallelization. When you parallelize an inner loop, the trip count (e.g., m) should not be huge.
    3. False sharing could be a reason. If your code modifies a lot of memory, it may cause false sharing, and the speedup could be hurt.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
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.