From 79e7a48a501bc7a4ad6376e97ec3cc84181c1675 Mon Sep 17 00:00:00 2001
From: JordanHanotiaux <103147288+JordanHanotiaux@users.noreply.github.com>
Date: Sat, 12 Apr 2025 11:32:59 +0200
Subject: [PATCH] Update

---
 P2/distributedtests.cpp             |  72 ++++++++++++++--------------
 P2/profile_mpi_computation.nsys-rep | Bin 6219083 -> 6219063 bytes
 2 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/P2/distributedtests.cpp b/P2/distributedtests.cpp
index e3d8ca7..cbc483a 100644
--- a/P2/distributedtests.cpp
+++ b/P2/distributedtests.cpp
@@ -6,20 +6,19 @@
 #include <cassert>
 #include <cmath>
 #include <functional>
+#include <nvToolsExt.h>  // Pour NVTX
 
-
-
-// Helper function to test if two doubles are approximately equal
+// Fonction utilitaire pour vérifier si deux doubles sont proches
 bool approxEqual(double a, double b, double epsilon = 1e-10) {
     return std::abs(a - b) < epsilon;
 }
 
-// Helper function to test if two matrices are approximately equal
+// Fonction utilitaire pour vérifier si deux matrices sont égales
 bool matricesEqual(const Matrix& a, const Matrix& b, double epsilon = 1e-10) {
     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 (!approxEqual(a.get(i, j), b.get(i, j), epsilon)) {
@@ -27,66 +26,75 @@ bool matricesEqual(const Matrix& a, const Matrix& b, double epsilon = 1e-10) {
             }
         }
     }
-    
+
     return true;
 }
 
-// Test multiplyTransposed
+// Test multiplyTransposed avec NVTX pour marquage et analyse des performances
 void testMultiplyTransposed() {
     int rank;
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
     
-    // Create test matrices
-    Matrix matrix1Full(256, 256);
-    Matrix matrix2Full(256, 256);
-    for (int i = 0; i < 256; i++) {
-        for (int j = 0; j < 256; j++) {
+    // Créer des matrices de test
+    Matrix matrix1Full(1024, 1024);  // Taille plus petite pour une exécution rapide
+    Matrix matrix2Full(1024, 1024);
+    for (int i = 0; i < 1024; i++) {
+        for (int j = 0; j < 1024; j++) {
             matrix1Full.set(i, j, i * 5 + j + 1);
         }
     }
-    for (int i = 0; i < 256; i++) {
-        for (int j = 0; j < 256; j++) {
+    for (int i = 0; i < 1024; i++) {
+        for (int j = 0; j < 1024; j++) {
             matrix2Full.set(i, j, i * 5 + j + 2);
         }
     }
-    
-    // Create distributed matrices
+
+    // Créer des matrices distribuées
     int numProcs;
     MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
     DistributedMatrix matrix1(matrix1Full, numProcs);
     DistributedMatrix matrix2(matrix2Full, numProcs);
-    
-    // Compute expected result
+
+    // Calculer la matrice attendue (référence)
     Matrix expectedMatrix = matrix1Full * matrix2Full.transpose();
 
-    // Compute A * B^T
+    // Profilage avec NVTX pour marquer les sections de calcul
+    nvtxRangePushA("MPI_Init");  // Début de l'initialisation MPI
+
+    // Profilage du calcul (avant l'opération)
+    nvtxRangePushA("DistributedMatrix::multiplyTransposed");
+
+    // Exécuter A * B^T
     Matrix result = matrix1.multiplyTransposed(matrix2);
-    
-    // Check
+
+    nvtxRangePop();  // Fin de l'opération multiplyTransposed
+    nvtxRangePop();  // Fin de l'initialisation MPI
+
+    // Vérification du résultat
     assert(matricesEqual(result, expectedMatrix, 1e-8));
-    
+
     if (rank == 0) {
         std::cout << "MultiplyTransposed test passed!" << std::endl;
     }
 }
 
 int main(int argc, char** argv) {
-    // Initialize MPI
+    // Initialiser MPI
     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 DistributedMatrix tests..." << std::endl;
     }
-    
+
     try {
-        // Run tests
+        // Lancer le test
         testMultiplyTransposed();
         
         if (rank == 0) {
@@ -99,14 +107,8 @@ int main(int argc, char** argv) {
         }
         MPI_Abort(MPI_COMM_WORLD, 1);
     }
-    
-    // Finalize MPI if we initialized it
-    // int finalized;
-    // MPI_Finalized(&finalized);
-    // if (!finalized && initialized) {
-    //     MPI_Finalize();
-    // }
 
+    // Finaliser MPI si nécessaire
     MPI_Finalize();
     return 0;
-}
\ No newline at end of file
+}
diff --git a/P2/profile_mpi_computation.nsys-rep b/P2/profile_mpi_computation.nsys-rep
index 8ffd1dbfd35e6e705424d7690dbeac0d19c8e1dd..9591b0509a910c333d80c1e61fe1c11d076a3321 100644
GIT binary patch
delta 216
zcmWl|Suz3u002<3XUm>7d&r($_OcftB6SVFKHeQ%#Ed)W8l1up-pnh1{scb$zN!>Z
zrCN<zb?P+;YSg4zi&i0R+I8sErCX1%UVZuv7&Ihe*oaYM#!Z+MHD%h2m|1h?Em*W<
zS=@?MYu0Vpv}Ieuj$M299XNC(DdpISQ)kXyxRjQ0<yzK_TX%BqJ;;0Xq~KZcy%hZp
Ry?vD`{^jB?g;XY4`~?ffO)UTb

delta 236
zcmWl|HBJKn006*JyjUq#+={!qw>ZUJwr;Qx62iuCf9OX@cmwbactscBl6(Km1i${i
z$`X_<N3J~i3KR+{QmjO&GGXN+DpaactwvO>I`tYfYSOGlt2XUoI&|vNtw*mu{RRvg
zGHk@CG2<ponlf$1tU2=*ELyT`#i})N3F|g&+OloOu02Wn4jeji?8K=v=Pq2ja_z?L
o+g;aBEEEY9o}}(m52>femvH(c6O0DZ-*<t3r(@68iDdlt7hs7~umAu6

-- 
GitLab