Skip to content

Commit

Permalink
Add NVTX ranges for Operators run (#73)
Browse files Browse the repository at this point in the history
* Add NVTX ranges for Operators run

Signed-off-by: Serge Panev <spanev@nvidia.com>

* Add colors for NVTX and TimeRange for Support Operators

Signed-off-by: Serge Panev <spanev@nvidia.com>
  • Loading branch information
Kh4L authored and ptrendx committed Jul 28, 2018
1 parent 400d637 commit 22f6527
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions dali/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct TimeRange {
static const uint32_t kBlue1 = 0x268BD2;
static const uint32_t kCyan = 0x2AA198;
static const uint32_t kGreen1 = 0x859900;
static const uint32_t knvGreen = 0x76B900;

TimeRange(std::string name, const uint32_t rgb = kBlue) { // NOLINT
#ifdef DALI_USE_NVTX
Expand Down
25 changes: 19 additions & 6 deletions dali/pipeline/executor/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ void Executor::RunCPU() {
try {
WorkspaceBlob &wsb = wss_[queue_idx];
for (int i = 0; i < graph_->NumSupportOp(); ++i) {
OperatorBase &op = graph_->support_op(i);
OpNode &op_node = graph_->support_node(i);
OperatorBase &op = *op_node.op;
SupportWorkspace &ws = wsb.support_op_data[i];
TimeRange tr("[Executor] Run Support op " + op_node.instance_name,
TimeRange::kCyan);
op.Run(&ws);
}
} catch (std::runtime_error &e) {
Expand All @@ -94,9 +97,13 @@ void Executor::RunCPU() {
TimeRange tr("[Executor] RunCPU on " + to_string(data_idx));
SampleWorkspace ws;
for (int j = 0; j < graph_->NumCPUOp(); ++j) {
OperatorBase &op = graph_->cpu_op(j);
wsb.cpu_op_data[j].GetSample(&ws, data_idx, tid);
op.Run(&ws);
OpNode &op_node = graph_->cpu_node(j);
OperatorBase &op = *op_node.op;
wsb.cpu_op_data[j].GetSample(&ws, data_idx, tid);
TimeRange tr("[Executor] Run CPU op " + op_node.instance_name
+ " on " + to_string(data_idx),
TimeRange::kBlue1);
op.Run(&ws);
}
}, i, std::placeholders::_1));
}
Expand Down Expand Up @@ -129,8 +136,11 @@ void Executor::RunMixed() {

try {
for (int i = 0; i < graph_->NumMixedOp(); ++i) {
OperatorBase &op = graph_->mixed_op(i);
OpNode &op_node = graph_->mixed_node(i);
OperatorBase &op = *op_node.op;
MixedWorkspace &ws = wsb.mixed_op_data[i];
TimeRange tr("[Executor] Run Mixed op " + op_node.instance_name,
TimeRange::kOrange);
op.Run(&ws);
if (ws.has_stream() && ws.has_event()) {
CUDA_CALL(cudaEventRecord(ws.event(), ws.stream()));
Expand Down Expand Up @@ -172,14 +182,17 @@ void Executor::RunGPU() {
try {
WorkspaceBlob &wsb = wss_[queue_idx];
for (int i = 0; i < graph_->NumGPUOp(); ++i) {
OperatorBase &op = graph_->gpu_op(i);
OpNode &op_node = graph_->gpu_node(i);
OperatorBase &op = *op_node.op;
DeviceWorkspace &ws = wsb.gpu_op_data[i];
auto parent_events = ws.ParentEvents();

for (auto &event : parent_events) {
CUDA_CALL(cudaStreamWaitEvent(ws.stream(), event, 0));
}

TimeRange tr("[Executor] Run GPU op " + op_node.instance_name,
TimeRange::knvGreen);
op.Run(&ws);
if (ws.has_event()) {
CUDA_CALL(cudaEventRecord(ws.event(), ws.stream()));
Expand Down

0 comments on commit 22f6527

Please sign in to comment.