Open MPI logo

Hardware Locality Users' Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Users mailing list

Subject: Re: [hwloc-users] [EXTERNAL] creation and destruction of bound threads
From: Albert Solernou (albert.solernou_at_[hidden])
Date: 2012-01-30 10:52:32


Hi,
I am not using pthreads but OpenMP. After Samuel's answer I have
realised that most (if not all) the OpenMP implementations reuse the
created threads. This reduces the overhead that would come from
effectively creating and a group of threads each time a process spawns.
Because of that, my testing on the re-usability of the binding was not
conclusive as I was getting only positive answers.

Best,
Albert

On Mon 30 Jan 2012 15:08:26 GMT, Wheeler, Kyle Bruce wrote:
> If you're working with pthreads, the answer is no. The binding was only relevant to the thread you created; when the thread was destroyed, so was the binding. The OS does not keep track of a history of where your now-nonexistent threads were bound.
>
> I'm surprised it's difficult to prove with a simple program, though... did getting the second thread's CPU-mask return ambiguous results? I'm thinking something like this pseudocode:
>
> void func(void* arg) {
> printf("initial CPU mask: %s", hwloc_cur_thread_getcpumask());
> hwloc_cur_thread_setcpumask(foo);
> printf("subsequent CPU mask: %s", hwloc_cur_thread_getcpumask());
> }
>
> int main()
> {
> pthread_t f;
>
> printf("mainthread CPU mask: %s", hwloc_cur_thread_getcpumask());
> pthread_create(&f, func);
> pthread_join(f);
> printf("mainthread CPU mask: %s", hwloc_cur_thread_getcpumask());
> pthread_create(&f, func);
> pthread_join(f);
> printf("mainthread CPU mask: %s", hwloc_cur_thread_getcpumask());
> }
>
> On Jan 30, 2012, at 4:36 AM, Albert Solernou wrote:
>
>> Hi,
>> I am working on a threaded code, and want to bind threads to cores. However, the process creates and destroys the threads, so here is the question:
>> What happens if I enter on a threaded part of the code, bind "thread X" to a core, return to a serial part and then thread again? Can I expect to find thread X bound to the core I bound it previously?
>>
>> I guessed that the answer is "no", but I couldn't prove it using a simple program.
>>
>> Thank you,
>> Albert
>> _______________________________________________
>> hwloc-users mailing list
>> hwloc-users_at_[hidden]
>> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users
>>
>