예제 #1
0
        //protected Thread master = null;

        private void setup_mpi()
        {
            int nc, color;

            string[] args = System.Environment.GetCommandLineArgs();
            mpi = new MPI.Environment(ref args);

            worldcomm = Communicator.world;

            total_nodes = worldcomm.Size;
            node        = worldcomm.Rank;

            //---------------------------------------------------------------------
            //     compute square root; add small number to allow for roundoff
            //---------------------------------------------------------------------
            nc       = Convert.ToInt32(Math.Sqrt(total_nodes) + 0.00001d);
            maxcells = Convert.ToInt32(Math.Sqrt(total_nodes));

            //---------------------------------------------------------------------
            // We handle a non-square number of nodes by making the excess nodes
            // inactive. However, we can never handle more cells than were compiled
            // in.
            //---------------------------------------------------------------------

            if (nc > maxcells)
            {
                nc = maxcells;
            }

            if (node >= nc * nc)
            {
                active = false;
                color  = 1;
            }
            else
            {
                active = true;
                color  = 0;
            }

            comm_setup = (Intracommunicator)worldcomm.Split(color, node);

            if (!active)
            {
                return;
            }

            no_nodes   = comm_setup.Size;
            comm_solve = (Intracommunicator)comm_setup.Clone();
            comm_rhs   = (Intracommunicator)comm_setup.Clone();


            //---------------------------------------------------------------------
            //     let node 0 be the root for the group (there is only one)
            //---------------------------------------------------------------------
            root = 0;
        }
 public override int go()
 {
     double[] src = new double[d1 * d2 * d3 * 2];
     double[] dst = new double[d1 * d2 * d3 * 2];
     worldcomm  = this.WorldComm;
     commslice2 = (Intracommunicator)worldcomm.Split(me2, me1);
     setVetor(xin, src);
     commslice2.AlltoallFlattened <double>(src, d1 * d2 * d3 * 2 / np1, ref dst);
     setVetor(dst, xout);
     return(0);
 }