Skip to content

Commit 4f97956

Browse files
committed
FunctionKernelTest tests were actually already in MapConversionTest and KernelTest. Updated desc in the latter to reflect actual test intent
1 parent f54ef7a commit 4f97956

File tree

3 files changed

+8
-55
lines changed

3 files changed

+8
-55
lines changed

src/test/scala/scalacl/FunctionKernelTest.scala

-50
Original file line numberDiff line numberDiff line change
@@ -94,54 +94,4 @@ class FunctionKernelTest extends BaseTest {
9494
println((timeMicros / 1000.0) + " milliseconds")
9595
}
9696
}
97-
98-
it should "capture simple scalars" in context {
99-
implicit context =>
100-
val f = 0.2f
101-
102-
val array = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
103-
val clArray: CLArray[Int] = array.cl
104-
105-
val clResult = clArray.map((x: Int) => x * 2 * f)
106-
val result = array.map(x => x * 2 * f)
107-
clResult.toList should equal(result.toList) // plusOrMinus 0.001f)
108-
109-
clArray.release()
110-
clResult.release()
111-
}
112-
113-
it should "capture simple arrays" in context {
114-
implicit context =>
115-
val clResult = {
116-
val f = CLArray(10, 20, 30, 40)
117-
val a = CLArray(0, 1, 2, 3)
118-
119-
val r = if (true) {
120-
val rr = new CLArray[Int](a.length)
121-
kernel {
122-
for (i <- 0 until a.length.toInt) {
123-
rr(i) = f(i) + i
124-
}
125-
}
126-
rr
127-
} else {
128-
a.map((x: Int) => f(x) + x)
129-
}
130-
//assertNotNull("result buffer doesn't have any write event", r.buffers(0).dataWrite)
131-
//assertEquals("source buffer doesn't have expected read event", 1, a.buffers(0).dataReads.size)
132-
//r.finish()
133-
//Thread.sleep(500)
134-
//assertNull("result buffer failed to clear its dataWrite upon finish()", r.buffers(0).dataWrite)
135-
//assertEquals("source buffer failed to clear its dataReads upon finish()", 0, a.buffers(0).dataReads.size)
136-
//assertEquals("captured buffer failed to clear its dataReads upon finish()", 0, f.buffers(0).dataReads.size)
137-
138-
r
139-
}
140-
val result = {
141-
val f = Array(10, 20, 30, 40)
142-
val a = Array(0, 1, 2, 3)
143-
a.map(x => f(x) + x)
144-
}
145-
clResult.toList should equal(result.toList)
146-
}
14797
}

src/test/scala/scalacl/KernelTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class KernelTest extends BaseTest {
9393
r
9494
}
9595

96-
result.toList should equal(clResult.toList)
96+
clResult.toList should equal(result.toList)
9797
}
9898

9999
it should "check equality of kernels" in {

src/test/scala/scalacl/MapConversionTest.scala

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ class MapConversionTest extends BaseTest {
44

55
behavior of "map"
66

7-
it should "compute scalar function with int type" in context {
7+
it should "capture simple scalars" in context {
88
implicit context =>
9-
val f = 0.2f
9+
val capturedScala = 0.2f
1010

1111
val array = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
1212
val clArray: CLArray[Int] = array.cl
1313

14-
val clResult = clArray.map((x: Int) => x * 2 * f)
15-
val result = array.map(x => x * 2 * f)
14+
val clResult = clArray.map((x: Int) => x * 2 * capturedScala)
15+
val result = array.map(x => x * 2 * capturedScala)
1616

1717
result.toArray zip clResult.toArray foreach {
1818
case (r, cl) => r should equal(cl +- 0.001f)
1919
}
20+
21+
clArray.release()
22+
clResult.release()
2023
}
2124

2225
}

0 commit comments

Comments
 (0)