Added an explicit OOM status for kernel ops and routed it as out‑of‑model

This commit is contained in:
Carl Niklas Rydberg 2025-12-22 00:41:18 +01:00
parent 3333b577ff
commit 7c19c04dc4
3 changed files with 14 additions and 10 deletions

View file

@ -24,6 +24,8 @@ enum {
}; };
enum { enum {
AMDUAT_PEL_KERNEL_STATUS_OOM = 0x00000001u,
AMDUAT_PEL_KERNEL_STATUS_INTERNAL = 0x00000002u,
AMDUAT_PEL_KERNEL_STATUS_CONCAT_TYPE_TAG_MISMATCH = 0x00010001u, AMDUAT_PEL_KERNEL_STATUS_CONCAT_TYPE_TAG_MISMATCH = 0x00010001u,
AMDUAT_PEL_KERNEL_STATUS_SLICE_RANGE_OUT_OF_BOUNDS = 0x00020001u AMDUAT_PEL_KERNEL_STATUS_SLICE_RANGE_OUT_OF_BOUNDS = 0x00020001u
}; };

View file

@ -8,8 +8,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
enum { AMDUAT_PEL_KERNEL_STATUS_INTERNAL = 1 };
static bool amduat_name_eq(amduat_octets_t name, const char *literal) { static bool amduat_name_eq(amduat_octets_t name, const char *literal) {
size_t len = strlen(literal); size_t len = strlen(literal);
if (name.len != len) { if (name.len != len) {
@ -175,7 +173,7 @@ static bool amduat_kernel_concat(const amduat_artifact_t *inputs,
buffer = (uint8_t *)malloc(total_len); buffer = (uint8_t *)malloc(total_len);
if (buffer == NULL) { if (buffer == NULL) {
if (out_status_code) { if (out_status_code) {
*out_status_code = AMDUAT_PEL_KERNEL_STATUS_INTERNAL; *out_status_code = AMDUAT_PEL_KERNEL_STATUS_OOM;
} }
return false; return false;
} }
@ -194,7 +192,7 @@ static bool amduat_kernel_concat(const amduat_artifact_t *inputs,
if (!amduat_alloc_outputs(1, out_outputs)) { if (!amduat_alloc_outputs(1, out_outputs)) {
free(buffer); free(buffer);
if (out_status_code) { if (out_status_code) {
*out_status_code = AMDUAT_PEL_KERNEL_STATUS_INTERNAL; *out_status_code = AMDUAT_PEL_KERNEL_STATUS_OOM;
} }
return false; return false;
} }
@ -254,7 +252,7 @@ static bool amduat_kernel_slice(const amduat_artifact_t *inputs,
buffer = (uint8_t *)malloc((size_t)length); buffer = (uint8_t *)malloc((size_t)length);
if (buffer == NULL) { if (buffer == NULL) {
if (out_status_code) { if (out_status_code) {
*out_status_code = AMDUAT_PEL_KERNEL_STATUS_INTERNAL; *out_status_code = AMDUAT_PEL_KERNEL_STATUS_OOM;
} }
return false; return false;
} }
@ -271,7 +269,7 @@ static bool amduat_kernel_slice(const amduat_artifact_t *inputs,
if (!amduat_alloc_outputs(1, out_outputs)) { if (!amduat_alloc_outputs(1, out_outputs)) {
free(buffer); free(buffer);
if (out_status_code) { if (out_status_code) {
*out_status_code = AMDUAT_PEL_KERNEL_STATUS_INTERNAL; *out_status_code = AMDUAT_PEL_KERNEL_STATUS_OOM;
} }
return false; return false;
} }
@ -314,7 +312,7 @@ static bool amduat_kernel_const(const amduat_pel_kernel_const_params_t *params,
buffer = (uint8_t *)malloc(params->bytes.len); buffer = (uint8_t *)malloc(params->bytes.len);
if (buffer == NULL) { if (buffer == NULL) {
if (out_status_code) { if (out_status_code) {
*out_status_code = AMDUAT_PEL_KERNEL_STATUS_INTERNAL; *out_status_code = AMDUAT_PEL_KERNEL_STATUS_OOM;
} }
return false; return false;
} }
@ -326,7 +324,7 @@ static bool amduat_kernel_const(const amduat_pel_kernel_const_params_t *params,
if (!amduat_alloc_outputs(1, out_outputs)) { if (!amduat_alloc_outputs(1, out_outputs)) {
free(buffer); free(buffer);
if (out_status_code) { if (out_status_code) {
*out_status_code = AMDUAT_PEL_KERNEL_STATUS_INTERNAL; *out_status_code = AMDUAT_PEL_KERNEL_STATUS_OOM;
} }
return false; return false;
} }
@ -384,7 +382,7 @@ static bool amduat_kernel_hash(const amduat_artifact_t *inputs,
buffer = (uint8_t *)malloc(desc->digest_len); buffer = (uint8_t *)malloc(desc->digest_len);
if (buffer == NULL) { if (buffer == NULL) {
if (out_status_code) { if (out_status_code) {
*out_status_code = AMDUAT_PEL_KERNEL_STATUS_INTERNAL; *out_status_code = AMDUAT_PEL_KERNEL_STATUS_OOM;
} }
return false; return false;
} }
@ -401,7 +399,7 @@ static bool amduat_kernel_hash(const amduat_artifact_t *inputs,
if (!amduat_alloc_outputs(1, out_outputs)) { if (!amduat_alloc_outputs(1, out_outputs)) {
free(buffer); free(buffer);
if (out_status_code) { if (out_status_code) {
*out_status_code = AMDUAT_PEL_KERNEL_STATUS_INTERNAL; *out_status_code = AMDUAT_PEL_KERNEL_STATUS_OOM;
} }
return false; return false;
} }

View file

@ -596,6 +596,10 @@ static bool amduat_pel_program_dag_exec_internal(
prepared.ops[node_index], resolved_inputs, node->inputs_len, prepared.ops[node_index], resolved_inputs, node->inputs_len,
&prepared.params[node_index], &node_results[node_index].outputs, &prepared.params[node_index], &node_results[node_index].outputs,
&node_results[node_index].outputs_len, &status_code)) { &node_results[node_index].outputs_len, &status_code)) {
if (status_code == AMDUAT_PEL_KERNEL_STATUS_OOM) {
free(resolved_inputs);
goto oom_finish;
}
if (status_code == 2 || status_code == 3 || status_code == 0) { if (status_code == 2 || status_code == 3 || status_code == 0) {
status_code = 1; status_code = 1;
} }