Community
cancel
Showing results for 
Search instead for 
Did you mean: 
svetlana_m
Beginner
54 Views

Execution time varies with OpenMP and Q6600

Hello,

I am trying to apply parallelism for an algoritm which sorts an array of 1,5 M records. I have divided the array into 4 parts and assigned each part to a core:

#pragma

omp parallel private(i,tid)

{

#pragma omp sections

{

#pragma omp section

{

BucketSort(A1); }

#pragma omp section

{

BucketSort(A2); }

#pragma omp section

{

BucketSort(A3); }

#pragma omp section

{

BucketSort(A4); }

} }

I am running the program on Intel Quad Q6600. I found that for the sequential program the execution time is 7 milisec. For the parallel program, the execution time varies significantly from 4ms to 22ms. I wonder what is the reason for this variation because it prevents me from measuring the real speedup. I tried to set the affinity for each thread to a different core, and there was no result. Can you please help me find the reason why performance is so unstable?

Thank you,

Svetlana

0 Kudos
2 Replies
jimdempseyatthecove
Black Belt
54 Views

Svetlana,

Consider setting block time to something other than 0ms and adding a dummy parallel section to get all threads running. Then fall into parallel section you wish to time

Jim Dempsey

 long count = 0;
// dummy parallel section to get all threads running
#pragma omp parallel private(i,tid)
{
_InterlockedIncrement(&count);
}
// get start time for compute section
double startTime = omp_get_wtime( );
#pragma omp parallel private(i,tid)
{
#pragma omp sections 
{ #pragma omp section
{ BucketSort(A1); }
#pragma omp section
{ BucketSort(A2); }
#pragma omp section
{ BucketSort(A3); }
#pragma omp section
{ BucketSort(A4); }
} }
// get end time for compute section
double endTime = omp_get_wtime( );
// compute elapse time
double elapsTime = endTime - startTime;
svetlana_m
Beginner
54 Views

Thank you Jim,

That solved the problem. The execution time is stable now.

Regards,

Svetlana

Reply