views:

303

answers:

1

Anyone think about it. OpenMP features to adjust cpu muscles to handle dumbbel. In my research for openmp we cannot set thread priority to execute block code with powerfull muscle. Only one way(_beginthreadex or CreateThread function with 5. parameters) to create threads with highest priority.

Here some code for this issue:

This is manual setting.

int numberOfCore = ( execute __cpuid to obtain number of cores on your cpu ).

HANDLES* hThreads = new HANDLES[ numberOfCore ];
hThreads[0] = _beginthreadex( NULL, 0, someThreadFunc, NULL, 0, NULL );

SetThreadPriority( hThreads[0], HIGH_PRIORITY_CLASS );

WaitForMultipleObjects(...);

Here is i want to see this part:

#pragma omp parallel
{
#pragma omp for ( threadpriority:HIGH_PRIORITY_CLASS )
 for( ;; ) { ... }
}

Or

#pragma omp parallel
{
// Generally this function greatly appreciativable.
_omp_set_priority( HIGH_PRIORITY_CLASS );
#pragma omp for
 for( ;; ) { ... }
}

I dont know if there was a way to setup priority with openmp pls inform us.

Best regars. İlhan

+1  A: 

You can do SetThreadPriority in the body of the loop without requiring special support from OpenMP:

for (...)
{
  DWORD priority=GetThreadPriority(...);
  SetThreadPriority(...);
  // stuff
  SetThreadPriority(priority);
}
1800 INFORMATION