Inheritance: Brahma.ComputeProvider
Esempio n. 1
0
        public Image2D(ComputeProvider provider, Operations operations, Memory memory, int width, int height, T[] data, int rowPitch = -1) // Create and copy/use data from host
        {
            ErrorCode error;

            _image = Cl.CreateImage2D(provider.Context, (MemFlags)operations | (memory == Memory.Host ? MemFlags.UseHostPtr : (MemFlags)memory | MemFlags.CopyHostPtr),
                                      new ImageFormat(_imageFormat.ChannelOrder, _imageFormat.ChannelType.ChannelType), (IntPtr)width, (IntPtr)height,
                                      rowPitch == -1 ? (IntPtr)(width * _imageFormat.ComponentCount * _imageFormat.ChannelType.Size) : (IntPtr)rowPitch,
                                      data, out error);

            if (error != ErrorCode.Success)
            {
                throw new CLException(error);
            }

            _width    = width;
            _height   = height;
            _rowPitch = rowPitch;
            if ((MemFlags)operations == MemFlags.ReadOnly)
            {
                _modifier = true;
            }
            else
            {
                _modifier = false;
            }
        }
Esempio n. 2
0
        public Image2D(ComputeProvider provider, Operations operations, bool hostAccessible, int width, int height, int rowPitch = -1) // Create, no data
        {
            ErrorCode error;

            _image = Cl.CreateImage2D(provider.Context, (MemFlags)operations | (hostAccessible ? MemFlags.AllocHostPtr : 0),
                                      new ImageFormat(_imageFormat.ChannelOrder, _imageFormat.ChannelType.ChannelType), (IntPtr)width, (IntPtr)height,
                                      rowPitch == -1 ? (IntPtr)(width * _imageFormat.ComponentCount * _imageFormat.ChannelType.Size) : (IntPtr)rowPitch,
                                      null, out error);

            if (error != ErrorCode.Success)
            {
                throw new CLException(error);
            }

            _width    = width;
            _height   = height;
            _rowPitch = rowPitch;
            if ((MemFlags)operations == MemFlags.ReadOnly)
            {
                _modifier = true;
            }
            else
            {
                _modifier = false;
            }
        }
Esempio n. 3
0
        public CommandQueue(ComputeProvider provider, Cl.Device device, bool outOfOrderExecution = false)
        {
            Cl.ErrorCode error;
            _queue = Cl.CreateCommandQueue(provider.Context, device, outOfOrderExecution ? Cl.CommandQueueProperties.OutOfOrderExecModeEnable : Cl.CommandQueueProperties.None, out error);

            if (error != Cl.ErrorCode.Success)
                throw new CLException(error);
        }
Esempio n. 4
0
        public CommandQueue(ComputeProvider provider, ClNet.Device device, bool outOfOrderExecution = false)
        {
            ClNet.ErrorCode error;
            _queue = Cl.CreateCommandQueue
                         (provider.Context
                         , device
                         , outOfOrderExecution
                    ? ClNet.CommandQueueProperties.OutOfOrderExecModeEnable
                    : ClNet.CommandQueueProperties.None, out error);

            if (error != ClNet.ErrorCode.Success)
            {
                throw new Cl.Exception(error);
            }
        }
Esempio n. 5
0
        public Buffer(ComputeProvider provider, Operations operations, Memory memory, IntPtr data, int length) // Create and copy/use data from host
        {
            ClNet.ErrorCode error;
            _length = length;
            _mem    = Cl.CreateBuffer(provider.Context, (ClNet.MemFlags)operations | (memory == Memory.Host ? ClNet.MemFlags.UseHostPtr : (ClNet.MemFlags)memory | (data != IntPtr.Zero ? ClNet.MemFlags.CopyHostPtr : 0)),
                                      (IntPtr)(_elementSize * _length), data, out error);

            if (error != ClNet.ErrorCode.Success)
            {
                throw new Cl.Exception(error);
            }

            Operations = operations;
            Memory     = memory;
        }
Esempio n. 6
0
        public Buffer(ComputeProvider provider, Operations operations, bool hostAccessible, int length) // Create, no data
        {
            ClNet.ErrorCode error;
            _length = length;
            var size = (IntPtr)(_length * _elementSize);

            _mem = Cl.CreateBuffer(
                provider.Context
                , (ClNet.MemFlags)operations | (hostAccessible ? ClNet.MemFlags.AllocHostPtr : 0)
                , size, null, out error);

            if (error != ClNet.ErrorCode.Success)
            {
                throw new Cl.Exception(error);
            }

            Operations = operations;
            Memory     = Memory.Device;
        }
Esempio n. 7
0
 public Buffer(ComputeProvider provider, Operations operations, Memory memory, T[] data) // Create and copy/use data from host
     : this(provider, operations, memory, (Array)data)
 {
 }