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
>
--
Kyle B. Wheeler
Dept. 1423: Scalable System Software
Sandia National Laboratories
505-844-0394
|