Beispiel #1
0
        internal Array(IntPtr pointer)
        {
#if DEBUG
            if (pointer == IntPtr.Zero)
            {
                throw new ArgumentNullException("Invalid Array Pointer");
            }
#endif
            this._ptr = pointer;
            Interlocked.Increment(ref _instances);
            if (_instances % 50 == 0)             // only do it every time we allocated new 50 instances, we can tweak this
            {
                UIntPtr bytes, buffers, lockbytes, lockbuffers;
                Internal.VERIFY(AFDevice.af_device_mem_info(out bytes, out buffers, out lockbytes, out lockbuffers));
                // code borrowed from the R wrapper:
                if ((double)lockbytes > Math.Pow(1000, 3) || (double)lockbuffers > 50)
                {
                    GC.Collect();
                }
            }
        }
Beispiel #2
0
 public static void PrintInfo()
 {
     Internal.VERIFY(AFDevice.af_info());
 }
Beispiel #3
0
 public static void SetDevice(int device)
 {
     Internal.VERIFY(AFDevice.af_set_device(device));
 }