예제 #1
0
        /// <summary>
        /// see <see cref="MatrixBase.AssembleFinalFormat"/>
        /// </summary>
        protected override MatrixBase.FormatBase AssembleFinalFormat(MatrixBase.TempCSR tmp)
        {
            using (new FuncTrace()) {
                ManualCacheELLPACK ret = null;
                bool TooBig            = true;
                int  maxSharesSize;
                cu.DeviceGetAttribute(out maxSharesSize, CUdevice_attribute.CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK, m_CudaEnv.CUDAdev);

                while (TooBig)
                {
                    ret = new ManualCacheELLPACK(tmp, 1, blocksize, 32);
                    int ReqSharedSize = ret.BlockSubVectorLength.Max() * sizeof(double);

                    if (ReqSharedSize > maxSharesSize)
                    {
                        blocksize /= 2;
                        if (blocksize < 16)
                        {
                            throw new ApplicationException("unable to create ELLPACKcache - matrix; not enough shared memory available;");
                        }
                    }
                    else
                    {
                        TooBig = false;
                    }
                }
                return(ret);
            }
        }
예제 #2
0
파일: mtMatrix.cs 프로젝트: xyuan/BoSSS
        /// <summary>
        /// the poor Man's test unit
        /// </summary>
        void TestFormats(MatrixBase.TempCSR _tmp)
        {
            MatrixBase.CSR comp1 = new CSR(_tmp);
            //MatrixBase.CCBCSR comp2 = new CCBCSR(_tmp, 128, CellSize);
            //MatrixBase.ELLPACKmod comp2 = new ELLPACKmod(_tmp, 40, 4);
            MatrixBase.ManualCacheELLPACK comp2 = new ManualCacheELLPACK(_tmp, 1, 4, 2);

            double[] x = new double[this.ColPartition.LocalLength];
            double[] y = new double[this.ColPartition.LocalLength];

            double alpha = 1.234;
            double beta  = 432.1;

            Random r = new Random(0);

            for (int i = 0; i < x.Length; i++)
            {
                x[i] = r.NextDouble();
            }
            for (int i = 0; i < y.Length; i++)
            {
                y[i] = r.NextDouble();
            }


            double[] res1 = (double[])y.Clone();
            comp1.RefSpMv(alpha, (double[])x.Clone(), beta, res1);

            double[] res2 = (double[])y.Clone();
            comp2.RefSpMv(alpha, (double[])x.Clone(), beta, res2);

            double err = 0;

            for (int i = 0; i < y.Length; i++)
            {
                err += Math.Abs(res1[i] - res2[i]);
            }

            Console.WriteLine("err = " + err);
            Console.Write("");
        }
예제 #3
0
파일: mtMatrix.cs 프로젝트: xyuan/BoSSS
 /// <summary>
 /// returns a <see cref="MatrixBase.CSR"/>-object.
 /// </summary>
 protected override MatrixBase.FormatBase AssembleFinalFormat(MatrixBase.TempCSR tmp)
 {
     //TestFormats(tmp);
     return(new MatrixBase.CSR(tmp));
 }
예제 #4
0
 /// <summary>
 /// returns a <see cref="MatrixBase.CSR"/>-object.
 /// </summary>
 protected override MatrixBase.FormatBase AssembleFinalFormat(MatrixBase.TempCSR tmp)
 {
     return(new MatrixBase.ELLPACKmod(tmp, 1, localsize));
 }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 protected override MatrixBase.FormatBase AssembleFinalFormat(MatrixBase.TempCSR tmp)
 {
     return(new CCBCSR(tmp, 1, base.CellSize));
 }
예제 #6
0
 /// <summary>
 /// returns a <see cref="MatrixBase.CSR"/>-object.
 /// </summary>
 protected override MatrixBase.FormatBase AssembleFinalFormat(MatrixBase.TempCSR tmp)
 {
     return(new MatrixBase.ManualCacheELLPACK(tmp, 1, localsize, 32));
 }