| 16978 | |
| 16979 | |
| 16980 | static thread_ret_t ggml_graph_compute_thread_hybrid(void * data) { |
| 16981 | struct ggml_compute_state * state = (struct ggml_compute_state *) data; |
| 16982 | |
| 16983 | const struct ggml_cgraph * cgraph = state->shared->cgraph; |
| 16984 | const struct ggml_cplan * cplan = state->shared->cplan; |
| 16985 | |
| 16986 | const int n_threads = state->shared->n_threads; |
| 16987 | |
| 16988 | set_numa_thread_affinity(state->ith, n_threads); |
| 16989 | |
| 16990 | // cpu_set_t mask; |
| 16991 | // CPU_ZERO(&mask); |
| 16992 | // CPU_SET(state->ith * 2, &mask); |
| 16993 | // if (sched_setaffinity(0, sizeof(mask), &mask) == -1) { |
| 16994 | // perror("sched_setaffinity"); |
| 16995 | // } |
| 16996 | |
| 16997 | int node_n = -1; |
| 16998 | |
| 16999 | while (true) { |
| 17000 | if (cplan->abort_callback && cplan->abort_callback(cplan->abort_callback_data)) { |
| 17001 | state->shared->node_n += 1; |
| 17002 | return (thread_ret_t) GGML_EXIT_ABORTED; |
| 17003 | } |
| 17004 | if (state->ith == 0) |
| 17005 | { |
| 17006 | // atomic_fetch_sub(&state->shared->n_active, 1); |
| 17007 | node_n = -1; |
| 17008 | // return 0; |
| 17009 | |
| 17010 | while (1) |
| 17011 | { |
| 17012 | state->shared->perf_node_start_cycles = ggml_perf_cycles(); |
| 17013 | state->shared->perf_node_start_time_us = ggml_perf_time_us(); |
| 17014 | node_n = node_n + 1; |
| 17015 | if (node_n >= cgraph->n_nodes) |
| 17016 | return 0; |
| 17017 | struct ggml_tensor *node = cgraph->nodes[node_n]; |
| 17018 | if (node->backend == GGML_BACKEND_CPU) |
| 17019 | continue; |
| 17020 | // uint64_t dbug = 0; |
| 17021 | while (1) |
| 17022 | { |
| 17023 | // dbug++; |
| 17024 | int status0 = atomic_load(&node->src[0]->is_finish); |
| 17025 | int status1 = 1; |
| 17026 | int status2 = 1; |
| 17027 | if (node->src[1] != NULL) |
| 17028 | status1 = atomic_load(&node->src[1]->is_finish); |
| 17029 | if (node->src[2] != NULL) |
| 17030 | status2 = atomic_load(&node->src[2]->is_finish); |
| 17031 | // if (dbug > 10000000) { |
| 17032 | // printf("stuck %s thread %d\n", ggml_get_name(node), n_threads); |
| 17033 | // int k; |
| 17034 | // scanf("%d", &k); |
| 17035 | // } |
| 17036 | if (status0 == 1 && status1 == 1 && status2 == 1) |
| 17037 | { |
no test coverage detected