| 21723 | } |
| 21724 | if (sizeof(int) != sizeof(int32_t) || DS4_N_EXPERT > DS4_MAX_EXPERT) { |
| 21725 | return false; |
| 21726 | } |
| 21727 | |
| 21728 | const uint64_t n_ids = (uint64_t)n_tokens * DS4_N_EXPERT_USED; |
| 21729 | if (n_ids > SIZE_MAX / sizeof(int32_t)) return false; |
| 21730 | int32_t *selected = xmalloc((size_t)n_ids * sizeof(selected[0])); |
| 21731 | |
| 21732 | const bool profile = |
| 21733 | glm_graph_env_present("DS4_ROCM_STREAMING_PREFILL_SELECTED_READAHEAD_PROFILE", |
| 21734 | "DS4_METAL_STREAMING_PREFILL_SELECTED_READAHEAD_PROFILE"); |
| 21735 | const double t0 = profile ? now_sec() : 0.0; |
| 21736 | bool ok = ds4_gpu_tensor_read(metal_graph_batch_router_selected(g), |
| 21737 | 0, |
| 21738 | selected, |
| 21739 | n_ids * sizeof(selected[0])) != 0; |
| 21740 | bool seen[DS4_MAX_EXPERT] = { false }; |
| 21741 | uint32_t unique = 0; |
| 21742 | uint32_t ranges = 0; |
| 21743 | uint64_t hint_bytes = 0; |
| 21744 | const uint32_t gap = metal_graph_stream_prefill_selected_readahead_gap(); |
no test coverage detected