From: J.A. M. <jam...@ab...> - 2002-06-14 00:25:15
|
Hi. Funny problem with a cluster of dual smp boxes. I am trying to rfork a process from the front-end and make each remote process split in two with pthreads. The problem is that thread creation gets blocked after the first thread. Below is a test program. The resul when compiled with ONLY_LOCAL is like: annwn:~/bp> bp bproc version: 3.1.10 nodes: 1 node 0 id -1 has 4 CPUs <============== run on master about to create thread... done about to create thread... done about to create thread... done about to create thread... done thread 0 on node 0 thread 1 on node 0 thread 2 on node 0 thread 3 on node 0 Running the program on a node via bpsh: annwn:~/bp> bpsh 1 bp bproc version: 3.1.10 nodes: 1 node 0 id 1 has 2 CPUs about to create thread... thread 0 on node 0 done about to create thread... thread 1 on node 0 done (SO you _can_ create threads after a move). And building without ONLY_LOCAL, and running on master: annwn:~/bp> bp bproc version: 3.1.10 nodes: 1 node 0 id 0 has 2 CPUs about to create thread... thread 0 on node 0 <IT STOPS HERE FOREVER> Any idea ??? Here is the test program (bp.cc, yup, g++ to build) #include <iostream> #include <sys/sysinfo.h> #include <sys/bproc.h> #include <sys/wait.h> #include <pthread.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <stdlib.h> //#define ONLY_LOCAL using namespace std; int nnodes; int nself; void nslave(); int nprocs; int self; void* pslave(void *); int main(int argc,char** argv) { bproc_version_t info; if (bproc_version(&info)) { cout << "bproc_version: "; cout << strerror(errno) << endl; exit(1); } cout << "bproc version: " << info.version_string << endl; //nnodes = bproc_numnodes(); nnodes = 1; cout << "nodes: " << nnodes << endl; #ifndef ONLY_LOCAL int spawned = 0; for (int i=0; i<nnodes; i++) { nself = spawned; switch(bproc_rfork(i)) { case -1: cout << "bproc_fork on " << i << ": "; cout << strerror(errno) << endl; break; case 0: nslave(); return 0; break; default: spawned++; } } for (int i=0; i<spawned; i++) wait(0); #else nself = 0; nslave(); #endif return 0; } void nslave() { nprocs = get_nprocs_conf(); cout << "node " << nself << " id " << bproc_currnode(); cout << " has " << nprocs << " CPUs" << endl; pthread_t tid[nprocs]; int spawned = 0; for (int i=0; i<nprocs; i++) { cout << "about to create thread..." << endl; pthread_create(&tid[i],0,pslave,(void*)spawned); cout << "done" << endl; spawned++; } for (int i=0; i<spawned; i++) pthread_join(tid[i],0); } void* pslave(void *data) { int tself = int(data); cout << "thread " << tself << " on node " << nself << endl; sleep(2); return 0; } -- J.A. Magallon \ Software is like sex: It's better when it's free mailto:jam...@ab... \ -- Linus Torvalds, FSF T-shirt Linux werewolf 2.4.19-pre10-jam3, Mandrake Linux 8.3 (Cooker) for i586 gcc (GCC) 3.1.1 (Mandrake Linux 8.3 3.1.1-0.4mdk) |