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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:44:28+00:00 2026-05-28T05:44:28+00:00

I would like to do some transformation to the IplImage using OpenMP. It is

  • 0

I would like to do some transformation to the IplImage using OpenMP. It is simple transformation that turns image upside down. The code with OpenMP runs the same as without. It doesn’t really matter.

void UpsideDownFilter::filter(IplImage* dstImage) {
uchar temp;
int j;
int i;
#pragma omp parallel shared(dstImage) private(j, i, temp)
{
    //        std::cout << omp_get_thread_num() << std::endl;
#pragma omp for schedule(static, 30) nowait
    for(j = 0; j < dstImage->height / 2; ++j) {

        for(i = 0; i < dstImage->widthStep; ++i) {
            temp = dstImage->imageData[i + j * dstImage->widthStep];

            dstImage->imageData[i + j * dstImage->widthStep] =
                dstImage->imageData[i + (dstImage->height - 1 - j) * 
                                    dstImage->widthStep];

            dstImage->imageData[i + (dstImage->height - 1 - j) * 
                                dstImage->widthStep] = temp;
        }
    }
}
}

I’ve already pushed the #pragma omp for to inner loop. I’ve done all the other magic stuff I usually do when I don’t have a clue what’s wrong (delete this, add that). This is how I call that method from my code:

for (vector<filter_ptr>::iterator it = filters.begin();
     it != filters.end(); ++it) {

    (*it)->filter(dstImage);
}

Could anybody tell me what I’m doing wrong?

  • 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-28T05:44:29+00:00Added an answer on May 28, 2026 at 5:44 am

    Since I couldn’t compile your code I wrote my own which I think is pretty similar. You have flattened your 2D matrix and I couldn’t be bothered but I don’t think that will affect what I think is going wrong for you.

    #include <vector>
    
    typedef std::vector<std::vector<double> > matrix_t;
    
    void flip(matrix_t& A, int const m, int n)
    {
        int m_2 = m / 2;
        #pragma omp parallel for
        for (int i = 0; i < m_2; ++i) {
            for (int j = 0; j < n; ++j) {
                std::swap(A[i][j], A[m - (i + 1)][j]);
            }
        }
    }
    
    int
    main()
    {
        int n = 20000;
        matrix_t A (n, std::vector<double>(n, 1.0));
        flip(A, n, n);
        return 0;
    }
    

    On a quad core machine I get no speedup as well.

    > g++ -O2 s18.cc && /usr/bin/time ./a.out && g++ -fopenmp -O2 s18.cc && /usr/bin/time ./a.out 
    2.61user 2.18system 0:04.79elapsed 99%CPU (0avgtext+0avgdata 12805936maxresident)k
    0inputs+0outputs (0major+800428minor)pagefaults 0swaps
    7.67user 2.23system 0:04.71elapsed 210%CPU (0avgtext+0avgdata 12806512maxresident)k
    0inputs+0outputs (0major+800481minor)pagefaults 0swaps
    

    I think the reason why there is no speedup is because the program is memory bound. That is the speed of the program is controlled by the speed of sending data to and from memory. So no matter how many cores you have you can’t go any faster because they are not the limiting factor.

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

Sidebar

Related Questions

I am developing a site and i would like some simple markup. I would
I would like some advice on the best approach to use in the following
I would like some of my preferences to have icons, like the Settings app.
I am learning C++ exceptions and I would like some clarification of the scenario:
I am designing RESTful Api's and would like some advice on designing an API
I'm writing a small application in VB.NET and I would like some of the
We are designing a new database and I would like some input in where
Hi I seem to be at an ORM Tool crossroad and would like some
I am considering starting an OSS project and would like some advice. I would
I got nabbed by the following bug again and would like some clarification to

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.