コード例 #1
0
        public Thread invoke(object action_id, Action reaction, out IActionFuture future)
        {
            int partner_size = channel.RemoteSize;
            int value        = ActionDef.action_ids[action_id];

            MPI.RequestList request_list = new MPI.RequestList();

            for (int i = 0; i < partner_size; i++)
            {
                MPI.Request req = channel.ImmediateSend <object>(value, i, value);
                request_list.Add(req);
            }

            for (int i = 0; i < partner_size; i++)
            {
                MPI.ReceiveRequest req = channel.ImmediateReceive <object>(i, value);
                request_list.Add(req);
            }

            ManualResetEvent sync = new ManualResetEvent(false);

            ActionFuture future_ = new ActionFuture(request_list, sync);

            future = future_;

            Thread t = new Thread(new ThreadStart(() => handle_request(future_, sync, reaction)));

            t.Start();

            return(t);
        }
コード例 #2
0
            private void receiveResult <T> (ref MPI.RequestList reqList, int operation_tag)
            {
                int remote_size = channel.RemoteSize;

                for (int server = 0; server < remote_size; server++)
                {
                    MPI.Request req = channel.ImmediateReceive <T> (server, operation_tag);
                    reqList.Add(req);
                }
            }
コード例 #3
0
        void returnResult(int[] result, int operation_tag)
        {
            MPI.RequestList reqList     = new MPI.RequestList();
            int             remote_size = channel.RemoteSize;

            for (int client = 0; client < remote_size; client++)
            {
                MPI.Request req = channel.ImmediateSend <int> (result[client], client, operation_tag);
                reqList.Add(req);
            }
            reqList.WaitAll();
        }
コード例 #4
0
        public void invoke(object action_id)
        {
            int partner_size = channel.RemoteSize;
            int value        = ActionDef.action_ids[action_id];

            MPI.RequestList request_list = new MPI.RequestList();

            for (int i = 0; i < partner_size; i++)
            {
                MPI.Request req = channel.ImmediateSend <object>(value, i, value);
                request_list.Add(req);
            }

            for (int i = 0; i < partner_size; i++)
            {
                MPI.ReceiveRequest req = channel.ImmediateReceive <object>(i, value);
                request_list.Add(req);
            }

            Console.WriteLine(channel.Rank + ": BEFORE WAIT ALL");
            request_list.WaitAll();
            Console.WriteLine(channel.Rank + ": AFTER WAIT ALL");
        }
コード例 #5
0
            private void sendArguments(int operation_tag, int arg1, int arg2, int arg3, IScatter <int> arg4, IScatter <int> arg5, IScatter <int> arg6, ref MPI.RequestList reqList)
            {
                int remote_size = channel.RemoteSize;

                for (int server = 0; server < remote_size; server++)
                {
                    if (channel.Rank == 0)
                    {
                        channel.Send <int> (operation_tag, server, OPERATION_TAG);
                    }

                    int arg1_ = arg1;
                    int arg2_ = arg2;
                    int arg3_ = arg3;
                    int arg4_ = arg4.Value[server];
                    int arg5_ = arg5.Value[server];
                    int arg6_ = arg6.Value[server];

                    Tuple <int, int, int, int, int, int> send_value = new Tuple <int, int, int, int, int, int> (arg1_, arg2_, arg3_, arg4_, arg5_, arg6_);

                    MPI.Request req = channel.ImmediateSend <Tuple <int, int, int, int, int, int> > (send_value, server, operation_tag);
                    reqList.Add(req);
                }
            }
コード例 #6
0
        public override void main()
        {
            int count = 0;

            Trace.WriteLine(WorldComm.Rank + ": STARTING SCATTER SPLIT DATA SOURCE #1");

            Bin_function.NumberOfPartitions = this.UnitSize["target"];

            IIteratorInstance <IKVPair <IMK, IMV> > bins_instance = (IIteratorInstance <IKVPair <IMK, IMV> >)Bins.Instance;

            int[] rank_workers = this.UnitRanks["target"];

            Trace.WriteLine(WorldComm.Rank + ": STARTING SCATTER SPLIT DATA SOURCE #2");

            // 1. Ler os bins, um a um, do iterator, e enviá-los a cada mapper (unidades target) usando MPI.
            object bins_object;

            while (bins_instance.fetch_next(out bins_object))
            {
                Trace.WriteLine(WorldComm.Rank + ": LOOP BIN " + (bins_object == null));

                // Ler um bin.
                IKVPairInstance <IMK, IMV> bin = (IKVPairInstance <IMK, IMV>)bins_object;


                Trace.WriteLine(bin.Key.GetType() + " +++++ " + Key.Instance.GetType());

                // Recuperar a chave do bin.
                Key.Instance = bin.Key;

                // Descobre o rank do Mapper.
                Trace.WriteLine(WorldComm.Rank + ": BEFORE BIN FUNCTION " + bins_instance.GetHashCode());
                Bin_function.go();
                Trace.WriteLine(WorldComm.Rank + ": AFTER BIN FUNCTION");

                int i    = (int)((IIntegerInstance)Rank.Instance).Value;
                int rank = rank_workers[i];

                // Inicia o envio do bin para o Mapper.
                Trace.WriteLine(WorldComm.Rank + ": BEGIN SEND BIN KEY/VALUE to " + rank + "cont=" + (count++));
                comm.Send <object> (bin.Key, rank, TAG_SPLITTER_IMK);                 //Trace.WriteLine(WorldComm.Rank + ": SEND BIN KEY OK to " + rank);
                comm.Send <object> (bin.Value, rank, TAG_SPLITTER_IMV);               //Trace.WriteLine(WorldComm.Rank + ": SEND BIN VALUE OK to " + rank);
                Trace.WriteLine(WorldComm.Rank + ": END SEND BIN KEY/VALUE to " + rank + "cont=" + (count++));
            }

            Trace.WriteLine(Rank + ": FINISH LOOP SEND BINS !!!");

            // send "finish" message
            MPI.RequestList requests = new MPI.RequestList();

            foreach (int i in rank_workers)
            {
                Trace.WriteLine(WorldComm.Rank + ": BEGIN SEND BIN FINISH OK to " + i);
                MPI.Request request = comm.ImmediateSend <object> (0, i, TAG_SPLITTER_IMK_FINISH);
                Trace.WriteLine(WorldComm.Rank + ": END SEND BIN FINISH OK to " + i);

                requests.Add(request);
            }

            requests.WaitAll();
//			Trace.WriteLine(WorldComm.Rank + ": SEND BIN FINISH OK ALL ");

            //requestList.WaitAll();
        }