You are on page 1of 10

A Pintool for Detecting Race in O

penMP Programs
12/08/2021
OSLab.

1
Probe Points
• #pragma omp parallel for  Link
– Entry:
• GOMP_parallel_loop_static(,,, start, end, step, );
 Cannot Catch!! Link
•  GOMP_parallel_start()
– insert PIN_Notify_For_Loop(start, end, step)
– Exit
• GOMP_parallel_end();
 Catch irregular
– insert PIN_Notify_For_End()

2
– Inside of a For Loop
• insert a pintool helper function
–  PIN_Notify_For_Index(i)

3
• #pragma omp ciritical  Link
– Entry
• GOMP_critical_start();  without lock name
• GOMP_critical_name_start();  with lock name
– Exit
• GOMP_critical_end();  without lock name
• GOMP_critical_name_end();  with lock name

4
Probe with Pintool
1. Searching a specific function in the OpenMP libra
ry
2. Registering callback function at Entry/Exit point
of the target function
3. Collecting data from arguments, return value, inst
ruction address, etc.

5
Searching function

RTN rtn = RTN_FindByName(img, FUNCTION_NAME);


if (RTN_Valid(rtn)) {
RTN_Open(rtn);
RTN_InsertCall(rtn, IPOINT_BEFORE, CALLBACK_FUNCTION, IARG_THREAD_ID,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, IARG_END);
RTN_InsertCall(rtn, IPOINT_AFTER, CALLBACK_FUNCTION, IARG_THREAD_ID,
IARG_FUNCARG_ENTRYPOINT_VALUE, 0, IARG_END);
RTN_Close(rtn);
}
Registering callback function Collecting Data

6
• Getting the line number & the source file name
INT32 line;
string file;
string s; Instruction Address
PIN_LockClient();

PIN_GetSourceLocation((ADDRINT)ip, NULL, &line, &file);

PIN_UnlockClient();

ReleaseLock(&lock);

7
Selection of a Shared Variable
• insert a pintool helper function
– PIN_Notify_Shared_Variable(addressOfVariable)

8
Insertion of Pintool helpers
main() {
...
int sharedVariable;
...
PIN_Notify_Shared_Variable(&sharedVariable);
...
PIN_Notify_For_Loop(0, loopcnt, 1);
#pragma omp parallel for
for(i = 0; i < loopcnt; i++)
{
PIN_Notify_For_Index(i);
...
}
PIN_Notify_For_End();
...
}

9
Reference
• GNU libgomp
– http://gcc.gnu.org/onlinedocs/gcc-4.4.4/libgomp/
• GNU GCC source
– http://gcc.gnu.org/viewcvs/tags/gcc_4_4_4_release/libg
omp/

10

You might also like