protected MemoryObject(IOpenClApi api, Context context, IntPtr id, MemoryHandle?hostMemory = null) { Api = api ?? throw new ArgumentNullException(nameof(api)); Context = context ?? throw new ArgumentNullException(nameof(context)); Id = id; _hostMemory = hostMemory; var infoHelper = new InfoHelper <MemoryObjectInfoParameter>(this, Api.BufferApi.clGetMemObjectInfo); Flags = infoHelper.GetValue <MemoryFlags>(MemoryObjectInfoParameter.Flags); Size = infoHelper.GetValue <ulong>(MemoryObjectInfoParameter.Size); }
private void AsyncBuildCallback(IntPtr program, IntPtr userData) { _delegateHandle.Free(); var buildErrors = new List <ProgramBuildException>(); var builds = new Dictionary <Device, BuildInfo>(); var availableBinaries = GetBinaries(); foreach (var device in _devices) { var buildInfoHelper = new InfoHelper <ProgramBuildInfoParameter>(device, BuildInfoFuncCurried); var status = buildInfoHelper.GetValue <BuildStatus>(ProgramBuildInfoParameter.Status); var log = buildInfoHelper.GetStringValue(ProgramBuildInfoParameter.Log); var options = buildInfoHelper.GetStringValue(ProgramBuildInfoParameter.Options); if (status == BuildStatus.Error) { buildErrors.Add(new ProgramBuildException(_program, device, log)); } builds[device] = new BuildInfo(status, log, options, availableBinaries[device.Id]); } if (buildErrors.Any()) { _taskCompletionSource.SetException(buildErrors); } else { _taskCompletionSource.SetResult(builds); } }
internal Kernel(IOpenClApi api, Program program, string name) { _api = api ?? throw new ArgumentNullException(nameof(api)); Program = program ?? throw new ArgumentNullException(nameof(program)); if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Value cannot be null or empty.", nameof(name)); } Name = name; var id = _api.KernelApi.clCreateKernel(program.Id, name, out var error); error.ThrowOnError(); Id = id; var infoHelper = new InfoHelper <KernelInfoParameter>(this, _api.KernelApi.clGetKernelInfo); NumberOfArguments = infoHelper.GetValue <uint>(KernelInfoParameter.NumberOfArguments); }
internal Device(Platform platform, IntPtr deviceId, IDeviceApi deviceApi) { Platform = platform ?? throw new ArgumentNullException(nameof(platform)); _deviceApi = deviceApi ?? throw new ArgumentNullException(nameof(deviceApi)); Id = deviceId; _deviceInfoHelper = new InfoHelper <DeviceInfoParameter>(this, _deviceApi.clGetDeviceInfo); Name = _deviceInfoHelper.GetStringValue(DeviceInfoParameter.Name); Type = _deviceInfoHelper.GetValue <DeviceType>(DeviceInfoParameter.Type); VendorId = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.VendorId); MaxComputeUnits = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MaxComputeUnits); MaxWorkItemDimensions = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MaxWorkItemDimensions); MaxWorkGroupSize = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MaxWorkGroupSize); MaxWorkItemSizes = _deviceInfoHelper.GetValues <ulong>(DeviceInfoParameter.MaxWorkItemSizes); //TODO: Get bit width of size_t from AddressBits - property //From enqueueNDRangeKernel: The sizeof(size_t) for a device can be determined using CL_DEVICE_ADDRESS_BITS MaxClockFrequency = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MaxClockFrequency); GlobalMemorySize = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.GlobalMemSize); MaxConstantArgs = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MaxConstantArgs); AddressBits = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.AddressBits); Vendor = _deviceInfoHelper.GetStringValue(DeviceInfoParameter.Vendor); PreferredVectorWidthChar = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.PreferredVectorWidthChar); PreferredVectorWidthDouble = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.PreferredVectorWidthDouble); PreferredVectorWidthFloat = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.PreferredVectorWidthFloat); PreferredVectorWidthHalf = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.PreferredVectorWidthHalf); PreferredVectorWidthInt = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.PreferredVectorWidthInt); PreferredVectorWidthLong = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.PreferredVectorWidthLong); PreferredVectorWidthShort = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.PreferredVectorWidthShort); NativeVectorWidthChar = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.NativeVectorWidthChar); NativeVectorWidthDouble = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.NativeVectorWidthDouble); NativeVectorWidthFloat = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.NativeVectorWidthFloat); NativeVectorWidthHalf = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.NativeVectorWidthHalf); NativeVectorWidthInt = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.NativeVectorWidthInt); NativeVectorWidthLong = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.NativeVectorWidthLong); NativeVectorWidthShort = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.NativeVectorWidthShort); Image2DMaxHeight = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.Image2DMaxHeight); Image2DMaxWidth = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.Image2DMaxWidth); Image3DMaxHeight = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.Image3DMaxHeight); Image3DMaxWidth = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.Image3DMaxWidth); Image3DMaxDepth = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.Image3DMaxDepth); MaxReadImageArgs = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MaxReadImageArgs); MaxWriteImageArgs = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MaxWriteImageArgs); ImageSupport = _deviceInfoHelper.GetValue <bool>(DeviceInfoParameter.ImageSupport); MaxSamplers = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MaxSamplers); MaxParameterSize = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.MaxParameterSize); MemBaseAddressAlign = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MemBaseAddrAlign); MinDataTypeAlignSize = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.MinDataTypeAlignSize); MaxMemAllocSize = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.MaxMemAllocSize); GlobalMemCacheType = _deviceInfoHelper.GetValue <CacheType>(DeviceInfoParameter.GlobalMemCacheType); GlobalMemCacheSize = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.GlobalMemCacheSize); GlobalMemCacheLineSize = _deviceInfoHelper.GetValue <uint>(DeviceInfoParameter.GlobalMemCachelineSize); MaxConstantBufferSize = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.MaxConstantBufferSize); LocalMemorySize = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.LocalMemSize); LocalMemoryType = _deviceInfoHelper.GetValue <LocalMemoryType>(DeviceInfoParameter.LocalMemType); ErrorCorrectionSupport = _deviceInfoHelper.GetValue <bool>(DeviceInfoParameter.ErrorCorrectionSupport); ProfilingTimerResolution = _deviceInfoHelper.GetValue <ulong>(DeviceInfoParameter.ProfilingTimerResolution); EndianLittle = _deviceInfoHelper.GetValue <bool>(DeviceInfoParameter.EndianLittle); DriverVersion = _deviceInfoHelper.GetStringValue(DeviceInfoParameter.DriverVersion); OpenClCVersion = _deviceInfoHelper.GetStringValue(DeviceInfoParameter.OpenClCVersion); HostUnifiedMemory = _deviceInfoHelper.GetValue <bool>(DeviceInfoParameter.HostUnifiedMemory); ExecutionCapabilities = _deviceInfoHelper.GetValue <ExecutionCapabilities>(DeviceInfoParameter.ExecutionCapabilities); QueueProperties = _deviceInfoHelper.GetValue <CommandQueueProperties>(DeviceInfoParameter.QueueProperties); SinglePrecisionFloatConfigurations = _deviceInfoHelper.GetValue <FloatConfigurations>(DeviceInfoParameter.SingleFpConfig); //Is double precision supported if (NativeVectorWidthDouble != 0) { DoublePrecisionFloatConfigurations = _deviceInfoHelper.GetValue <FloatConfigurations>(DeviceInfoParameter.DoubleFpConfig); } //Is half precision supported if (NativeVectorWidthHalf != 0) { HalfPrecisionFloatConfigurations = _deviceInfoHelper.GetValue <FloatConfigurations>(DeviceInfoParameter.HalfFpConfig); } }