public static unsafe int[,] TransMatrix(int[,] matrix, int sizeN, int sizeM) { int[,] res = new int[sizeN, sizeM]; fixed(int *ptrMatrix = matrix) fixed(int *ptrRes = res) AMP.trans_matrix(ptrMatrix, ptrRes, sizeN, sizeM); return(res); }
public static unsafe int[] SumVectors(int[] one, int[] two, int size) { int[] res = new int[size]; fixed(int *ptrOne = one) fixed(int *ptrTwo = two) fixed(int *ptrRes = res) AMP.sum_vectors(ptrOne, ptrTwo, ptrRes, size); return(res); }
public static void TransMatrix(int sizeN, int sizeM) { AMP.set_device(); Console.WriteLine("TransMatrix"); Console.WriteLine("========================="); Console.WriteLine("Preparing data..."); var matrix = Tools.RandomMatrix(sizeN, sizeM); Tools.ShowTime("GPU", () => GPU.TransMatrix(matrix, sizeN, sizeM)); Tools.ShowTime("CPU(seq)", () => CPU.TransMatrix_Seq(matrix, sizeN, sizeM)); Tools.ShowTime("CPU(par)", () => CPU.TransMatrix_Par(matrix, sizeN, sizeM)); Console.WriteLine(); }
public static unsafe int[,] MatrixesMultipy(int[,] matrix_one, int[,] matrix_two) { var size = new int[] { matrix_one.GetLength(0), matrix_one.GetLength(1), matrix_two.GetLength(0), matrix_two.GetLength(1) }; int[,] res = new int[size[0], size[3]]; fixed(int *ptrMatrixOne = matrix_one) fixed(int *ptrMatrixTwo = matrix_two) fixed(int *ptrSize = size) fixed(int *ptrRes = res) AMP.multiply_matrix(ptrMatrixOne, ptrMatrixTwo, ptrSize, ptrRes); return(res); }
public static unsafe int[,] MultiplyMatrixByNumber(int[,] matrix, int number) { int n = matrix.GetLength(0); int m = matrix.GetLength(1); int[,] res = new int[n, m]; fixed(int *ptrMatrix = matrix) fixed(int *ptrRes = res) AMP.multiply_matrix_by_number(ptrMatrix, 5, ptrRes, n, m); return(res); }
public static void ProductMatrix(int oneSizeN, int oneSizeM, int twoSizeN, int twoSizeM) { AMP.set_device(); Console.WriteLine("ProductMatrix"); Console.WriteLine("========================="); Console.WriteLine("Preparing data..."); var one = Tools.RandomMatrix(oneSizeN, oneSizeM); var two = Tools.RandomMatrix(twoSizeN, twoSizeM); Console.WriteLine("========================="); Tools.ShowTime("GPU", () => GPU.MatrixesMultipy(one, two)); Tools.ShowTime("CPU(seq)", () => CPU.MatrixesMultipy_Seq(one, two)); Tools.ShowTime("CPU(par)", () => CPU.MatrixesMultipy_Par(one, two)); Console.WriteLine(); }
public static void SumVectors(int size) { AMP.set_device(); Console.WriteLine("Sum Vectors"); Console.WriteLine("========================="); Console.WriteLine("Preparing data..."); var one = Tools.RandomVector(size); var two = Tools.RandomVector(size); Console.WriteLine("========================="); Tools.ShowTime("GPU", () => GPU.SumVectors(one, two, size)); Tools.ShowTime("CPU(seq)", () => CPU.SumVectors_Seq(one, two, size)); Tools.ShowTime("GPU(par)", () => CPU.SumVectors_Par(one, two, size)); Console.WriteLine(); }
public static void MultipyMatrixNumber(int sizeN, int sizeM) { AMP.set_device(); Console.WriteLine("Multiply Matrix by number"); Console.WriteLine("========================="); Console.WriteLine("Preparing data..."); var matrix = Tools.RandomMatrix(sizeN, sizeM); Console.WriteLine("========================="); Tools.ShowTime("GPU", () => GPU.MultiplyMatrixByNumber(matrix, 5)); Tools.ShowTime("CPU(seq)", () => CPU.MultiplyMatrixByNumber_Seq(matrix, 5)); Tools.ShowTime("GPU(par)", () => CPU.MultiplyMatrixByNumber_Par(matrix, 5)); Console.WriteLine(); }