Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6704 Discussions

Help: Want to setup the IPP environment inside of my program

like2learn
Beginner
364 Views

Thank you for your time in reading my post.

I am developing a C++ program with Visual Studio 2008 at Windows Vista platform. I would like to set a few OpenMP environment variables inside of my program. For example, I would like to set "KMP_AFFINITY=compact". Could anybody show me how to do it? I think setenv only works for UNIX and LINUX, right?

I also would like to know how to set the OpenMP environment variables manually or in the script. Is there any script/configuration file for the IPP? Can I set the OpenMP environment variables the same way as other windows system variables? I mean, buy opening "My Computer", select "Environment Variables", and create a variable for the environment variable then set its value?

Thank you!

Johnson

0 Kudos
3 Replies
like2learn
Beginner
364 Views

I tried _putenv to assign the environment variables. However, I was not sure if it is the right way to assign to set the OpenMP environment variables. Please verify.

_putenv( "KMP_AFFINITY=compact" );

0 Kudos
PaulF_IntelCorp
Employee
364 Views

Hello Johnson,

On a Windows system you can use the _putenv() function, but the effect will be limited to your process, and it may not have an impact on the OpenMP component of your app, depending on when that component initializes and reads the application environment space (the application environment space is essentially a copy of the system environment when your app started, similar to a Linux/UNIX machine). So this approach might not work... but I've never tested it so I can't be sure. Here's more info on that for Windows:

http://msdn.microsoft.com/en-us/library/aa298540(VS.60).aspx

Here's a link to how to change the environment variables directly within your system environment space. You'll see there is a system environment and a personal environment. Both appear when you go to the command line (run a cmd.exe box) and type "set" at the command line:

http://support.microsoft.com/kb/310519

You could also create a batch file that defines the environment variables and run it within a cmd.exe window before running your app (make sure to run the app from the same command line as the batch file, 'cause the environment variable changes implemented by the batch file will only apply to that cmd.exe window). Based on your post, the batch file could contain a single line:

set KMP_AFFINITY=compact

You could follow that line with the name of your app, so the batch file would set the environment variable and then start your app.

Here's more info from Microsoft regarding the command line and batch files and environment variables.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx

Hope that helps,

Paul

0 Kudos
like2learn
Beginner
364 Views

Thank you for your reply, Paul.

I also tried

Environment::SetEnvironmentVariable Method (String, String) in my program. It works fine and I can read and write environment variables (user, system) for the whole application.

Johnson

0 Kudos
Reply