我在一段并行代码中使用多个matlab引擎时遇到了一些麻烦.我可以使用多个引擎成功生成多个引擎,engOpenSingleUse但无法与多个引擎通信(即调用engPutVariable失败).
与往常一样,最小(VS)示例:
#include "stdafx.h"
#include <engine.h>
#include <omp.h>
int _tmain(int argc, _TCHAR* argv[])
{
//First spawn the matlab engine sessions
Engine *m_Engines[2];
for (int i = 0; i < 2; i++)
{
m_Engines[i] = engOpenSingleUse(NULL, NULL, NULL);
}
//Then spawn the worker threads...
#pragma omp parallel num_threads(2)
{
// Allocate an engine to each thread
int thread_num = omp_get_thread_num();
Engine *thisEngine = m_Engines[thread_num];
#pragma omp for
for (int i = 0; i < 10000; i++)
{ …Run Code Online (Sandbox Code Playgroud) 有几个关于 SO 的精彩讨论已经涵盖了如何在 Linux 上生成可执行共享库:
在 C/C++ 中,这似乎相对简单;基本上有两个部分:
.interp内容,向 ELF添加一个部分(因为ld不包括共享库的部分):const char interp_section[] __attribute__((section(".interp"))) = "/path/to/dynamic/linker";-Wl,-e,entry_point有谁知道如何使用 Fortran 编写的库来实现这一目标?具体来说,如何将一个.interp部分添加到使用编译的共享库中ifort?