编译多线程代码时遇到麻烦

时间:2013-10-06 12:43:08

标签: c++ c multithreading

我尝试使用Visual Studio 2012编译this代码但我收到以下错误。我该如何解决这个问题?他们是由于什么?但是程序运行正常但是处于单线程模式。

#include <stdio.h>
#include <time.h>
#include <omp.h>

int main() {
    double start, end;
    double runTime;
    start = omp_get_wtime();
    int num = 1,primes = 0;

    int limit = 1000000;

#pragma omp parallel for schedule(dynamic) reduction(+ : primes)
    for (num = 1; num <= limit; num++) { 
        int i = 2; 
        while(i <= num) { 
            if(num % i == 0)
                break;
            i++; 
        }
        if(i == num)
            primes++;
//      printf("%d prime numbers calculated\n",primes);
    }

    end = omp_get_wtime();
    runTime = end - start;
    printf("This machine calculated all %d prime numbers under %d in %g seconds\n",primes,limit,runTime);

    return 0;
}

'ConsoleApplication4.exe' (Win32): Loaded 'C:\Users\Administrator\Documents\Visual Studio 2012\Projects\ConsoleApplication4\x64\Debug\ConsoleApplication4.exe'. Symbols loaded.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\msvcp110d.dll'. Symbols loaded.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\msvcr110d.dll'. Symbols loaded.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\vcomp110d.dll'. Symbols loaded.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\lpk.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\usp10.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Cannot find or open the PDB file.
'ConsoleApplication4.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Cannot find or open the PDB file.
The thread 0x11f0 has exited with code -1073741510 (0xc000013a).
The program '[4908] ConsoleApplication4.exe' has exited with code -1073741510 (0xc000013a).

0 个答案:

没有答案
相关问题