[OpenMP] ne fonctionne pas...
Résolu/Fermé
Char Snipeur
Messages postés
9688
Date d'inscription
vendredi 23 avril 2004
Statut
Contributeur
Dernière intervention
2 octobre 2020
-
31 mai 2011 à 15:45
Char Snipeur Messages postés 9688 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 2 octobre 2020 - 7 juin 2011 à 09:02
Char Snipeur Messages postés 9688 Date d'inscription vendredi 23 avril 2004 Statut Contributeur Dernière intervention 2 octobre 2020 - 7 juin 2011 à 09:02
3 réponses
Char Snipeur
Messages postés
9688
Date d'inscription
vendredi 23 avril 2004
Statut
Contributeur
Dernière intervention
2 octobre 2020
1 328
1 juin 2011 à 08:24
1 juin 2011 à 08:24
personne ne connait OpenMP ?
Char Snipeur
Messages postés
9688
Date d'inscription
vendredi 23 avril 2004
Statut
Contributeur
Dernière intervention
2 octobre 2020
1 328
6 juin 2011 à 10:21
6 juin 2011 à 10:21
une idée où chercher ?
Char Snipeur
Messages postés
9688
Date d'inscription
vendredi 23 avril 2004
Statut
Contributeur
Dernière intervention
2 octobre 2020
1 328
7 juin 2011 à 09:02
7 juin 2011 à 09:02
J'ai trouvé, mais ce fut dur, il faut spécifier une portion de code en parallele :
#include <cmath>
#include <omp.h>
#include <iostream>
const int Nb=500;
int main()
{
double a,b[Nb][Nb],c[Nb][Nb],d[Nb][Nb],e[Nb][Nb],f[Nb][Nb],g[Nb][Nb];
#pragma omp parallel shared(default)
{
omp_set_num_threads(2);
std::cout<<omp_get_num_threads()<<std::endl;
#pragma omp for
for(unsigned long i=0;i<Nb;++i)
for(unsigned long j=0;j<Nb;++j)
{
a=0.1574143*i+0.654*j;
b[i][j]=cos(a);
c[i][j]=sin(a);
d[i][j]=tan(a);
e[i][j]=asin(a-int(a));
f[i][j]=acos(a-int(a));
g[i][j]=atan2(b[i][j],c[i][j]);
if(omp_get_num_threads()>1)std::cout<<"OK !";
}
}
return 0;
}