使用 mpicc (MPICH2) 和 pthread_barrier (-lpthread) 进行编译
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
这意味着 pthread_barrier_t 类型不在范围内。你有
#include
pthread.h
吗?This means that
pthread_barrier_t
type is not in scope. Have you#include
'dpthread.h
?