MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Wait

Method Wait

tensorflow/lite/delegates/gpu/gl/gl_sync.cc:104–119  ·  view source on GitHub ↗

How it works: GPU writes a buffer and CPU checks the buffer value to be changed. The buffer is accessible for writing by GPU and reading by CPU simultaneously - persistent buffer or buffer across shild context can be used for that.

Source from the content-addressed store, hash-verified

102// simultaneously - persistent buffer or buffer across shild context can be used
103// for that.
104Status GlShaderSync::Wait() {
105 if (!flag_buffer_.is_valid()) {
106 return UnavailableError("GlShaderSync is not initialized.");
107 }
108 RETURN_IF_ERROR(flag_buffer_.BindToIndex(0));
109 volatile int* flag_ptr_ = reinterpret_cast<int*>(flag_buffer_.data());
110 *flag_ptr_ = 0;
111 RETURN_IF_ERROR(flag_program_.Dispatch({1, 1, 1}));
112 // glFlush must be called to upload GPU task. Adreno won't start executing
113 // the task without glFlush.
114 glFlush();
115 // Wait for the value is being updated by the shader.
116 while (*flag_ptr_ != 1) {
117 }
118 return OkStatus();
119}
120
121} // namespace gl
122} // namespace gpu

Callers 2

TESTFunction · 0.45
CloseMethod · 0.45

Calls 6

OkStatusFunction · 0.85
BindToIndexMethod · 0.80
UnavailableErrorFunction · 0.50
is_validMethod · 0.45
dataMethod · 0.45
DispatchMethod · 0.45

Tested by 1

TESTFunction · 0.36