Esempio n. 1
0
        public GpuMatrix(CudaProvider cuda, int rows, int columns, Func <int, int, float> init)
        {
            _cuda    = cuda;
            _rows    = rows;
            _columns = columns;

            var count = rows * columns;
            var data  = new float[count];

            for (var j = 0; j < columns; j++)
            {
                for (var i = 0; i < rows; i++)
                {
                    data[j * rows + i] = init(i, j);
                }
            }
            _data = cuda.Allocate(count);
            _data.CopyToDevice(data);
            cuda.Register(this);

#if DEBUG
            if (_id == _badAlloc)
            {
                Debugger.Break();
            }
#endif
        }
Esempio n. 2
0
        public void CopyFrom(IVector vector)
        {
            Debug.Assert(vector.IsValid);
            var other = (GpuVector)vector;

            Debug.Assert(other.Count == Count);

            _data.CopyToDevice(other._data);
        }
Esempio n. 3
0
        public GpuVector(CudaProvider cuda, int size, Func <int, float> init)
        {
            _cuda = cuda;
            var data = new float[size];

            for (var i = 0; i < size; i++)
            {
                data[i] = init(i);
            }
            _data = cuda.Allocate(size);
            _data.CopyToDevice(data);
            cuda.Register(this);
#if DEBUG
            if (_id == _badAlloc)
            {
                Debugger.Break();
            }
#endif
        }