于 2011/7/9 1:33, PcX 写道:
Hi, all

    I built winpthread with "./configure --enable-static --disable-shared", and I use it to build gcc4.6.1 with "./configure --enable-libgomp --enable-static --disable-shared".
    But when I build a openmp program, the compiler and linker stage works well, but run the program will crash.
    I use gdb to debug the program, and found that a "segmentation fault" coming out:

    Program received signal SIGSEGV, Segmentation fault.
    0x00405a2d in mutex_ref ()



        But if I use pthread-win32 static edition to build libgomp, all work fine.

        Where am I wrong?

        Thanks.
-- 
Best Regards,
PcX
This is a test program in attachment. (gcc -O3 -fopenmp main.c)
Thanks.

-- 
Best Regards,
PcX

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(int argc, char *argv[])
{
    int i;
    int start, end; 
    int    number_of_primes=0; 
    int number_of_41primes=0;
    int number_of_43primes=0;
    double s1,s2;
    start = 1;
    end = 40000000; 

    printf("Range to check for Primes: %d - %d\n\n",start, end);
    s1=clock();
#pragma omp parallel for schedule(dynamic,100) 
reduction(+:number_of_primes,number_of_41primes,number_of_43primes)

    for (i = start; i <= end; i += 2) {
        int limit, j, prime;
        limit = (int) sqrt((float)i) + 1;
        prime = 1; 
        j = 3;
        
        while (prime && (j <= limit)) {
            if (i%j == 0) prime = 0;
            j += 2;
        }
        if (prime) {
            number_of_primes++;
            if (i%4 == 1) number_of_41primes++;
            if (i%4 == 3) number_of_43primes++;
        }
    }
    s2=clock();
      printf("\n%10e\n",s2-s1);
    printf("\nProgram Done.\n %d primes found\n",number_of_primes);
    printf("\nNumber of 4n+1 primes found: %d\n",number_of_41primes);
    printf("\nNumber of 4n-1 primes found: %d\n",number_of_43primes);

    return 0; 
}
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to