Exemplo n.º 1
0
Arquivo: Image.cs Projeto: bHimes/warp
        private void Add(Image summands, uint elements, uint batch)
        {
            if (ElementsReal != elements * batch ||
                summands.ElementsReal != elements ||
                //IsFT != summands.IsFT ||
                IsComplex != summands.IsComplex)
            {
                throw new DimensionMismatchException();
            }

            if (IsHalf && summands.IsHalf)
            {
                GPU.AddToSlicesHalf(GetDevice(Intent.Read), summands.GetDevice(Intent.Read), GetDevice(Intent.Write), elements, batch);
            }
            else if (!IsHalf && !summands.IsHalf)
            {
                GPU.AddToSlices(GetDevice(Intent.Read), summands.GetDevice(Intent.Read), GetDevice(Intent.Write), elements, batch);
            }
            else
            {
                Image ThisSingle     = AsSingle();
                Image SummandsSingle = summands.AsSingle();

                GPU.AddToSlices(ThisSingle.GetDevice(Intent.Read), SummandsSingle.GetDevice(Intent.Read), ThisSingle.GetDevice(Intent.Write), elements, batch);

                if (IsHalf)
                {
                    GPU.HalfToSingle(ThisSingle.GetDevice(Intent.Read), GetDevice(Intent.Write), elements * batch);
                }
                else
                {
                    GPU.CopyDeviceToDevice(ThisSingle.GetDevice(Intent.Read), GetDevice(Intent.Write), elements * batch);
                }

                ThisSingle.Dispose();
                SummandsSingle.Dispose();
            }
        }