diff --git a/P2/distributedmatrix.o b/P2/distributedmatrix.o new file mode 100644 index 0000000000000000000000000000000000000000..20d6a20fd32d76e740d8ea786d3fb7bfff8bc03a Binary files /dev/null and b/P2/distributedmatrix.o differ diff --git a/P2/distributedtests b/P2/distributedtests new file mode 100755 index 0000000000000000000000000000000000000000..13a845fe50d8f6fc4617dc41f29ca8a9fb0448c8 Binary files /dev/null and b/P2/distributedtests differ diff --git a/P2/distributedtests.o b/P2/distributedtests.o new file mode 100644 index 0000000000000000000000000000000000000000..a033b5bfe83e10f7d5a0a7f932dc9205fabf0d5c Binary files /dev/null and b/P2/distributedtests.o differ diff --git a/P2/globals.o b/P2/globals.o new file mode 100644 index 0000000000000000000000000000000000000000..6870c1902e709f9ccc57307ab09565ec7a2abaf1 Binary files /dev/null and b/P2/globals.o differ diff --git a/P2/matrix.o b/P2/matrix.o new file mode 100644 index 0000000000000000000000000000000000000000..7f185cce182028dac522773cf5a934de3fb0739e Binary files /dev/null and b/P2/matrix.o differ diff --git a/P2/mlp_sgd_distributed.o b/P2/mlp_sgd_distributed.o new file mode 100644 index 0000000000000000000000000000000000000000..241802e28abcc425d6473eed685bea3291fbfc70 Binary files /dev/null and b/P2/mlp_sgd_distributed.o differ diff --git a/P2/profile.cpp b/P2/profile.cpp deleted file mode 100644 index 21677a84a0d63f3df4a8cadb11c9d3ad097dc38f..0000000000000000000000000000000000000000 --- a/P2/profile.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include <iostream> -#include <mpi.h> -#include <cassert> -#include <cmath> -#include <nvToolsExt.h> -#include <functional> -#include "matrix.hpp" -#include "distributedmatrix.hpp" - -// Fonction utilitaire pour comparer deux matrices -bool matricesEqual(const Matrix& a, const Matrix& b, double tol = 1e-8) { - if (a.numRows() != b.numRows() || a.numCols() != b.numCols()) return false; - for (int i = 0; i < a.numRows(); ++i) { - for (int j = 0; j < a.numCols(); ++j) { - if (std::abs(a.get(i, j) - b.get(i, j)) > tol) return false; - } - } - return true; -} - -void testMultiplyTransposed(int rowsA, int colsA, int rowsB) { - int rank, numProcs; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &numProcs); - - // Générer matrices pleines - Matrix matrix1Full(rowsA, colsA); - Matrix matrix2Full(rowsB, colsA); - - for (int i = 0; i < rowsA; i++) { - for (int j = 0; j < colsA; j++) { - matrix1Full.set(i, j, sin(i * colsA + j)); - } - } - - for (int i = 0; i < rowsB; i++) { - for (int j = 0; j < colsA; j++) { - matrix2Full.set(i, j, cos(i * colsA + j)); - } - } - - DistributedMatrix distA(matrix1Full, numProcs); - DistributedMatrix distB(matrix2Full, numProcs); - - // Calcule de référence - Matrix expected = matrix1Full * matrix2Full.transpose(); - - if (rank == 0) { - std::cout << "Expected result [0][0]: " << expected.get(0, 0) << std::endl; - } - - // Test de multiplyTransposed avec marquage NVTX - nvtxRangePushA("DistributedMatrix::multiplyTransposed"); - Matrix result = distA.multiplyTransposed(distB); - nvtxRangePop(); - - if (rank == 0) { - std::cout << "Result [0][0]: " << result.get(0, 0) << std::endl; - } - - // Vérification du résultat - assert(matricesEqual(result, expected, 1e-8)); - if (rank == 0) { - std::cout << "Test passed! Matrices are equal." << std::endl; - } -} - -int main(int argc, char** argv) { - int initialized; - MPI_Initialized(&initialized); - if (!initialized) { - MPI_Init(&argc, &argv); - } - - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) { - std::cout << "Starting MultiplyTransposed tests..." << std::endl; - } - - try { - testMultiplyTransposed(512, 256, 512); // Taille paramétrable - if (rank == 0) { - std::cout << "Tests passed successfully!" << std::endl; - } - } - catch (std::exception& e) { - if (rank == 0) { - std::cerr << "Test failed with exception: " << e.what() << std::endl; - } - MPI_Abort(MPI_COMM_WORLD, 1); - } - - // Finalize MPI if we initialized it - // int finalized; - // MPI_Finalized(&finalized); - // if (!finalized && initialized) { - // MPI_Finalize(); - // } - - MPI_Finalize(); - return 0; -} diff --git a/P2/results.csv b/P2/results.csv new file mode 100644 index 0000000000000000000000000000000000000000..8f0acfe38c1e80688847964a8938481f8efb8d5e --- /dev/null +++ b/P2/results.csv @@ -0,0 +1,4 @@ +MatrixSize,AverageSequentialTime,AverageDistributedTime,AverageSpeedUp +256,0.655928,0.182856,3.58713 +512,5.07488,1.39987,3.62526 +1024,40.312,10.5835,3.80895