コード例 #1
0
 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)
コード例 #2
0
 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]
コード例 #3
0
 def assign_vectorized():
     ti.bit_vectorize(32)
     for i, j in x:
         y[i, j] = x[i, j]