并行运行MEX文件时出现分段错误 [英] Segmentation Faults when Running MEX Files in Parallel

查看:93
本文介绍了并行运行MEX文件时出现分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在运行一个重复实验,该实验使用MATLAB 2012a中的MEX文件,偶尔会遇到我无法理解的细分错误.

I am currently running repetitions of an experiment that uses MEX files in MATLAB 2012a and occasionally running into segmentation faults that I cannot understand.

有关故障的一些信息

  • 它们随机出现

  • They occur randomly

仅当我使用parfor循环在Linux机器上并行运行多次实验时,它们才会发生.

They only occur when I run multiple repetitions of my experiment in parallel on a Linux machine using a parfor loop.

当我使用parfor循环在Mac OSX 10.7上并行运行多次实验时,它们不会出现 .

They do not occur when I run multiple repetitions of my experiment in parallel on Mac OSX 10.7 using a parfor loop.

当我运行时它们不会发生,或者当我依次运行重复项时它们会发生.

They do not occur when I run or do they occur when I run the repetitions sequentially.

当我并行运行2个实验时,它们出现的频率似乎要低得多,而并行运行12个实验则相反.

They seem to occur far less frequently when I run 2 experiments in parallel - as opposed to 12 experiments in parallel.

有关我的MEX文件的一些信息:

Some information about my MEX file:

  • 它是用C语言编写的

  • It is written in C

它使用IBM CPLEX 12.4 API(这是线程安全的)

It uses the IBM CPLEX 12.4 API (this is thread-safe)

它是使用GCC 4.6.3编译的

It was compiled using GCC 4.6.3

我的想法是,在多个内核中访问MEX文件可能存在一些问题.任何人都可以对可能发生的事情有所了解或提出解决方案吗?我很乐意在必要时提供更多信息.

My thoughts are that there may be some issue in accessing the MEX file in multiple cores. Can anyone shed any light on what might be going on or suggest a fix? I'd be happy to provide more information as necessary.

推荐答案

我最近向MATLAB的人员发送了堆栈跟踪,结果发现罪魁祸首不是我的代码,而是CPLEX 12.4中的功能之一. API.事实证明,此函数在C中使用putenv()函数,该函数不一定是线程安全的.

I've recently sent a stack trace to the people at MATLAB and it turns out that the culprit is not my code but one of the functions from the CPLEX 12.4 API. It turns out that this function uses the putenv() function in C which is not necessarily thread-safe.

不幸的是,我必须继续使用此功能和API,因此我发布了

Unfortunately, I have to keep using this function and the API so I've posted a follow-up thread that focuses on finding ways to avoid this fault.

任何建议将不胜感激.

Any advice would be appreciated.

这篇关于并行运行MEX文件时出现分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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