Exemplo n.º 1
0
        /// <summary>
        /// Allocate memory and copy matrix data on GPU
        /// </summary>
        public override void Lock()
        {
            base.Lock();

            MatrixBase.CSR LocalMatrix = (MatrixBase.CSR)base.m_LocalMtx;

            d_val      = cl.CreateBuffer(device.env.context, cl_mem_flags.CL_MEM_COPY_HOST_PTR | cl_mem_flags.CL_MEM_READ_ONLY, (uint)LocalMatrix.Val.Length * sizeof(double), LocalMatrix.Val);
            d_rowStart = cl.CreateBuffer(device.env.context, cl_mem_flags.CL_MEM_COPY_HOST_PTR | cl_mem_flags.CL_MEM_READ_ONLY, (uint)LocalMatrix.RowStart.Length * sizeof(double), LocalMatrix.RowStart);
            d_colIdx   = cl.CreateBuffer(device.env.context, cl_mem_flags.CL_MEM_COPY_HOST_PTR | cl_mem_flags.CL_MEM_READ_ONLY, (uint)LocalMatrix.ColInd.Length * sizeof(double), LocalMatrix.ColInd);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Allocate memory and copy matrix data on GPU
        /// </summary>
        public override void Lock()
        {
            base.Lock();

            MatrixBase.CSR LocalMatrix = (MatrixBase.CSR)base.m_LocalMtx;

            cu.MemAlloc(out d_val, (uint)LocalMatrix.Val.Length * sizeof(double));
            cu.MemAlloc(out d_rowStart, (uint)LocalMatrix.RowStart.Length * sizeof(int));
            cu.MemAlloc(out d_colIdx, (uint)LocalMatrix.ColInd.Length * sizeof(int));
            cu.MemcpyHtoD(d_val, LocalMatrix.Val, (uint)LocalMatrix.Val.Length * sizeof(double));
            cu.MemcpyHtoD(d_rowStart, LocalMatrix.RowStart, (uint)LocalMatrix.RowStart.Length * sizeof(int));
            cu.MemcpyHtoD(d_colIdx, LocalMatrix.ColInd, (uint)LocalMatrix.ColInd.Length * sizeof(int));
        }