none
OpenMP development questions RRS feed

  • Question

  •  

    Hi there, I get a desktop machine having  two Intel Core2 processors, to utilise the mutli-processor machine with OpenMP, I wrote a benckmark code to verify the supportness of OpenMP in Visual Studio 2005.

     

    When I increase the numbe of parallel thread from One to Two, I saw the improvement in performance which is in term of the running time nearly decreased by half; however when I continue increase the number of threads to 4, I didn't see much improvement, the perofrmance seems stay constantly at the level of 2 parallel thread.

     

    In Solaris system, when I submitted a such parallel code, I can specify how many cpu resouce I want for executing it, does anybody know do I need to do that in VS 2005 and how?

     

    There is the code

     

     for (int loop = 0 ; loop < 10; loop++)
     { 
      time[loop] = 0.0;

      __int64 ctr1 = 0, ctr2 = 0, freq = 0;

     

      QueryPerformanceCounter((LARGE_INTEGER *)&ctr1);

      int tid, i, j;


      omp_set_num_threads(NUM_THREAD);
       #pragma omp parallel shared(A,B,D) private(tid,i,j)
      {
       tid = omp_get_thread_num();
       for (j = tid; j < MAXLOOP; j += NUM_THREAD)
       { 
        for(i = 0; i < MAX; i++)
         D [ i ] = A [ i ] * A [ i ] + B [ i ] * B [ i ] + A [ i ] * B [ i ] ;
       }
      }

     

      QueryPerformanceCounter((LARGE_INTEGER *)&ctr2);

      QueryPerformanceFrequency((LARGE_INTEGER *)&freq);

      time[loop] = (ctr2 - ctr1) * 1.0 / freq;

      AverageExTime += time[loop];
     }

     AverageExTime = AverageExTime/10;

    Friday, September 21, 2007 2:47 PM

Answers

  • When you have dual core, you actually have 2 processors, and 2 processors can run two separate threads actually at a time (not like the simulation of parallel executaion in case of single processor), so once you increase the number of threads beyond the number of processors available, it's not gonna make any difference in 'time' factor.

    Saturday, September 22, 2007 9:34 AM