Skip to content

ComputeBuffer data array improperly pinned #20

@odomobo

Description

@odomobo

For the ComputeBuffer constructor which takes a T[] data parameter, the array is pinned only for the duration of the call to clCreateBuffer. This appears to be fine if using CopyHostPointer, but is a bug when using UseHostPointer. This is because there's no guarantee that the array won't be moved by GC. Note that a fix to this will also handle the case that's given in the remark, about immediate parameters not working.

Steps to reproduce incorrect behavior:

  1. Create some temporary objects on the small object heap.
  2. Create some smallish arrays (< 85k bytes, so they go on the small object heap, so they will be candidates for compaction).
  3. Create compute buffers from these arrays, using the flag UseHostPointer.
  4. Create a lot of temporary objects on the small object heap, enough to cause a GC and compaction. The compaction will move your buffer arrays.
  5. Execute a kernel, and observe that the data isn't correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions