使用 mpicc (MPICH2) 和 pthread_barrier (-lpthread) 进行编译

发布于 2024-09-08 01:16:20 字数 647 浏览 3 评论 0原文

我有一个 MPI 例程的功能实现,它工作得很好。在使其成为 MPI 和共享内存之间的混合体的过程中,我使用了 pthreads。这反过来证明了 pthread_barriers 的需要。

但是,当我尝试使用 mpicc 编译器编译代码时,它会抱怨 pthread_barrier_t 和其他屏障命令。如果我删除这些,并保留其他线程部分,它编译得很好。

这是我插入的用于中断编译的代码行:

pthread_barrier_t* barrier;

对于编译,我使用:

mpicc -lm myprogram.c -o myprogram

从编译器返回的错误是:

myprogram.c:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token

其中第 34 行对应于我上面写的内容。

[编辑] 我在 Ubuntu 9.10 上运行它,使用以下 gcc/mpicc 编译器: gcc(Ubuntu 4.4.1-4ubuntu9)4.4.1。 [/编辑]

有谁知道可能出了什么问题以及如何使其编译?

干杯!

I have a functioning implementation of a MPI routine, which works fine. In the process of making this a hybrid between MPI and shared memory, I am using pthreads. This in turn proofed the need of pthread_barriers.

But when I try to compile my code with the mpicc compiler, it complains over pthread_barrier_t and other barrier commands. If I remove these, and keep other threading parts it compiles just fine.

This is the line of code I insert to break the compilation:

pthread_barrier_t* barrier;

And for compilation I use:

mpicc -lm myprogram.c -o myprogram

The error returned from the compiler is:

myprogram.c:34: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token

Where line 34 corresponds to what I wrote above.

[Edit] I am runnings this on Ubuntu 9.10, with the following gcc/mpicc compiler:
gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1.
[/Edit]

Does anyone know what could be wrong and how I can make it compile?

Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无可置疑 2024-09-15 01:16:20

pthread_barrier_t 是 ADVANCED REALTIME THREAD 选项的一部分,因此它可能在您的系统上不可用。
顺便说一句,如果你提出这样一个具体的问题,你应该总是提到操作系统、版本号和类似的东西。

pthread_barrier_t is part of the ADVANCED REALTIME THREAD option, so it might not be available on your system.
BTW, if you pose such a specific question you should always mention OS, version number and things like that.

故事还在继续 2024-09-15 01:16:20

这意味着 pthread_barrier_t 类型不在范围内。你有#includepthread.h吗?

This means that pthread_barrier_t type is not in scope. Have you #include'd pthread.h?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文