Before

…lines 1–70 unchanged (70 lines)
71 h->prod_cb(s);
72 }
73 delete h;
74 }
75 table->clear();
76}
77
78string BufRendezvous::Hook::DebugString() const {
79 return absl::StrCat(
80 "[dev:", (prod_dev ? prod_dev->name() : "none"),
81 ", ctx:", reinterpret_cast<uint64>(prod_ctx),
82 ", val:", reinterpret_cast<uint64>(prod_value),
83 ", pcb:", prod_cb ? reinterpret_cast<uint64>(&prod_cb) : 0,
84 ", ccb:", cons_cb ? reinterpret_cast<uint64>(&cons_cb) : 0, "]");
85}
86
87void BufRendezvous::ProvideBuf(const string& key, Device* dev,
88 DeviceContext* dev_ctx, const Tensor* v,
89 const AllocatorAttributes& attr,
90 const ProducerCallback& done,
91 CancellationManager* cancellation_manager) {
92 DVLOG(4) << "ProvideBuf: key = " << key;
93#ifndef NDEBUG
…lines 94–151 unchanged (58 lines)
152 }
153 if (!providebuf_status.ok()) {
154 done(providebuf_status);
155 }
156}
157
158void BufRendezvous::ConsumeBuf(const string& key, const string& device_name,
159 const uint64 device_incarnation,
160 const ConsumerCallback& done,
161 CancellationManager* cancellation_manager) {
162 DVLOG(4) << "ConsumeBuf: key = " << key << " device_name = " << device_name;
163#ifndef NDEBUG
164 if (VLOG_IS_ON(4)) {
165 LogContents();
…lines 166–229 unchanged (64 lines)
230 if (!consumebuf_status.ok()) {
231 done(consumebuf_status, nullptr);
232 return;
233 }
234}
235
236void BufRendezvous::CancelHook(const string& key) {
237 Hook* h = nullptr;
238 {
239 mutex_lock l(mu_);
240 auto it = hook_table_.find(key);
241 if (it == hook_table_.end()) return;
242 h = it->second;
243 hook_table_.erase(it);
244 }
245 if (h != nullptr) {
246 auto s = errors::Cancelled("Operation was cancelled for BufRendezvous key ",
247 key);
248 if (h->prod_cb != nullptr) {
249 h->prod_cb(s);
250 }
251 if (h->cons_cb != nullptr) {
252 h->cons_cb(s, /*Hook=*/nullptr);
253 }
254 delete h;
255 }
256}
257
258/*static*/
259void BufRendezvous::DoneWithHook(Hook* h) {
260 h->prod_cb(absl::OkStatus());
261 delete h;
262}
263
264void BufRendezvous::LogContents() {
265 mutex_lock l(mu_);
266 LOG(INFO) << strings::StrCat("BufRendezvous ",
267 strings::Hex(reinterpret_cast<uint64>(this)),
268 " step_id=", step_id_, " current contents:");
269 for (const auto& it : hook_table_) {
270 LOG(INFO) << it.first << ":" << it.second->DebugString();
271 }
272}
273
274} // namespace tensorflow
275

After

…lines 1–71 unchanged (71 lines)
72 }
73 delete h;
74 }
75 table->clear();
76}
77
78std::string BufRendezvous::Hook::DebugString() const {
79 return absl::StrCat(
80 "[dev:", (prod_dev ? prod_dev->name() : "none"),
81 ", ctx:", reinterpret_cast<uint64_t>(prod_ctx),
82 ", val:", reinterpret_cast<uint64_t>(prod_value),
83 ", pcb:", prod_cb ? reinterpret_cast<uint64_t>(&prod_cb) : 0,
84 ", ccb:", cons_cb ? reinterpret_cast<uint64_t>(&cons_cb) : 0, "]");
85}
86
87void BufRendezvous::ProvideBuf(const std::string& key, Device* dev,
88 DeviceContext* dev_ctx, const Tensor* v,
89 const AllocatorAttributes& attr,
90 const ProducerCallback& done,
91 CancellationManager* cancellation_manager) {
92 DVLOG(4) << "ProvideBuf: key = " << key;
93#ifndef NDEBUG
…lines 94–151 unchanged (58 lines)
152 }
153 if (!providebuf_status.ok()) {
154 done(providebuf_status);
155 }
156}
157
158void BufRendezvous::ConsumeBuf(const std::string& key,
159 const std::string& device_name,
160 const uint64_t device_incarnation,
161 const ConsumerCallback& done,
162 CancellationManager* cancellation_manager) {
163 DVLOG(4) << "ConsumeBuf: key = " << key << " device_name = " << device_name;
164#ifndef NDEBUG
165 if (VLOG_IS_ON(4)) {
166 LogContents();
…lines 167–230 unchanged (64 lines)
231 if (!consumebuf_status.ok()) {
232 done(consumebuf_status, nullptr);
233 return;
234 }
235}
236
237void BufRendezvous::CancelHook(const std::string& key) {
238 Hook* h = nullptr;
239 {
240 mutex_lock l(mu_);
241 auto it = hook_table_.find(key);
242 if (it == hook_table_.end()) return;
243 h = it->second;
244 hook_table_.erase(it);
245 }
246 if (h != nullptr) {
247 auto s = errors::Cancelled("Operation was cancelled for BufRendezvous key ",
248 key);
249 if (h->prod_cb != nullptr) {
250 h->prod_cb(s);
251 }
252 if (h->cons_cb != nullptr) {
253 h->cons_cb(s, /*Hook=*/nullptr);
254 }
255 delete h;
256 }
257}
258
259/*static*/
260void BufRendezvous::DoneWithHook(Hook* h) {
261 h->prod_cb(absl::OkStatus());
262 delete h;
263}
264
265void BufRendezvous::LogContents() {
266 mutex_lock l(mu_);
267 LOG(INFO) << strings::StrCat("BufRendezvous ",
268 strings::Hex(reinterpret_cast<uint64_t>(this)),
269 " step_id=", step_id_, " current contents:");
270 for (const auto& it : hook_table_) {
271 LOG(INFO) << it.first << ":" << it.second->DebugString();
272 }
273}
274
275} // namespace tensorflow
276

Before

translation_unit
comment "/* Copyright 2018 The TensorFlow Authors. All Rights Reserve"...
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/common_runtime/buf_rendezvous.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "absl/strings/numbers.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "absl/strings/str_cat.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "absl/strings/string_view.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/common_runtime/device.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/common_runtime/device_mgr.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/common_runtime/process_util.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/framework/cancellation.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/lib/core/errors.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/lib/core/notification.h"
" "\""
namespace_definition
namespace "namespace"
namespace_identifier "tensorflow"
declaration_list
{ "{"
namespace_definition (+78 nodes collapsed)
comment "// namespace"
function_definition (+65 nodes collapsed)
function_definition (+103 nodes collapsed)
function_definition (+162 nodes collapsed)
function_definition
type_identifier "string"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
qualified_identifier
namespace_identifier "Hook"
:: "::"
identifier "DebugString"
parameter_list
( "("
) ")"
type_qualifier
const "const"
compound_statement
{ "{"
return_statement
return "return"
call_expression
qualified_identifier
namespace_identifier "absl"
:: "::"
identifier "StrCat"
argument_list
( "("
string_literal
" "\""
string_content "[dev:"
" "\""
, ","
parenthesized_expression
( "("
conditional_expression
identifier "prod_dev"
? "?"
call_expression
field_expression
identifier "prod_dev"
-> "->"
field_identifier "name"
argument_list
( "("
) ")"
: ":"
string_literal
" "\""
string_content "none"
" "\""
) ")"
, ","
string_literal
" "\""
string_content ", ctx:"
" "\""
, ","
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
type_identifier "uint64"
> ">"
argument_list
( "("
identifier "prod_ctx"
) ")"
, ","
string_literal
" "\""
string_content ", val:"
" "\""
, ","
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
type_identifier "uint64"
> ">"
argument_list
( "("
identifier "prod_value"
) ")"
, ","
string_literal
" "\""
string_content ", pcb:"
" "\""
, ","
conditional_expression
identifier "prod_cb"
? "?"
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
type_identifier "uint64"
> ">"
argument_list
( "("
pointer_expression
& "&"
identifier "prod_cb"
) ")"
: ":"
number_literal "0"
, ","
string_literal
" "\""
string_content ", ccb:"
" "\""
, ","
conditional_expression
identifier "cons_cb"
? "?"
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
type_identifier "uint64"
> ">"
argument_list
( "("
pointer_expression
& "&"
identifier "cons_cb"
) ")"
: ":"
number_literal "0"
, ","
string_literal
" "\""
string_content "]"
" "\""
) ")"
; ";"
} "}"
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
identifier "ProvideBuf"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
type_identifier "string"
reference_declarator
& "&"
identifier "key"
, ","
parameter_declaration
type_identifier "Device"
pointer_declarator
* "*"
identifier "dev"
, ","
parameter_declaration
type_identifier "DeviceContext"
pointer_declarator
* "*"
identifier "dev_ctx"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "Tensor"
pointer_declarator
* "*"
identifier "v"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "AllocatorAttributes"
reference_declarator
& "&"
identifier "attr"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "ProducerCallback"
reference_declarator
& "&"
identifier "done"
, ","
parameter_declaration
type_identifier "CancellationManager"
pointer_declarator
* "*"
identifier "cancellation_manager"
) ")"
compound_statement (+551 nodes collapsed)
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
identifier "ConsumeBuf"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
type_identifier "string"
reference_declarator
& "&"
identifier "key"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "string"
reference_declarator
& "&"
identifier "device_name"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "uint64"
identifier "device_incarnation"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "ConsumerCallback"
reference_declarator
& "&"
identifier "done"
, ","
parameter_declaration
type_identifier "CancellationManager"
pointer_declarator
* "*"
identifier "cancellation_manager"
) ")"
compound_statement (+653 nodes collapsed)
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
identifier "CancelHook"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
type_identifier "string"
reference_declarator
& "&"
identifier "key"
) ")"
compound_statement (+178 nodes collapsed)
comment "/*static*/"
function_definition (+41 nodes collapsed)
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
identifier "LogContents"
parameter_list
( "("
) ")"
compound_statement
{ "{"
declaration
type_identifier "mutex_lock"
function_declarator
identifier "l"
parameter_list
( "("
parameter_declaration
type_identifier "mu_"
) ")"
; ";"
expression_statement
binary_expression
call_expression
identifier "LOG"
argument_list
( "("
identifier "INFO"
) ")"
<< "<<"
call_expression
qualified_identifier
namespace_identifier "strings"
:: "::"
identifier "StrCat"
argument_list
( "("
string_literal
" "\""
string_content "BufRendezvous "
" "\""
, ","
call_expression
qualified_identifier
namespace_identifier "strings"
:: "::"
identifier "Hex"
argument_list
( "("
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
type_identifier "uint64"
> ">"
argument_list
( "("
this "this"
) ")"
) ")"
, ","
string_literal
" "\""
string_content " step_id="
" "\""
, ","
identifier "step_id_"
, ","
string_literal
" "\""
string_content " current contents:"
" "\""
) ")"
; ";"
for_range_loop (+49 nodes collapsed)
} "}"
} "}"
comment "// namespace tensorflow"

After

translation_unit
comment "/* Copyright 2018 The TensorFlow Authors. All Rights Reserve"...
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/common_runtime/buf_rendezvous.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "absl/strings/numbers.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "absl/strings/str_cat.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "absl/strings/string_view.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/common_runtime/device.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/common_runtime/device_mgr.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/common_runtime/process_util.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/framework/cancellation.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/lib/core/errors.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "tensorflow/core/lib/core/notification.h"
" "\""
namespace_definition
namespace "namespace"
namespace_identifier "tensorflow"
declaration_list
{ "{"
namespace_definition (+78 nodes collapsed)
comment "// namespace"
function_definition (+65 nodes collapsed)
function_definition (+103 nodes collapsed)
function_definition (+162 nodes collapsed)
function_definition
qualified_identifier
namespace_identifier "std"
:: "::"
type_identifier "string"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
qualified_identifier
namespace_identifier "Hook"
:: "::"
identifier "DebugString"
parameter_list
( "("
) ")"
type_qualifier
const "const"
compound_statement
{ "{"
return_statement
return "return"
call_expression
qualified_identifier
namespace_identifier "absl"
:: "::"
identifier "StrCat"
argument_list
( "("
string_literal
" "\""
string_content "[dev:"
" "\""
, ","
parenthesized_expression
( "("
conditional_expression
identifier "prod_dev"
? "?"
call_expression
field_expression
identifier "prod_dev"
-> "->"
field_identifier "name"
argument_list
( "("
) ")"
: ":"
string_literal
" "\""
string_content "none"
" "\""
) ")"
, ","
string_literal
" "\""
string_content ", ctx:"
" "\""
, ","
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
primitive_type "uint64_t"
> ">"
argument_list
( "("
identifier "prod_ctx"
) ")"
, ","
string_literal
" "\""
string_content ", val:"
" "\""
, ","
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
primitive_type "uint64_t"
> ">"
argument_list
( "("
identifier "prod_value"
) ")"
, ","
string_literal
" "\""
string_content ", pcb:"
" "\""
, ","
conditional_expression
identifier "prod_cb"
? "?"
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
primitive_type "uint64_t"
> ">"
argument_list
( "("
pointer_expression
& "&"
identifier "prod_cb"
) ")"
: ":"
number_literal "0"
, ","
string_literal
" "\""
string_content ", ccb:"
" "\""
, ","
conditional_expression
identifier "cons_cb"
? "?"
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
primitive_type "uint64_t"
> ">"
argument_list
( "("
pointer_expression
& "&"
identifier "cons_cb"
) ")"
: ":"
number_literal "0"
, ","
string_literal
" "\""
string_content "]"
" "\""
) ")"
; ";"
} "}"
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
identifier "ProvideBuf"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
qualified_identifier
namespace_identifier "std"
:: "::"
type_identifier "string"
reference_declarator
& "&"
identifier "key"
, ","
parameter_declaration
type_identifier "Device"
pointer_declarator
* "*"
identifier "dev"
, ","
parameter_declaration
type_identifier "DeviceContext"
pointer_declarator
* "*"
identifier "dev_ctx"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "Tensor"
pointer_declarator
* "*"
identifier "v"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "AllocatorAttributes"
reference_declarator
& "&"
identifier "attr"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "ProducerCallback"
reference_declarator
& "&"
identifier "done"
, ","
parameter_declaration
type_identifier "CancellationManager"
pointer_declarator
* "*"
identifier "cancellation_manager"
) ")"
compound_statement (+551 nodes collapsed)
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
identifier "ConsumeBuf"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
qualified_identifier
namespace_identifier "std"
:: "::"
type_identifier "string"
reference_declarator
& "&"
identifier "key"
, ","
parameter_declaration
type_qualifier
const "const"
qualified_identifier
namespace_identifier "std"
:: "::"
type_identifier "string"
reference_declarator
& "&"
identifier "device_name"
, ","
parameter_declaration
type_qualifier
const "const"
primitive_type "uint64_t"
identifier "device_incarnation"
, ","
parameter_declaration
type_qualifier
const "const"
type_identifier "ConsumerCallback"
reference_declarator
& "&"
identifier "done"
, ","
parameter_declaration
type_identifier "CancellationManager"
pointer_declarator
* "*"
identifier "cancellation_manager"
) ")"
compound_statement (+653 nodes collapsed)
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
identifier "CancelHook"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
qualified_identifier
namespace_identifier "std"
:: "::"
type_identifier "string"
reference_declarator
& "&"
identifier "key"
) ")"
compound_statement (+178 nodes collapsed)
comment "/*static*/"
function_definition (+41 nodes collapsed)
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "BufRendezvous"
:: "::"
identifier "LogContents"
parameter_list
( "("
) ")"
compound_statement
{ "{"
declaration
type_identifier "mutex_lock"
function_declarator
identifier "l"
parameter_list
( "("
parameter_declaration
type_identifier "mu_"
) ")"
; ";"
expression_statement
binary_expression
call_expression
identifier "LOG"
argument_list
( "("
identifier "INFO"
) ")"
<< "<<"
call_expression
qualified_identifier
namespace_identifier "strings"
:: "::"
identifier "StrCat"
argument_list
( "("
string_literal
" "\""
string_content "BufRendezvous "
" "\""
, ","
call_expression
qualified_identifier
namespace_identifier "strings"
:: "::"
identifier "Hex"
argument_list
( "("
call_expression
template_function
identifier "reinterpret_cast"
template_argument_list
< "<"
type_descriptor
primitive_type "uint64_t"
> ">"
argument_list
( "("
this "this"
) ")"
) ")"
, ","
string_literal
" "\""
string_content " step_id="
" "\""
, ","
identifier "step_id_"
, ","
string_literal
" "\""
string_content " current contents:"
" "\""
) ")"
; ";"
for_range_loop (+49 nodes collapsed)
} "}"
} "}"
comment "// namespace tensorflow"