never try to evaluate an empty command buffer

This fixes the immediate crashes with test-backend-ops - when
evaluatating individual no-ops like OP_VIEW, it tries to submit an empty
command buffer, which crashes RADV and hangs AMDVLK.
This commit is contained in:
Jared Van Bortel 2024-01-18 16:11:00 -05:00
parent 16bc3c3be8
commit 7addf2b878

View File

@ -1385,6 +1385,8 @@ void ggml_vk_graph_compute(struct ggml_kompute_context * ctx, struct ggml_cgraph
const int node_start = (seq_idx + 0) * n_nodes_per_seq; const int node_start = (seq_idx + 0) * n_nodes_per_seq;
const int node_end = std::min((seq_idx == n_seq - 1) ? gf->n_nodes : (seq_idx + 1) * n_nodes_per_seq, gf->n_nodes); const int node_end = std::min((seq_idx == n_seq - 1) ? gf->n_nodes : (seq_idx + 1) * n_nodes_per_seq, gf->n_nodes);
bool any_commands_recorded = false;
for (int i = node_start; i < node_end; ++i) { for (int i = node_start; i < node_end; ++i) {
struct ggml_tensor * src0 = gf->nodes[i]->src[0]; struct ggml_tensor * src0 = gf->nodes[i]->src[0];
struct ggml_tensor * src1 = gf->nodes[i]->src[1]; struct ggml_tensor * src1 = gf->nodes[i]->src[1];
@ -1402,6 +1404,8 @@ void ggml_vk_graph_compute(struct ggml_kompute_context * ctx, struct ggml_cgraph
break; break;
} }
any_commands_recorded = true;
if (!ggml_kompute_supports_op(dst)) { if (!ggml_kompute_supports_op(dst)) {
fprintf(stderr, "%s: error: unsupported op '%s'\n", __func__, ggml_op_desc(dst)); fprintf(stderr, "%s: error: unsupported op '%s'\n", __func__, ggml_op_desc(dst));
GGML_ASSERT(!"unsupported op"); GGML_ASSERT(!"unsupported op");
@ -1647,8 +1651,10 @@ void ggml_vk_graph_compute(struct ggml_kompute_context * ctx, struct ggml_cgraph
} }
// Evaluate sequence // Evaluate sequence
if (any_commands_recorded) {
seq.evalAsync(); seq.evalAsync();
} }
}
// Wait for all sequences to finish // Wait for all sequences to finish
for (auto& sequence : sequences) { for (auto& sequence : sequences) {