Skip to content

Commit 06a46ce

Browse files
committed
numa mirroring
1 parent dccea3c commit 06a46ce

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ggml/include/ggml.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,14 @@ extern "C" {
683683
extern __thread int ggml_current_numa_node;
684684

685685
static inline void * tensor_data(const struct ggml_tensor * tensor) {
686-
int numa_node = ggml_current_numa_node;
686+
// Fast path: if no NUMA mirrors exist, avoid thread-local access entirely
687+
if (tensor->__data[1] == NULL) {
688+
return tensor->__data[0];
689+
}
687690

688-
if (numa_node >= 0 && numa_node < GGML_NUMA_MAX_NODES
691+
// NUMA path: only read thread-local variable when NUMA mirrors exist
692+
int numa_node = ggml_current_numa_node;
693+
if (numa_node > 0 && numa_node < GGML_NUMA_MAX_NODES
689694
&& tensor->__data[numa_node] != NULL) {
690695
return tensor->__data[numa_node];
691696
}

0 commit comments

Comments
 (0)