Skip to content

Commit 1856e8f

Browse files
committed
CkArray: Allow broadcasts of ckDestroy
Deliver array broadcasts to local elements in reverse order, starting at the end of the local element vector and proceeding to the beginning. This pattern allows the target function of the broadcast to destroy the array element without invalidating the remainder of the iteration space for the local element vector.
1 parent 07d8ad7 commit 1856e8f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ck-core/ckarray.C

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,10 +1697,12 @@ void CkArray::recvBroadcast(CkMessage* m)
16971697
if (zc_msgtype == CMK_ZC_BCAST_RECV_DONE_MSG) {
16981698
updateTagArray(env, localElemVec.size());
16991699
}
1700-
for (unsigned int i = 0; i < len; ++i)
1700+
// Deliver in reverse order in case the target method destroys and removes
1701+
// the element from localElemVec
1702+
for (int i = len - 1; i >= 0; --i)
17011703
{
17021704
bool doFree = false;
1703-
if (stableLocations && i == len - 1)
1705+
if (stableLocations && i == 0)
17041706
doFree = true;
17051707
// Do not free if CMK_ZC_BCAST_RECV_DONE_MSG, since it'll be freed by the
17061708
// first element during CMK_ZC_BCAST_ALL_DONE_MSG

0 commit comments

Comments
 (0)