Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tsl/profiler/lib/nvtx_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ limitations under the License.
#include "nvtx3/nvToolsExt.h"
#include "nvtx3/nvToolsExtCuda.h"
#include "nvtx3/nvToolsExtCudaRt.h"
#include "nvtx3/nvToolsExtMemCudaRt.h"
#include "nvtx3/nvToolsExtPayload.h"
#include "third_party/gpus/cuda/include/cuda.h"

Expand Down Expand Up @@ -119,4 +120,21 @@ StringHandle RegisterString(ProfilerDomainHandle domain,
buffer.append(suffix);
return impl(buffer.c_str());
}

void MarkMemoryInitialized(void const* address, size_t size,
StreamHandle stream) {
auto domain = DefaultProfilerDomain();
nvtxMemVirtualRangeDesc_t range_desc{size, address};
nvtxMemMarkInitializedBatch_t regions_desc{
NVTX_EXT_COMPATID_MEM,
sizeof(nvtxMemMarkInitializedBatch_t),
NVTX_MEM_TYPE_VIRTUAL_ADDRESS,
/*regionDescCount=*/1,
sizeof(nvtxMemVirtualRangeDesc_t),
&range_desc};
nvtxMemCudaMarkInitialized(reinterpret_cast<nvtxDomainHandle_t>(domain),
reinterpret_cast<cudaStream_t>(stream),
/*isPerThreadStream=*/false, &regions_desc);
}

} // namespace tsl::profiler
5 changes: 5 additions & 0 deletions tsl/profiler/lib/nvtx_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,10 @@ void RangePush(ProfilerDomainHandle domain, StringHandle title,
// Register the schema of a custom payload type, for use with the more powerful
// version of RangePush
uint64_t RegisterSchema(ProfilerDomainHandle domain, const void* schemaAttr);

// Mark a memory region as initialized.
// This mitigates false positives from the compute sanitizer (initcheck).
void MarkMemoryInitialized(void const* address, size_t size,
StreamHandle stream);
} // namespace tsl::profiler
#endif // TENSORFLOW_TSL_PROFILER_LIB_NVTX_UTILS_H_
2 changes: 2 additions & 0 deletions tsl/profiler/lib/nvtx_utils_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ uint64_t RegisterSchema(ProfilerDomainHandle, const void*) { return 0; }
StringHandle RegisterString(ProfilerDomainHandle, const std::string&) {
return {};
}
void MarkMemoryInitialized(void const* address, size_t size,
StreamHandle stream) {}
} // namespace tsl::profiler