[Omp] Detecting No. of processors during OpenMP execution

Waibhav Tembe tembe at bioanalysis.org
Tue Jan 18 14:00:40 PST 2005


Hello,

Thanks for the response and explanation about omp_set_num_threads.

I had thought of using "hostname". But will it work when the process is 
running on a multi-processor single
node that has shared memory? I was under the impression that the 
"hostname" would refer to the node
and would output the same name independent of the actual cpu that is 
executing a thread. Perhaps, I
should have rephrased the question: Is it possible to monitor/find out 
which of the multiple cpus on a single
node is executing a particular thread called from OpenMP parallel 
execution routine? Is there a cpu_id
for each physical cpu on a given node in a cluster?

Apologies for not being clear when I stated my problem.

Thanks.

-waibhav

Marina Kraeva wrote:

> Hello,
>
> First of all, you can't set the number of processors from within your 
> program. The omp_set_num_threads function specifies the number of 
> threads, not processors.
>
> To find out the number of threads that are running specific piece of 
> the code you can call omp_get_num_threads.
>
> As I understood you would like to know on what processors your threads 
> are running. You can try to use something like this:
>
>   #include <unistd.h>
>   ...
>   char name[50];
>   size_t len;
>   ...
>   gethostname(name, len);
>   printf("thread %d is running on hostname %s\n",MyId,name);
>
> Marina.
>
> Waibhav Tembe wrote:
>
>> Hello,
>>
>> I am using OpenMP for my application on Linux system using Intel's 
>> ecc compiler with -openmp option on a node that has multiple 
>> processors sharing memory. Although there is a facility in OpenMP to 
>> set the number of processors (by selecting omp_ set_num_threads ), I 
>> was  wondering if there is any way (perhaps from the OS)  to check 
>> the actual number of processors that were used. For example, if I set 
>> num. of threads = 8 and for some reason, only 4 processors are used 
>> (each processors typically executes 2 threads), then I would like to 
>> be able to generate a report that captures this information. Its 
>> going to be used to test the effectiveness of some tools in using the 
>> parallel processing capabilities. Is there any way to find IDs of the 
>> processors that were used for a specific run of a program?
>> I thought of issuing a "ps" command during execution. But I am hoping 
>> that there is some smarter way. Any pointers in this direction are 
>> welcome!
>>  
>> Thanks a lot.
>>
>> w
>>
>>
>>
>> _______________________________________________
>> Omp mailing list
>> Omp at openmp.org
>> http://openmp.org/mailman/listinfo/omp_openmp.org
>>
>>

-- 
Waibhav Tembe.






More information about the Omp mailing list