minseok
๐ Release BioPhys 6.0 Grand Master: 16GB (14.89GB) Gemma-4 100% Devour, Ecosystem Evolution, Solar MoE, SNN Autoregressive SDK, Dynamic PhaseVM
be99550 | use rayon::prelude::*; | |
| pub trait SyncStrategy: Sync + Send { | |
| fn apply_sync(packed_phase: u64, sync_pull: u64, mask_2bit: u64) -> u64; | |
| } | |
| pub struct PaletteAStrategy; | |
| impl SyncStrategy for PaletteAStrategy { | |
| fn apply_sync(packed_phase: u64, sync_pull: u64, _mask: u64) -> u64 { | |
| // `--1` ์ํ(0b11)๋ฅผ ์ ์ฒด 32๊ฐ ๋ด๋ฐ์ ์ฌ๋ฐ๋ฅด๊ฒ ์ ์ฉํ๊ธฐ ์ํ ๋นํธ ์ฐ์ฐ ์์ | |
| let pull_11 = sync_pull | (sync_pull << 1); | |
| (packed_phase & !pull_11) | pull_11 | |
| } | |
| } | |
| /// ์ฑ๊ธ ์ค๋ ๋ ๋๊ธฐํ (๊ธฐ์กด) | |
| pub fn synchronize_phases_fast<T: SyncStrategy>(packed_phases: &mut [u64], context_signal: u64) { | |
| let mask_2bit = 0x5555555555555555; | |
| for phase in packed_phases.iter_mut() { | |
| let phase_difference = *phase ^ context_signal; | |
| let sync_pull = (phase_difference & mask_2bit) >> 1; | |
| *phase = T::apply_sync(*phase, sync_pull, mask_2bit); | |
| } | |
| } | |
| /// [์ ๊ท] ๋ฉํฐ์ฝ์ด CPU 100% ์ ์ ๋๊ธฐํ (Rayon ์ ์ฉ) | |
| pub fn synchronize_phases_par<T: SyncStrategy>(packed_phases: &mut [u64], context_signal: u64) { | |
| let mask_2bit = 0x5555555555555555; | |
| packed_phases.par_iter_mut().for_each(|phase| { | |
| let phase_difference = *phase ^ context_signal; | |
| let sync_pull = (phase_difference & mask_2bit) >> 1; | |
| *phase = T::apply_sync(*phase, sync_pull, mask_2bit); | |
| }); | |
| } | |