sleep main until all processed, add lum flag to jobs to pick qtable

This commit is contained in:
Muaz Ahmad 2023-11-28 13:42:53 +05:00
parent 9eb08afb61
commit d670f8f880

View file

@ -27,6 +27,7 @@ fn read_lum(f: std.fs.File, source_buff: [][][4]util.Block, target_buff: [][][4]
try queue.prepend(util.Job{
.source = &source_buff[idxs.@"0"][idxs.@"1"][idxs.@"2"],
.target = &target_buff[idxs.@"0"][idxs.@"1"][idxs.@"2"],
.is_lum = true,
});
}
}
@ -49,6 +50,7 @@ fn read_chrom(f: std.fs.File, source_buff: [][]util.Block, target_buff: [][]util
try queue.prepend(util.Job{
.source = &source_buff[i][j],
.target = &target_buff[i][j],
.is_lum = false,
});
}
}
@ -60,5 +62,5 @@ pub fn main_loop(f: std.fs.File, buffs: util.Buffers, thread_mgr: threads.Thread
try read_lum(f, buffs.Y, buffs.Y_quant, buffs.input_buff, thread_mgr.queue_wrp.queue);
try read_chrom(f, buffs.U, buffs.U_quant, buffs.input_buff[0 .. buffs.input_buff.len / 2], thread_mgr.queue_wrp.queue);
try read_chrom(f, buffs.V, buffs.V_quant, buffs.input_buff[0 .. buffs.input_buff.len / 2], thread_mgr.queue_wrp.queue);
while (thread_mgr.signals.processed.load(.Acquire) != buffs.num_blocks) {}
while (thread_mgr.signals.processed.load(.Acquire) != buffs.num_blocks) : (std.time.sleep(1)) {}
}