Beispiel #1
0
 public Device(IntPtr handle, Platform platform)
 {
     Handle   = handle;
     Platform = platform;
     _maxComputeUnitsCache         = new GetInfoStructCache <DeviceInfo, UInt32>(NativeMethods.GetDeviceInfo, handle, DeviceInfo.MaxComputeUnits);
     _maxWorkGroupSizeCache        = new GetInfoStructCache <DeviceInfo, IntPtr>(NativeMethods.GetDeviceInfo, handle, DeviceInfo.MaxWorkGroupSize);
     _maxClockFrequencyCache       = new GetInfoStructCache <DeviceInfo, UInt32>(NativeMethods.GetDeviceInfo, handle, DeviceInfo.MaxClockFrequency);
     _maxMemoryAllocationSizeCache = new GetInfoStructCache <DeviceInfo, UInt64>(NativeMethods.GetDeviceInfo, handle, DeviceInfo.MaxMemoryAllocationSize);
     _globalMemorySizeCache        = new GetInfoStructCache <DeviceInfo, UInt64>(NativeMethods.GetDeviceInfo, handle, DeviceInfo.GlobalMemorySize);
     _nameCache             = new GetInfoStringCache <DeviceInfo>(NativeMethods.GetDeviceInfo, handle, DeviceInfo.Name);
     _maxWorkItemDimensions = new GetInfoStructCache <DeviceInfo, UInt32>(NativeMethods.GetDeviceInfo, handle, DeviceInfo.MaxWorkItemDimensions);
     _maxWorkItemSizes      = new GetInfoArrayCache <DeviceInfo, IntPtr>(_maxWorkItemDimensions.GetValue, NativeMethods.GetDeviceInfo, handle, DeviceInfo.MaxWorkItemSizes);
 }
Beispiel #2
0
        public EventObject(IntPtr handle, GCHandle?pinnedArgumentHandle)
        {
            _handle = handle;
            _pinnedArgumentHandle = pinnedArgumentHandle;
            _lock                     = new Object();
            _callbacks                = new List <EventObjectCompletionCallback>();
            _queuedTimeCache          = new GetInfoStructCache <CommandProfilingInfo, UInt64>(NativeMethods.GetEventProfilingInfo, _handle, CommandProfilingInfo.Queued);
            _submittedTimeCache       = new GetInfoStructCache <CommandProfilingInfo, UInt64>(NativeMethods.GetEventProfilingInfo, _handle, CommandProfilingInfo.Submitted);
            _startedTimeCache         = new GetInfoStructCache <CommandProfilingInfo, UInt64>(NativeMethods.GetEventProfilingInfo, _handle, CommandProfilingInfo.Started);
            _finishedTimeCache        = new GetInfoStructCache <CommandProfilingInfo, UInt64>(NativeMethods.GetEventProfilingInfo, _handle, CommandProfilingInfo.Ended);
            _internalCallbackDelegate = Callback;
            ReturnCode code = NativeMethods.SetEventCallback(_handle, CommandExecutionStatus.Complete, _internalCallbackDelegate, IntPtr.Zero);

            OpenCLException.ThrowOnError(code);
            lock (rootCallbacks)
            {
                rootCallbacks.Add(this);
            }
        }