def atomic_add(x, y): """Atomically compute `x + y`, store the result in `x`, and return the old value of `x`. `x` must be a writable target, constant expressions or scalars are not allowed. Args: x, y (Union[:mod:`~taichi.types.primitive_types`, :class:`~taichi.Matrix`]): \ The input. Returns: The old value of `x`. Example:: >>> @ti.kernel >>> def test(): >>> x = ti.Vector([0, 0, 0]) >>> y = ti.Vector([1, 2, 3]) >>> z = ti.atomic_add(x, y) >>> print(x) # [1, 2, 3] the new value of x >>> print(z) # [0, 0, 0], the old value of x >>> >>> ti.atomic_add(1, x) # will raise TaichiSyntaxError """ return impl.expr_init( expr.Expr(_ti_core.expr_atomic_add(x.ptr, y.ptr), tb=stack_info()))
def atomic_add(a, b): return impl.expr_init( expr.Expr(_ti_core.expr_atomic_add(a.ptr, b.ptr), tb=stack_info()))