Skip to content

Commit e08ce72

Browse files
unamedkrclaude
andcommitted
Fix GCC 15 build errors: Vulkan pointer types, unused variables
- tq_vulkan_init.c: change shader table from `const uint32_t**` to `const uint32_t*` — arrays decay to pointers, fixes incompatible pointer type errors on GCC 15 (stricter -Wincompatible-pointer-types) - tq_vulkan_dispatch.c: use memcpy for function pointer → void* cast to avoid -Wpedantic on strict ISO C compilers - tq_ops.c: guard tq_quantize_row_1bit against n<=0 (fixes GCC stringop-overflow warning), suppress unused vsum variable - tq_model.c: remove unused mlocked variable, suppress unused qg_dim and inter variables in GGUF Q4 conversion path Fixes #3 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5f08bc4 commit e08ce72

4 files changed

Lines changed: 28 additions & 21 deletions

File tree

src/backend/vulkan/tq_vulkan_dispatch.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,20 @@ static tq_vk_dispatch_entry_t g_vk_dispatch[7] = {
505505
{ tq_uniform_2b_quantize_vk_wrap, NULL },
506506
};
507507

508+
/* POSIX guarantees function pointer <-> void* round-trip.
509+
* Use memcpy to avoid -Wpedantic on strict ISO C compilers (GCC 15+). */
508510
void* tq_vulkan_get_quantize_fn(int type_id) {
509511
if (type_id < 0 || type_id >= 7) return NULL;
510-
return (void*)g_vk_dispatch[type_id].quantize;
512+
void* p;
513+
memcpy(&p, &g_vk_dispatch[type_id].quantize, sizeof(p));
514+
return p;
511515
}
512516

513517
void* tq_vulkan_get_attention_fn(int type_id) {
514518
if (type_id < 0 || type_id >= 7) return NULL;
515-
return (void*)g_vk_dispatch[type_id].attention;
519+
void* p;
520+
memcpy(&p, &g_vk_dispatch[type_id].attention, sizeof(p));
521+
return p;
516522
}
517523

518524
#endif /* TQ_BUILD_VULKAN */

src/backend/vulkan/tq_vulkan_init.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,22 @@ extern const size_t tq_value_quant_2b_spv_size;
5353
extern const uint32_t tq_value_dequant_matmul_4b_spv[];
5454
extern const size_t tq_value_dequant_matmul_4b_spv_size;
5555

56-
/* SPIR-V lookup table */
56+
/* SPIR-V lookup table.
57+
* Arrays decay to pointers, so we store const uint32_t* directly.
58+
* The size externs are scalar — take their address for uniform access. */
5759
static const struct {
58-
const uint32_t** code;
59-
const size_t* size;
60+
const uint32_t* code;
61+
const size_t* size;
6062
} g_shader_table[TQ_VK_PIPE_COUNT] = {
61-
{ &tq_polar_quantize_spv, &tq_polar_quantize_spv_size },
62-
{ &tq_polar_attention_spv, &tq_polar_attention_spv_size },
63-
{ &tq_qjl_quantize_spv, &tq_qjl_quantize_spv_size },
64-
{ &tq_qjl_attention_spv, &tq_qjl_attention_spv_size },
65-
{ &tq_turbo_quantize_spv, &tq_turbo_quantize_spv_size },
66-
{ &tq_turbo_attention_spv, &tq_turbo_attention_spv_size },
67-
{ &tq_value_quant_4b_spv, &tq_value_quant_4b_spv_size },
68-
{ &tq_value_quant_2b_spv, &tq_value_quant_2b_spv_size },
69-
{ &tq_value_dequant_matmul_4b_spv,&tq_value_dequant_matmul_4b_spv_size },
63+
{ tq_polar_quantize_spv, &tq_polar_quantize_spv_size },
64+
{ tq_polar_attention_spv, &tq_polar_attention_spv_size },
65+
{ tq_qjl_quantize_spv, &tq_qjl_quantize_spv_size },
66+
{ tq_qjl_attention_spv, &tq_qjl_attention_spv_size },
67+
{ tq_turbo_quantize_spv, &tq_turbo_quantize_spv_size },
68+
{ tq_turbo_attention_spv, &tq_turbo_attention_spv_size },
69+
{ tq_value_quant_4b_spv, &tq_value_quant_4b_spv_size },
70+
{ tq_value_quant_2b_spv, &tq_value_quant_2b_spv_size },
71+
{ tq_value_dequant_matmul_4b_spv,&tq_value_dequant_matmul_4b_spv_size },
7072
};
7173

7274
/* ============================================================
@@ -410,7 +412,7 @@ static int tq_vk_create_pipeline_layout(void) {
410412

411413
static int tq_vk_create_pipelines(void) {
412414
for (int i = 0; i < TQ_VK_PIPE_COUNT; i++) {
413-
const uint32_t* code = *g_shader_table[i].code;
415+
const uint32_t* code = g_shader_table[i].code;
414416
size_t code_size = *g_shader_table[i].size;
415417

416418
if (!code || code_size == 0) {

src/engine/tq_model.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ void tq_quantize_weights_q4(tq_model_t* model) {
20172017
int full_kv_dim = (c->full_n_kv_heads > 0 && c->full_head_dim > 0)
20182018
? c->full_n_kv_heads * c->full_head_dim : kv_dim;
20192019
int inter = c->intermediate_dim;
2020-
int qg_dim = c->attn_output_gate ? q_dim * 2 : q_dim;
2020+
(void)inter;
20212021

20222022
/* DeltaNet dimensions */
20232023
int delta_nkv = c->delta_n_kv_heads > 0 ? c->delta_n_kv_heads : c->delta_n_heads;
@@ -3606,7 +3606,7 @@ tq_model_t* tq_load_gguf(const char* path) {
36063606
int full_kv_dim = (c->full_n_kv_heads > 0 && c->full_head_dim > 0)
36073607
? c->full_n_kv_heads * c->full_head_dim : kv_dim;
36083608
int inter = c->intermediate_dim;
3609-
int qg_dim = c->attn_output_gate ? q_dim * 2 : q_dim;
3609+
(void)inter;
36103610
int delta_nkv = c->delta_n_kv_heads > 0 ? c->delta_n_kv_heads : c->delta_n_heads;
36113611
int delta_qkv_dim = delta_nkv * c->delta_key_head_dim * 2
36123612
+ c->delta_n_heads * c->delta_value_head_dim;
@@ -3927,9 +3927,7 @@ skip_q4_conversion: ;
39273927
* Without mlock, expert weights get evicted by OS memory pressure,
39283928
* causing 100x+ slowdown from SSD page faults.
39293929
* mlock may fail if ulimit is too low — fall back to MADV_WILLNEED. */
3930-
int mlocked = 0;
39313930
if (mlock(gctx->mmap_data, gctx->mmap_size) == 0) {
3932-
mlocked = 1;
39333931
fprintf(stderr, "tq_load_gguf: mlock(%.1f GB) — expert weights pinned in RAM\n",
39343932
(double)gctx->mmap_size / (1024.0 * 1024.0 * 1024.0));
39353933
} else {

src/engine/tq_ops.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,10 +1747,11 @@ void tq_matmul_q4q2_preq(float* out,
17471747

17481748
/* Per-row 1-bit quantize: store sign bits + L2 norm */
17491749
void tq_quantize_row_1bit(const float* src, uint8_t* sign_bits, float* norm_out, int n) {
1750+
if (n <= 0) { *norm_out = 0; return; }
17501751
float norm_sq = 0;
17511752
for (int j = 0; j < n; j++) norm_sq += src[j] * src[j];
17521753
*norm_out = sqrtf(norm_sq);
1753-
1754+
17541755
int n_bytes = (n + 7) / 8;
17551756
memset(sign_bits, 0, (size_t)n_bytes);
17561757
for (int j = 0; j < n; j++) {
@@ -1772,7 +1773,7 @@ void tq_matmul_1bit(float* out, const float* x,
17721773
#ifdef __ARM_NEON
17731774
/* NEON: process 16 bytes (128 bits) at a time */
17741775
int b = 0;
1775-
float32x4_t vsum = vdupq_n_f32(0);
1776+
float32x4_t vsum = vdupq_n_f32(0); (void)vsum; /* TODO: vectorize */
17761777
for (; b + 15 < n_bytes; b += 16) {
17771778
for (int k = 0; k < 16; k++) {
17781779
uint8_t s = signs[b + k];

0 commit comments

Comments
 (0)