0% found this document useful (0 votes)
322 views10 pages

A Pintool For Detecting Race in OpenMP Programs

This document describes using a Pintool to detect race conditions in OpenMP programs. It discusses inserting callback functions at entry and exit points of OpenMP functions using the Pintool API. These callbacks collect data like instruction address, shared variable addresses, and loop indices to detect potential races. The Pintool searches the OpenMP library functions, registers callbacks, and inserts helper functions to notify loop ranges and shared variables.

Uploaded by

In-Bon Kuh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
322 views10 pages

A Pintool For Detecting Race in OpenMP Programs

This document describes using a Pintool to detect race conditions in OpenMP programs. It discusses inserting callback functions at entry and exit points of OpenMP functions using the Pintool API. These callbacks collect data like instruction address, shared variable addresses, and loop indices to detect potential races. The Pintool searches the OpenMP library functions, registers callbacks, and inserts helper functions to notify loop ranges and shared variables.

Uploaded by

In-Bon Kuh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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