diff options
Diffstat (limited to 'src/abstract_hardware_model.cc')
| -rw-r--r-- | src/abstract_hardware_model.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/abstract_hardware_model.cc b/src/abstract_hardware_model.cc index 9262a92..86427ad 100644 --- a/src/abstract_hardware_model.cc +++ b/src/abstract_hardware_model.cc @@ -129,6 +129,52 @@ void warp_inst_t::compute_simd_sets_compacted(unsigned num_sets, } } +void warp_inst_t::compute_simd_sets_xor_static(unsigned num_sets, + unsigned set_width, + unsigned start_set) { + // start_set is unused for XOR-static: the lane permutation is fully + // determined by warp_id. Accepted for signature compatibility with + // compute_simd_sets_compacted. + (void)start_set; + + m_simd_sets.resize(num_sets); + for (unsigned s = 0; s < num_sets; s++) { + simd_set_info &info = m_simd_sets[s]; + info.set_id = s; + info.warp_id = m_warp_id; + info.set_active_mask.reset(); + info.active_mask_in_warp.reset(); + info.num_active_threads = 0; + } + + // xor_key = reverse of the low log2(warp_size) bits of m_warp_id + unsigned warp_size = m_config->warp_size; + unsigned bits = 0; + while ((1u << bits) < warp_size) bits++; + unsigned xor_key = 0; + for (unsigned i = 0; i < bits; i++) { + if (m_warp_id & (1u << i)) xor_key |= (1u << (bits - 1 - i)); + } + + // Physical lane P runs logical thread T = P ^ xor_key. + for (unsigned P = 0; P < warp_size; P++) { + unsigned T = P ^ xor_key; + unsigned s = P / set_width; + unsigned lane = P % set_width; + simd_set_info &info = m_simd_sets[s]; + info.thread_ids[lane] = T; + if (m_warp_active_mask.test(T)) { + info.set_active_mask.set(lane); + info.active_mask_in_warp.set(T); + info.num_active_threads++; + } + } + + for (unsigned s = 0; s < num_sets; s++) { + m_simd_sets[s].valid = (m_simd_sets[s].num_active_threads > 0); + } +} + unsigned warp_inst_t::num_active_simd_sets() const { unsigned count = 0; for (unsigned i = 0; i < m_simd_sets.size(); i++) { |
