Skip to content

Remove pseudo-commands for mid-execution capture.#1527

Merged
AWoloszyn merged 30 commits into
google:masterfrom
AWoloszyn:move-mec
Feb 5, 2018
Merged

Remove pseudo-commands for mid-execution capture.#1527
AWoloszyn merged 30 commits into
google:masterfrom
AWoloszyn:move-mec

Conversation

@AWoloszyn

@AWoloszyn AWoloszyn commented Jan 2, 2018

Copy link
Copy Markdown
Contributor

Instead of serializing pseudo-commands for mid-execution capture "eg: RecreateInstance", serialize the state block as-is.

Only re-create the state block when we need to on the server side.

TODO in a future MR:

  • Remove the cases where we generate the commands when not necessary
    1. Generating the dependency graph
    1. Resolving resources

# See the License for the specific language governing permissions and
# limitations under the License.

go_install() No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be go_installl(DESTINATION ${TARGET_INSTALL_PATH})?

Comment thread cmd/linearize_trace/main.go Outdated
}

initialCmds := capt.GetInitialCommands(ctx)
_ = initialCmds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant?

if err != nil {
return err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer f.Close() ?

Comment thread gapii/cc/chunk_writer.cpp Outdated
void ChunkWriterImpl::flush() {
mStreamGood = mWriter->write(mBuffer.data(), mBuffer.size());
size_t bufferSize = mBuffer.size();
// If we flush en empty buffer, this will return false, which is incorrect.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this comment is describing the stale code? Probably not necessary or should be changed for the new code here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - Andrew?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct, removed the comment.

Comment thread gapii/cc/spy_base.h
#include <unordered_map>

namespace gapii {
const uint8_t kAllAPIs = 0xFF;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we can change the getEncoder to make is accept a bit mask, instead the shift value, so we can avoid using this 'mask' like thing with the 'shift value' like thing in should_trace()? Hmm, probably not in this CL anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would prefer to leave this for a future CL.

markerNameData.Data()).AddRead(markerInfoData.Data()), nil
}

func GetCommandArgs(ctx context.Context,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we should add comment for it?

Comment thread gapis/api/vulkan/externs.go Outdated
})
}

func (e externs) callSub(ctx context.Context, cmd api.Cmd, id api.CmdID, s *api.GlobalState, b *rb.Builder, sub, data interface{}) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop it? It is only used once.

}
}

func GetCommandFunction(cr CommandReference) interface{} {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blurbs?

Comment thread gapis/api/vulkan/state_rebuilder.go Outdated

// TODO: wherever possible, use old resources instead of doing full reads on the old pools.
// This is especially useful for things that are internal pools, (Shader words for example)
func (s *State) RebuildState(ctx context.Context, oldState *api.GlobalState) []api.Cmd {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blurbs?

if numHandled == 0 {
// There is a cycle in the basePipeline indices.
// Or the no base pipelines does exist.
// Create the rest without base pipelines

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it allowed to by cyclical? Probably we should emit an error in the report view for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it is technically allowed, but I want to at least continue to work if it is.
Hopefully the validation layers can catch this.

}

numHandled := 0
for len(unhandledPipelines) != 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like not optimal? Anyway, we can optimize it later if it matters.

@qining qining left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had a fast read, Still reading the details of the code...

Comment thread gapis/api/vulkan/state_rebuilder.go Outdated
VkMemoryAllocateInfo{
VkStructureType_VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
NewVoidᶜᵖ(memory.Nullptr),
size * 2, // Overallocate by a factor of 2.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for the overallocate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to be documented in the code. 😉

Comment thread gapis/api/vulkan/state_rebuilder.go Outdated
func (sb *stateBuilder) getSparseQueueFor(lastBoundQueue *QueueObject, device VkDevice, queueFamilyIndices *map[uint32]uint32) *QueueObject {
hasQueueFamilyIndices := queueFamilyIndices != nil

queueProperties := sb.s.PhysicalDevices.Get(sb.s.Devices.Get(lastBoundQueue.Device).PhysicalDevice).QueueFamilyProperties

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw lastBoundQueue != nil in the next line. So if it can be nil here, lastBoundQueue.Device will crash.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping

Comment thread gapis/api/vulkan/state_rebuilder.go Outdated
size,
}).Ptr(),
VkResult_VK_SUCCESS,
).AddWrite(dat.Data()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be AddRead(dat.Data())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping

@AWoloszyn AWoloszyn changed the title WIP: Remove pseudo-commands for mid-execution capture. Remove pseudo-commands for mid-execution capture. Jan 30, 2018

@ben-clayton ben-clayton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address comments in follow up CLs once bazel branch is merged.

Comment thread gapii/cc/chunk_writer.cpp Outdated
void ChunkWriterImpl::flush() {
mStreamGood = mWriter->write(mBuffer.data(), mBuffer.size());
size_t bufferSize = mBuffer.size();
// If we flush en empty buffer, this will return false, which is incorrect.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - Andrew?

Comment thread gapii/cc/pool.h Outdated
class Pool {
public:
static std::shared_ptr<Pool> create(uint32_t id, uint64_t size);
// This creates a pool that can be serialized, but has no actual

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Indent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread gapii/cc/slice.h
: mBase(base), mCount(count), mPool(pool) {
GAPID_ASSERT(mBase != nullptr || count == 0 /* Slice: null pointer */);

if (!mPool || !mPool->is_virtual()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is mPool null?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC mPool is nullptr, if this is the application pool. I might be wrong, but I think that is the reasoning for this logic.

Comment thread gapii/cc/spy.cpp Outdated
set_suspended(false);
saveInitialSate();
set_recording_state(true);
//set_recording_state(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should all be cleaned up and gone now. Not sure why it shows in this CR.

// There is a cycle in the basePipeline indices.
// Or the no base pipelines does exist.
// Create the rest without base pipelines
for k, _ := range unhandledPipelines {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superdooperübernit:

for k := range unhandledPipelines {

Is more idiomatic

Comment thread gapis/api/vulkan/state_rebuilder.go Outdated
VkMemoryAllocateInfo{
VkStructureType_VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
NewVoidᶜᵖ(memory.Nullptr),
size * 2, // Overallocate by a factor of 2.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to be documented in the code. 😉

Comment thread gapis/api/vulkan/state_rebuilder.go Outdated
size,
}).Ptr(),
VkResult_VK_SUCCESS,
).AddWrite(dat.Data()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping

Comment thread gapis/api/vulkan/state_rebuilder.go Outdated
func (sb *stateBuilder) getSparseQueueFor(lastBoundQueue *QueueObject, device VkDevice, queueFamilyIndices *map[uint32]uint32) *QueueObject {
hasQueueFamilyIndices := queueFamilyIndices != nil

queueProperties := sb.s.PhysicalDevices.Get(sb.s.Devices.Get(lastBoundQueue.Device).PhysicalDevice).QueueFamilyProperties

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping

func (*State) SetupInitialState(ctx context.Context) {}

func (*State) RebuildState(ctx context.Context, s *api.GlobalState) []api.Cmd { return nil }
func (c *State) SetupInitialState(ctx context.Context) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs please

Instead of passing across synthetic commands, pass across the
entire state block. This allows us to more efficiently handle the
state block on the server side.
We were accidentally removing all buffer descriptor sets. This was
causing replays to fail.
This re-writes the capture so that the state block at the start is
replaced with the commands needed to generate the state block.
This will create a virtual command when a subcommand is requested.
Now that we serialize state, we have to let the early-terminator
know that is it running with extra commands. This is so that the
sync data matches the actual command list.
This will instruct the allocator to not allocate over the memory
ranges needed by the initial commands.
AWoloszyn and others added 16 commits February 5, 2018 14:46
This fixes textures in the UI.
Also work around a validation warning in read_framebuffer.go
When we re-create pools we do it through the observations.
Therefore add a single 0-byte observation to each pool.
Also, recover the inheritance info of command buffers and bring back the
missing layout transition for images that have mutiple samples or
not-color aspect.
When the queue submission does not contain any commands, the signaled semaphore
label still should be written.

And for the wait semaphores, the submission will unsignal the semaphore,
so it is a modify to the label, not just a read.
@AWoloszyn AWoloszyn merged commit 8d3d93d into google:master Feb 5, 2018
@AWoloszyn AWoloszyn deleted the move-mec branch February 5, 2018 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants