Fix: Memory leak by failing to dispose kernel in unit tests for Local array arguments, plus code quality improvements  (refs - minor code quality improvement
@@ -251,10 +251,9 @@ public class Issue81AtomicsSupportAdvTest {
localBarrier();
int maxValue = atomicGet(maxs[MAX_VAL_IDX]);
- if (maxValue == localMaxVal) {
//Only the threads that have the max value will reach this point, however the max value, may
//occur at multiple indices of the input array.
- if (atomicXchg(maxs[LOCK_IDX], 0xff) == 0) {
+ if (maxValue == localMaxVal && atomicXchg(maxs[LOCK_IDX], 0xff) == 0) {
//Only one of the threads with the max value will get here, thus ensuring consistent update of
//maxPosFromRight and maxPosFromLeft.
atomicSet(maxs[MAX_POS_LEFT_IDX], localMaxPosFromLeft);
@@ -265,7 +264,6 @@ public class Issue81AtomicsSupportAdvTest {
}
}
}
- }
private static final class AtomicBKernel extends Kernel {
private int in[];
@@ -313,10 +311,9 @@ public class Issue81AtomicsSupportAdvTest {
localBarrier();
int maxValue = atomicGet(maxs[MAX_VAL_IDX]);
- if (maxValue == localMaxVal) {
//Only the threads that have the max value will reach this point, however the max value, may
//occur at multiple indices of the input array.
- if (atomicXchg(maxs[LOCK_IDX], 0xff) == 0) {
+ if (maxValue == localMaxVal && atomicXchg(maxs[LOCK_IDX], 0xff) == 0) {
//Only one of the threads with the max value will get here, thus ensuring consistent update of
//maxPosFromRight and maxPosFromLeft.
atomicSet(maxs[MAX_POS_LEFT_IDX], localMaxPosFromLeft);
@@ -327,6 +324,5 @@ public class Issue81AtomicsSupportAdvTest {
}
}
}
- }
}
