示例#1
0
文件: GPUManager.cs 项目: Wowo51/Sym
        public void Initialize(Context context, AcceleratorId acceleratorId, double[,] independents, double[] dependants)
        {
            AcceleratorId = acceleratorId;
            AcceleratorType acceleratorType = AcceleratorId.AcceleratorType;

            if (acceleratorType == AcceleratorType.CPU)
            {
                Accelerator = Accelerator.Create(context, AcceleratorId);
            }
            else if (acceleratorType == AcceleratorType.OpenCL)
            {
                Accelerator = CLAccelerator.Create(context, AcceleratorId);
            }
            else if (acceleratorType == AcceleratorType.Cuda)
            {
                Accelerator = CudaAccelerator.Create(context, AcceleratorId);
            }
            EvaluationKernel      = Accelerator.LoadAutoGroupedStreamKernel <Index2, ArrayView2D <double>, ArrayView <double>, ArrayView <NodeGPU>, ArrayView <int>, ArrayView2D <double> >(EvaluationKernelFunction);
            ProcessResultsKernel  = Accelerator.LoadAutoGroupedStreamKernel <Index1, ArrayView2D <double>, ArrayView <double> >(ProcessResultsKernelFunction);
            IndependentsTableSize = new Index2(independents.GetUpperBound(0) + 1, independents.GetUpperBound(1) + 1);
            Independents          = Accelerator.Allocate <double>(IndependentsTableSize);
            Independents.CopyFrom(independents, new Index2(), new Index2(), IndependentsTableSize);
            Dependants = Accelerator.Allocate <double>(dependants.Length);
            Dependants.CopyFrom(dependants, 0, 0, dependants.Length);
        }