Skip to content

Commit

Permalink
Use pinned memory only when interfacing with MakeContiguous
Browse files Browse the repository at this point in the history
Signed-off-by: ptredak <[email protected]>
  • Loading branch information
ptrendx authored and JanuszL committed Sep 17, 2018
1 parent cc214da commit 74d9b58
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dali/pipeline/executor/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,13 @@ void Executor::SetupDataForGraph(WorkspaceBlob *wsb) {

HostWorkspace &src_ws = wsb->cpu_op_data[parent_idx];
auto input = src_ws.SharedCPUOutput(input_src_idx);
for (auto t : input) {
t->set_pinned(true);
// Use pinned memory only when it is useful
if (node.spec.name() == "MakeContiguous" &&
node.spec.NumOutput() == 1 &&
node.spec.OutputDevice(0) == "gpu") {
for (auto t : input) {
t->set_pinned(true);
}
}
ws.AddInput(input);
}
Expand Down
9 changes: 9 additions & 0 deletions dali/pipeline/executor/pipelined_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ void PipelinedExecutor::SetStageOutputsForIter(
int input_idx = info.con_and_idx[j].second;
wsb->mixed_op_data[mixed_op_id].SetInput(
input_idx, tvp.Get(queue_idx));
const OpNode &node = graph_->mixed_node(mixed_op_id);
// Use pinned memory only when it is useful
if (node.spec.name() == "MakeContiguous" &&
node.spec.NumOutput() == 1 &&
node.spec.OutputDevice(0) == "gpu") {
for (auto& v : tvp.Get(queue_idx)) {
v->set_pinned(true);
}
}
} else if (graph_->NodeType(node_id) == DALI_CPU) {
int cpu_op_id = graph_->NodeIdx(node_id);
int input_idx = info.con_and_idx[j].second;
Expand Down
1 change: 1 addition & 0 deletions dali/pipeline/executor/pipelined_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class DLL_PUBLIC PipelinedExecutor : public Executor {
for (int j = 0; j < batch_size; ++j) {
tvs_[i].push_back(std::make_shared<Tensor<Backend>>());
tvs_[i].back()->Resize({(Index)bytes_hint});
tvs_[i].back()->set_pinned(false);
}
}
}
Expand Down

0 comments on commit 74d9b58

Please sign in to comment.