WSL是否支持OpenMP?

时间:2019-04-10 11:51:00

标签: c gcc openmp windows-subsystem-for-linux mingw-w64

WSL是否支持OpenMP?与运行Windows的Windows相比,WSL似乎有很大的下降。此外,它计算的持续时间与实时不符。

当我在Windows上编译它时,一切正常,时间合适,结果表明使用OpenMP时可以更快地执行。但是,在WSL上运行时并非如此。

    s = clock();
    printf("%ld\n",s);
    #pragma  omp parallel for num_threads(THREADS_NUM) private(i,j,m)
    for (int l = 0; l < THREADS_NUM; ++l)
    {
        int id = omp_get_thread_num();
        printf("here is %d\n",id);
        int k =0;
        for (; k < CIRCLES; ++k)
        {
            i = rand()%10;
            j = rand()%10;
            m = rand()%10;
            m = i+j;
            i = j+m;
            j = i+m;
        }
        printf("complete %d %d %d\n",l,k,id);
    }
    f=clock();
    printf("%ld\n",f);
    printf("%f\n",(double)(f-s)/CLOCKS_PER_SEC);
    printf("%ld\n",CLOCKS_PER_SEC);

这是Windows上的结果:

1755//start clock
here is 1
here is 0
here is 3
here is 2
complete 3 10000000 3
complete 2 10000000 2
complete 0 10000000 0
complete 1 10000000 1
2378//end clock
0.623000//this is time
1000//clock per second

这是关于wsl的结果:

1218750//start clock
here is 0
here is 1
here is 3
here is 2
complete 2 10000000 2
complete 0 10000000 0
complete 3 10000000 3
complete 1 10000000 1
33328125//end clock
32.109375//this is time
1000000//clock per second

看起来它计算的持续时间是实际使用的时间的4倍。enter code here

0 个答案:

没有答案