【发布时间】:2010-08-12 22:25:11
【问题描述】:
大家好。我的程序在几个部分使用 OpenMP 来执行多线程。它在大多数情况下都有效,但偶尔会停顿并坐在那里。所以我在调试器中运行它,我发现它停止的区域。然后我尝试检查当前变量,我得到了这个:
169 if(0<=myPtr[3] && myPtr[3]<=1){//Reassign the velocities.
(gdb) print myPtr[3]
No symbol "myPtr" in current context.
我不确定这是为什么。当它只是单线程时,我可以打印它。我私有化了那个变量,我想当我要求它打印一些东西时,程序不会知道我指的是哪个线程(即使这个http://cc.jct.ac.il/cc-res/online-doc/gdb/gdb_26.html#SEC26 说总会有一个当前线程......?)。所以,如果我选择一个线程,我会得到相同的东西:
(gdb) info threads
3 process 32970 thread 0x4203 0x90f9846e in __semwait_signal ()
2 process 32970 thread 0x3007 0x90f9846e in __semwait_signal ()
* 1 process 32970 local thread 0x2e03 mover3dsurfaces (.omp_data_i=0xbffff030) at mover3dsurfaces.cpp:174
(gdb) thread 1
[Switching to thread 1 (process 32970 local thread 0x2e03)]
mover3dsurfaces (.omp_data_i=0xbffff030) at mover3dsurfaces.cpp:174
174 partList.velocity(i,3) = velPtr[2];
(gdb) print velPtr[1]
No symbol "velPtr" in current context.
我实际上对这部分有点困惑。我的机器只有两个处理器。怎么会有3个线程?我看到 __semwait_signal() 之前的两个十六进制数字是相同的,但我不知道他们为什么要分开。如何查看单个线程的变量?
谢谢!
【问题讨论】:
标签: c++ multithreading gdb openmp