Skip to content

Commit 1164c9c

Browse files
committed
Workaround for AMD SDK
1 parent de59952 commit 1164c9c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Tensors/src/main/scala/com/thoughtworks/compute/Tensors.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ trait Tensors extends OpenCL {
6969
def buffer: DeviceBuffer[Float]
7070

7171
def toHostBuffer = {
72-
buffer.toHostBuffer(event)
72+
// We want to read buffer after `event` complete.
73+
// According to OpenCL's specification, we should pass the `event` as an `event_wait_list` to `clEnqueueReadBuffer`.
74+
// Unfortunately it seems not work on AMD SDK
75+
// buffer.toHostBuffer(event)
76+
//
77+
// Instead, we have to wait the event then call `clEnqueueReadBuffer`:
78+
Do.garbageCollected(event.waitForComplete()) >> buffer.toHostBuffer(event)
79+
80+
// TODO: find other solution instead of this workaround
7381
}
7482
}
7583
object Tensor {

0 commit comments

Comments
 (0)