I am experimenting with openMP for large data processing and relatively new to it. My input data set is huge and so I divided it into multiple subsets and each thread working on the subset of data. Each data item in the subset is acted up on by the thread. If one of the threads fails during its operation on any dataitem, i would like to terminate other threads and return a failure. Using shared variable is an option, but is there a better way to do the same ?
问问题
3153 次
1 回答
2
如果您的一个线程在其输入中阻塞,您希望发生什么?你想让程序突然停止吗?还是您想停止并行执行并整理程序的串行部分?
OpenMP 并不是真正为这两种操作而设计的,因此您将与其苦苦挣扎,而不是像大多数初学者那样苦苦挣扎。正如您所建议的,您当然可以使用共享变量并编写自己的逻辑来停止程序或在其中一个线程失败时跳转到并行区域的末尾。但是这些操作没有 OpenMP 内在机制。
您可能想要研究task
OpenMP 3.0 的新功能。使用这些,您当然可以实现一个系统,其中任务被分派到返回成功或失败的线程,并具有处理失败的其他任务。
最后,有人可能会争辩说错误的输入不应该导致程序崩溃,但这是另一个话题。
于 2010-10-12T12:30:03.580 回答