Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

{
/// <summary>
/// then file is empty
/// </summary>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что-то с отступами злое

namespace ParallelMatrixMultiplication
{
/// <summary>
/// then we couldn't multiplication matrices
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как-то не по-английски

static void Main(string[] args)
{
var matrixTest = new int[1000, 1000];
Stopwatch stopWatch = new Stopwatch();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var?

stopWatch.Start();
for (int i = 0; i < 10; i++)
{
var testTime =MatrixFunctions.MatrixMultiplicationParallel(matrixTest, matrixTest);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var testTime =MatrixFunctions.MatrixMultiplicationParallel(matrixTest, matrixTest);
var testTime = MatrixFunctions.MatrixMultiplicationParallel(matrixTest, matrixTest);

stopWatch.Stop();
var time = stopWatch.ElapsedMilliseconds;
Console.WriteLine($"Среднее время обычного умножения матриц 1000*1000: {time / 10} ms");
Console.WriteLine($"Среднее время параллельного умножения матриц 1000*1000: {timeParallel / 10} ms");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это лучше, чем ничего, но надо было на разных размерностях попробовать, чтобы понять, всегда ли многопоточный алгоритм быстрее. И записать сюда в комментарии результаты, которые конкретно у Вас получились

{
if (filePath == "")
{
throw new Exception();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArgumentException лучше. Просто Exception вообще никогда не надо кидать, его не отфильтровать потом в catch-е

fileOut.Delete();
}
using var newFile = new FileStream(filePath, FileMode.Create);
var file = new StreamWriter(newFile);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Он вроде тоже IDisposable, так что using

[Test]
public void TestNormalDataParallel()
{
var matrix1 = new int[1000,1000];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пробелов после "," не хватает

var matrix1 = new int[1000,1000];
var matrix2 = new int[1000,1000];
var result = new int[1000,1000];
var matrix = MatrixFunctions.MatrixMultiplicationParallel(matrix1, matrix2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мм, нулевые матрицы перемножаются?

{
static void Main(string[] args)
{
var matrixTest = new int[1000, 1000];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Непоказательно. Надо именно сгенерировать какие-нибудь матрицы с какими-нибудь адекватными числами

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо немного код в порядок привести

[Test]
public void TestNormalFilePath()
{
int[,] result = {{ 2, 1, 2}, {4, 1, 5}, {1, 5, 3}} ;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что-то как-то пробелы то ли один лишний, то ли много не хватает. И двумерные массивы лучше на нескольких строчках писать, чтобы было в виде матрицы.

namespace ParallelMatrixMultiplication
{
/// <summary>
/// File's function
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функция Файла? :) Какая функция и какого файла? Надо по-английски тренироваться писать (можно сначала с Google Translate или аналогичным сервисом от Яндекса, потом привыкнете и можно будет без них)

}
}

private static (int, int) CountSizeMatrix(string filePath)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CountMatrixSize

/// </summary>
public static class MatrixFunctions
{
public static int[,] MatrixMultiplicationParallel(int[,] matrix1, int[,] matrix2)

This comment was marked as resolved.

Результаты на матрицах размеров 128*128.
Количество повторов: 100.
Паралельное умножение:
Матожидание = 13,75
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Обязательно приводите размерность величин

Количество повторов: 100.
Паралельное умножение:
Матожидание = 13,75
Среднеквадратичное отклонение = 3,897114317029974
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не надо столько знаков после запятой. Матожидание имеет два знака, так и тут можно.


namespace ParallelMatrixMultiplication
{
public class Statistics

This comment was marked as resolved.

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут уже число попыток близко к исчерпанию, поэтому надо, чтобы в следующий раз всё было идеально, или всё-таки минус полбалла :)

Comment on lines 64 to 65
var matrix1 = new int[3,4];
var matrix2 = new int[3,3];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

С пробелами беда. Научитесь пользоваться https://github.com/DotNetAnalyzers/StyleCopAnalyzers, поможет :)

{
if (string.IsNullOrEmpty(filePath))
{
throw new FilePathException("Error file path!");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

С английским беда. "Ошибка файл путь!"


private static (int, int) CountMatrixSize(string filePath)
{
CheckFilePath((filePath));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CheckFilePath((filePath));
CheckFilePath(filePath);

Comment on lines 43 to 44
CheckFilePath((filePath));
(int length, int width) size = CountMatrixSize((filePath));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Скобочки богу скобочек! https://lurkmore.to/LISP

throw new MultiplicationException("Number of columns in the first matrix are not equal to the rows in the second matrix!");
}
var matrix = new int[matrix1.GetLength(0), matrix2.GetLength(1)];
var threads = new Thread[Environment.ProcessorCount];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если в матрице меньше строк, чем Environment.ProcessorCount, просто зря потоки создаёте

*/

var matrixFirst = FileFunctions.CreateMatrix((args[0]));
var matrixSecond = FileFunctions.CreateMatrix(((args[1])));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

О, ещё больше скобок

results[0] = (averageParallel, standardDeviationParallel);
results[1] = (averageNotParallel, standardDeviationNotParallel);
return results;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут вот с отступом не повезло, а я уж было хотел зачесть задачу полностью :) Рекомендую при коммите или хотя бы когда делаете пуллреквест просматривать диффы на предмет таких косяков, они сразу в глаза бросаются

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, всё хорошо, зачтена

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants