MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cooccur_worker_sparse

Function cooccur_worker_sparse

src/semantic/semantic.c:918–946  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

916}
917
918static void cooccur_worker_sparse(int worker_id, void *ctx_ptr) {
919 (void)worker_id;
920 cooccur_sparse_ctx_t *cc = ctx_ptr;
921 while (true) {
922 int ci =
923 atomic_fetch_add_explicit(&cc->next_chunk, CBM_SEM_ATOMIC_INC, memory_order_relaxed);
924 if (ci >= cc->num_chunks) {
925 break;
926 }
927 int chunk_start = ci * cc->chunk_size;
928 int chunk_end = chunk_start + cc->chunk_size;
929 if (chunk_end > cc->entry_count) {
930 chunk_end = cc->entry_count;
931 }
932
933 /* Cache-blocked target tiling: process tile_size targets at a time so
934 * their vectors stay resident in L2 cache during their accumulation. */
935 for (int tile_start = chunk_start; tile_start < chunk_end; tile_start += cc->tile_size) {
936 int tile_end = tile_start + cc->tile_size;
937 if (tile_end > chunk_end) {
938 tile_end = chunk_end;
939 }
940 for (int tid = tile_start; tid < tile_end; tid++) {
941 sem_target_init_from_src(&cc->entries[tid].enriched_vec, &cc->src_entries[tid]);
942 cooccur_sparse_one_target(cc, tid, &cc->entries[tid].enriched_vec);
943 }
944 }
945 }
946}
947
948/* Pass 2 (RRI) context: uses int8-quantized pass1 vectors as source.
949 * Pass1 outputs are dense float32 post-normalization, values in [-1,1].

Callers

nothing calls this directly

Calls 2

sem_target_init_from_srcFunction · 0.85

Tested by

no test coverage detected