<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Hello ,</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">I am trying to schedule tasks in a batch file using a small MPI c program as a scheduler.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Processor 0 is the scheduler, sends jobs to others, checks when a work is finished and sends</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">the idle processor to work again. Other than that it doesn't do real work.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Using mpich2 the program works but I sometimes get the below error <span style="font-size: 12pt; ">when
the job takes a long time to finish. </span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span style="font-size: 12pt; ">It tells me it could be something related to timeout. The error is shown below. Thank you for any suggestions</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span style="font-size: 12pt; "><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span style="font-size: 12pt; ">[quote]</span><br></div><div><div>E:\Alltests\solver\Projects\Release>mpiexec -n 2 test commands.bat 68</div><div>Process [Process [Worker 1 started problem 0</div><div>0/2] on cee-3624-ab52 : pid 118980</div><div>1/2] on cee-3624-ab52 : pid 120092</div><div>mytest\controls.txt</div><div>mytest\controlsp.txt</div><div>10 File(s) copied<br></div><div> 1 file(s)
copied.</div><div>[01:97888]..ERROR:Error while connecting to host, No connection could be made because the target machine actively refuse</div><div>d it. (10061)</div><div>Fatal error in MPI_Init: Other MPI error, error stack:</div><div>MPIR_Init_thread(388):</div><div>MPID_Init(107).......: channel initialization failed</div><div>MPID_Init(371).......: PMI_Init returned -1</div><div>[/quote]<br></div><div><br></div><div>And the code is shown below</div><div><br></div><div>[code]</div><div><div>int main(int argc, char* argv[] ) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>int myid,nprocs,namelen,master;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>char processor_name[MPI_MAX_PROCESSOR_NAME];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Request request;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Status status;</div><div><span
class="Apple-tab-span" style="white-space:pre">        </span>int NTOTAL;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>int job;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/*command and number of times to execute it*/</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>command = argv[1];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>NTOTAL = atoi(argv[2]);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/*</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>* Inititalize MPI environment</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>*/</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>int res = MPI_Init(&argc,&argv);</div><div><span class="Apple-tab-span" style="white-space:pre">
        </span>MPI_Comm_size(MPI_COMM_WORLD,&nprocs);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Comm_rank(MPI_COMM_WORLD,&myid);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Get_processor_name(processor_name, &namelen);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>cerr << "Process [" << myid << "/" << nprocs<< "] on " </div><div><span class="Apple-tab-span" style="white-space:pre">                </span> << processor_name << " : pid " << PID << endl;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>cerr.flush();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>master = 0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>nprocs--;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span"
style="white-space:pre">        </span>/*</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>* master</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>*/</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if(myid == master) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>int r,sent,njobs;<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>/*</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>* Master sends slaves to work here</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>*/ </div><div><span class="Apple-tab-span" style="white-space:pre">                </span>sent = 0;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>njobs = 0; </div><div><span
class="Apple-tab-span" style="white-space:pre">                </span>while(njobs < NTOTAL && sent < nprocs) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>sent++;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>njobs++;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>MPI_Send(&njobs,1,MPI_INT,sent,njobs,MPI_COMM_WORLD);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>while(sent) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>/*</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span> *Non blocking recieve to do housekeeping</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span> *staff in the mean time</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span> */</div><div>
int flag = 0;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>MPI_Irecv(&r,1,MPI_INT,MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,&request);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>MPI_Test(&request, &flag, &status);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>double t1,t2;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>t1 = MPI_Wtime();</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>while (!flag) {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>SLEEP(1000);</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>t2 = MPI_Wtime();</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>if(t2 - t1 >= update) {</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>cout << "Progress "
<< njobs << "/" << NTOTAL << " completed." << endl;</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>workProgress();</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>t1 = t2;</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>MPI_Test(&request, &flag, &status);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>/*We got an idle processor now*/</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>if(njobs < NTOTAL) {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>njobs++;</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>MPI_Send(&njobs,1,MPI_INT,r,njobs,MPI_COMM_WORLD);</div><div><span
class="Apple-tab-span" style="white-space:pre">                        </span>} else {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>MPI_Send(MPI_BOTTOM,0,MPI_INT,r,0,MPI_COMM_WORLD);</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>sent--;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cout << "Work finished" << endl;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>workProgress();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>} </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/*</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>* Slave processors pick up jobs here</div><div><span class="Apple-tab-span" style="white-space:pre">
        </span>*/</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>else {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>while(true) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>MPI_Recv(&job,1,MPI_INT,master,MPI_ANY_TAG,MPI_COMM_WORLD,&status);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>if(status.MPI_TAG == 0) {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>break;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>} else {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>work(myid,job);</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>MPI_Send(&myid,1,MPI_INT,master,status.MPI_TAG,MPI_COMM_WORLD);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        
        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>MPI_Finalize();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return 0;</div><div>}</div><div><br></div></div><div>[/code]</div><div><br></div></div></div></body></html>