public static void copy(ref CArray destination, short[] source) { if (destination.type == EType.short_t) { if (destination.length < source.Length) destination.alloc(source.Length, EType.short_t, EMemorySpace.device, destination._model); destination._length = source.Length; unsafe { fixed (short* sourcep = &source[0]) { opcuda_memcpy_h2d(destination.ptr, (IntPtr)sourcep, (uint)(source.Length * sizeof(short))); } } int status = opcuda_get_status(); if (status != 0) throw new System.Exception(); return; } throw new System.Exception(); }
public static void copy(ref CArray destination, CArray source) { if (source._model != destination._model) throw new System.Exception(); destination._type = source.type; destination.alloc(source.length, source.type, destination.side, source._model); if (source.side == EMemorySpace.device && destination.side == EMemorySpace.host) { opcuda_memcpy_d2h(source.ptr, destination.hptr, (uint)(source.Size_of_one * source.length)); } if (source.side == EMemorySpace.device && destination.side == EMemorySpace.device) { if (source.Size_of_one == 4) { opcuda_scopy1(destination.ptr, source.ptr, (uint)(source.length)); } else { opcuda_memcpy_d2d(destination.ptr, source.ptr, (uint)(source.Size_of_one * source.length)); } } if (source.side == EMemorySpace.host && destination.side == EMemorySpace.device) { opcuda_memcpy_h2d(destination.ptr, source.hptr, (uint)(source.Size_of_one * source.length)); } if (source.side == EMemorySpace.host && destination.side == EMemorySpace.host) { throw new System.Exception(); } int status = opcuda_get_status(); if (status != 0) throw new System.Exception(); }