コード例 #1
0
ファイル: Program.cs プロジェクト: Yey007/FastMatrices
        static void Main(string[] args)
        {
            Random    random = new Random();
            Stopwatch watch  = Stopwatch.StartNew();

            GPUOperator <DoubleWrapper> gpu = new GPUOperator <DoubleWrapper>();

            Console.WriteLine($"GPU init: {watch.ElapsedMilliseconds}ms");
            watch.Restart();

            SingleThreadedOperator <DoubleWrapper> cpu = new SingleThreadedOperator <DoubleWrapper>();

            Console.WriteLine($"CPU init: {watch.ElapsedMilliseconds}ms");
            watch.Restart();

            MultiThreadedOperator <DoubleWrapper> cpumult = new MultiThreadedOperator <DoubleWrapper>();

            Console.WriteLine($"Parallel init: {watch.ElapsedMilliseconds}ms");
            watch.Restart();

            BufferedFastMatrix <DoubleWrapper> one = new BufferedFastMatrix <DoubleWrapper>(64, 64);
            BufferedFastMatrix <DoubleWrapper> two = new BufferedFastMatrix <DoubleWrapper>(64, 64);

            Console.WriteLine($"Two 100x100 allocations: {watch.ElapsedMilliseconds}ms");
            watch.Restart();

            one.CopyToGPU();
            two.CopyToGPU();
            Console.WriteLine($"Copy: {watch.ElapsedMilliseconds}ms");
            watch.Restart();

            Utilities.FillMatrix(one, 10);
            Utilities.FillMatrix(two, 20);
            Console.WriteLine($"Filling matrices: {watch.ElapsedMilliseconds}ms");
            watch.Restart();

            var bruh = gpu.AddShared(one, two);

            Console.WriteLine($"GPU Add: {watch.ElapsedMilliseconds}ms");
            watch.Restart();
            gpu.Multiply(one, two);
            Console.WriteLine($"GPU Mult: {watch.ElapsedMilliseconds}ms");
            watch.Restart();

            cpu.Add(one, two);
            Console.WriteLine($"CPU Add: {watch.ElapsedMilliseconds}ms");
            watch.Restart();
            cpu.Multiply(one, two);
            Console.WriteLine($"CPU Mult: {watch.ElapsedMilliseconds}ms");
            watch.Restart();

            cpumult.Add(one, two);
            Console.WriteLine($"Parallel Add: {watch.ElapsedMilliseconds}ms");
            watch.Restart();
            cpumult.Multiply(one, two);
            Console.WriteLine($"Parallel Mult: {watch.ElapsedMilliseconds}ms");
            watch.Restart();
        }
コード例 #2
0
        public void Multiply()
        {
            double[,] expected = MakeResult(size, size, 750);

            FastMatrix one    = MakeMatrix(size, size, 15);
            FastMatrix two    = MakeMatrix(size, size, 10);
            FastMatrix actual = gpu.Multiply(one, two);

            VerifyResults(actual, expected);
        }
コード例 #3
0
        public void Multiply()
        {
            Vector3[,] expected = MakeResult(size, size, new Vector3(375, 375, 375));

            BufferedFastMatrix <Vector3> one    = MakeBufferedMatrix(size, size, fifteen);
            BufferedFastMatrix <Vector3> two    = MakeBufferedMatrix(size, size, five);
            BufferedFastMatrix <Vector3> actual = gpu.Multiply(one, two);

            VerifyResults(actual, expected);
        }
コード例 #4
0
        public void Multiply()
        {
            IntWrapper[,] expected = MakeResult(size, size, 750);

            BufferedFastMatrix <IntWrapper> one    = MakeBufferedMatrix <IntWrapper>(size, size, 15);
            BufferedFastMatrix <IntWrapper> two    = MakeBufferedMatrix <IntWrapper>(size, size, 10);
            BufferedFastMatrix <IntWrapper> actual = gpu.Multiply(one, two);

            VerifyResults(actual, expected);
        }
コード例 #5
0
ファイル: GPUMult.cs プロジェクト: Yey007/FastMatrices
        static void Multiply()
        {
            GPUOperator <IntWrapper> op = new GPUOperator <IntWrapper>();

            //two 5*3 matrices
            BufferedFastMatrix <IntWrapper> one = new BufferedFastMatrix <IntWrapper>(5, 3);
            BufferedFastMatrix <IntWrapper> two = new BufferedFastMatrix <IntWrapper>(3, 5);

            Utilities.FillMatrix(one, 5);
            Utilities.FillMatrix(two, 10);

            BufferedFastMatrix <IntWrapper> result = op.Multiply(one, two);
        }
コード例 #6
0
        static void Multiply()
        {
            GPUOperator op = new GPUOperator();

            //two 5*3 matrices
            FastMatrix one = new FastMatrix(5, 3);
            FastMatrix two = new FastMatrix(3, 5);

            Utilities.FillMatrix(one, 5);
            Utilities.FillMatrix(two, 10);

            FastMatrix result = op.Multiply(one, two);
        }