Skip to content

Commit

Permalink
[OpenMP][OMPT] Refactor internal device tracing function signatures
Browse files Browse the repository at this point in the history
Refactor signatures of:
 * start-/stopTargetDataRetrieveTrace
 * start-/stopTargetDataSubmitTrace
Fix some misleading variable names

Since signatures have been changed to accomodate D2D data transfers for
callbacks, we adapt the signatures of tracing functions for the sake of
consistency.

Change-Id: Ia35e704306e259cb60486e228da51852ec5502d6
  • Loading branch information
mhalk authored and ronlieb committed Feb 29, 2024
1 parent 794183a commit a95cd9e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 39 deletions.
24 changes: 14 additions & 10 deletions openmp/libomptarget/include/OpenMP/OMPT/Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@ class Interface {
void *Code);

/// Top-level function for starting trace before data submit
void startTargetDataSubmitTrace(int64_t DeviceId, void *HstPtrBegin,
void *TgtPtrBegin, size_t Size, void *Code);
void startTargetDataSubmitTrace(int64_t SrcDeviceId, void *SrcPtrBegin,
int64_t DstDeviceId, void *DstPtrBegin,
size_t Size, void *Code);

/// Top-level function for stopping trace after data submit
ompt_record_ompt_t *stopTargetDataSubmitTrace(int64_t DeviceId,
void *HstPtrBegin,
void *TgtPtrBegin, size_t Size,
ompt_record_ompt_t *stopTargetDataSubmitTrace(int64_t SrcDeviceId,
void *SrcPtrBegin,
int64_t DstDeviceId,
void *DstPtrBegin, size_t Size,
void *Code);

/// Top-level function for starting trace before device data deallocation
Expand All @@ -157,13 +159,15 @@ class Interface {
void *TgtPtrBegin, void *Code);

/// Top-level function for starting trace before data retrieve
void startTargetDataRetrieveTrace(int64_t DeviceId, void *HstPtrBegin,
void *TgtPtrBegin, size_t Size, void *Code);
void startTargetDataRetrieveTrace(int64_t SrcDeviceId, void *SrcPtrBegin,
int64_t DstDeviceId, void *DstPtrBegin,
size_t Size, void *Code);

/// Top-level function for stopping trace after data retrieve
ompt_record_ompt_t *stopTargetDataRetrieveTrace(int64_t DeviceId,
void *HstPtrBegin,
void *TgtPtrBegin,
ompt_record_ompt_t *stopTargetDataRetrieveTrace(int64_t SrcDeviceId,
void *SrcPtrBegin,
int64_t DstDeviceId,
void *DstPtrBegin,
size_t Size, void *Code);

/// Top-level function for starting trace before kernel dispatch
Expand Down
47 changes: 23 additions & 24 deletions openmp/libomptarget/src/OmptTracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,64 +325,63 @@ ompt_record_ompt_t *Interface::stopTargetDataDeleteTrace(int64_t DeviceId,
return DataPtr;
}

void Interface::startTargetDataSubmitTrace(int64_t DeviceId, void *TgtPtrBegin,
void *HstPtrBegin, size_t Size,
void Interface::startTargetDataSubmitTrace(int64_t SrcDeviceId,
void *SrcPtrBegin,
int64_t DstDeviceId,
void *DstPtrBegin, size_t Size,
void *Code) {}

ompt_record_ompt_t *Interface::stopTargetDataSubmitTrace(int64_t DeviceId,
void *TgtPtrBegin,
void *HstPtrBegin,
size_t Size,
void *Code) {
ompt_record_ompt_t *
Interface::stopTargetDataSubmitTrace(int64_t SrcDeviceId, void *SrcPtrBegin,
int64_t DstDeviceId, void *DstPtrBegin,
size_t Size, void *Code) {
if (isTracingTypeDisabled(ompt_callback_target_data_op))
return nullptr;

ompt_record_ompt_t *DataPtr =
(ompt_record_ompt_t *)TraceRecordManager.assignCursor(
ompt_callback_target_data_op, DeviceId);
ompt_callback_target_data_op, DstDeviceId);

// This event will not be traced
if (DataPtr == nullptr)
return nullptr;

setTraceRecordCommon(DataPtr, ompt_callback_target_data_op);
setTraceRecordTargetDataOp(&DataPtr->record.target_data_op,
ompt_target_data_transfer_to_device, HstPtrBegin,
/*SrcDeviceNum=*/omp_get_initial_device(),
TgtPtrBegin, DeviceId, Size, Code);
ompt_target_data_transfer_to_device, SrcPtrBegin,
SrcDeviceId, DstPtrBegin, DstDeviceId, Size, Code);

// The trace record has been created, mark it ready for delivery to the tool
TraceRecordManager.setTRStatus(DataPtr, OmptTracingBufferMgr::TR_ready);
DP("Generated target_data_submit trace record %p\n", DataPtr);
return DataPtr;
}

void Interface::startTargetDataRetrieveTrace(int64_t DeviceId,
void *TgtPtrBegin,
void *HstPtrBegin, size_t Size,
void Interface::startTargetDataRetrieveTrace(int64_t SrcDeviceId,
void *SrcPtrBegin,
int64_t DstDeviceId,
void *DstPtrBegin, size_t Size,
void *Code) {}

ompt_record_ompt_t *Interface::stopTargetDataRetrieveTrace(int64_t DeviceId,
void *TgtPtrBegin,
void *HstPtrBegin,
size_t Size,
void *Code) {
ompt_record_ompt_t *
Interface::stopTargetDataRetrieveTrace(int64_t SrcDeviceId, void *SrcPtrBegin,
int64_t DstDeviceId, void *DstPtrBegin,
size_t Size, void *Code) {
if (isTracingTypeDisabled(ompt_callback_target_data_op))
return nullptr;

ompt_record_ompt_t *DataPtr =
(ompt_record_ompt_t *)TraceRecordManager.assignCursor(
ompt_callback_target_data_op, DeviceId);
ompt_callback_target_data_op, SrcDeviceId);

// This event will not be traced
if (DataPtr == nullptr)
return nullptr;

setTraceRecordCommon(DataPtr, ompt_callback_target_data_op);
setTraceRecordTargetDataOp(
&DataPtr->record.target_data_op, ompt_target_data_transfer_from_device,
TgtPtrBegin, /*SrcDeviceNum=*/DeviceId, HstPtrBegin,
/*DstDeviceNum=*/omp_get_initial_device(), Size, Code);
setTraceRecordTargetDataOp(&DataPtr->record.target_data_op,
ompt_target_data_transfer_from_device, SrcPtrBegin,
SrcDeviceId, DstPtrBegin, DstDeviceId, Size, Code);

// The trace record has been created, mark it ready for delivery to the tool
TraceRecordManager.setTRStatus(DataPtr, OmptTracingBufferMgr::TR_ready);
Expand Down
16 changes: 11 additions & 5 deletions openmp/libomptarget/src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void *DeviceTy::allocData(int64_t Size, void *HstPtr, int32_t Kind) {
HstPtr, &TargetPtr, Size,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);
// ToDo: mhalk Do we need a check for TracingActive here?
InterfaceRAII TargetDataSubmitTraceRAII(
InterfaceRAII TargetDataAllocTraceRAII(
RegionInterface.getTraceGenerators<ompt_target_data_alloc>(),
RTLDeviceID, HstPtr, &TargetPtr, Size,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);)
Expand All @@ -147,7 +147,7 @@ int32_t DeviceTy::deleteData(void *TgtAllocBegin, int32_t Kind) {
TgtAllocBegin,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);
// ToDo: mhalk Do we need a check for TracingActive here?
InterfaceRAII TargetDataSubmitTraceRAII(
InterfaceRAII TargetDataDeleteTraceRAII(
RegionInterface.getTraceGenerators<ompt_target_data_delete>(),
DeviceID, TgtAllocBegin,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);)
Expand All @@ -172,7 +172,7 @@ int32_t DeviceTy::submitData(void *TgtPtrBegin, void *HstPtrBegin, int64_t Size,
InterfaceRAII TargetDataSubmitTraceRAII(
RegionInterface
.getTraceGenerators<ompt_target_data_transfer_to_device>(),
DeviceID, TgtPtrBegin, HstPtrBegin, Size,
omp_get_initial_device(), HstPtrBegin, DeviceID, TgtPtrBegin, Size,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);)

if (ForceSynchronousTargetRegions || !AsyncInfo ||
Expand Down Expand Up @@ -201,10 +201,10 @@ int32_t DeviceTy::retrieveData(void *HstPtrBegin, void *TgtPtrBegin,
DeviceID, TgtPtrBegin, omp_get_initial_device(), HstPtrBegin, Size,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);
// ToDo: mhalk Do we need a check for TracingActive here?
InterfaceRAII TargetDataSubmitTraceRAII(
InterfaceRAII TargetDataRetrieveTraceRAII(
RegionInterface
.getTraceGenerators<ompt_target_data_transfer_from_device>(),
DeviceID, TgtPtrBegin, HstPtrBegin, Size,
DeviceID, TgtPtrBegin, omp_get_initial_device(), HstPtrBegin, Size,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);)

if (ForceSynchronousTargetRegions || !RTL->data_retrieve_async ||
Expand All @@ -230,6 +230,12 @@ int32_t DeviceTy::dataExchange(void *SrcPtr, DeviceTy &DstDev, void *DstPtr,
InterfaceRAII TargetDataExchangeRAII(
RegionInterface.getCallbacks<ompt_target_data_transfer_from_device>(),
RTLDeviceID, SrcPtr, DstDev.RTLDeviceID, DstPtr, Size,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);
// ToDo: mhalk Do we need a check for TracingActive here?
InterfaceRAII TargetDataExchangeTraceRAII(
RegionInterface
.getTraceGenerators<ompt_target_data_transfer_from_device>(),
RTLDeviceID, SrcPtr, DstDev.RTLDeviceID, DstPtr, Size,
/*CodePtr=*/OMPT_GET_RETURN_ADDRESS);)
if (ForceSynchronousTargetRegions || !AsyncInfo ||
#ifdef OMPT_SUPPORT
Expand Down

0 comments on commit a95cd9e

Please sign in to comment.