Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProgrammationParallelle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JACQUIER Timeo
ProgrammationParallelle
Commits
2e7cdb96
Commit
2e7cdb96
authored
2 years ago
by
timeo
Browse files
Options
Downloads
Patches
Plain Diff
protection des variables pour openMP
parent
777e33e8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ProgrammesEnVrac/main.cpp
+15
-10
15 additions, 10 deletions
src/ProgrammesEnVrac/main.cpp
with
15 additions
and
10 deletions
src/ProgrammesEnVrac/main.cpp
+
15
−
10
View file @
2e7cdb96
...
...
@@ -98,7 +98,7 @@ void sommeAdditiveCentre(){
* Bloc délimité par son indice de début et de fin dans la string
*/
inline
int
valeurBloc
(
int
debutBloc
,
int
finBloc
){
compteur_somme
++
;
//
compteur_somme++;
return
(
sommeAdditiveArray
[
finBloc
+
1
]
-
sommeAdditiveArray
[
debutBloc
]);
}
...
...
@@ -448,7 +448,6 @@ int32_t nbAdditifSuffixTreeWithOpenMP(int nb){
int32_t
tailleBloc
;
//Premier tour
#pragma omp parallel for num_threads(nb)
for
(
int
i
=
0
;
i
<
fichier
.
size
()
-
suffixTree
[
0
];
i
++
){
tailleChaine
=
i
+
1
;
//Taille de la chaine courante
if
((
tailleChaine
%
3
)
==
0
){
//Si la taille est divisible par 3
...
...
@@ -465,10 +464,13 @@ int32_t nbAdditifSuffixTreeWithOpenMP(int nb){
}
}
int
additionbloc1
;
int
additionbloc2
;
int
additionbloc3
;
//Boucle pour les tours suivants
int32_t
compteur_parcours
;
//Compte le nombre de tours de boucle lors du parcours pour comparer les 2 suffixes
#pragma omp parallel for num_threads(nb)
#pragma omp parallel for num_threads(nb)
shared(sommeAdditiveArray) private(additionbloc1) private(additionbloc2) private(additionbloc3) private(tailleChaine) private(tailleBloc) private(compteur_parcours)
for
(
int
i
=
1
;
i
<
fichier
.
size
();
i
++
){
compteur_parcours
=
0
;
...
...
@@ -483,10 +485,13 @@ int32_t nbAdditifSuffixTreeWithOpenMP(int nb){
if
((
tailleChaine
%
3
==
0
)
&&
tailleChaine
<
fichier
.
size
()){
tailleBloc
=
tailleChaine
/
3
;
int
additionbloc1
=
valeurBloc
(
suffixTree
[
i
],
suffixTree
[
i
]
+
tailleBloc
-
1
);
int
additionbloc2
=
valeurBloc
(
suffixTree
[
i
]
+
tailleBloc
,
suffixTree
[
i
]
+
2
*
tailleBloc
-
1
);
int
additionbloc3
=
valeurBloc
(
suffixTree
[
i
]
+
2
*
tailleBloc
,
suffixTree
[
i
]
+
3
*
tailleBloc
-
1
);
//#pragma omp critical
{
additionbloc1
=
valeurBloc
(
suffixTree
[
i
],
suffixTree
[
i
]
+
tailleBloc
-
1
);
additionbloc2
=
valeurBloc
(
suffixTree
[
i
]
+
tailleBloc
,
suffixTree
[
i
]
+
2
*
tailleBloc
-
1
);
additionbloc3
=
valeurBloc
(
suffixTree
[
i
]
+
2
*
tailleBloc
,
suffixTree
[
i
]
+
3
*
tailleBloc
-
1
);
}
if
(
additionbloc1
==
additionbloc2
&&
additionbloc2
==
additionbloc3
)
// Lorsqu'il y a une additivité cubique
{
nbAdditive
++
;
...
...
@@ -504,16 +509,16 @@ int main(){
high_resolution_clock
::
time_point
t1
=
high_resolution_clock
::
now
();
std
::
cout
<<
std
::
endl
<<
nbAdditif
WithSomme
(
)
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
<<
nbAdditif
SuffixTreeWithOpenMP
(
16
)
<<
std
::
endl
;
int32_t
compteur_somme_sans_arbre
=
compteur_somme
;
compteur_somme
=
0
;
std
::
cout
<<
std
::
endl
<<
nbAdditifSuffixTree
()
<<
std
::
endl
;
/*
std::cout << std::endl << nbAdditifSuffixTree() << std::endl;
std::cout << "Différence appel : " << compteur_somme_sans_arbre - compteur_somme << std::endl;
float pourcentage = (1 - ((float) compteur_somme / (float) compteur_somme_sans_arbre)) * 100;
std
::
cout
<<
"Pourcentage différence "
<<
pourcentage
<<
std
::
endl
;
std::cout << "Pourcentage différence " << pourcentage << std::endl;
*/
high_resolution_clock
::
time_point
t2
=
high_resolution_clock
::
now
();
duration
<
double
>
time_span
=
duration_cast
<
duration
<
double
>>
(
t2
-
t1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment