def evolve_vectorized(x: ti.template(), y: ti.template()): ti.bit_vectorize(32) for i, j in x: num_active_neighbors = 0 num_active_neighbors += ti.cast(x[i - 1, j - 1], ti.u32) num_active_neighbors += ti.cast(x[i - 1, j], ti.u32) num_active_neighbors += ti.cast(x[i - 1, j + 1], ti.u32) num_active_neighbors += ti.cast(x[i, j - 1], ti.u32) num_active_neighbors += ti.cast(x[i, j + 1], ti.u32) num_active_neighbors += ti.cast(x[i + 1, j - 1], ti.u32) num_active_neighbors += ti.cast(x[i + 1, j], ti.u32) num_active_neighbors += ti.cast(x[i + 1, j + 1], ti.u32) y[i, j] = (num_active_neighbors == 3) or (num_active_neighbors == 2 and x[i, j] == 1)
def assign_vectorized(dx: ti.template(), dy: ti.template()): ti.bit_vectorize(32) for i, j in x: y[i, j] = x[i + dx, j + dy] z[i, j] = x[i + dx, j + dy]
def assign_vectorized(): ti.bit_vectorize(32) for i, j in x: y[i, j] = x[i, j]