mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-06 07:43:10 +00:00
attempted fix
This commit is contained in:
parent
f04f2bc381
commit
d6983951a4
@ -216,6 +216,8 @@ mod tests {
|
||||
cpu_stark.generate(&mut row);
|
||||
cpu_trace_rows.push(row);
|
||||
}
|
||||
let mut current_cpu_index = 0;
|
||||
let mut last_timestamp = memory_trace[memory::registers::TIMESTAMP].values[0];
|
||||
for i in 0..num_memory_ops {
|
||||
let mem_timestamp = memory_trace[memory::registers::TIMESTAMP].values[i];
|
||||
let clock = mem_timestamp;
|
||||
@ -223,20 +225,25 @@ mod tests {
|
||||
.filter(|&o| memory_trace[memory::registers::is_memop(o)].values[i] == F::ONE)
|
||||
.collect_vec()[0];
|
||||
|
||||
cpu_trace_rows[i][cpu::columns::uses_memop(op)] = F::ONE;
|
||||
cpu_trace_rows[i][cpu::columns::CLOCK] = clock;
|
||||
cpu_trace_rows[i][cpu::columns::memop_is_read(op)] =
|
||||
cpu_trace_rows[current_cpu_index][cpu::columns::uses_memop(op)] = F::ONE;
|
||||
cpu_trace_rows[current_cpu_index][cpu::columns::CLOCK] = clock;
|
||||
cpu_trace_rows[current_cpu_index][cpu::columns::memop_is_read(op)] =
|
||||
memory_trace[memory::registers::IS_READ].values[i];
|
||||
cpu_trace_rows[i][cpu::columns::memop_addr_context(op)] =
|
||||
cpu_trace_rows[current_cpu_index][cpu::columns::memop_addr_context(op)] =
|
||||
memory_trace[memory::registers::ADDR_CONTEXT].values[i];
|
||||
cpu_trace_rows[i][cpu::columns::memop_addr_segment(op)] =
|
||||
cpu_trace_rows[current_cpu_index][cpu::columns::memop_addr_segment(op)] =
|
||||
memory_trace[memory::registers::ADDR_SEGMENT].values[i];
|
||||
cpu_trace_rows[i][cpu::columns::memop_addr_virtual(op)] =
|
||||
cpu_trace_rows[current_cpu_index][cpu::columns::memop_addr_virtual(op)] =
|
||||
memory_trace[memory::registers::ADDR_VIRTUAL].values[i];
|
||||
for j in 0..8 {
|
||||
cpu_trace_rows[i][cpu::columns::memop_value(op, j)] =
|
||||
cpu_trace_rows[current_cpu_index][cpu::columns::memop_value(op, j)] =
|
||||
memory_trace[memory::registers::value_limb(j)].values[i];
|
||||
}
|
||||
|
||||
if mem_timestamp != last_timestamp {
|
||||
current_cpu_index += 1;
|
||||
last_timestamp = mem_timestamp;
|
||||
}
|
||||
}
|
||||
trace_rows_to_poly_values(cpu_trace_rows)
|
||||
}
|
||||
|
||||
@ -49,11 +49,9 @@ pub fn generate_random_memory_ops<F: RichField, R: Rng>(
|
||||
|
||||
let mut current_memory_values: HashMap<(F, F, F), [F; 8]> = HashMap::new();
|
||||
for i in 0..num_ops {
|
||||
let is_read = if i == 0 { false } else { rng.gen() };
|
||||
let is_read_field = F::from_bool(is_read);
|
||||
|
||||
let timestamp = F::from_canonical_usize(i);
|
||||
let mut used_indices = HashSet::new();
|
||||
let mut new_writes_this_cycle = HashSet::new();
|
||||
for _ in 0..2 {
|
||||
let mut channel_index = rng.gen_range(0..4);
|
||||
while used_indices.contains(&channel_index) {
|
||||
@ -61,6 +59,9 @@ pub fn generate_random_memory_ops<F: RichField, R: Rng>(
|
||||
}
|
||||
used_indices.insert(channel_index);
|
||||
|
||||
let is_read = if i == 0 { false } else { rng.gen() };
|
||||
let is_read_field = F::from_bool(is_read);
|
||||
|
||||
let (context, segment, virt, vals) = if is_read {
|
||||
let written: Vec<_> = current_memory_values.keys().collect();
|
||||
let &(context, segment, virt) = written[rng.gen_range(0..written.len())];
|
||||
@ -79,7 +80,7 @@ pub fn generate_random_memory_ops<F: RichField, R: Rng>(
|
||||
let val: [u32; 8] = rng.gen();
|
||||
let vals: [F; 8] = val.map(F::from_canonical_u32);
|
||||
|
||||
current_memory_values.insert((context, segment, virt), vals);
|
||||
new_writes_this_cycle.insert(((context, segment, virt), vals));
|
||||
|
||||
(context, segment, virt, vals)
|
||||
};
|
||||
@ -94,6 +95,10 @@ pub fn generate_random_memory_ops<F: RichField, R: Rng>(
|
||||
value: vals,
|
||||
});
|
||||
}
|
||||
for (k, v) in new_writes_this_cycle {
|
||||
current_memory_values.insert(k, v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
memory_ops
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user