IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

optimisation de code fractale mandelbrot


Sujet :

C++

  1. #1
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut optimisation de code fractale mandelbrot
    Bonjour
    Étant passionné par les fractales(notamment l'ensemble de Mandelbrot),j'ai créé un code qui permet de zoomer dessus et de sauvegarder des images de zoom.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    #include <SDL/SDL.h>
    int pycode(int c_1,int c_2,int c_3)
    {
        return c_3+c_2*256+c_1*256*256;
    }
    void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
    {
        int nbOctetsParPixel = surface->format->BytesPerPixel;
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
        switch(nbOctetsParPixel)
        {
            case 1:
                *p = pixel;
                break;
            case 2:
                *(Uint16 *)p = pixel;
                break;
            case 3:
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                {
                    p[0] = (pixel >> 16) & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = pixel & 0xff;
                }
                else
                {
                    p[0] = pixel & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = (pixel >> 16) & 0xff;
                }
                break;
            case 4:
                *(Uint32 *)p = pixel;
                break;
        }
    }
    int main(int argc, char *argv[])
    {
        int ri=250;
        int vi=0;
        int bi=0;
        int i;
        int couleur[150];
        for (i=0;i<25;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi+=10;
        }
        for (;i<50;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri-=10;
        }
        for (;i<75;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi+=10;
        }
        for (;i<100;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi-=10;
        }
        for (;i<125;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri+=10;
        }
        for (;i<150;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi-=10;
        }
        double xa=0,ya=0;
        SDL_Surface *ecran = NULL;
        SDL_Event event;
        int continuer = 1;
        int tempsPrecedent = 0, tempsActuel = 0;
        SDL_Init(SDL_INIT_VIDEO);
        ecran = SDL_SetVideoMode(600, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
        SDL_WM_SetCaption("Mandelbrot", NULL);
        int iteration_max=150;
        double zoom=200;
        double eca=zoom/200;
        double x1 =-1.5/eca;
        double x2 =1.5/eca;
        double y1 =-1.2/eca;
        double y2 =1.2/eca;
        int image_x = (x2 - x1) * zoom;
        int image_y = (y2 - y1) * zoom;
        for(int x=0;x<image_x;x++)
        {
            for(int y=0;y<image_y;y++)
            {
                double c_r = x / zoom + x1;
                double c_i = y / zoom + y1;
                double z_r = 0;
                double z_i = 0;
                int i = 0;
                while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                {
                    double tmp = z_r;
                    z_r = z_r*z_r - z_i*z_i + c_r;
                    z_i = 2*z_i*tmp + c_i;
                    i++;
                }
                if (i < iteration_max)
                    definirPixel(ecran,x,y,couleur[i%150]);
                else
                    definirPixel(ecran,x,y,0);
            }
        }
        while (continuer)
        {
            SDL_WaitEvent(&event);
            switch(event.type)
            {
                case SDL_QUIT:
                    continuer = 0;
                    break;
                case SDL_KEYDOWN:
                    switch (event.key.keysym.sym)
                    {
                        case SDLK_u:
                            iteration_max+=50;
                            break;
                        case SDLK_t:
                            SDL_SaveBMP(ecran,"mandelbrot.bmp");
                            break;
                        case SDLK_RALT:
                            zoom/=1.5;
                            break;
                        case SDLK_r:
                            zoom=200;
                            break;
                        case SDLK_LEFT:
                            xa-=50/zoom;
                            break;
                        case SDLK_RIGHT:
                            xa+=50/zoom;
                            break;
                        case SDLK_UP:
                            ya-=50/zoom;
                            break;
                        case SDLK_DOWN:
                            ya+=50/zoom;
                            break;
                        case SDLK_SPACE:
                            zoom*=1.5;
                            break;
                        case SDLK_BACKSPACE:
                            iteration_max+=20;
                            break;
                        case SDLK_e:
                            iteration_max-=50;
                            break;
                    }
                    long double eca=zoom/200;
                    long double x1 =xa-1.5/eca;
                    long double x2 =xa+1.5/eca;
                    long double y1 =ya-1.2/eca;
                    long double y2 =ya+1.2/eca;
                    int image_x = (x2 - x1) * zoom;
                    int image_y = (y2 - y1) * zoom;
                    for(int x=0;x<image_x;x++)
                    {
                        for(int y=0;y<image_y;y++)
                        {
                            long double c_r = x / zoom + x1,c_i = y / zoom + y1,z_r = 0,z_i = 0;
                            int i = 0;
                            while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                            {
                                long double tmp = z_r;
                                z_r = z_r*z_r - z_i*z_i + c_r;
                                z_i = 2*z_i*tmp + c_i;
                                i++;
                            }
                            if (i < iteration_max)
                                definirPixel(ecran,x,y,couleur[i%150]);
                            else
                                definirPixel(ecran,x,y,0);
                        }
                    }
            }
            SDL_Flip(ecran);
        }
        SDL_Quit();
        return EXIT_SUCCESS;
    }
    Il marche plutôt bien mais calculer cette fractale étant toujours assez lent,j'aimerais que l'on propose des optimisations ou des amélioration.
    N’hésitez pas à poser des question dessus.

  2. #2
    Expert confirmé

    Inscrit en
    Août 2006
    Messages
    3 942
    Détails du profil
    Informations forums :
    Inscription : Août 2006
    Messages : 3 942
    Points : 5 654
    Points
    5 654
    Par défaut
    Bonjour,
    Citation Envoyé par fifafou Voir le message
    Bonjour
    Étant passionné par les fractales(notamment l'ensemble de Mandelbrot),j'ai créé un code qui permet de zoomer dessus et de sauvegarder des images de zoom.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
       while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                {
                    double tmp = z_r;
                    z_r = (z_r*z_r - z_i*z_i + c_r;
                    z_i = 2*z_i*tmp + c_i;
                    i++;
                }
    Je n'ai pas épluché ton code, mais déjà là, tu as 2 fois les mêmes élévations au carré.
    Si les cons volaient, il ferait nuit à midi.

  3. #3
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2011
    Messages
    739
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2011
    Messages : 739
    Points : 3 627
    Points
    3 627
    Par défaut
    C'est à vérifier, mais à mon avis, le switch dans definirPixel n'est pas optimiser par le compilateur. À chaque tour de boucle, il est évalué alors que la profondeur de couleur ne change pas. Mettre les boucles dans le switch plutôt que l'inverse, devrait faire une différence.

    Pour éviter une duplication d'écriture, je verrais bien un proto template<SetPixFn> void mandelbrot(setPixFn set_px_fn);
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
      case 1: mandelbrot([](Uint8 * p, Uint32 c) { *p = c; }); break;
      case 2: mandelbrot([](Uint8 * p, Uint32 c) { *reinterpret_cast<Uint16 *>(p) = pixel; }); break;
      etc

  4. #4
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    Citation Envoyé par droggo Voir le message
    Bonjour,

    Je n'ai pas épluché ton code, mais déjà là, tu as 2 fois les mêmes élévations au carré.
    Le problème est que une partie est dans la boucle et que les valeurs de z_r et z_i changent tout le temps

  5. #5
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    Citation Envoyé par jo_link_noir Voir le message
    C'est à vérifier, mais à mon avis, le switch dans definirPixel n'est pas optimiser par le compilateur. À chaque tour de boucle, il est évalué alors que la profondeur de couleur ne change pas. Mettre les boucles dans le switch plutôt que l'inverse, devrait faire une différence.

    Pour éviter une duplication d'écriture, je verrais bien un proto template<SetPixFn> void mandelbrot(setPixFn set_px_fn);
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
      case 1: mandelbrot([](Uint8 * p, Uint32 c) { *p = c; }); break;
      case 2: mandelbrot([](Uint8 * p, Uint32 c) { *reinterpret_cast<Uint16 *>(p) = pixel; }); break;
      etc
    A mon avis,la vitesse de l'affichage des pixels est négligeable.
    la lenteur du programme se trouve surtout ici
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
    {
            long double tmp = z_r;
            z_r = z_r*z_r - z_i*z_i + c_r;
            z_i = 2*z_i*tmp + c_i;
            i++;
    }

  6. #6
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    26 859
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 26 859
    Points : 218 580
    Points
    218 580
    Billets dans le blog
    120
    Par défaut
    Bonjour,

    Peut être regarder du côté du multithreading (OpenMP par exemple).
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  7. #7
    Expert éminent sénior
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2005
    Messages
    5 073
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2005
    Messages : 5 073
    Points : 12 119
    Points
    12 119
    Par défaut
    A mon avis,la vitesse de l'affichage des pixels est négligeable.
    la lenteur du programme se trouve surtout ici
    NE JAMAIS SORTIR CE GENRE DE CONNER.. SANS UN RAPPORT DE PROFILLING POTABLE.

    En résumé, utilisez un profiler plutôt que votre doigt, même sortant de votre douche.

  8. #8
    Rédacteur/Modérateur


    Homme Profil pro
    Network game programmer
    Inscrit en
    Juin 2010
    Messages
    7 115
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Canada

    Informations professionnelles :
    Activité : Network game programmer

    Informations forums :
    Inscription : Juin 2010
    Messages : 7 115
    Points : 32 967
    Points
    32 967
    Billets dans le blog
    4
    Par défaut
    Surotut que perso, je vois l'utilisation de SDL, et peut-être même pas SDL2. Donc la lenteur de l'affichage, on peut aisément parier dessus justement. Et on ne sait rien de comment est créée la texture, est-elle en ram ou en mémoire vidéo ? Profites-tu de l'accélération matérielle ? Dans tous les cas, la manipulation de pixels reste une action lente en général. Pourquoi ne pas faire ça dans un shader d'ailleurs ?

    Edit: d'ailleurs cette fonction ressemble trait pour trait à la fonction exemple setPixel que l'on trouve dans la doc de SDL1, et dans cette même doc, dans mes souvenirs, il est mentionné que c'est une opération plutôt lente.
    Pensez à consulter la FAQ ou les cours et tutoriels de la section C++.
    Un peu de programmation réseau ?
    Aucune aide via MP ne sera dispensée. Merci d'utiliser les forums prévus à cet effet.

  9. #9
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    Bon bas j'ai essayé mais ne comprenant pas trop la fonction definirPixel,je n'ais pas fait grand chose mais c'est déjà ça
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    #include <SDL/SDL.h>
    int pycode(int c_1,int c_2,int c_3)
    {
        return c_3+c_2*256+c_1*256*256;
    }
    void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel,int nbOctetsParPixel)
    {
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
        switch(nbOctetsParPixel)
        {
            case 1:
                *p = pixel;
                break;
            case 2:
                *(Uint16 *)p = pixel;
                break;
            case 3:
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                {
                    p[0] = (pixel >> 16) & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = pixel & 0xff;
                }
                else
                {
                    p[0] = pixel & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = (pixel >> 16) & 0xff;
                }
                break;
            case 4:
                *(Uint32 *)p = pixel;
                break;
        }
    }
    int main(int argc, char *argv[])
    {
        int ri=250;
        int vi=0;
        int bi=0;
        int i;
        int couleur[150];
        for (i=0;i<25;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi+=10;
        }
        for (;i<50;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri-=10;
        }
        for (;i<75;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi+=10;
        }
        for (;i<100;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi-=10;
        }
        for (;i<125;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri+=10;
        }
        for (;i<150;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi-=10;
        }
        double xa=0,ya=0;
        SDL_Surface *ecran = NULL;
        SDL_Event event;
        int continuer = 1;
        int tempsPrecedent = 0, tempsActuel = 0;
        SDL_Init(SDL_INIT_VIDEO);
        ecran = SDL_SetVideoMode(600, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
        SDL_WM_SetCaption("Mandelbrot", NULL);
        int nbOctetsParPixel = ecran->format->BytesPerPixel;
        int iteration_max=150;
        double zoom=200;
        double eca=zoom/200;
        double x1 =-1.5/eca;
        double x2 =1.5/eca;
        double y1 =-1.2/eca;
        double y2 =1.2/eca;
        int image_x = (x2 - x1) * zoom;
        int image_y = (y2 - y1) * zoom;
        for(int x=0;x<image_x;x++)
        {
            for(int y=0;y<image_y;y++)
            {
                double c_r = x / zoom + x1;
                double c_i = y / zoom + y1;
                double z_r = 0;
                double z_i = 0;
                int i = 0;
                while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                {
                    double tmp = z_r;
                    z_r = z_r*z_r - z_i*z_i + c_r;
                    z_i = 2*z_i*tmp + c_i;
                    i++;
                }
                if (i < iteration_max)
                    definirPixel(ecran,x,y,couleur[i%150],nbOctetsParPixel);
                else
                    definirPixel(ecran,x,y,0,nbOctetsParPixel);
            }
        }
        while (continuer)
        {
            SDL_WaitEvent(&event);
            switch(event.type)
            {
                case SDL_QUIT:
                    continuer = 0;
                    break;
                case SDL_KEYDOWN:
                    switch (event.key.keysym.sym)
                    {
                        case SDLK_u:
                            iteration_max+=50;
                            break;
                        case SDLK_t:
                            SDL_SaveBMP(ecran,"mandelbrot.bmp");
                            break;
                        case SDLK_RALT:
                            zoom/=1.5;
                            break;
                        case SDLK_r:
                            zoom=200;
                            break;
                        case SDLK_LEFT:
                            xa-=50/zoom;
                            break;
                        case SDLK_RIGHT:
                            xa+=50/zoom;
                            break;
                        case SDLK_UP:
                            ya-=50/zoom;
                            break;
                        case SDLK_DOWN:
                            ya+=50/zoom;
                            break;
                        case SDLK_SPACE:
                            zoom*=1.5;
                            break;
                        case SDLK_BACKSPACE:
                            iteration_max+=20;
                            break;
                        case SDLK_e:
                            iteration_max-=50;
                            break;
                    }
                    long double eca=zoom/200;
                    long double x1 =xa-1.5/eca;
                    long double x2 =xa+1.5/eca;
                    long double y1 =ya-1.2/eca;
                    long double y2 =ya+1.2/eca;
                    int image_x = (x2 - x1) * zoom;
                    int image_y = (y2 - y1) * zoom;
                    for(int x=0;x<image_x;x++)
                    {
                        for(int y=0;y<image_y;y++)
                        {
                            long double c_r = x / zoom + x1,c_i = y / zoom + y1,z_r = 0,z_i = 0;
                            int i = 0;
                            while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                            {
                                long double tmp = z_r;
                                z_r = z_r*z_r - z_i*z_i + c_r;
                                z_i = 2*z_i*tmp + c_i;
                                i++;
                            }
                            if (i < iteration_max)
                                definirPixel(ecran,x,y,couleur[i%150],nbOctetsParPixel);
                            else
                                definirPixel(ecran,x,y,0,nbOctetsParPixel);
                        }
                    }
            }
            SDL_Flip(ecran);
        }
        SDL_Quit();
        return EXIT_SUCCESS;
    }
    pour template<SetPixFn> void mandelbrot(setPixFn set_px_fn);
    Je suis plutôt debutant et je ne connais pas ce machin template

  10. #10
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    Bonjour,
    Mon frère m'a proposé une optimisation possible:
    pour les déplacements sur le coté on peut garder le centre de l'image,ce qui fait beaucoup moins de calculs
    J'ai donc réussi à programmer cela,le programme est du coup beaucoup plus rapide pour les déplacements sur les cotés
    (mais pas pour le zoom)
    Code C++ : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    #include <SDL.h>
    #include <algorithm>
    using namespace std;
    int pycode(int c_1,int c_2,int c_3)
    {
        return c_3+c_2*256+c_1*256*256;
    }
    void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel,int nbOctetsParPixel)
    {
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
        switch(nbOctetsParPixel)
        {
            case 1:
                *p = pixel;
                break;
            case 2:
                *(Uint16 *)p = pixel;
                break;
            case 3:
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                {
                    p[0] = (pixel >> 16) & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = pixel & 0xff;
                }
                else
                {
                    p[0] = pixel & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = (pixel >> 16) & 0xff;
                }
                break;
            case 4:
                *(Uint32 *)p = pixel;
                break;
        }
    }
    Uint32 lirePixel(SDL_Surface *surface, int x, int y,int nbOctetsParPixel)
    {
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
        switch(nbOctetsParPixel)
        {
            case 1:
                return *p;
            case 2:
                return *(Uint16 *)p;
            case 3:
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                    return p[0] << 16 | p[1] << 8 | p[2];
                else
                    return p[0] | p[1] << 8 | p[2] << 16;
            case 4:
                return *(Uint32 *)p;
            default:
                return 0;
        }
    }
    void decale(SDL_Surface *ecran,int x,int y,int nbOctetsParPixel)
    {
        Uint32 temp[480][600];
        for(int i=max(0,x);i<min(600,600+x);i++)
        {
            for(int j=max(0,y);j<min(480,480+y);j++)
            {
                temp[j][i]=lirePixel(ecran,i,j,nbOctetsParPixel);
            }
        }
        for(int i=max(0,x);i<min(600,600+x);i++)
        {
            for(int j=max(0,y);j<min(480,480+y);j++)
            {
                definirPixel(ecran,i-x,j-y,temp[j][i],nbOctetsParPixel);
            }
        }
    }
    int main(int argc, char *argv[])
    {
        int tx1=0;
        int ty1=0;
        int tx2=0;
        int ty2=0;
        int ri=250;
        int vi=0;
        int bi=0;
        int i;
        int couleur[150];
        for (i=0;i<25;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi+=10;
        }
        for (;i<50;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri-=10;
        }
        for (;i<75;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi+=10;
        }
        for (;i<100;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi-=10;
        }
        for (;i<125;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri+=10;
        }
        for (;i<150;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi-=10;
        }
        double xa=0,ya=0;
        SDL_Surface *ecran = NULL;
        SDL_Event event;
        int continuer = 1;
        int tempsPrecedent = 0, tempsActuel = 0;
        SDL_Init(SDL_INIT_VIDEO);
        ecran = SDL_SetVideoMode(600, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
        SDL_WM_SetCaption("Mandelbrot", NULL);
        int nbOctetsParPixel = ecran->format->BytesPerPixel;
        int iteration_max=150;
        double zoom=200;
        double eca=zoom/200;
        double x1 =-1.5/eca;
        double x2 =1.5/eca;
        double y1 =-1.2/eca;
        double y2 =1.2/eca;
        int image_x = (x2 - x1) * zoom;
        int image_y = (y2 - y1) * zoom;
        for(int x=0;x<image_x;x++)
        {
            for(int y=0;y<image_y;y++)
            {
                double c_r = x / zoom + x1;
                double c_i = y / zoom + y1;
                double z_r = 0;
                double z_i = 0;
                int i = 0;
                while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                {
                    double tmp = z_r;
                    z_r = z_r*z_r - z_i*z_i + c_r;
                    z_i = 2*z_i*tmp + c_i;
                    i++;
                }
                if (i < iteration_max)
                    definirPixel(ecran,x,y,couleur[i%150],nbOctetsParPixel);
                else
                    definirPixel(ecran,x,y,0,nbOctetsParPixel);
            }
        }
        SDL_EnableKeyRepeat(400,200);
        while (continuer)
        {
            SDL_WaitEvent(&event);
            switch(event.type)
            {
                case SDL_QUIT:
                    continuer = 0;
                    break;
                case SDL_KEYDOWN:
                    switch (event.key.keysym.sym)
                    {
                        case SDLK_u:
                            iteration_max+=50;
                            break;
                        case SDLK_t:
                            SDL_SaveBMP(ecran,"mandelbrot.bmp");
                            break;
                        case SDLK_RALT:
                            zoom/=1.5;
                            break;
                        case SDLK_r:
                            zoom=200;
                            break;
                        case SDLK_LEFT:
                            xa-=50/zoom;
                            tx2=550;
                            decale(ecran,-50,0,nbOctetsParPixel);
                            break;
                        case SDLK_RIGHT:
                            xa+=50/zoom;
                            tx1=550;
                            decale(ecran,50,0,nbOctetsParPixel);
                            break;
                        case SDLK_UP:
                            ya-=50/zoom;
                            ty2=430;
                            decale(ecran,0,-50,nbOctetsParPixel);
                            break;
                        case SDLK_DOWN:
                            ya+=50/zoom;
                            ty1=430;
                            decale(ecran,0,50,nbOctetsParPixel);
                            break;
                        case SDLK_SPACE:
                            zoom*=1.5;
                            break;
                        case SDLK_BACKSPACE:
                            iteration_max+=20;
                            break;
                        case SDLK_e:
                            iteration_max-=50;
                            break;
                    }
                    long double eca=zoom/200;
                    long double x1 =xa-1.5/eca;
                    long double x2 =xa+1.5/eca;
                    long double y1 =ya-1.2/eca;
                    long double y2 =ya+1.2/eca;
                    int image_x = (x2 - x1) * zoom;
                    int image_y = (y2 - y1) * zoom;
                    for(int x=tx1;x<600-tx2;x++)
                    {
                        for(int y=ty1;y<480-ty2;y++)
                        {
                            long double c_r = x / zoom + x1,c_i = y / zoom + y1,z_r = 0,z_i = 0;
                            int i = 0;
                            while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                            {
                                long double tmp = z_r;
                                z_r = z_r*z_r - z_i*z_i + c_r;
                                z_i = 2*z_i*tmp + c_i;
                                i++;
                            }
                            if (i < iteration_max)
                                definirPixel(ecran,x,y,couleur[i%150],nbOctetsParPixel);
                            else
                                definirPixel(ecran,x,y,0,nbOctetsParPixel);
                        }
                    }
                    tx1=0;
                    ty1=0;
                    tx2=0;
                    ty2=0;
            }
            SDL_Flip(ecran);
        }
        SDL_Quit();
        return EXIT_SUCCESS;
    }

  11. #11
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    Devant les lignes 135 for(int x=0;x<image_x;x++) et 218 for(int x=tx1;x<600-tx2;x++) ; rajoute la ligne #pragma omp parallel for schedule(dynamic, 1) pour paralléliser le code avec OpenMP. Assure toi d'avoir un compilateur qui supporte OpenMP et d'ajouter les bonnes options pour l'activer (option -fopenmp pour GCC).

    Tu peux aussi vectoriser ton code (pour utiliser les instructions SIMD), ça améliore les performances mais ce n'est pas évident à mettre en place.

  12. #12
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    pas sur d'avoir compris
    quels calculs vont être en parallèle?

  13. #13
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    En utilisant OpenMP, tu demandes au compilateur de paralléliser pour toi.
    Les itérations de la première boucle seront traitées en parallèle.

    Ça correspond au calcul suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
            for(int y=0;y<image_y;y++)
            {
                double c_r = x / zoom + x1;
                double c_i = y / zoom + y1;
                double z_r = 0;
                double z_i = 0;
                int i = 0;
                while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                {
                    double tmp = z_r;
                    z_r = z_r*z_r - z_i*z_i + c_r;
                    z_i = 2*z_i*tmp + c_i;
                    i++;
                }
                if (i < iteration_max)
                    definirPixel(ecran,x,y,couleur[i%150],nbOctetsParPixel);
                else
                    definirPixel(ecran,x,y,0,nbOctetsParPixel);
            }
    Idem pour :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
                        for(int y=ty1;y<480-ty2;y++)
                        {
                            long double c_r = x / zoom + x1,c_i = y / zoom + y1,z_r = 0,z_i = 0;
                            int i = 0;
                            while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                            {
                                long double tmp = z_r;
                                z_r = z_r*z_r - z_i*z_i + c_r;
                                z_i = 2*z_i*tmp + c_i;
                                i++;
                            }
                            if (i < iteration_max)
                                definirPixel(ecran,x,y,couleur[i%150],nbOctetsParPixel);
                            else
                                definirPixel(ecran,x,y,0,nbOctetsParPixel);
                        }

  14. #14
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    Je suis sous code::blocks et ça ne marche pas
    Je vais essayer de mettre openMP dessus
    merci beaucoup

  15. #15
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    Sous Windows avec MinGW ?
    Si oui, il faut prendre la bonne version de MinGW et la configurer pour avoir le support des thread posix.
    Ensuite dans Code::Blocks, il faut ajouter l'option -fopenmp dans les compiler settings et linker settings

  16. #16
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    J'ai réussi à mettre openmp et à compiler sans problème mais il me met comme warning main.cpp:192:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
    es-ce que ça active OpenMP où pas?
    PS:founir un mode d'emploi et economiser du code,je l'ai un peu modifié
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    #include <SDL.h>
    #include <algorithm>
    using namespace std;
    int pycode(int c_1,int c_2,int c_3)
    {
        return c_3+c_2*256+c_1*256*256;
    }
    void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel,int nbOctetsParPixel)
    {
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
        switch(nbOctetsParPixel)
        {
            case 1:
                *p = pixel;
                break;
            case 2:
                *(Uint16 *)p = pixel;
                break;
            case 3:
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                {
                    p[0] = (pixel >> 16) & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = pixel & 0xff;
                }
                else
                {
                    p[0] = pixel & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = (pixel >> 16) & 0xff;
                }
                break;
            case 4:
                *(Uint32 *)p = pixel;
                break;
        }
    }
    Uint32 lirePixel(SDL_Surface *surface, int x, int y,int nbOctetsParPixel)
    {
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
        switch(nbOctetsParPixel)
        {
            case 1:
                return *p;
            case 2:
                return *(Uint16 *)p;
            case 3:
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                    return p[0] << 16 | p[1] << 8 | p[2];
                else
                    return p[0] | p[1] << 8 | p[2] << 16;
            case 4:
                return *(Uint32 *)p;
            default:
                return 0;
        }
    }
    void decale(SDL_Surface *ecran,int x,int y,int nbOctetsParPixel)
    {
        Uint32 temp[480][600];
        for(int i=max(0,x);i<min(600,600+x);i++)
        {
            for(int j=max(0,y);j<min(480,480+y);j++)
            {
                temp[j][i]=lirePixel(ecran,i,j,nbOctetsParPixel);
            }
        }
        for(int i=max(0,x);i<min(600,600+x);i++)
        {
            for(int j=max(0,y);j<min(480,480+y);j++)
            {
                definirPixel(ecran,i-x,j-y,temp[j][i],nbOctetsParPixel);
            }
        }
    }
    int main(int argc, char *argv[])
    {
        int tx1=0;
        int ty1=0;
        int tx2=0;
        int ty2=0;
        int ri=250;
        int vi=0;
        int bi=0;
        int i;
        int couleur[150];
        for (i=0;i<25;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi+=10;
        }
        for (;i<50;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri-=10;
        }
        for (;i<75;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi+=10;
        }
        for (;i<100;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            vi-=10;
        }
        for (;i<125;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            ri+=10;
        }
        for (;i<150;i++)
        {
            couleur[i]=pycode(ri,vi,bi);
            bi-=10;
        }
        double xa=0,ya=0;
        SDL_Event event;
        int continuer = 1;
        int tempsPrecedent = 0, tempsActuel = 0;
        SDL_Init(SDL_INIT_VIDEO);
        SDL_Surface *ecran =NULL,*Fond = NULL;
        SDL_Rect positionFond;
        positionFond.x = 0;
        positionFond.y = 0;
        ecran = SDL_SetVideoMode(600, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
        SDL_WM_SetCaption("Mandelbrot", NULL);
        int nbOctetsParPixel = ecran->format->BytesPerPixel;
        Fond = SDL_LoadBMP("debut.bmp");
        SDL_BlitSurface(Fond, NULL, ecran, &positionFond);
        int iteration_max=150;
        double zoom=200;
        SDL_EnableKeyRepeat(400,200);
        while (continuer)
        {
            SDL_WaitEvent(&event);
            switch(event.type)
            {
                case SDL_QUIT:
                    continuer = 0;
                    break;
                case SDL_KEYDOWN:
                    switch (event.key.keysym.sym)
                    {
                        case SDLK_u:
                            iteration_max+=50;
                            break;
                        case SDLK_t:
                            SDL_SaveBMP(ecran,"mandelbrot.bmp");
                            break;
                        case SDLK_RALT:
                            zoom/=1.5;
                            break;
                        case SDLK_r:
                            zoom=200;
                            break;
                        case SDLK_LEFT:
                            xa-=50/zoom;
                            tx2=550;
                            decale(ecran,-50,0,nbOctetsParPixel);
                            break;
                        case SDLK_RIGHT:
                            xa+=50/zoom;
                            tx1=550;
                            decale(ecran,50,0,nbOctetsParPixel);
                            break;
                        case SDLK_UP:
                            ya-=50/zoom;
                            ty2=430;
                            decale(ecran,0,-50,nbOctetsParPixel);
                            break;
                        case SDLK_DOWN:
                            ya+=50/zoom;
                            ty1=430;
                            decale(ecran,0,50,nbOctetsParPixel);
                            break;
                        case SDLK_SPACE:
                            zoom*=1.5;
                            break;
                        case SDLK_BACKSPACE:
                            iteration_max+=20;
                            break;
                        case SDLK_e:
                            iteration_max-=50;
                            break;
                    }
                    long double eca=zoom/200;
                    long double x1 =xa-1.5/eca;
                    long double x2 =xa+1.5/eca;
                    long double y1 =ya-1.2/eca;
                    long double y2 =ya+1.2/eca;
                    #pragma omp parallel for schedule(dynamic, 1)
                    for(int x=tx1;x<600-tx2;x++)
                    {
                        for(int y=ty1;y<480-ty2;y++)
                        {
                            long double c_r = x / zoom + x1,c_i = y / zoom + y1,z_r = 0,z_i = 0;
                            int i = 0;
                            while(z_r*z_r + z_i*z_i <4 && i < iteration_max)
                            {
                                long double tmp = z_r;
                                z_r = z_r*z_r - z_i*z_i + c_r;
                                z_i = 2*z_i*tmp + c_i;
                                i++;
                            }
                            if (i < iteration_max)
                                definirPixel(ecran,x,y,couleur[i%150],nbOctetsParPixel);
                            else
                                definirPixel(ecran,x,y,0,nbOctetsParPixel);
                        }
                    }
                    tx1=0;
                    ty1=0;
                    tx2=0;
                    ty2=0;
            }
            SDL_Flip(ecran);
        }
        SDL_Quit();
        return EXIT_SUCCESS;
    }

  17. #17
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    Citation Envoyé par fifafou Voir le message
    warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
    Raté, il dit qu'il a ignoré le pragma demandant à OpenMP de paralléliser.

    Tu as bien rajouté -fopenmp dans les options du compilateur et du linkeur ?

    Sinon, sous Windows, toutes les versions de MinGW ne supportent pas OpenMP, il faut installer la bonne version.
    Par exemple celle-ci https://sourceforge.net/projects/mingw-w64 en choisissant les threads posix durant l'installation.

  18. #18
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    Je l'avais bien rajouté
    avec ton lien,il me met:
    "SDLtest - Debug": The compiler's setup (GNU GCC Compiler) is invalid, so Code::Blocks cannot find/run the compiler.
    Probably the toolchain path within the compiler options is not setup correctly?! (Do you have a compiler installed?)
    Goto "Settings->Compiler...->Global compiler settings->GNU GCC Compiler->Toolchain executables" and fix the compiler's setup.
    Skipping...

  19. #19
    Membre régulier Avatar de fifafou
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2016
    Messages
    173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 22
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Janvier 2016
    Messages : 173
    Points : 92
    Points
    92
    Par défaut
    apres avoir réparé le bazar que j'avais fais,mon projet a été modifié un peu partout
    le compilateur me met maintenant,
    lib\._libSDL.dll.a: file not recognized: File format not recognized
    collect2.exe: error: ld returned 1 exit status

  20. #20
    Membre chevronné Avatar de Ehonn
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    788
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 788
    Points : 2 160
    Points
    2 160
    Par défaut
    Il faut que tu indiques où est la SDL dans les options du linker.

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. optimiser le code d'une fonction
    Par yanis97 dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 15/07/2005, 08h41
  2. Optimiser mon code ASP/HTML
    Par ahage4x4 dans le forum ASP
    Réponses: 7
    Dernier message: 30/05/2005, 10h29
  3. optimiser le code
    Par bibi2607 dans le forum ASP
    Réponses: 3
    Dernier message: 03/02/2005, 14h30
  4. syntaxe et optimisation de codes
    Par elitol dans le forum Langage SQL
    Réponses: 18
    Dernier message: 12/08/2004, 11h54
  5. optimisation du code et var globales
    Par tigrou2405 dans le forum ASP
    Réponses: 2
    Dernier message: 23/01/2004, 10h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo