Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
SC2710
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Jordan Hanotiaux
SC2710
Validations
79e7a48a
Valider
79e7a48a
rédigé
Il y a 2 mois
par
JordanHanotiaux
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Update
parent
d8126bff
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
P2/distributedtests.cpp
+37
-35
37 ajouts, 35 suppressions
P2/distributedtests.cpp
P2/profile_mpi_computation.nsys-rep
+0
-0
0 ajout, 0 suppression
P2/profile_mpi_computation.nsys-rep
avec
37 ajouts
et
35 suppressions
P2/distributedtests.cpp
+
37
−
35
Voir le fichier @
79e7a48a
...
@@ -6,20 +6,19 @@
...
@@ -6,20 +6,19 @@
#include
<cassert>
#include
<cassert>
#include
<cmath>
#include
<cmath>
#include
<functional>
#include
<functional>
#include
<nvToolsExt.h>
// Pour NVTX
// Fonction utilitaire pour vérifier si deux doubles sont proches
// Helper function to test if two doubles are approximately equal
bool
approxEqual
(
double
a
,
double
b
,
double
epsilon
=
1e-10
)
{
bool
approxEqual
(
double
a
,
double
b
,
double
epsilon
=
1e-10
)
{
return
std
::
abs
(
a
-
b
)
<
epsilon
;
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
)
{
bool
matricesEqual
(
const
Matrix
&
a
,
const
Matrix
&
b
,
double
epsilon
=
1e-10
)
{
if
(
a
.
numRows
()
!=
b
.
numRows
()
||
a
.
numCols
()
!=
b
.
numCols
())
{
if
(
a
.
numRows
()
!=
b
.
numRows
()
||
a
.
numCols
()
!=
b
.
numCols
())
{
return
false
;
return
false
;
}
}
for
(
int
i
=
0
;
i
<
a
.
numRows
();
i
++
)
{
for
(
int
i
=
0
;
i
<
a
.
numRows
();
i
++
)
{
for
(
int
j
=
0
;
j
<
a
.
numCols
();
j
++
)
{
for
(
int
j
=
0
;
j
<
a
.
numCols
();
j
++
)
{
if
(
!
approxEqual
(
a
.
get
(
i
,
j
),
b
.
get
(
i
,
j
),
epsilon
))
{
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) {
...
@@ -27,66 +26,75 @@ bool matricesEqual(const Matrix& a, const Matrix& b, double epsilon = 1e-10) {
}
}
}
}
}
}
return
true
;
return
true
;
}
}
// Test multiplyTransposed
// Test multiplyTransposed
avec NVTX pour marquage et analyse des performances
void
testMultiplyTransposed
()
{
void
testMultiplyTransposed
()
{
int
rank
;
int
rank
;
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
// Cr
eate t
es
t
matrices
// Cr
éer d
es matrices
de test
Matrix
matrix1Full
(
256
,
256
);
Matrix
matrix1Full
(
1024
,
1024
);
// Taille plus petite pour une exécution rapide
Matrix
matrix2Full
(
256
,
256
);
Matrix
matrix2Full
(
1024
,
1024
);
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
for
(
int
i
=
0
;
i
<
1024
;
i
++
)
{
for
(
int
j
=
0
;
j
<
256
;
j
++
)
{
for
(
int
j
=
0
;
j
<
1024
;
j
++
)
{
matrix1Full
.
set
(
i
,
j
,
i
*
5
+
j
+
1
);
matrix1Full
.
set
(
i
,
j
,
i
*
5
+
j
+
1
);
}
}
}
}
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
for
(
int
i
=
0
;
i
<
1024
;
i
++
)
{
for
(
int
j
=
0
;
j
<
256
;
j
++
)
{
for
(
int
j
=
0
;
j
<
1024
;
j
++
)
{
matrix2Full
.
set
(
i
,
j
,
i
*
5
+
j
+
2
);
matrix2Full
.
set
(
i
,
j
,
i
*
5
+
j
+
2
);
}
}
}
}
// Cr
eate distributed matric
es
// Cr
éer des matrices distribué
es
int
numProcs
;
int
numProcs
;
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
numProcs
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
numProcs
);
DistributedMatrix
matrix1
(
matrix1Full
,
numProcs
);
DistributedMatrix
matrix1
(
matrix1Full
,
numProcs
);
DistributedMatrix
matrix2
(
matrix2Full
,
numProcs
);
DistributedMatrix
matrix2
(
matrix2Full
,
numProcs
);
// C
ompute expected result
// C
alculer la matrice attendue (référence)
Matrix
expectedMatrix
=
matrix1Full
*
matrix2Full
.
transpose
();
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
);
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
));
assert
(
matricesEqual
(
result
,
expectedMatrix
,
1e-8
));
if
(
rank
==
0
)
{
if
(
rank
==
0
)
{
std
::
cout
<<
"MultiplyTransposed test passed!"
<<
std
::
endl
;
std
::
cout
<<
"MultiplyTransposed test passed!"
<<
std
::
endl
;
}
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
// Initiali
ze
MPI
// Initiali
ser
MPI
int
initialized
;
int
initialized
;
MPI_Initialized
(
&
initialized
);
MPI_Initialized
(
&
initialized
);
if
(
!
initialized
)
{
if
(
!
initialized
)
{
MPI_Init
(
&
argc
,
&
argv
);
MPI_Init
(
&
argc
,
&
argv
);
}
}
int
rank
;
int
rank
;
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
if
(
rank
==
0
)
{
if
(
rank
==
0
)
{
std
::
cout
<<
"Starting DistributedMatrix tests..."
<<
std
::
endl
;
std
::
cout
<<
"Starting DistributedMatrix tests..."
<<
std
::
endl
;
}
}
try
{
try
{
//
Run
test
s
//
Lancer le
test
testMultiplyTransposed
();
testMultiplyTransposed
();
if
(
rank
==
0
)
{
if
(
rank
==
0
)
{
...
@@ -99,14 +107,8 @@ int main(int argc, char** argv) {
...
@@ -99,14 +107,8 @@ int main(int argc, char** argv) {
}
}
MPI_Abort
(
MPI_COMM_WORLD
,
1
);
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
();
MPI_Finalize
();
return
0
;
return
0
;
}
}
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
P2/profile_mpi_computation.nsys-rep
+
0
−
0
Voir le fichier @
79e7a48a
Aucun aperçu pour ce type de fichier
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter