- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
I'm using the Intel compiler / openMP to parallelize some work as follows:
#pragma omp parallel num_threads(4)
{
DoWork();
}
I'd like to experiment with Intel's thread affinity feature for OpenMP but I'munsure of exactlyhow to use the environment variable (for example, where do i place the environment statement statement in my code?). Could someone please give a little example showing proper usage and where to place the statement? Thank you in advance.
-L
I'm using the Intel compiler / openMP to parallelize some work as follows:
#pragma omp parallel num_threads(4)
{
DoWork();
}
I'd like to experiment with Intel's thread affinity feature for OpenMP but I'munsure of exactlyhow to use the environment variable (for example, where do i place the environment statement statement in my code?). Could someone please give a little example showing proper usage and where to place the statement? Thank you in advance.
-L
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Normally, you would set the environment variable in your shell before launching the program, e.g.
export KMP_AFFINITY=compact
for Core 2 Quad: that would put consecutive threads on same cache. For Core i7, it would put consecutive threads on the same core, using both logicals, if HT is enabled.
or
KMP_AFFINITY=physical
##(for Core I7: use 1 logical per core)
Of course, you could build it into your program by a putenv() function call prior to your first omp parallel .
The verbose version, which shows what the Intel OpenMP library sees on your system, and what it does with the options you set, is obtained by appending ,0,verbose e.g. on Windows CMD shell,
SET KMP_AFFINITY=physical,0,verbose
The affinity setting is most effective with default static scheduling, using the same scheduling from the first time the array is touched. For schedule(guided), it will work well with the initial phase.
If you were using KMP_AFFINITY to promote peaceful coexistence of multiple jobs, you would have to specify a separate set of cores for each job (not so simple to explain).
export KMP_AFFINITY=compact
for Core 2 Quad: that would put consecutive threads on same cache. For Core i7, it would put consecutive threads on the same core, using both logicals, if HT is enabled.
or
KMP_AFFINITY=physical
##(for Core I7: use 1 logical per core)
Of course, you could build it into your program by a putenv() function call prior to your first omp parallel .
The verbose version, which shows what the Intel OpenMP library sees on your system, and what it does with the options you set, is obtained by appending ,0,verbose e.g. on Windows CMD shell,
SET KMP_AFFINITY=physical,0,verbose
The affinity setting is most effective with default static scheduling, using the same scheduling from the first time the array is touched. For schedule(guided), it will work well with the initial phase.
If you were using KMP_AFFINITY to promote peaceful coexistence of multiple jobs, you would have to specify a separate set of cores for each job (not so simple to explain).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tim18
Normally, you would set the environment variable in your shell before launching the program, e.g.
export KMP_AFFINITY=compact
for Core 2 Quad: that would put consecutive threads on same cache. For Core i7, it would put consecutive threads on the same core, using both logicals, if HT is enabled.
or
KMP_AFFINITY=physical
##(for Core I7: use 1 logical per core)
Of course, you could build it into your program by a putenv() function call prior to your first omp parallel .
The verbose version, which shows what the Intel OpenMP library sees on your system, and what it does with the options you set, is obtained by appending ,0,verbose e.g. on Windows CMD shell,
SET KMP_AFFINITY=physical,0,verbose
The affinity setting is most effective with default static scheduling, using the same scheduling from the first time the array is touched. For schedule(guided), it will work well with the initial phase.
If you were using KMP_AFFINITY to promote peaceful coexistence of multiple jobs, you would have to specify a separate set of cores for each job (not so simple to explain).
export KMP_AFFINITY=compact
for Core 2 Quad: that would put consecutive threads on same cache. For Core i7, it would put consecutive threads on the same core, using both logicals, if HT is enabled.
or
KMP_AFFINITY=physical
##(for Core I7: use 1 logical per core)
Of course, you could build it into your program by a putenv() function call prior to your first omp parallel .
The verbose version, which shows what the Intel OpenMP library sees on your system, and what it does with the options you set, is obtained by appending ,0,verbose e.g. on Windows CMD shell,
SET KMP_AFFINITY=physical,0,verbose
The affinity setting is most effective with default static scheduling, using the same scheduling from the first time the array is touched. For schedule(guided), it will work well with the initial phase.
If you were using KMP_AFFINITY to promote peaceful coexistence of multiple jobs, you would have to specify a separate set of cores for each job (not so simple to explain).
I'm sorry, do you mean (in WinXP) go to:
Control Panel -> System -> Advanced -> Environment Variables -> New...
and enter "KMP_AFFINITY" in the "Variable name" field and "compact" in the "Variable value" field?
-L
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - ltkeene
I'm sorry, do you mean (in WinXP) go to:
Control Panel -> System -> Advanced -> Environment Variables -> New...
and enter "KMP_AFFINITY" in the "Variable name" field and "compact" in the "Variable value" field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have created an article to explain it with an example. The article is available at http://software.intel.com/en-us/articles/intel-thread-affinity-environment-variable-for-openmp/.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page