예제 #1
0
        private void CalculateDistributed()
        {
            int s = GridA.Count;

            helpers = new List <DistributedHelper>();

            for (int i = 0; i < s; i++)
            {
                for (int j = 0; j < s; j++)
                {
                    DistributedHelper helper = new DistributedHelper();

                    helper.FirstIndex  = i;
                    helper.SecondIndex = j;

                    for (int k = 0; k < s; k++)
                    {
                        helper.WorkItems.Add(new MatrixMultiplicationWorkItem()
                        {
                            GridAValue = GridA[i][k].Value, GridBValue = GridB[k][j].Value
                        });
                    }

                    helpers.Add(helper);
                }
            }

            var t1 = new List <MatrixMultiplicationWorkItem>();

            foreach (var t in helpers)
            {
                t1.AddRange(t.WorkItems);
            }

            var t2 = helpers.SelectMany(dh => dh.WorkItems);

            workQueue.Enqueue(helpers.SelectMany(dh => dh.WorkItems));
            workQueue.CompleteEnqueuing();
            ((INotifyCollectionChanged)workQueue.Results).CollectionChanged += HandleDistributedResult;
            workQueue.Start();
        }
예제 #2
0
        private void CalculateDistributed()
        {
            int s = GridA.Count;
            helpers = new List<DistributedHelper>();

            for (int i = 0; i < s; i++)
            {
                for (int j = 0; j < s; j++)
                {
                    DistributedHelper helper = new DistributedHelper();

                    helper.FirstIndex = i;
                    helper.SecondIndex = j;

                    for (int k = 0; k < s; k++)
                    {
                        helper.WorkItems.Add(new MatrixMultiplicationWorkItem() { GridAValue = GridA[i][k].Value, GridBValue = GridB[k][j].Value });
                    }

                    helpers.Add(helper);
                }
            }

            var t1 = new List<MatrixMultiplicationWorkItem>();
            foreach (var t in helpers)
            {
                t1.AddRange(t.WorkItems);
            }

            var t2 = helpers.SelectMany(dh => dh.WorkItems);

            workQueue.Enqueue(helpers.SelectMany(dh => dh.WorkItems));
            workQueue.CompleteEnqueuing();
            ((INotifyCollectionChanged)workQueue.Results).CollectionChanged += HandleDistributedResult;
            workQueue.Start();
        }