From 433a92401a9aeed9cb1b7ae1607f02ef4ac2cf13 Mon Sep 17 00:00:00 2001 From: nihuini Date: Wed, 13 Mar 2019 17:33:36 +0800 Subject: [PATCH] auto barrier in pipeline and copy command --- src/allocator.h | 1 + src/command.cpp | 21 +++++++++++++++++++++ src/command.h | 25 +++++++++++-------------- src/layer.cpp | 4 ---- src/layer/absval.cpp | 1 - src/layer/batchnorm.cpp | 1 - src/layer/binaryop.cpp | 6 +----- src/layer/clip.cpp | 1 - src/layer/concat.cpp | 18 ------------------ src/layer/convolution.cpp | 5 ----- src/layer/convolutiondepthwise.cpp | 4 ---- src/layer/crop.cpp | 4 ---- src/layer/deconvolution.cpp | 2 -- src/layer/deconvolutiondepthwise.cpp | 4 ---- src/layer/dropout.cpp | 1 - src/layer/eltwise.cpp | 9 +-------- src/layer/flatten.cpp | 2 -- src/layer/innerproduct.cpp | 2 -- src/layer/interp.cpp | 2 -- src/layer/lrn.cpp | 4 ---- src/layer/packing.cpp | 3 --- src/layer/padding.cpp | 2 -- src/layer/permute.cpp | 3 --- src/layer/pooling.cpp | 4 ---- src/layer/prelu.cpp | 1 - src/layer/priorbox.cpp | 4 ---- src/layer/relu.cpp | 1 - src/layer/reorg.cpp | 2 -- src/layer/reshape.cpp | 2 -- src/layer/scale.cpp | 3 --- src/layer/shufflechannel.cpp | 2 -- src/layer/sigmoid.cpp | 1 - src/layer/softmax.cpp | 8 -------- src/layer/tanh.cpp | 1 - src/layer/unaryop.cpp | 1 - src/net.cpp | 7 ------- 36 files changed, 35 insertions(+), 127 deletions(-) diff --git a/src/allocator.h b/src/allocator.h index 7b9cdd87a..61a03c7cd 100644 --- a/src/allocator.h +++ b/src/allocator.h @@ -207,6 +207,7 @@ public: // 1=created // 2=transfer // 3=compute + // 4=readonly mutable int state; // initialize and modified by mat diff --git a/src/command.cpp b/src/command.cpp index 101fcb5c2..ba1d7a074 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -183,6 +183,8 @@ VkCompute::~VkCompute() void VkCompute::record_upload(const VkMat& m) { + record_prepare_transfer_barrier(m); + if (vkdev->info.support_VK_KHR_push_descriptor) return copy_buffer(m.staging_buffer(), 0, m.buffer(), m.buffer_offset(), m.total() * m.elemsize); @@ -198,6 +200,8 @@ void VkCompute::record_upload(const VkMat& m) void VkCompute::record_download(const VkMat& m) { + record_prepare_transfer_barrier(m); + if (vkdev->info.support_VK_KHR_push_descriptor) return copy_buffer(m.buffer(), m.buffer_offset(), m.staging_buffer(), 0, m.total() * m.elemsize); @@ -213,6 +217,8 @@ void VkCompute::record_download(const VkMat& m) void VkCompute::record_clone(const VkMat& src, const VkMat& dst) { + record_prepare_transfer_barrier(src); + if (vkdev->info.support_VK_KHR_push_descriptor) return copy_buffer(src.buffer(), src.buffer_offset(), dst.buffer(), dst.buffer_offset(), src.total() * src.elemsize); @@ -236,6 +242,8 @@ void VkCompute::record_copy_region(const VkMat& src, const VkMat& dst, const VkB void VkCompute::record_copy_regions(const VkMat& src, const VkMat& dst, const std::vector& regions) { + record_prepare_transfer_barrier(src); + if (vkdev->info.support_VK_KHR_push_descriptor) return copy_buffer_regions(src.buffer(), dst.buffer(), regions); @@ -249,6 +257,16 @@ void VkCompute::record_copy_regions(const VkMat& src, const VkMat& dst, const st void VkCompute::record_pipeline(const Pipeline* pipeline, const std::vector& bindings, const std::vector& constants, const VkMat& m) { + const int binding_count = bindings.size(); + for (int i=0; istate == 4) + continue; + + record_prepare_compute_barrier(bindings[i]); + } + record_bind_pipeline(pipeline->pipeline); record_update_bindings(pipeline->pipeline_layout, pipeline->descriptorset_layout, pipeline->descriptor_update_template, bindings); @@ -715,6 +733,9 @@ void VkTransfer::record_upload(const Mat& src, VkMat& dst) { dst.create_like(src, weight_vkallocator, staging_vkallocator); + // set weight blob as readonly + dst.data->state = 4; + if (dst.allocator->mappable) { dst.upload(src); diff --git a/src/command.h b/src/command.h index 382d4b41f..b0f73c6ab 100644 --- a/src/command.h +++ b/src/command.h @@ -70,18 +70,6 @@ public: void record_copy_regions(const VkMat& src, const VkMat& dst, const std::vector& regions); - void record_transfer_compute_barrier(const VkMat& m); - - void record_compute_transfer_barrier(const VkMat& m); - - void record_compute_compute_barrier(const VkMat& m); - - void record_transfer_transfer_barrier(const VkMat& m); - - void record_prepare_transfer_barrier(const VkMat& m); - - void record_prepare_compute_barrier(const VkMat& m); - void record_pipeline(const Pipeline* pipeline, const std::vector& bindings, const std::vector& constants, const VkMat& m); int submit(); @@ -90,14 +78,23 @@ public: int reset(); -// protected: -public: +protected: // record pipeline things void record_bind_pipeline(VkPipeline pipeline); void record_update_bindings(VkPipelineLayout pipeline_layout, VkDescriptorSetLayout descriptorset_layout, VkDescriptorUpdateTemplateKHR descriptor_update_template, const std::vector& bindings); void record_push_constants(VkPipelineLayout pipeline_layout, const std::vector& constants); void record_dispatch(const uint32_t* group_count_xyz); + // record barrier things + void record_transfer_compute_barrier(const VkMat& m); + void record_compute_transfer_barrier(const VkMat& m); + void record_compute_compute_barrier(const VkMat& m); + void record_transfer_transfer_barrier(const VkMat& m); + + // record prepare things + void record_prepare_transfer_barrier(const VkMat& m); + void record_prepare_compute_barrier(const VkMat& m); + protected: // recording issue void copy_buffer(VkBuffer src, size_t src_offset, VkBuffer dst, size_t dst_offset, size_t size); diff --git a/src/layer.cpp b/src/layer.cpp index 45084805e..3414f4286 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -148,8 +148,6 @@ int Layer::forward(const std::vector& bottom_blobs, std::vector& t if (top_blobs[i].empty()) return -100; - cmd.record_prepare_transfer_barrier(bottom_blobs[i]); - cmd.record_prepare_transfer_barrier(top_blobs[i]); cmd.record_clone(bottom_blobs[i], top_blobs[i]); } @@ -165,8 +163,6 @@ int Layer::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, co if (top_blob.empty()) return -100; - cmd.record_prepare_transfer_barrier(bottom_blob); - cmd.record_prepare_transfer_barrier(top_blob); cmd.record_clone(bottom_blob, top_blob); return forward_inplace(top_blob, cmd, opt); diff --git a/src/layer/absval.cpp b/src/layer/absval.cpp index 70ac42985..331111b1a 100644 --- a/src/layer/absval.cpp +++ b/src/layer/absval.cpp @@ -104,7 +104,6 @@ int AbsVal::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Option const Pipeline* pipeline = packing == 4 ? pipeline_absval_pack4 : pipeline_absval; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/batchnorm.cpp b/src/layer/batchnorm.cpp index 8fcddada1..57110d212 100644 --- a/src/layer/batchnorm.cpp +++ b/src/layer/batchnorm.cpp @@ -217,7 +217,6 @@ int BatchNorm::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Opt const Pipeline* pipeline = packing == 4 ? pipeline_batchnorm_pack4 : pipeline_batchnorm; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/binaryop.cpp b/src/layer/binaryop.cpp index f03e5ba2a..bf18fa0b8 100644 --- a/src/layer/binaryop.cpp +++ b/src/layer/binaryop.cpp @@ -544,7 +544,7 @@ int BinaryOp::forward(const std::vector& bottom_blobs, std::vector if (top_blob.empty()) return -100; -// fprintf(stderr, "BinaryOp::forward %p %p %p\n", (void*)bottom_blob.buffer() + bottom_blob.buffer_offset(), (void*)bottom_blob1.buffer() + bottom_blob1.buffer_offset(), (void*)top_blob.buffer() + top_blob.buffer_offset()); +// fprintf(stderr, "BinaryOp::forward %p %p %p\n", bottom_blob.buffer(), bottom_blob1.buffer(), top_blob.buffer()); std::vector bindings(3); bindings[0] = bottom_blob; @@ -571,9 +571,6 @@ int BinaryOp::forward(const std::vector& bottom_blobs, std::vector const Pipeline* pipeline = packing == 4 ? pipeline_binaryop_pack4 : pipeline_binaryop; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(bottom_blob1); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; @@ -599,7 +596,6 @@ int BinaryOp::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Opti const Pipeline* pipeline = packing == 4 ? pipeline_binaryop_pack4 : pipeline_binaryop; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/clip.cpp b/src/layer/clip.cpp index faa647cb0..4cd23e26f 100644 --- a/src/layer/clip.cpp +++ b/src/layer/clip.cpp @@ -118,7 +118,6 @@ int Clip::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Option& const Pipeline* pipeline = packing == 4 ? pipeline_clip_pack4 : pipeline_clip; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/concat.cpp b/src/layer/concat.cpp index eaa650188..b9bee3d0b 100644 --- a/src/layer/concat.cpp +++ b/src/layer/concat.cpp @@ -363,8 +363,6 @@ int Concat::forward(const std::vector& bottom_blobs, std::vector& if (top_blob.empty()) return -100; - cmd.record_prepare_compute_barrier(top_blob); - int woffset = 0; for (size_t b=0; b& bottom_blobs, std::vector& } // record - cmd.record_prepare_compute_barrier(bottom_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_blob); woffset += bottom_blob.w * bottom_blob.packing / out_packing; @@ -443,8 +440,6 @@ int Concat::forward(const std::vector& bottom_blobs, std::vector& if (top_blob.empty()) return -100; - cmd.record_prepare_compute_barrier(top_blob); - int hoffset = 0; for (size_t b=0; b& bottom_blobs, std::vector& } // record - cmd.record_prepare_compute_barrier(bottom_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_blob); hoffset += bottom_blob.h * bottom_blob.packing / out_packing; @@ -511,8 +505,6 @@ int Concat::forward(const std::vector& bottom_blobs, std::vector& if (top_blob.empty()) return -100; - cmd.record_prepare_compute_barrier(top_blob); - int woffset = 0; for (size_t b=0; b& bottom_blobs, std::vector& const Pipeline* pipeline = packing == 4 ? pipeline_concat_pack4[b%2] : pipeline_concat[b%2]; // record - cmd.record_prepare_compute_barrier(bottom_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_blob); woffset += bottom_blob.w; @@ -580,8 +571,6 @@ int Concat::forward(const std::vector& bottom_blobs, std::vector& if (top_blob.empty()) return -100; - cmd.record_prepare_compute_barrier(top_blob); - int coffset = 0; for (size_t b=0; b& bottom_blobs, std::vector& } // record - cmd.record_prepare_compute_barrier(bottom_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_blob); coffset += bottom_blob.c * bottom_blob.packing / out_packing; @@ -649,8 +637,6 @@ int Concat::forward(const std::vector& bottom_blobs, std::vector& if (top_blob.empty()) return -100; - cmd.record_prepare_compute_barrier(top_blob); - int hoffset = 0; for (size_t b=0; b& bottom_blobs, std::vector& const Pipeline* pipeline = packing == 4 ? pipeline_concat_pack4[b%2] : pipeline_concat[b%2]; // record - cmd.record_prepare_compute_barrier(bottom_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_blob); hoffset += bottom_blob.h; @@ -706,8 +691,6 @@ int Concat::forward(const std::vector& bottom_blobs, std::vector& if (top_blob.empty()) return -100; - cmd.record_prepare_compute_barrier(top_blob); - int woffset = 0; for (size_t b=0; b& bottom_blobs, std::vector& const Pipeline* pipeline = packing == 4 ? pipeline_concat_pack4[b%2] : pipeline_concat[b%2]; // record - cmd.record_prepare_compute_barrier(bottom_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_blob); woffset += bottom_blob.w; diff --git a/src/layer/convolution.cpp b/src/layer/convolution.cpp index 1e51598b1..1933bfc57 100644 --- a/src/layer/convolution.cpp +++ b/src/layer/convolution.cpp @@ -958,8 +958,6 @@ int Convolution::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& c } // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; @@ -1017,9 +1015,6 @@ int Convolution::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& c } // record - cmd.record_prepare_compute_barrier(bottom_blob_bordered); - cmd.record_prepare_compute_barrier(top_blob); - if (packing == 1 && out_packing == 1 && kernel_w == 1 && kernel_h == 1 && stride_w == 1 && stride_h == 1 && dilation_w == 1 && dilation_h == 1) { std::vector constants(8); diff --git a/src/layer/convolutiondepthwise.cpp b/src/layer/convolutiondepthwise.cpp index 428f88d87..1fd7e38ac 100644 --- a/src/layer/convolutiondepthwise.cpp +++ b/src/layer/convolutiondepthwise.cpp @@ -1189,8 +1189,6 @@ int ConvolutionDepthWise::forward(const VkMat& bottom_blob, VkMat& top_blob, VkC const Pipeline* pipeline = packing == 4 ? pipeline_convolutiondepthwise_pack4 : pipeline_convolutiondepthwise; // record - cmd.record_prepare_compute_barrier(bottom_blob_bordered); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; @@ -1272,8 +1270,6 @@ int ConvolutionDepthWise::forward(const VkMat& bottom_blob, VkMat& top_blob, VkC } // record - cmd.record_prepare_compute_barrier(bottom_blob_bordered_unpacked); - cmd.record_prepare_compute_barrier(top_blob_unpacked); cmd.record_pipeline(pipeline, bindings, constants, top_blob_unpacked); // packing diff --git a/src/layer/crop.cpp b/src/layer/crop.cpp index b81a5f176..dbda29c7e 100644 --- a/src/layer/crop.cpp +++ b/src/layer/crop.cpp @@ -197,8 +197,6 @@ int Crop::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, con } // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; @@ -270,8 +268,6 @@ int Crop::forward(const std::vector& bottom_blobs, std::vector& to } // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; diff --git a/src/layer/deconvolution.cpp b/src/layer/deconvolution.cpp index 7cfa6e225..895ecb9ce 100644 --- a/src/layer/deconvolution.cpp +++ b/src/layer/deconvolution.cpp @@ -570,8 +570,6 @@ int Deconvolution::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& } // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob_bordered); cmd.record_pipeline(pipeline, bindings, constants, top_blob_bordered); if (pad_w > 0 || pad_h > 0) diff --git a/src/layer/deconvolutiondepthwise.cpp b/src/layer/deconvolutiondepthwise.cpp index 7a2316d1d..bc32061db 100644 --- a/src/layer/deconvolutiondepthwise.cpp +++ b/src/layer/deconvolutiondepthwise.cpp @@ -741,8 +741,6 @@ int DeconvolutionDepthWise::forward(const VkMat& bottom_blob, VkMat& top_blob, V const Pipeline* pipeline = packing == 4 ? pipeline_deconvolutiondepthwise_pack4 : pipeline_deconvolutiondepthwise; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob_bordered); cmd.record_pipeline(pipeline, bindings, constants, top_blob_bordered); if (pad_w > 0 || pad_h > 0) @@ -846,8 +844,6 @@ int DeconvolutionDepthWise::forward(const VkMat& bottom_blob, VkMat& top_blob, V } // record - cmd.record_prepare_compute_barrier(bottom_blob_unpacked); - cmd.record_prepare_compute_barrier(top_blob_unpacked); cmd.record_pipeline(pipeline, bindings, constants, top_blob_unpacked); // packing diff --git a/src/layer/dropout.cpp b/src/layer/dropout.cpp index c8be06d84..e3b5ec58d 100644 --- a/src/layer/dropout.cpp +++ b/src/layer/dropout.cpp @@ -120,7 +120,6 @@ int Dropout::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Optio const Pipeline* pipeline = packing == 4 ? pipeline_dropout_pack4 : pipeline_dropout; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/eltwise.cpp b/src/layer/eltwise.cpp index 94246533b..14e6362e6 100644 --- a/src/layer/eltwise.cpp +++ b/src/layer/eltwise.cpp @@ -277,19 +277,14 @@ int Eltwise::forward(const std::vector& bottom_blobs, std::vector& const Pipeline* pipeline = packing == 4 ? pipeline_eltwise_pack4[1] : pipeline_eltwise[1]; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(bottom_blob1); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); for (size_t b=2; b bindings(3); bindings[0] = top_blob; bindings[1] = bottom_blobs[b]; - bindings[2] = top_blob; + bindings[2] = top_blob;// TODO use separated pipeline ? std::vector constants(5 + 2); constants[0].i = top_blob.dims; @@ -303,8 +298,6 @@ int Eltwise::forward(const std::vector& bottom_blobs, std::vector& const Pipeline* pipeline = packing == 4 ? pipeline_eltwise_pack4[b%2] : pipeline_eltwise[b%2]; // record - cmd.record_prepare_compute_barrier(top_blob); - cmd.record_prepare_compute_barrier(bottom_blobs[b]); cmd.record_pipeline(pipeline, bindings, constants, top_blob); } diff --git a/src/layer/flatten.cpp b/src/layer/flatten.cpp index 2a0fc5855..0d7a67e2d 100644 --- a/src/layer/flatten.cpp +++ b/src/layer/flatten.cpp @@ -146,8 +146,6 @@ int Flatten::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, const Pipeline* pipeline = packing == 4 ? pipeline_flatten_pack4 : pipeline_flatten; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); if (packing == 1 && out_packing == 4) { VkMat dispatcher; diff --git a/src/layer/innerproduct.cpp b/src/layer/innerproduct.cpp index 4ec945dfc..93e5dadec 100644 --- a/src/layer/innerproduct.cpp +++ b/src/layer/innerproduct.cpp @@ -573,8 +573,6 @@ int InnerProduct::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& } // record - cmd.record_prepare_compute_barrier(bottom_blob_flattened); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; diff --git a/src/layer/interp.cpp b/src/layer/interp.cpp index 9f6251a2d..59e051c7b 100644 --- a/src/layer/interp.cpp +++ b/src/layer/interp.cpp @@ -197,8 +197,6 @@ int Interp::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, c const Pipeline* pipeline = packing == 4 ? pipeline_interp_pack4 : pipeline_interp; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; diff --git a/src/layer/lrn.cpp b/src/layer/lrn.cpp index b7b24eac0..4c0943153 100644 --- a/src/layer/lrn.cpp +++ b/src/layer/lrn.cpp @@ -327,8 +327,6 @@ int LRN::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Option& o } // record - cmd.record_prepare_compute_barrier(bottom_top_blob); - cmd.record_prepare_compute_barrier(square_workspace); cmd.record_pipeline(pipeline, bindings, constants, square_workspace); } @@ -362,8 +360,6 @@ int LRN::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Option& o } // record - cmd.record_prepare_compute_barrier(square_workspace); - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); } diff --git a/src/layer/packing.cpp b/src/layer/packing.cpp index ec5941325..ec29ad34e 100644 --- a/src/layer/packing.cpp +++ b/src/layer/packing.cpp @@ -265,9 +265,6 @@ int Packing::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, constants[9].i = top_blob.cstep; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); - if (packing == 1 && out_packing == 4) { cmd.record_pipeline(pipeline_packing_1to4, bindings, constants, top_blob); diff --git a/src/layer/padding.cpp b/src/layer/padding.cpp index 47823a058..2ac4322b2 100644 --- a/src/layer/padding.cpp +++ b/src/layer/padding.cpp @@ -336,8 +336,6 @@ int Padding::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, const Pipeline* pipeline = packing == 4 ? pipeline_padding_pack4 : pipeline_padding; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; diff --git a/src/layer/permute.cpp b/src/layer/permute.cpp index f6e00f8df..856cea4a9 100644 --- a/src/layer/permute.cpp +++ b/src/layer/permute.cpp @@ -336,9 +336,6 @@ int Permute::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, constants[9].i = top_blob.cstep; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); - if (packing == 1) { cmd.record_pipeline(pipeline_permute, bindings, constants, top_blob); diff --git a/src/layer/pooling.cpp b/src/layer/pooling.cpp index 77622f9cb..0316d4ddc 100644 --- a/src/layer/pooling.cpp +++ b/src/layer/pooling.cpp @@ -435,8 +435,6 @@ int Pooling::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, const Pipeline* pipeline = packing == 4 ? pipeline_pooling_global_pack4 : pipeline_pooling_global; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; @@ -493,8 +491,6 @@ int Pooling::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, const Pipeline* pipeline = packing == 4 ? pipeline_pooling_pack4 : pipeline_pooling; // record - cmd.record_prepare_compute_barrier(bottom_blob_bordered); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); // TODO avgpool exclude padding diff --git a/src/layer/prelu.cpp b/src/layer/prelu.cpp index 5a43c866c..34f7d5869 100644 --- a/src/layer/prelu.cpp +++ b/src/layer/prelu.cpp @@ -194,7 +194,6 @@ int PReLU::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Option& const Pipeline* pipeline = packing == 4 ? pipeline_prelu_pack4 : pipeline_prelu; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/priorbox.cpp b/src/layer/priorbox.cpp index ba7c8e2b7..09b766f67 100644 --- a/src/layer/priorbox.cpp +++ b/src/layer/priorbox.cpp @@ -369,8 +369,6 @@ int PriorBox::forward(const std::vector& bottom_blobs, std::vector constants[3].f = step_h; // record - cmd.record_prepare_compute_barrier(top_blob); - VkMat dispatcher; dispatcher.w = num_sizes; dispatcher.h = w; @@ -425,8 +423,6 @@ int PriorBox::forward(const std::vector& bottom_blobs, std::vector constants[5].f = step_h; // record - cmd.record_prepare_compute_barrier(top_blob); - VkMat dispatcher; dispatcher.w = num_min_size; dispatcher.h = w; diff --git a/src/layer/relu.cpp b/src/layer/relu.cpp index 081ba38bc..4134e77fc 100644 --- a/src/layer/relu.cpp +++ b/src/layer/relu.cpp @@ -173,7 +173,6 @@ int ReLU::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Option& const Pipeline* pipeline = packing == 4 ? pipeline_relu_pack4 : pipeline_relu; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/reorg.cpp b/src/layer/reorg.cpp index ac3bd6b27..305181b7b 100644 --- a/src/layer/reorg.cpp +++ b/src/layer/reorg.cpp @@ -175,8 +175,6 @@ int Reorg::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, co } // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; diff --git a/src/layer/reshape.cpp b/src/layer/reshape.cpp index 2cf88a114..dbd0de42a 100644 --- a/src/layer/reshape.cpp +++ b/src/layer/reshape.cpp @@ -322,8 +322,6 @@ int Reshape::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, } // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); if (packing == 4 && out_packing == 1) { cmd.record_pipeline(pipeline, bindings, constants, bottom_blob); diff --git a/src/layer/scale.cpp b/src/layer/scale.cpp index 99ecc4205..402cc649a 100644 --- a/src/layer/scale.cpp +++ b/src/layer/scale.cpp @@ -297,9 +297,6 @@ int Scale::forward_inplace(std::vector& bottom_top_blobs, VkCompute& cmd, const Pipeline* pipeline = packing == 4 ? pipeline_scale_pack4 : pipeline_scale; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); - if (scale_data_size == -233) - cmd.record_prepare_compute_barrier(scale_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/shufflechannel.cpp b/src/layer/shufflechannel.cpp index 74fda6c6f..e71ef5a55 100644 --- a/src/layer/shufflechannel.cpp +++ b/src/layer/shufflechannel.cpp @@ -132,8 +132,6 @@ int ShuffleChannel::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute const Pipeline* pipeline = packing == 4 ? pipeline_shufflechannel_pack4 : pipeline_shufflechannel; // record - cmd.record_prepare_compute_barrier(bottom_blob); - cmd.record_prepare_compute_barrier(top_blob); cmd.record_pipeline(pipeline, bindings, constants, top_blob); return 0; diff --git a/src/layer/sigmoid.cpp b/src/layer/sigmoid.cpp index bba44ff73..59ab5220f 100644 --- a/src/layer/sigmoid.cpp +++ b/src/layer/sigmoid.cpp @@ -104,7 +104,6 @@ int Sigmoid::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Optio const Pipeline* pipeline = packing == 4 ? pipeline_sigmoid_pack4 : pipeline_sigmoid; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/softmax.cpp b/src/layer/softmax.cpp index 43bc8bba0..ad9ee76f3 100644 --- a/src/layer/softmax.cpp +++ b/src/layer/softmax.cpp @@ -599,8 +599,6 @@ int Softmax::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Optio const Pipeline* pipeline = packing == 4 ? pipeline_softmax_reduce_max_pack4 : pipeline_softmax_reduce_max; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); - cmd.record_prepare_compute_barrier(max_workspace); cmd.record_pipeline(pipeline, bindings, constants, max_workspace); } @@ -625,8 +623,6 @@ int Softmax::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Optio const Pipeline* pipeline = packing == 4 ? pipeline_softmax_exp_sub_max_pack4 : pipeline_softmax_exp_sub_max; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); - cmd.record_prepare_compute_barrier(max_workspace); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); } @@ -651,8 +647,6 @@ int Softmax::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Optio const Pipeline* pipeline = packing == 4 ? pipeline_softmax_reduce_sum_pack4 : pipeline_softmax_reduce_sum; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); - cmd.record_prepare_compute_barrier(sum_workspace); cmd.record_pipeline(pipeline, bindings, constants, sum_workspace); } @@ -677,8 +671,6 @@ int Softmax::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Optio const Pipeline* pipeline = packing == 4 ? pipeline_softmax_div_sum_pack4 : pipeline_softmax_div_sum; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); - cmd.record_prepare_compute_barrier(sum_workspace); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); } diff --git a/src/layer/tanh.cpp b/src/layer/tanh.cpp index dfc2183b5..104caeb8a 100644 --- a/src/layer/tanh.cpp +++ b/src/layer/tanh.cpp @@ -104,7 +104,6 @@ int TanH::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Option& const Pipeline* pipeline = packing == 4 ? pipeline_tanh_pack4 : pipeline_tanh; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/layer/unaryop.cpp b/src/layer/unaryop.cpp index 2c42634d0..519ada5c7 100644 --- a/src/layer/unaryop.cpp +++ b/src/layer/unaryop.cpp @@ -238,7 +238,6 @@ int UnaryOp::forward_inplace(VkMat& bottom_top_blob, VkCompute& cmd, const Optio const Pipeline* pipeline = packing == 4 ? pipeline_unaryop_pack4 : pipeline_unaryop; // record - cmd.record_prepare_compute_barrier(bottom_top_blob); cmd.record_pipeline(pipeline, bindings, constants, bottom_top_blob); return 0; diff --git a/src/net.cpp b/src/net.cpp index 278638fcf..d46237645 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1317,7 +1317,6 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector if (!bottom_blob.allocator->mappable) { - cmd.record_prepare_transfer_barrier(bottom_blob); cmd.record_upload(bottom_blob); } @@ -1340,7 +1339,6 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector // fprintf(stderr, "clone %p %p\n", bottom_blob.buffer(), bottom_blob_copy.buffer()); - cmd.record_prepare_transfer_barrier(bottom_blob); cmd.record_clone(bottom_blob, bottom_blob_copy); bottom_blob = bottom_blob_copy; @@ -1426,7 +1424,6 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector if (!bottom_blob.allocator->mappable) { - cmd.record_prepare_transfer_barrier(bottom_blob); cmd.record_upload(bottom_blob); } @@ -1449,7 +1446,6 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector // fprintf(stderr, "clone %p %p\n", bottom_blobs[i].buffer(), bottom_blob_copy.buffer()); - cmd.record_prepare_transfer_barrier(bottom_blobs[i]); cmd.record_clone(bottom_blobs[i], bottom_blob_copy); bottom_blobs[i] = bottom_blob_copy; @@ -1541,7 +1537,6 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector if (!bottom_blob.allocator->mappable) { - cmd.record_prepare_transfer_barrier(bottom_blob); bottom_blob.prepare_staging_buffer(); cmd.record_download(bottom_blob); } @@ -1632,7 +1627,6 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector if (!bottom_blob.allocator->mappable) { - cmd.record_prepare_transfer_barrier(bottom_blob); bottom_blob.prepare_staging_buffer(); cmd.record_download(bottom_blob); } @@ -1855,7 +1849,6 @@ int Extractor::extract(int blob_index, Mat& feat) // download if (!feat_gpu.allocator->mappable) { - cmd.record_prepare_transfer_barrier(feat_gpu); feat_gpu.prepare_staging_buffer(); cmd.record_download(feat_gpu); }