From f0316bdbbd351cff24b49b9376fab9b56f962e3d Mon Sep 17 00:00:00 2001 From: dzhwinter Date: Tue, 9 Jan 2018 23:13:01 -0800 Subject: [PATCH] "add flags" --- paddle/framework/operator.cc | 10 ++++++++-- paddle/platform/gpu_info.cc | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/paddle/framework/operator.cc b/paddle/framework/operator.cc index 35ebe48ba68..c1a6d0221ba 100644 --- a/paddle/framework/operator.cc +++ b/paddle/framework/operator.cc @@ -543,8 +543,14 @@ void OperatorWithKernel::Run(const Scope& scope, auto kernel_iter = kernels.find(expected_kernel_key); - kernel_iter->second->Compute(ExecutionContext( - *this, new_scope, *pool.Get(expected_kernel_key.place_))); + auto* new_dev_ctx = pool.Get(expected_kernel_key.place_); + kernel_iter->second->Compute( + ExecutionContext(*this, new_scope, *new_dev_ctx)); + + /*For profiling/benchmark only*/ + if (FLAGS_op_sync) { + new_dev_ctx->Wait(); + } } proto::DataType OperatorWithKernel::IndicateDataType( diff --git a/paddle/platform/gpu_info.cc b/paddle/platform/gpu_info.cc index 7037551d754..9d3147362ab 100644 --- a/paddle/platform/gpu_info.cc +++ b/paddle/platform/gpu_info.cc @@ -22,6 +22,10 @@ DEFINE_double(fraction_of_gpu_memory_to_use, 0.92, "Default use 92% of GPU memory for PaddlePaddle," "reserve the rest for page tables, etc"); +DEFINE_bool(op_sync, false, + "Default cuda is asynchronous device, set to True will" + "force op run in synchronous mode."); + namespace paddle { namespace platform { -- GitLab