Skip to content

ORC support #692

@lf-araujo

Description

@lf-araujo

Hi all,

I am developing (though I am not a developer, weird new times) a tool that estimates structural equation models in the gpu using L-BFGS. My tool works great for my use and I validated against classical optimizers for SEM in R. At some point I decided to try to use ORC throughout (removing --mm:refc) and asked Claude to add the sinks and copies in the relevant parts. This is what Claude changed:

data_structure.nim — ClStorage type replaced:

  • Removed Fref_tracking: CudaTensorRefTracker (GC finalizer approach)
  • Added Fdeleter/Fretainer callback fields (plain proc pointers)
  • Added ORC-compatible =destroy (calls Fdeleter) and =copy (calls Fretainer) hooks

opencl_backend.nim — newClStorage and layout handling replaced:

  • Removed deallocCl finalizer proc
  • Added clStorageRelease/clStorageRetain callbacks wired into newClStorage
  • ClLayoutArray changed from ref with finalizer → ptr UncheckedArray[cint]
  • Added =destroy on ClTensorLayout to release device memory; =copy marked {.error.}

p_kernels_interface_opencl.nim — kernel arg passing updated:

  • All .buffer accesses on shape/strides replaced with .toClpointer (since they're now plain ptr, not
    ref)

I am not a programmer, and while this works for me, I don't have a slight idea about other consequences that this may have to Arraymancer. It is a bit of slop.

  • Is there any interest in reviewing these changes if I push a commit? I completely understand if this is not welcome.

I've read #616 and it seems the issues on memory management are more complex than just adjusting those files.

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