You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defrun(function: Callable[[], Optional[TaskSpace]]):
assertcallable(function), "The function argument must be callable."# Start the Parla runtime.withParla():
# Create a top-level task to kick off the computation@spawn(placement=cpu, vcus=0)asyncdeftop_level_task():
# Note that unless function returns a TaskSpace, this will NOT be blocking.# If you want to wait on the completion of the tasks launched by function, you must return a TaskSpace that contains their terminal tasks.awaitfunction()
# Runtime exists at the end of the context_manager# All tasks are guaranteed to be complete at this pointasyncdefvalue_return():
importnumpyasnp# Although we typically return values via shared memory# Task Futures can be explicitly returned via synchronizationT=TaskSpace("T")
foriinrange(2):
@spawn(T[i])deft():
local_array=np.random.rand(3)
print(f"Task {i} returning: ", local_array, flush=True)
returnlocal_arrayarray1=awaitT[0]
print("Task 0 returned: ", array1, flush=True)
array2=awaitT[1]
print("Task 1 returned: ", array2, flush=True)
# array3 = await T[2]#print("Task 0 returned: ", array1, flush=True)#print("Task 1 returned: ", array2, flush=True)# print("Task 3 returned: ", array3, flush=True)returnT
The text was updated successfully, but these errors were encountered:
This does not give the expected result.
The text was updated successfully, but these errors were encountered: