Skip to content

[Regression | OMPT] missing ompt_scope_end for target enter/exit data #527

@Thyre

Description

@Thyre

Description:
The OMPT interface offers different callbacks to track the execution of an OpenMP program. For regions on target devices the callback ompt_callback_target is certainly the most important.

The target region callback is defined like this:

typedef void (*ompt_callback_target_t) (
    ompt_target_t kind,
    ompt_scope_endpoint_t endpoint,
    int device_num,
    ompt_data_t *task_data,
    ompt_id_t target_id,
    const void *codeptr_ra
);

A target region can have different kinds, which describe what type of target directive was used. This issue will focus on two kinds, which were working fine in aomp 16.x and ROCm 5.4.x. We are looking at #pragma omp target enter data and #pragma omp target exit data.

Target region callbacks will get called twice with a different endpoint. When entering a target region, an endpoint of ompt_scope_begin is used. When exiting the region, the endpoint ompt_scope_end is chosen. There's also ompt_scope_beginend but I'm not sure when this is ever used.
Previously, we would get both endpoints.

With this issue present, we are unable to track any target enter data or target exit data regions at all as we require ompt_scope_end to know when the regions did finish! For Score-P, we would run into error messages because we cannot match the locations and wouldn't be able to produce any tracing data.

Reproduce the issue:
We can take the following source code as an example:

#include <omp.h>
#include <stdio.h>
#include "callbacks.h"

int main( void )
{
    int M[10];
#pragma omp target enter data map(to: M[:10]) 
#pragma omp target 
    {
#pragma omp teams distribute parallel for simd
        for(int i = 0; i < 10; ++i)
        {
            M[i] = i;
        }
    }
#pragma omp target exit data map(from: M[:10])
    return 0;
}

callbacks.h is the header file used in the veccopy-ompt-target-tracing example

With ROCm 5.4.x, everything seems fine. However, target_id=6 is missing ompt_scope_end in the device tracing interface:

> ./error_missing_scope_end | grep endpoint
Callback Target: target_id=1 kind=2 endpoint=1 device_num=0 code=0x55da7977084c
Callback Target: target_id=1 kind=2 endpoint=2 device_num=0 code=0x55da7977084c
Callback Target: target_id=4 kind=1 endpoint=1 device_num=0 code=0x55da797708cf
	Record Target: kind=2 endpoint=1 device=0 task_id=0 target_id=1 codeptr=0x55da7977084c
	Record Target: kind=2 endpoint=2 device=0 task_id=0 target_id=1 codeptr=0x55da7977084c
Callback Target: target_id=4 kind=1 endpoint=2 device_num=0 code=0x55da797708cf
Callback Target: target_id=6 kind=3 endpoint=1 device_num=0 code=0x55da7977093a
	Record Target: kind=1 endpoint=1 device=0 task_id=0 target_id=4 codeptr=0x55da797708cf
Callback Target: target_id=6 kind=3 endpoint=2 device_num=0 code=0x55da7977093a
	Record Target: kind=1 endpoint=2 device=0 task_id=0 target_id=4 codeptr=0x55da797708cf
	Record Target: kind=3 endpoint=1 device=0 task_id=0 target_id=6 codeptr=0x55da7977093a

With aomp 17.0, the situation is worse. If we check for the endpoints, all target enter data and target exit data are missing ompt_scope_end

> ./error_missing_scope_end | grep endpoint
Callback Target: target_id=1 kind=2 endpoint=1 device_num=0 code=0x55803e209be0
Callback Target: target_id=4 kind=1 endpoint=1 device_num=0 code=0x55803e209c6c
	Record Target: kind=2 endpoint=1 device=0 task_id=0 target_id=1 codeptr=0x55803e209be0
Callback Target: target_id=4 kind=1 endpoint=2 device_num=0 code=0x55803e209c6c
Callback Target: target_id=6 kind=2 endpoint=1 device_num=0 code=0x55803e209cd8
	Record Target: kind=1 endpoint=1 device=0 task_id=0 target_id=4 codeptr=0x55803e209c6c
	Record Target: kind=1 endpoint=2 device=0 task_id=0 target_id=4 codeptr=0x55803e209c6c
	Record Target: kind=3 endpoint=1 device=0 task_id=0 target_id=6 codeptr=0x55803e209cd8

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions