[atomics] test streamIn/Out with OpenCL atomics
package uk.ac.manchester.tornado.unittests.atomics;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.concurrent.atomic.AtomicInteger;
-
import org.junit.Test;
-
import uk.ac.manchester.tornado.api.TaskSchedule;
import uk.ac.manchester.tornado.api.TornadoVM_Intrinsics;
import uk.ac.manchester.tornado.api.annotations.Parallel;
@@ -36,6 +28,14 @@ import uk.ac.manchester.tornado.api.runtime.TornadoRuntime;
import uk.ac.manchester.tornado.unittests.common.TornadoNotSupported;
import uk.ac.manchester.tornado.unittests.common.TornadoTestBase;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.IntStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class TestAtomics extends TornadoTestBase {
/**
@@ -510,11 +510,11 @@ public class TestAtomics extends TornadoTestBase {
.task("t0", TestAtomics::atomic16, a, ai) //
.streamOut(ai, a);
- ts.execute();
- ts.execute();
+ final int iterations = 50;
+ IntStream.range(0, iterations).forEach(i -> ts.execute());
int lastValue = ai.get();
- assertEquals(initialValueA + size + size, lastValue);
+ assertEquals(initialValueA + (iterations * size), lastValue);
}
}
