关于在收集实验之前检测应用程序以检测数据争用的提示:
如果没有检测二进制代码以进行数据争用检测,collect -r race 命令会发出一条如下所示的警告:
% collect -r race a.out WARNING: Target `a.out' is not instrumented for datarace detection; reported datarace data may be misleading
通过使用 nm 命令以及查找对 tha 例程的调用,可以确定是否检测了二进制代码以进行数据争用检测。如果显示名称以 __tha_ 开头的例程,则表明已检测二进制代码。示例输出如下所示。
源代码级检测:
% cc -xopenmp -g -xinstrument=datarace source.c % nm a.out | grep __tha_ [71] | 135408| 0|FUNC |GLOB |0 |UNDEF |__tha_get_stack_id [53] | 135468| 0|FUNC |GLOB |0 |UNDEF |__tha_src_read_w_frame [61] | 135444| 0|FUNC |GLOB |0 |UNDEF |__tha_src_write_w_frame
二进制代码级检测:
% cc -xopenmp -g source.c % discover -i datarace -o a.out.i a.out % nm a.out.i | grep __tha_ [88] | 0| 0|NOTY |GLOB |0 |UNDEF |__tha_read_w_pc_frame [49] | 0| 0|NOTY |GLOB |0 |UNDEF |__tha_write_w_pc_frame