SET KMP_AFFINITY=compact would cause your Intel OpenMP application to attempt to pair up threads [0,1],[2,3],.... on shared cache. This would usually be a good strategy, provided that it is the only task running. If you have a HyperThreading enabled, as on quad core I7, and wish to use 1 thread per core, try SET KMP_AFFINITY=compact,1 SET OMP_NUM_THREADS=4
The ,1 directs the affinity to use alternate logical processors.
The verbose option gives you all the information about topology discovery and the assignments you requested, including whether it is set to choose any logical processor in a specified group. You can specifiy a full mapping with the proclist option, e.g. SET KMP_AFFINITY="proclist=[0,2],explicit,verbose" SET OMP_NUM_THREADS=2 for 1 job, and proclist=[1,3] for another, if you wanted to run 2 2-thread jobs on a Q6600 with minimum interference. Note that Q6600 BIOS numbers cores in a checkerboard order; you can see this with verbose.
kmp_set_affinity() is available as a call to libiomp from the application. It takes similar strings to the environment variable strings. Evidently, you would include verbose at first to check it. It would not affect a current parallel region.
The documents on this subject which come with the compiler are important reading.
but it says : error C2065: 'KMP_AFFINITY' : undeclared identifier
is there any prerequisite required before writing this statement in my program?? i mean any environment variable to be set explicitly?? if so can you please elaborate it.. please.. as i said i am a newbie so please explain in detail...
KMP_AFFINITY is an environment variable. I set it in bash, but I assumed you would use SET. kmp_set_affinity should be resolved in libiomp, if you make the function call. Try the environment variable first.