Пример #1
0
        void GenerateTasks()
        {
            Task temp;

            int step = dataCount / tasksCount; // на каждую задачу приходится равная порция массива

            for (int i = 0; i < tasksCount; i++)
            {
                temp = new Task();
                temp.start = i * step;
                temp.stop = temp.start + step - 1;
                pendingTasks.Enqueue(temp);
            }


        }
Пример #2
0
        public void FetchData(Task task,out double[] b1,out double[,] temp  )
        {
            Log.Print("Client has fetched data");
             temp = new double[m,n];
            b1 = new double[n];
            for (int i = task.start; i < task.stop; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    temp[i,j] = dataArray[i,j];
                }

            }
            for (int j = 0; j < n; j++)
            {
                b1[j] = B[j];
            }
        }
Пример #3
0
        public int sort()
        {
            
        
                task = obj.GetTask();
      
                if (task == null)
                    return 0;
                double[,] arr;
                double[] b1;
                double[] C;
                 obj.FetchData(task, out b1, out arr);
               C= new double[SharedObject.n];
                Console.Out.Write("Полученные данные:");
                    
                for (int i = task.start; i < task.stop; i++)
                {
                    for (int j = 0; j < SharedObject.n; j++)
                    {
                        Console.Out.Write(arr[i,j]+" ");

                    }
                    Console.Out.WriteLine();
                }

           for (int i = task.start; i < task.stop; i++)
            {
                for (int j = 0; j < SharedObject.n; j++)
                {
                    C[i] += arr[i, j] * b1[j];

                }
            }


                obj.Finish(C);

            return 1;
        }