#include "ckernel_codegen_v2_emit.h"
#include <stdio.h>
Go to the source code of this file.
◆ ck_codegen_v2_emit_preamble()
| int ck_codegen_v2_emit_preamble |
( |
FILE * |
out | ) |
|
Definition at line 5 of file ckernel_codegen_v2_struct.c.
8 "/* Auto-generated runtime from CKIRV2Graph.\n"
9 " * This v2 emitter currently writes the schedule and buffer layout\n"
10 " * stubs. Kernel wiring will be layered on as IR v2 grows.\n"
13 "#include <stddef.h>\n"
14 "#include <stdint.h>\n"
15 "#include <stdio.h>\n"
16 "#include <string.h>\n\n");
Referenced by ck_codegen_v2_emit_runtime().
◆ ck_codegen_v2_emit_struct()
| void ck_codegen_v2_emit_struct |
( |
FILE * |
out, |
|
|
const CKIRV2Graph * |
graph, |
|
|
const CKMemPlan * |
plan, |
|
|
const char * |
tag |
|
) |
| |
Definition at line 20 of file ckernel_codegen_v2_struct.c.
25 const char *suffix = tag ? tag :
"prefill";
26 fprintf(out,
"typedef struct {\n"
27 " size_t offset_bytes;\n"
28 " size_t size_bytes;\n"
30 "} CKV2BufferLayout;\n\n");
32 fprintf(out,
"static const CKV2BufferLayout ck_v2_%s_buffers[] = {\n", suffix);
36 " { %zu, %zu, %d }, /* %s */\n",
42 fprintf(out,
"};\n\n");
44 fprintf(out,
"static const size_t ck_v2_%s_total_bytes[] = {\n", suffix);
46 fprintf(out,
" %zu%s\n",
50 fprintf(out,
"};\n\n");
52 fprintf(out,
"typedef struct {\n"
53 " const CKV2BufferLayout *buffers;\n"
55 " const size_t *total_bytes;\n"
56 " size_t alignment_bytes;\n"
57 "} CKV2Runtime;\n\n");
59 fprintf(out,
"static const CKV2Runtime ck_v2_%s_runtime = {\n"
60 " ck_v2_%s_buffers,\n"
62 " ck_v2_%s_total_bytes,\n"
#define CK_MEM_PLAN_DEFAULT_ALIGN
size_t total_bytes[CK_MEM_ARENA_COUNT]
References CKMemSpan::arena, CKIRV2Graph::buffers, CK_MEM_ARENA_COUNT, CK_MEM_PLAN_DEFAULT_ALIGN, CKIRV2Buffer::name, CKIRV2Graph::num_buffers, CKMemSpan::offset_bytes, CKMemSpan::size_bytes, CKMemPlan::spans, and CKMemPlan::total_bytes.
Referenced by ck_codegen_v2_emit_runtime().