-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Description
During the discussion of designing Go op in Fluid, we discovered that we might need a synchronized op in fluid that acquires a mutex on shared variables, if the Go op is used with other operators in Fluid. For example, to execute the following:
import fluid
W = fluid.tensor(...)
X = fluid.tensor(...)
with fluid.go():
mul_op(W, X)
# main thread
mul_op(W, X)We need to acquire a mutex on the variables W and X in case other Go routines are trying to access them. This is how Go performs it as well (reference: https://golang.org/ref/mem#tmp_5). So one proposal is:
import fluid
W = fluid.tensor(...)
X = fluid.tensor(...)
mutex = fluid.mutex(...)
with fluid.go():
with fluid.synchronize(mutex):
mul_op(W, X)
# main thread
with fluid.synchronize(mutex):
mul_op(W, X)We need to figure out how to share the lock between threads.
This work would require us to create a new variable that holds a mutex and a new operator synchronize that takes in the mutex and the block to protect.
Metadata
Metadata
Labels
No labels