public static void cuParamSetv(CUfunction hfunc, int offset, Object obj) { Wrap(() => { try { obj.AssertNotNull().GetType().IsValueType.AssertTrue(); var size = Marshal.SizeOf(obj); var ptr = Marshal.AllocHGlobal(size); try { Marshal.StructureToPtr(obj, ptr, false); var error = nativeParamSetv(hfunc, offset, ptr, (uint)size); if (error != CUresult.CUDA_SUCCESS) throw new CudaException(error); } finally { Marshal.FreeHGlobal(ptr); } } catch (CudaException) { throw; } catch (DllNotFoundException dnfe) { throw new CudaException(CudaError.NoDriver, dnfe); } catch (Exception e) { throw new CudaException(CudaError.Unknown, e); } }); }
public KernelArgument(ParameterDirection direction, Object value) { Direction = direction; _type = value == null ? null : value.GetType(); _value = value.AssertNotNull(); CudaDriver.Ensure(); CopyHtoD(); }