File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -138,12 +138,18 @@ return a ``DistributedRequest`` object upon which we can choose to
138
138
# Receive tensor from process 0
139
139
req = dist.irecv(tensor = tensor, src = 0 )
140
140
print (' Rank 1 started receiving' )
141
- print (' Rank 1 has data ' , tensor[0 ])
142
141
req.wait()
143
142
print (' Rank ' , rank, ' has data ' , tensor[0 ])
144
143
145
- Running the above function might result in process 1 still having 0.0
146
- while having already started receiving. However, after ``req.wait() ``
144
+ When using immediates we have to be careful about with our usage of the sent and received tensors.
145
+ Since we do not know when the data will be communicated to the other process,
146
+ we should not modify the sent tensor nor access the received tensor before ``req.wait() `` has completed.
147
+ In other words,
148
+
149
+ - writing to ``tensor `` after ``dist.isend() `` will result in undefined behaviour.
150
+ - reading from ``tensor `` after ``dist.irecv() `` will result in undefined behaviour.
151
+
152
+ However, after ``req.wait() ``
147
153
has been executed we are guaranteed that the communication took place,
148
154
and that the value stored in ``tensor[0] `` is 1.0.
149
155
You can’t perform that action at this time.
0 commit comments