C OpenMP:libgomp:线程创建失败:资源暂时不可用 [英] C OpenMP : libgomp: Thread creation failed: Resource temporarily unavailable

查看:211
本文介绍了C OpenMP:libgomp:线程创建失败:资源暂时不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一个基本项目,但似乎线程用完了?你们知道我该如何解决这个问题吗?

I was trying to do a p basic project and It seems like I have run out of threads? Do you guys know how do can I fix the problem?

代码如下:

int main()
{
    omp_set_num_threads(2150);
    #pragma omp parallel
    {
        printf("%d\n",omp_get_thread_num());
    }


    return 0;
}

这里是我在其他编译器选项"上写的全局编译器设置在代码块上:

and here is the global compiler setting I have written on "other compiler options" on CodeBlocks:

-fopenmp

我收到以下错误:

libgomp:线程创建失败:资源暂时不可用

libgomp: Thread creation failed: Resource temporarily unavailable

我在网站上看到过类似的帖子,但我还没有得到答案或解决方案.

I have seen similar threads on the site, but I have not got the answer or solution as of yet.

规格:

英特尔 i5 6400

Intel i5 6400

2x8GB 内存

Windows 10 64 位

Windows 10 64 bit

推荐答案

问题是

omp_set_num_threads(2150);

操作系统会对进程可以创建的线程数施加限制.这可以是间接的,例如通过限制堆栈大小.创2150超限.

The OS will impose a limit on the number of threads a process can create. This may be indirect for example by limiting the stack size. Creating 2150 exceeds the limits.

您提到您拥有四核芯片 intel 15 6400.尝试将线程数设置为更合理的值.在你的情况下:

You mention that you've got the intel 15 6400 which is a quad core chip. Try setting the number of threads to something more reasonable. In your case:

omp_set_num_threads(4);

对于数值处理,在 4 核系统上使用超过 4 个线程时,性能可能会受到影响

For numerical processing, performance will likely suffer when using more than 4 threads on a 4 core system

这篇关于C OpenMP:libgomp:线程创建失败:资源暂时不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆