为什么使用openmp时会间歇性出现“fatal error C1001”错误?

Why might the “fatal error C1001” error occur intermittently when using openmp?

我的代码在没有 #openmp 的情况下运行良好 但是当我添加#openmp compiler

时出现了这个错误

1>c:\users\hdd amd ali\documents\v studio 10 projects\visual studio 2010\projects\escaledesvols2 - copy\escaledesvols2\djikstra.cpp(116): fatal error C1001: An internal error occurred in the compiler. 1> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\wvm\mdmiscw.c', ligne 1098)

注意: 我使用许多不同的库(如#boost)

#include <string>
#include <iostream>
#include <stdio.h>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <msclr\marshal_cppstd.h> // for unmanaged piece of code
#include <vcclr.h> 

你应该简单地报告它。

就解决方法而言,它可能与 memory/resource 消耗有关。降低消耗的常用技巧是

  • 禁用调试信息
  • 将编译单元拆分成更小的尺寸(这可能是这里的关键:"I'm using many libraries" 应该不是问题,除非您将所有 headers 包含在一个翻译单元中
  • 尝试减少模板实例化

或者

  • 减少系统负载(关闭其他程序,例如可能占用宝贵资源的 Whosebug 浏览器:))

在我的例子中,它是来自 OpenMP 循环的 return 函数。删除 "return" 行解决了问题。

我最近遇到了这个问题;我正在使用 visual studio 2015 进行编译。我尝试使用 visual studio 2017 进行编译,但仍然出现内部编译器错误。然后我用 visual studio 2013 尝试了它,它告诉我我不能在 openMP 部分中有 "return" 语句。当我从 VS 2013 和 VS 2105 中删除 return 时,编译器能够成功编译。所以,在 VS 2013 中尝试它是有意义的,它会给你一个更好的错误描述。您也可能在 openMP 部分中有 return 语句,这可能是出现 c1001 错误的原因。