diff --git a/.github/workflows/on commit.yaml b/.github/workflows/on commit.yaml index 02e78b07..8b0650a1 100644 --- a/.github/workflows/on commit.yaml +++ b/.github/workflows/on commit.yaml @@ -43,7 +43,7 @@ jobs: - name: Download and unpack Pascal compiler run: | - Invoke-WebRequest -Uri 'https://github.com/SunSerega/pascalabcnet/releases/download/unstable/PABCNETC.zip' -OutFile 'D:\PABCNETC.zip' + Invoke-WebRequest -Uri 'https://github.com/SunSerega/pascalabcnet/releases/download/custom-build-tag/PABCNETC.zip' -OutFile 'D:\PABCNETC.zip' Expand-Archive -Path 'D:\PABCNETC.zip' -DestinationPath 'D:\PABCNETC' -Force diff --git a/DataScraping/Reps/OpenCL-Docs b/DataScraping/Reps/OpenCL-Docs index 81ad45aa..2d470a4a 160000 --- a/DataScraping/Reps/OpenCL-Docs +++ b/DataScraping/Reps/OpenCL-Docs @@ -1 +1 @@ -Subproject commit 81ad45aa50a38268fd225f3cb57ad809c41e4e02 +Subproject commit 2d470a4ae5ebc7ba743e0334c731ed24d2730ce4 diff --git a/DataScraping/XML/OpenCL/funcs.bin b/DataScraping/XML/OpenCL/funcs.bin index e70ab6b0..ae9b3aac 100644 Binary files a/DataScraping/XML/OpenCL/funcs.bin and b/DataScraping/XML/OpenCL/funcs.bin differ diff --git a/LastPack.log b/LastPack.log index 92499fcf..62d4e19f 100644 --- a/LastPack.log +++ b/LastPack.log @@ -56,7 +56,7 @@ ScrapXML[OpenCL]: Parsing "cl" ScrapXML[OpenCL]: Constructing named items ScrapXML[OpenCL]: Saving as binary ScrapXML[OpenCL]: VendorSuffix: Saved 11 items -ScrapXML[OpenCL]: Enum: Saved 1119 items +ScrapXML[OpenCL]: Enum: Saved 1125 items ScrapXML[OpenCL]: BasicType: Saved 30 items ScrapXML[OpenCL]: Group: Saved 119 items ScrapXML[OpenCL]: IdClass: Saved 18 items @@ -249,7 +249,7 @@ Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Dumping Id Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Dumping Struct items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Dumping Delegate items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: PascalBasicType: Packed 12 items -Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Group: Packed 111 items +Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Group: Packed 112 items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: IdClass: Packed 28 items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Struct: Packed 17 items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Delegate: Packed 7 items diff --git a/Log/FirstPack.log b/Log/FirstPack.log index 5ac5fafa..a58cc91f 100644 --- a/Log/FirstPack.log +++ b/Log/FirstPack.log @@ -46,7 +46,7 @@ ScrapXML[OpenCL]: Parsing "cl" ScrapXML[OpenCL]: Constructing named items ScrapXML[OpenCL]: Saving as binary ScrapXML[OpenCL]: VendorSuffix: Saved 11 items -ScrapXML[OpenCL]: Enum: Saved 1119 items +ScrapXML[OpenCL]: Enum: Saved 1125 items ScrapXML[OpenCL]: BasicType: Saved 30 items ScrapXML[OpenCL]: Group: Saved 119 items ScrapXML[OpenCL]: IdClass: Saved 18 items diff --git a/Log/OpenCL.log b/Log/OpenCL.log index 0328cb92..8592f3b5 100644 --- a/Log/OpenCL.log +++ b/Log/OpenCL.log @@ -103,7 +103,7 @@ Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Dumping Id Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Dumping Struct items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Dumping Delegate items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: PascalBasicType: Packed 12 items -Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Group: Packed 111 items +Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Group: Packed 112 items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: IdClass: Packed 28 items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Struct: Packed 17 items Template[OpenCL]: TemplateCommand[LowLvl/OpenCL/Pack Essentials.exe]: Delegate: Packed 7 items diff --git a/Modules.Packed/OpenCL.pas b/Modules.Packed/OpenCL.pas index 0b042acb..740e0d0b 100644 --- a/Modules.Packed/OpenCL.pas +++ b/Modules.Packed/OpenCL.pas @@ -1832,6 +1832,7 @@ clDeviceInfo = record public static property DEVICE_PAGE_SIZE: clDeviceInfo read new clDeviceInfo($40A1); public static property DEVICE_SVM_CAPABILITIES_ARM: clDeviceInfo read new clDeviceInfo($40B6); public static property DEVICE_COMPUTE_UNITS_BITFIELD: clDeviceInfo read new clDeviceInfo($40BF); + public static property DEVICE_MEMORY_CAPABILITIES: clDeviceInfo read new clDeviceInfo($40D8); public static property DEVICE_SPIR_VERSIONS: clDeviceInfo read new clDeviceInfo($40E0); public static property DEVICE_SIMULTANEOUS_INTEROPS: clDeviceInfo read new clDeviceInfo($4104); public static property DEVICE_NUM_SIMULTANEOUS_INTEROPS: clDeviceInfo read new clDeviceInfo($4105); @@ -2203,6 +2204,8 @@ clDeviceInfo = record Result := 'DEVICE_SVM_CAPABILITIES_ARM' else if DEVICE_COMPUTE_UNITS_BITFIELD = self then Result := 'DEVICE_COMPUTE_UNITS_BITFIELD' else + if DEVICE_MEMORY_CAPABILITIES = self then + Result := 'DEVICE_MEMORY_CAPABILITIES' else if DEVICE_SPIR_VERSIONS = self then Result := 'DEVICE_SPIR_VERSIONS' else if DEVICE_SIMULTANEOUS_INTEROPS = self then @@ -5202,6 +5205,76 @@ clDevicePartitionPropertyEXT = record end; + /// + clMemAllocFlagsIMG = record + public val: UInt64; + public constructor(val: UInt64) := self.val := val; + + public static property MEM_ALLOC_RELAX_REQUIREMENTS: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 0); + public static property MEM_ALLOC_GPU_WRITE_COMBINE: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 1); + public static property MEM_ALLOC_GPU_CACHED: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 2); + public static property MEM_ALLOC_CPU_LOCAL: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 3); + public static property MEM_ALLOC_GPU_LOCAL: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 4); + public static property MEM_ALLOC_GPU_PRIVATE: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 5); + + public static function operator+(v1, v2: clMemAllocFlagsIMG) := new clMemAllocFlagsIMG(v1.val or v2.val); + public static function operator or(v1, v2: clMemAllocFlagsIMG) := new clMemAllocFlagsIMG(v1.val or v2.val); + + public static procedure operator+=(var v1: clMemAllocFlagsIMG; v2: clMemAllocFlagsIMG) := v1 := v1+v2; + + public static function operator in(v1, v2: clMemAllocFlagsIMG) := v1.val and v2.val = v1.val; + + public function ToString: string; override; + begin + var res := new StringBuilder; + var left_val := self.val; + if left_val=0 then + begin + Result := 'clMemAllocFlagsIMG[0]'; + exit; + end; + if MEM_ALLOC_RELAX_REQUIREMENTS in self then + begin + res += 'MEM_ALLOC_RELAX_REQUIREMENTS+'; + left_val := left_val and not MEM_ALLOC_RELAX_REQUIREMENTS.val; + end; + if MEM_ALLOC_GPU_WRITE_COMBINE in self then + begin + res += 'MEM_ALLOC_GPU_WRITE_COMBINE+'; + left_val := left_val and not MEM_ALLOC_GPU_WRITE_COMBINE.val; + end; + if MEM_ALLOC_GPU_CACHED in self then + begin + res += 'MEM_ALLOC_GPU_CACHED+'; + left_val := left_val and not MEM_ALLOC_GPU_CACHED.val; + end; + if MEM_ALLOC_CPU_LOCAL in self then + begin + res += 'MEM_ALLOC_CPU_LOCAL+'; + left_val := left_val and not MEM_ALLOC_CPU_LOCAL.val; + end; + if MEM_ALLOC_GPU_LOCAL in self then + begin + res += 'MEM_ALLOC_GPU_LOCAL+'; + left_val := left_val and not MEM_ALLOC_GPU_LOCAL.val; + end; + if MEM_ALLOC_GPU_PRIVATE in self then + begin + res += 'MEM_ALLOC_GPU_PRIVATE+'; + left_val := left_val and not MEM_ALLOC_GPU_PRIVATE.val; + end; + if left_val<>0 then + begin + res += 'clMemAllocFlagsIMG['; + res += self.val.ToString; + res += ']+'; + end; + res.Length -= 1; + Result := res.ToString; + end; + + end; + /// clMemAllocFlagsINTEL = record public val: UInt64; @@ -11099,6 +11172,14 @@ cl_queue_family_properties = record if param_value_validate_size and (param_value_ret_size<>param_value_sz) then raise new InvalidOperationException($'Implementation returned a size of {param_value_ret_size} instead of {param_value_sz}'); end; + public [MethodImpl(MethodImplOptions.AggressiveInlining)] static function GetDeviceInfo_DEVICE_MEMORY_CAPABILITIES(device: cl_device_id; var param_value: clMemAllocFlagsIMG; param_value_validate_size: boolean := false): clErrorCode; + begin + var param_value_sz := new UIntPtr(Marshal.SizeOf&); + var param_value_ret_size: UIntPtr; + Result := GetDeviceInfo(device, clDeviceInfo.DEVICE_MEMORY_CAPABILITIES, param_value_sz,param_value,param_value_ret_size); + if param_value_validate_size and (param_value_ret_size<>param_value_sz) then + raise new InvalidOperationException($'Implementation returned a size of {param_value_ret_size} instead of {param_value_sz}'); + end; public [MethodImpl(MethodImplOptions.AggressiveInlining)] static function GetDeviceInfo_DEVICE_SPIR_VERSIONS(device: cl_device_id; var param_value: string): clErrorCode; begin var param_value_sz: UIntPtr; diff --git a/Modules.Packed/OpenCLABC.pas b/Modules.Packed/OpenCLABC.pas index 36162783..ed64d621 100644 --- a/Modules.Packed/OpenCLABC.pas +++ b/Modules.Packed/OpenCLABC.pas @@ -57,6 +57,12 @@ //=================================== // Обязательно сделать до следующей стабильной версии: +//TODO Сеттеры параметров не всегда известно, нужны ли +// - Добавить параметр "unuse_is_error := true" + +//TODO При создании CLArray и т.п. указывается map_use, но влияет он и на .ReadArray и т.п. +// - Перетестить и переименовать... host_use? + //TODO Если кинуло AggEx, возвращать из тестов его внутренний массив исключений // - TestExecutor сейчас возвращает исключение текстом... Ужас //TODO Устечка памяти в виде ивентов после исключения в очереди @@ -1525,7 +1531,7 @@ EventRetainReleaseData = record CLMemoryObserver = static class - public static auto property &Default: MemoryObserver := new EmptyMemoryObserver; + public static auto property Current: MemoryObserver := new EmptyMemoryObserver; private static procedure ReportFree(ntv: cl_mem{$ifdef DEBUG}; mem_obj: object{$endif}); begin @@ -1533,7 +1539,7 @@ EventRetainReleaseData = record OpenCLABCInternalException.RaiseIfError( cl.GetMemObjectInfo_MEM_SIZE(ntv, sz) ); - &Default.RemoveMemoryUse(sz.ToUInt64, {$ifdef DEBUG}mem_obj{$else}ntv{$endif}); + Current.RemoveMemoryUse(sz.ToUInt64, {$ifdef DEBUG}mem_obj{$else}ntv{$endif}); end; end; @@ -2391,6 +2397,10 @@ CLDeviceProperties = class begin cl.GetDeviceInfo_DEVICE_FEATURE_CAPABILITIES(self.ntv, Result).RaiseIfError; end; + private function GetMemoryCapabilities: clMemAllocFlagsIMG; + begin + cl.GetDeviceInfo_DEVICE_MEMORY_CAPABILITIES(self.ntv, Result).RaiseIfError; + end; public property &Type: clDeviceType read GetType; public property VendorId: clKhronosVendorId read GetVendorId; @@ -2569,6 +2579,7 @@ CLDeviceProperties = class public property NumEusPerSubSlice: UInt32 read GetNumEusPerSubSlice; public property NumThreadsPerEu: UInt32 read GetNumThreadsPerEu; public property FeatureCapabilities: clDeviceFeatureCapabilities read GetFeatureCapabilities; + public property MemoryCapabilities: clMemAllocFlagsIMG read GetMemoryCapabilities; private static procedure AddProp(res: StringBuilder; get_prop: ()->T) := try @@ -2755,7 +2766,8 @@ CLDeviceProperties = class res += 'NumSubSlicesPerSlice = '; AddProp(res, GetNumSubSlicesPerSlice ); res += #10; res += 'NumEusPerSubSlice = '; AddProp(res, GetNumEusPerSubSlice ); res += #10; res += 'NumThreadsPerEu = '; AddProp(res, GetNumThreadsPerEu ); res += #10; - res += 'FeatureCapabilities = '; AddProp(res, GetFeatureCapabilities ); + res += 'FeatureCapabilities = '; AddProp(res, GetFeatureCapabilities ); res += #10; + res += 'MemoryCapabilities = '; AddProp(res, GetMemoryCapabilities ); end; public function ToString: string; override; begin @@ -4213,6 +4225,25 @@ CLProgramLinkOptions = class(CLProgramOptions) begin self.code := code; self.k_name := k_name; + + // Create one instance, to check if everything is valid + var ec: clErrorCode; + var k := cl.CreateKernel(code.ntv, k_name, ec); + + if ec.IS_ERROR then + begin + if ec=clErrorCode.INVALID_KERNEL_NAME then + begin + var names: string; + OpenCLABCInternalException.RaiseIfError( + cl.GetProgramInfo_PROGRAM_KERNEL_NAMES(code.ntv, names) + ); + raise new OpenCLABCInternalException($'Kernel [{k_name}] is not defined in {code}. Existing kernel names: {names}'); + end; + OpenCLABCInternalException.RaiseIfError(ec); + end; + + AddExistingNative(k); end; public constructor(ntv: cl_kernel); @@ -4369,7 +4400,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), size, nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(size.ToUInt64, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(size.ToUInt64, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; public constructor(size: integer; c: CLContext; kernel_use: CLMemoryUsage := CLMemoryUsage.read_write_bits; map_use: CLMemoryUsage := CLMemoryUsage.read_write_bits) := @@ -5042,7 +5073,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), new UIntPtr(ValueSize), nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; public constructor(c: CLContext; val: T; kernel_use: CLMemoryUsage := CLMemoryUsage.read_write_bits; map_use: CLMemoryUsage := CLMemoryUsage.read_write_bits); @@ -5052,7 +5083,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use) + clMemFlags.MEM_COPY_HOST_PTR, new UIntPtr(ValueSize), val, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; @@ -5172,7 +5203,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), new UIntPtr(ByteSize), nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; private procedure InitByVal(c: CLContext; var els: T; kernel_use, map_use: CLMemoryUsage); @@ -5182,7 +5213,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use) + clMemFlags.MEM_COPY_HOST_PTR, new UIntPtr(ByteSize), els, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; @@ -37491,6 +37522,12 @@ GLIteropApiBlock = record var prev_ev := l.AttachInvokeActions(g{$ifdef EventDebug}, l{$endif}); var res_ev: cl_event; InvokeImpl(api_block, g.GetCQ(false), ntv_mem_objs, prev_ev, res_ev); + //TODO Проверить и сделать всё релевантное из EnqueueableCore + // - В частности что если enq_ev=0 из за предыдущих ошибок? Может ли тут NV тоже отказываться давать ивент? + // - И сделать issue в OpenCL-Docs об этом, типа кто прав (или оба?) + {$ifdef EventDebug} + EventDebug.RegisterEventRetain(res_ev, $'Enq by {TypeName(self)}, waiting on: {prev_ev.evs?.Take(prev_ev.count).JoinToString}'); + {$endif EventDebug} Result := new QueueResNil(prev_ev + res_ev); end; @@ -37954,7 +37991,9 @@ procedure CLArray.SetSliceProp(range: IntRange; value: array of T) := end; begin - var left_mem_objs := EmptyMemoryObserver(CLMemoryObserver.Default).impl.mem_uses.Keys; + var obs := CLMemoryObserver.Current as TrackingMemoryObserver; + if obs=nil then obs := EmptyMemoryObserver(CLMemoryObserver.Current).impl; + var left_mem_objs := obs.mem_uses.Keys; if left_mem_objs.Any then raise new OpenCLABCInternalException($'Not all memory objects were disposed: ' + left_mem_objs.JoinToString); end; diff --git a/Modules/OpenCLABC.pas b/Modules/OpenCLABC.pas index b310db85..741c38e5 100644 --- a/Modules/OpenCLABC.pas +++ b/Modules/OpenCLABC.pas @@ -47,6 +47,12 @@ //=================================== // Обязательно сделать до следующей стабильной версии: +//TODO Сеттеры параметров не всегда известно, нужны ли +// - Добавить параметр "unuse_is_error := true" + +//TODO При создании CLArray и т.п. указывается map_use, но влияет он и на .ReadArray и т.п. +// - Перетестить и переименовать... host_use? + //TODO Если кинуло AggEx, возвращать из тестов его внутренний массив исключений // - TestExecutor сейчас возвращает исключение текстом... Ужас //TODO Устечка памяти в виде ивентов после исключения в очереди @@ -1413,7 +1419,7 @@ EventRetainReleaseData = record CLMemoryObserver = static class - public static auto property &Default: MemoryObserver := new EmptyMemoryObserver; + public static auto property Current: MemoryObserver := new EmptyMemoryObserver; private static procedure ReportFree(ntv: cl_mem{$ifdef DEBUG}; mem_obj: object{$endif}); begin @@ -1421,7 +1427,7 @@ EventRetainReleaseData = record OpenCLABCInternalException.RaiseIfError( cl.GetMemObjectInfo_MEM_SIZE(ntv, sz) ); - &Default.RemoveMemoryUse(sz.ToUInt64, {$ifdef DEBUG}mem_obj{$else}ntv{$endif}); + Current.RemoveMemoryUse(sz.ToUInt64, {$ifdef DEBUG}mem_obj{$else}ntv{$endif}); end; end; @@ -2380,6 +2386,25 @@ CLProgramLinkOptions = class(CLProgramOptions) begin self.code := code; self.k_name := k_name; + + // Create one instance, to check if everything is valid + var ec: clErrorCode; + var k := cl.CreateKernel(code.ntv, k_name, ec); + + if ec.IS_ERROR then + begin + if ec=clErrorCode.INVALID_KERNEL_NAME then + begin + var names: string; + OpenCLABCInternalException.RaiseIfError( + cl.GetProgramInfo_PROGRAM_KERNEL_NAMES(code.ntv, names) + ); + raise new OpenCLABCInternalException($'Kernel [{k_name}] is not defined in {code}. Existing kernel names: {names}'); + end; + OpenCLABCInternalException.RaiseIfError(ec); + end; + + AddExistingNative(k); end; public constructor(ntv: cl_kernel); @@ -2525,7 +2550,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), size, nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(size.ToUInt64, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(size.ToUInt64, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; public constructor(size: integer; c: CLContext; kernel_use: CLMemoryUsage := CLMemoryUsage.read_write_bits; map_use: CLMemoryUsage := CLMemoryUsage.read_write_bits) := @@ -2653,7 +2678,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), new UIntPtr(ValueSize), nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; public constructor(c: CLContext; val: T; kernel_use: CLMemoryUsage := CLMemoryUsage.read_write_bits; map_use: CLMemoryUsage := CLMemoryUsage.read_write_bits); @@ -2663,7 +2688,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use) + clMemFlags.MEM_COPY_HOST_PTR, new UIntPtr(ValueSize), val, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; @@ -2730,7 +2755,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), new UIntPtr(ByteSize), nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; private procedure InitByVal(c: CLContext; var els: T; kernel_use, map_use: CLMemoryUsage); @@ -2740,7 +2765,7 @@ CLMemoryUsage = record self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use) + clMemFlags.MEM_COPY_HOST_PTR, new UIntPtr(ByteSize), els, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; @@ -10979,6 +11004,12 @@ GLIteropApiBlock = record var prev_ev := l.AttachInvokeActions(g{$ifdef EventDebug}, l{$endif}); var res_ev: cl_event; InvokeImpl(api_block, g.GetCQ(false), ntv_mem_objs, prev_ev, res_ev); + //TODO Проверить и сделать всё релевантное из EnqueueableCore + // - В частности что если enq_ev=0 из за предыдущих ошибок? Может ли тут NV тоже отказываться давать ивент? + // - И сделать issue в OpenCL-Docs об этом, типа кто прав (или оба?) + {$ifdef EventDebug} + EventDebug.RegisterEventRetain(res_ev, $'Enq by {TypeName(self)}, waiting on: {prev_ev.evs?.Take(prev_ev.count).JoinToString}'); + {$endif EventDebug} Result := new QueueResNil(prev_ev + res_ev); end; @@ -11442,7 +11473,9 @@ procedure CLArray.SetSliceProp(range: IntRange; value: array of T) := end; begin - var left_mem_objs := EmptyMemoryObserver(CLMemoryObserver.Default).impl.mem_uses.Keys; + var obs := CLMemoryObserver.Current as TrackingMemoryObserver; + if obs=nil then obs := EmptyMemoryObserver(CLMemoryObserver.Current).impl; + var left_mem_objs := obs.mem_uses.Keys; if left_mem_objs.Any then raise new OpenCLABCInternalException($'Not all memory objects were disposed: ' + left_mem_objs.JoinToString); end; diff --git a/Packing/Descriptions/OpenCL.predoc b/Packing/Descriptions/OpenCL.predoc index b73802a6..97a3870e 100644 --- a/Packing/Descriptions/OpenCL.predoc +++ b/Packing/Descriptions/OpenCL.predoc @@ -1832,6 +1832,7 @@ type public static property DEVICE_PAGE_SIZE: clDeviceInfo read new clDeviceInfo($40A1); public static property DEVICE_SVM_CAPABILITIES_ARM: clDeviceInfo read new clDeviceInfo($40B6); public static property DEVICE_COMPUTE_UNITS_BITFIELD: clDeviceInfo read new clDeviceInfo($40BF); + public static property DEVICE_MEMORY_CAPABILITIES: clDeviceInfo read new clDeviceInfo($40D8); public static property DEVICE_SPIR_VERSIONS: clDeviceInfo read new clDeviceInfo($40E0); public static property DEVICE_SIMULTANEOUS_INTEROPS: clDeviceInfo read new clDeviceInfo($4104); public static property DEVICE_NUM_SIMULTANEOUS_INTEROPS: clDeviceInfo read new clDeviceInfo($4105); @@ -2203,6 +2204,8 @@ type Result := 'DEVICE_SVM_CAPABILITIES_ARM' else if DEVICE_COMPUTE_UNITS_BITFIELD = self then Result := 'DEVICE_COMPUTE_UNITS_BITFIELD' else + if DEVICE_MEMORY_CAPABILITIES = self then + Result := 'DEVICE_MEMORY_CAPABILITIES' else if DEVICE_SPIR_VERSIONS = self then Result := 'DEVICE_SPIR_VERSIONS' else if DEVICE_SIMULTANEOUS_INTEROPS = self then @@ -5202,6 +5205,76 @@ type end; + /// + clMemAllocFlagsIMG = record + public val: UInt64; + public constructor(val: UInt64) := self.val := val; + + public static property MEM_ALLOC_RELAX_REQUIREMENTS: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 0); + public static property MEM_ALLOC_GPU_WRITE_COMBINE: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 1); + public static property MEM_ALLOC_GPU_CACHED: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 2); + public static property MEM_ALLOC_CPU_LOCAL: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 3); + public static property MEM_ALLOC_GPU_LOCAL: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 4); + public static property MEM_ALLOC_GPU_PRIVATE: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 5); + + public static function operator+(v1, v2: clMemAllocFlagsIMG) := new clMemAllocFlagsIMG(v1.val or v2.val); + public static function operator or(v1, v2: clMemAllocFlagsIMG) := new clMemAllocFlagsIMG(v1.val or v2.val); + + public static procedure operator+=(var v1: clMemAllocFlagsIMG; v2: clMemAllocFlagsIMG) := v1 := v1+v2; + + public static function operator in(v1, v2: clMemAllocFlagsIMG) := v1.val and v2.val = v1.val; + + public function ToString: string; override; + begin + var res := new StringBuilder; + var left_val := self.val; + if left_val=0 then + begin + Result := 'clMemAllocFlagsIMG[0]'; + exit; + end; + if MEM_ALLOC_RELAX_REQUIREMENTS in self then + begin + res += 'MEM_ALLOC_RELAX_REQUIREMENTS+'; + left_val := left_val and not MEM_ALLOC_RELAX_REQUIREMENTS.val; + end; + if MEM_ALLOC_GPU_WRITE_COMBINE in self then + begin + res += 'MEM_ALLOC_GPU_WRITE_COMBINE+'; + left_val := left_val and not MEM_ALLOC_GPU_WRITE_COMBINE.val; + end; + if MEM_ALLOC_GPU_CACHED in self then + begin + res += 'MEM_ALLOC_GPU_CACHED+'; + left_val := left_val and not MEM_ALLOC_GPU_CACHED.val; + end; + if MEM_ALLOC_CPU_LOCAL in self then + begin + res += 'MEM_ALLOC_CPU_LOCAL+'; + left_val := left_val and not MEM_ALLOC_CPU_LOCAL.val; + end; + if MEM_ALLOC_GPU_LOCAL in self then + begin + res += 'MEM_ALLOC_GPU_LOCAL+'; + left_val := left_val and not MEM_ALLOC_GPU_LOCAL.val; + end; + if MEM_ALLOC_GPU_PRIVATE in self then + begin + res += 'MEM_ALLOC_GPU_PRIVATE+'; + left_val := left_val and not MEM_ALLOC_GPU_PRIVATE.val; + end; + if left_val<>0 then + begin + res += 'clMemAllocFlagsIMG['; + res += self.val.ToString; + res += ']+'; + end; + res.Length -= 1; + Result := res.ToString; + end; + + end; + /// clMemAllocFlagsINTEL = record public val: UInt64; @@ -11095,6 +11168,14 @@ type if param_value_validate_size and (param_value_ret_size<>param_value_sz) then raise new InvalidOperationException($'Implementation returned a size of {param_value_ret_size} instead of {param_value_sz}'); end; + public [MethodImpl(MethodImplOptions.AggressiveInlining)] static function GetDeviceInfo_DEVICE_MEMORY_CAPABILITIES(device: cl_device_id; var param_value: clMemAllocFlagsIMG; param_value_validate_size: boolean := false): clErrorCode; + begin + var param_value_sz := new UIntPtr(Marshal.SizeOf&); + var param_value_ret_size: UIntPtr; + Result := GetDeviceInfo(device, clDeviceInfo.DEVICE_MEMORY_CAPABILITIES, param_value_sz,param_value,param_value_ret_size); + if param_value_validate_size and (param_value_ret_size<>param_value_sz) then + raise new InvalidOperationException($'Implementation returned a size of {param_value_ret_size} instead of {param_value_sz}'); + end; public [MethodImpl(MethodImplOptions.AggressiveInlining)] static function GetDeviceInfo_DEVICE_SPIR_VERSIONS(device: cl_device_id; var param_value: string): clErrorCode; begin var param_value_sz: UIntPtr; diff --git a/Packing/Descriptions/OpenCLABC.predoc b/Packing/Descriptions/OpenCLABC.predoc index 000847c8..eb3bc670 100644 --- a/Packing/Descriptions/OpenCLABC.predoc +++ b/Packing/Descriptions/OpenCLABC.predoc @@ -57,6 +57,12 @@ unit OpenCLABC; //=================================== // Обязательно сделать до следующей стабильной версии: +//TODO Сеттеры параметров не всегда известно, нужны ли +// - Добавить параметр "unuse_is_error := true" + +//TODO При создании CLArray и т.п. указывается map_use, но влияет он и на .ReadArray и т.п. +// - Перетестить и переименовать... host_use? + //TODO Если кинуло AggEx, возвращать из тестов его внутренний массив исключений // - TestExecutor сейчас возвращает исключение текстом... Ужас //TODO Устечка памяти в виде ивентов после исключения в очереди @@ -1423,7 +1429,7 @@ type CLMemoryObserver = static class - public static auto property &Default: MemoryObserver := new EmptyMemoryObserver; + public static auto property Current: MemoryObserver := new EmptyMemoryObserver; private static procedure ReportFree(ntv: cl_mem{$ifdef DEBUG}; mem_obj: object{$endif}); begin @@ -1431,7 +1437,7 @@ type OpenCLABCInternalException.RaiseIfError( cl.GetMemObjectInfo_MEM_SIZE(ntv, sz) ); - &Default.RemoveMemoryUse(sz.ToUInt64, {$ifdef DEBUG}mem_obj{$else}ntv{$endif}); + Current.RemoveMemoryUse(sz.ToUInt64, {$ifdef DEBUG}mem_obj{$else}ntv{$endif}); end; end; @@ -2289,6 +2295,10 @@ type begin cl.GetDeviceInfo_DEVICE_FEATURE_CAPABILITIES(self.ntv, Result).RaiseIfError; end; + private function GetMemoryCapabilities: clMemAllocFlagsIMG; + begin + cl.GetDeviceInfo_DEVICE_MEMORY_CAPABILITIES(self.ntv, Result).RaiseIfError; + end; public property &Type: clDeviceType read GetType; public property VendorId: clKhronosVendorId read GetVendorId; @@ -2467,6 +2477,7 @@ type public property NumEusPerSubSlice: UInt32 read GetNumEusPerSubSlice; public property NumThreadsPerEu: UInt32 read GetNumThreadsPerEu; public property FeatureCapabilities: clDeviceFeatureCapabilities read GetFeatureCapabilities; + public property MemoryCapabilities: clMemAllocFlagsIMG read GetMemoryCapabilities; private static procedure AddProp(res: StringBuilder; get_prop: ()->T) := try @@ -2653,7 +2664,8 @@ type res += 'NumSubSlicesPerSlice = '; AddProp(res, GetNumSubSlicesPerSlice ); res += #10; res += 'NumEusPerSubSlice = '; AddProp(res, GetNumEusPerSubSlice ); res += #10; res += 'NumThreadsPerEu = '; AddProp(res, GetNumThreadsPerEu ); res += #10; - res += 'FeatureCapabilities = '; AddProp(res, GetFeatureCapabilities ); + res += 'FeatureCapabilities = '; AddProp(res, GetFeatureCapabilities ); res += #10; + res += 'MemoryCapabilities = '; AddProp(res, GetMemoryCapabilities ); end; public function ToString: string; override; begin @@ -4109,6 +4121,25 @@ type begin self.code := code; self.k_name := k_name; + + // Create one instance, to check if everything is valid + var ec: clErrorCode; + var k := cl.CreateKernel(code.ntv, k_name, ec); + + if ec.IS_ERROR then + begin + if ec=clErrorCode.INVALID_KERNEL_NAME then + begin + var names: string; + OpenCLABCInternalException.RaiseIfError( + cl.GetProgramInfo_PROGRAM_KERNEL_NAMES(code.ntv, names) + ); + raise new OpenCLABCInternalException($'Kernel [{k_name}] is not defined in {code}. Existing kernel names: {names}'); + end; + OpenCLABCInternalException.RaiseIfError(ec); + end; + + AddExistingNative(k); end; public constructor(ntv: cl_kernel); @@ -4264,7 +4295,7 @@ type self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), size, nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(size.ToUInt64, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(size.ToUInt64, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; public constructor(size: integer; c: CLContext; kernel_use: CLMemoryUsage := CLMemoryUsage.read_write_bits; map_use: CLMemoryUsage := CLMemoryUsage.read_write_bits) := @@ -4692,7 +4723,7 @@ type self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), new UIntPtr(ValueSize), nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; public constructor(c: CLContext; val: T; kernel_use: CLMemoryUsage := CLMemoryUsage.read_write_bits; map_use: CLMemoryUsage := CLMemoryUsage.read_write_bits); @@ -4702,7 +4733,7 @@ type self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use) + clMemFlags.MEM_COPY_HOST_PTR, new UIntPtr(ValueSize), val, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ValueSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; @@ -4803,7 +4834,7 @@ type self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use), new UIntPtr(ByteSize), nil, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; private procedure InitByVal(c: CLContext; var els: T; kernel_use, map_use: CLMemoryUsage); @@ -4813,7 +4844,7 @@ type self.ntv := cl.CreateBuffer(c.ntv, CLMemoryUsage.MakeCLFlags(kernel_use,map_use) + clMemFlags.MEM_COPY_HOST_PTR, new UIntPtr(ByteSize), els, ec); OpenCLABCInternalException.RaiseIfError(ec); - CLMemoryObserver.Default.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); + CLMemoryObserver.Current.AddMemoryUse(ByteSize, {$ifdef DEBUG}new CLMemoryAlloc(self, ntv){$else}ntv{$endif}); end; @@ -36425,6 +36456,12 @@ end; var prev_ev := l.AttachInvokeActions(g{$ifdef EventDebug}, l{$endif}); var res_ev: cl_event; InvokeImpl(api_block, g.GetCQ(false), ntv_mem_objs, prev_ev, res_ev); + //TODO Проверить и сделать всё релевантное из EnqueueableCore + // - В частности что если enq_ev=0 из за предыдущих ошибок? Может ли тут NV тоже отказываться давать ивент? + // - И сделать issue в OpenCL-Docs об этом, типа кто прав (или оба?) + {$ifdef EventDebug} + EventDebug.RegisterEventRetain(res_ev, $'Enq by {TypeName(self)}, waiting on: {prev_ev.evs?.Take(prev_ev.count).JoinToString}'); + {$endif EventDebug} Result := new QueueResNil(prev_ev + res_ev); end; @@ -36888,7 +36925,9 @@ type end; begin - var left_mem_objs := EmptyMemoryObserver(CLMemoryObserver.Default).impl.mem_uses.Keys; + var obs := CLMemoryObserver.Current as TrackingMemoryObserver; + if obs=nil then obs := EmptyMemoryObserver(CLMemoryObserver.Current).impl; + var left_mem_objs := obs.mem_uses.Keys; if left_mem_objs.Any then raise new OpenCLABCInternalException($'Not all memory objects were disposed: ' + left_mem_objs.JoinToString); end; diff --git a/Packing/Template/HighLvl/OpenCLABC/!Def/WrapperProperties/02#CLDevice.dat b/Packing/Template/HighLvl/OpenCLABC/!Def/WrapperProperties/02#CLDevice.dat index 6644b1ef..005d42c7 100644 --- a/Packing/Template/HighLvl/OpenCLABC/!Def/WrapperProperties/02#CLDevice.dat +++ b/Packing/Template/HighLvl/OpenCLABC/!Def/WrapperProperties/02#CLDevice.dat @@ -181,6 +181,7 @@ cl.GetDeviceInfo # NUM_EUS_PER_SUB_SLICE # NUM_THREADS_PER_EU # FEATURE_CAPABILITIES +# MEMORY_CAPABILITIES Flat diff --git a/Packing/Template/HighLvl/OpenCLABC/WrapperProperties.template b/Packing/Template/HighLvl/OpenCLABC/WrapperProperties.template index 315eb635..11a874c3 100644 --- a/Packing/Template/HighLvl/OpenCLABC/WrapperProperties.template +++ b/Packing/Template/HighLvl/OpenCLABC/WrapperProperties.template @@ -834,6 +834,10 @@ begin cl.GetDeviceInfo_DEVICE_FEATURE_CAPABILITIES(self.ntv, Result).RaiseIfError; end; + private function GetMemoryCapabilities: clMemAllocFlagsIMG; + begin + cl.GetDeviceInfo_DEVICE_MEMORY_CAPABILITIES(self.ntv, Result).RaiseIfError; + end; public property &Type: clDeviceType read GetType; public property VendorId: clKhronosVendorId read GetVendorId; @@ -1012,6 +1016,7 @@ public property NumEusPerSubSlice: UInt32 read GetNumEusPerSubSlice; public property NumThreadsPerEu: UInt32 read GetNumThreadsPerEu; public property FeatureCapabilities: clDeviceFeatureCapabilities read GetFeatureCapabilities; + public property MemoryCapabilities: clMemAllocFlagsIMG read GetMemoryCapabilities; private static procedure AddProp(res: StringBuilder; get_prop: ()->T) := try @@ -1198,7 +1203,8 @@ res += 'NumSubSlicesPerSlice = '; AddProp(res, GetNumSubSlicesPerSlice ); res += #10; res += 'NumEusPerSubSlice = '; AddProp(res, GetNumEusPerSubSlice ); res += #10; res += 'NumThreadsPerEu = '; AddProp(res, GetNumThreadsPerEu ); res += #10; - res += 'FeatureCapabilities = '; AddProp(res, GetFeatureCapabilities ); + res += 'FeatureCapabilities = '; AddProp(res, GetFeatureCapabilities ); res += #10; + res += 'MemoryCapabilities = '; AddProp(res, GetMemoryCapabilities ); end; public function ToString: string; override; begin diff --git a/Packing/Template/LowLvl/OpenCL/Feature.Interface.template b/Packing/Template/LowLvl/OpenCL/Feature.Interface.template index ffcb7a5a..8257b789 100644 --- a/Packing/Template/LowLvl/OpenCL/Feature.Interface.template +++ b/Packing/Template/LowLvl/OpenCL/Feature.Interface.template @@ -4911,6 +4911,14 @@ if param_value_validate_size and (param_value_ret_size<>param_value_sz) then raise new InvalidOperationException($'Implementation returned a size of {param_value_ret_size} instead of {param_value_sz}'); end; + public [MethodImpl(MethodImplOptions.AggressiveInlining)] static function GetDeviceInfo_DEVICE_MEMORY_CAPABILITIES(device: cl_device_id; var param_value: clMemAllocFlagsIMG; param_value_validate_size: boolean := false): clErrorCode; + begin + var param_value_sz := new UIntPtr(Marshal.SizeOf&); + var param_value_ret_size: UIntPtr; + Result := GetDeviceInfo(device, clDeviceInfo.DEVICE_MEMORY_CAPABILITIES, param_value_sz,param_value,param_value_ret_size); + if param_value_validate_size and (param_value_ret_size<>param_value_sz) then + raise new InvalidOperationException($'Implementation returned a size of {param_value_ret_size} instead of {param_value_sz}'); + end; public [MethodImpl(MethodImplOptions.AggressiveInlining)] static function GetDeviceInfo_DEVICE_SPIR_VERSIONS(device: cl_device_id; var param_value: string): clErrorCode; begin var param_value_sz: UIntPtr; diff --git a/Packing/Template/LowLvl/OpenCL/Log/All EnumToTypeBinding's.log b/Packing/Template/LowLvl/OpenCL/Log/All EnumToTypeBinding's.log index f8a4e5a0..07d6b97c 100644 --- a/Packing/Template/LowLvl/OpenCL/Log/All EnumToTypeBinding's.log +++ b/Packing/Template/LowLvl/OpenCL/Log/All EnumToTypeBinding's.log @@ -507,6 +507,9 @@ clDeviceSVMCapabilities --- DEVICE_COMPUTE_UNITS_BITFIELD !output UInt64 +--- DEVICE_MEMORY_CAPABILITIES +!output +clMemAllocFlagsIMG --- DEVICE_SPIR_VERSIONS !output string diff --git a/Packing/Template/LowLvl/OpenCL/Log/All Extension's.log b/Packing/Template/LowLvl/OpenCL/Log/All Extension's.log index a7028c5e..0a783d0e 100644 --- a/Packing/Template/LowLvl/OpenCL/Log/All Extension's.log +++ b/Packing/Template/LowLvl/OpenCL/Log/All Extension's.log @@ -205,7 +205,13 @@ # clMemPropertiesIMG (cl_img_mem_properties) Enum [cl::MEM_ALLOC_RELAX_REQUIREMENTS] + Enum [cl::MEM_ALLOC_GPU_WRITE_COMBINE] + Enum [cl::MEM_ALLOC_GPU_CACHED] + Enum [cl::MEM_ALLOC_CPU_LOCAL] + Enum [cl::MEM_ALLOC_GPU_LOCAL] + Enum [cl::MEM_ALLOC_GPU_PRIVATE] Enum [cl::MEM_ALLOC_FLAGS + IMG] + Enum [cl::DEVICE_MEMORY_CAPABILITIES] # clUseGrallocPtrIMG (cl_img_use_gralloc_ptr) Enum [cl::COMMAND_ACQUIRE_GRALLOC_OBJECTS] diff --git a/Packing/Template/LowLvl/OpenCL/Log/All Func's.log b/Packing/Template/LowLvl/OpenCL/Log/All Func's.log index 76f405ff..477301c1 100644 --- a/Packing/Template/LowLvl/OpenCL/Log/All Func's.log +++ b/Packing/Template/LowLvl/OpenCL/Log/All Func's.log @@ -1551,7 +1551,7 @@ param_value_size: UIntPtr param_value: pointer param_value_size_ret: var UIntPtr / IntPtr !ffo -204 +205 clErrorCode | cl_device_id | clDeviceInfo | UIntPtr | var T | var UIntPtr | clErrorCode | cl_device_id | clDeviceInfo | UIntPtr | var T | IntPtr | clErrorCode | cl_device_id | clDeviceInfo | UIntPtr | pointer | var UIntPtr | @@ -1720,6 +1720,7 @@ param_value_size_ret: var UIntPtr / IntPtr clErrorCode | cl_device_id | clDeviceInfo.DEVICE_ME_VERSION | * | var clDeviceMeVersion | * | clErrorCode | cl_device_id | clDeviceInfo.DEVICE_SVM_CAPABILITIES_ARM | * | var clDeviceSVMCapabilities | * | clErrorCode | cl_device_id | clDeviceInfo.DEVICE_COMPUTE_UNITS_BITFIELD | * | var UInt64 | * | + clErrorCode | cl_device_id | clDeviceInfo.DEVICE_MEMORY_CAPABILITIES | * | var clMemAllocFlagsIMG | * | clErrorCode | cl_device_id | clDeviceInfo.DEVICE_SPIR_VERSIONS | * | var string | * | clErrorCode | cl_device_id | clDeviceInfo.DEVICE_SIMULTANEOUS_INTEROPS | * | var array of UInt32 | * | clErrorCode | cl_device_id | clDeviceInfo.DEVICE_SIMULTANEOUS_INTEROPS | UInt32 | var UInt32 | * | diff --git a/Packing/Template/LowLvl/OpenCL/Log/All Group's.log b/Packing/Template/LowLvl/OpenCL/Log/All Group's.log index 3723f8a8..e85a3bef 100644 --- a/Packing/Template/LowLvl/OpenCL/Log/All Group's.log +++ b/Packing/Template/LowLvl/OpenCL/Log/All Group's.log @@ -523,6 +523,7 @@ DEVICE_PAGE_SIZE[$40A1] DEVICE_SVM_CAPABILITIES + ARM[$40B6] DEVICE_COMPUTE_UNITS_BITFIELD[$40BF] + DEVICE_MEMORY_CAPABILITIES[$40D8] DEVICE_SPIR_VERSIONS[$40E0] DEVICE_SIMULTANEOUS_INTEROPS[$4104] DEVICE_NUM_SIMULTANEOUS_INTEROPS[$4105] @@ -1205,6 +1206,11 @@ # clMemAllocFlagsIMG (cl::MemAllocFlags + img) : UInt64 (Bitfield) MEM_ALLOC_RELAX_REQUIREMENTS[1 shl 0] + MEM_ALLOC_GPU_WRITE_COMBINE[1 shl 1] + MEM_ALLOC_GPU_CACHED[1 shl 2] + MEM_ALLOC_CPU_LOCAL[1 shl 3] + MEM_ALLOC_GPU_LOCAL[1 shl 4] + MEM_ALLOC_GPU_PRIVATE[1 shl 5] # clMemAllocFlagsINTEL (cl::MemAllocFlags + intel) : UInt64 (Bitfield) MEM_ALLOC_WRITE_COMBINED[1 shl 0] diff --git a/Packing/Template/LowLvl/OpenCL/Log/Essentials.log b/Packing/Template/LowLvl/OpenCL/Log/Essentials.log index f07c7121..26abd565 100644 --- a/Packing/Template/LowLvl/OpenCL/Log/Essentials.log +++ b/Packing/Template/LowLvl/OpenCL/Log/Essentials.log @@ -104,7 +104,7 @@ Dumping IdClass items Dumping Struct items Dumping Delegate items PascalBasicType: Packed 12 items -Group: Packed 111 items +Group: Packed 112 items IdClass: Packed 28 items Struct: Packed 17 items Delegate: Packed 7 items diff --git a/Packing/Template/LowLvl/OpenCL/Types.Interface.template b/Packing/Template/LowLvl/OpenCL/Types.Interface.template index 4ccf568f..03d566b5 100644 --- a/Packing/Template/LowLvl/OpenCL/Types.Interface.template +++ b/Packing/Template/LowLvl/OpenCL/Types.Interface.template @@ -1798,6 +1798,7 @@ public static property DEVICE_PAGE_SIZE: clDeviceInfo read new clDeviceInfo($40A1); public static property DEVICE_SVM_CAPABILITIES_ARM: clDeviceInfo read new clDeviceInfo($40B6); public static property DEVICE_COMPUTE_UNITS_BITFIELD: clDeviceInfo read new clDeviceInfo($40BF); + public static property DEVICE_MEMORY_CAPABILITIES: clDeviceInfo read new clDeviceInfo($40D8); public static property DEVICE_SPIR_VERSIONS: clDeviceInfo read new clDeviceInfo($40E0); public static property DEVICE_SIMULTANEOUS_INTEROPS: clDeviceInfo read new clDeviceInfo($4104); public static property DEVICE_NUM_SIMULTANEOUS_INTEROPS: clDeviceInfo read new clDeviceInfo($4105); @@ -2169,6 +2170,8 @@ Result := 'DEVICE_SVM_CAPABILITIES_ARM' else if DEVICE_COMPUTE_UNITS_BITFIELD = self then Result := 'DEVICE_COMPUTE_UNITS_BITFIELD' else + if DEVICE_MEMORY_CAPABILITIES = self then + Result := 'DEVICE_MEMORY_CAPABILITIES' else if DEVICE_SPIR_VERSIONS = self then Result := 'DEVICE_SPIR_VERSIONS' else if DEVICE_SIMULTANEOUS_INTEROPS = self then @@ -5168,6 +5171,76 @@ end; + /// + clMemAllocFlagsIMG = record + public val: UInt64; + public constructor(val: UInt64) := self.val := val; + + public static property MEM_ALLOC_RELAX_REQUIREMENTS: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 0); + public static property MEM_ALLOC_GPU_WRITE_COMBINE: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 1); + public static property MEM_ALLOC_GPU_CACHED: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 2); + public static property MEM_ALLOC_CPU_LOCAL: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 3); + public static property MEM_ALLOC_GPU_LOCAL: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 4); + public static property MEM_ALLOC_GPU_PRIVATE: clMemAllocFlagsIMG read new clMemAllocFlagsIMG(1 shl 5); + + public static function operator+(v1, v2: clMemAllocFlagsIMG) := new clMemAllocFlagsIMG(v1.val or v2.val); + public static function operator or(v1, v2: clMemAllocFlagsIMG) := new clMemAllocFlagsIMG(v1.val or v2.val); + + public static procedure operator+=(var v1: clMemAllocFlagsIMG; v2: clMemAllocFlagsIMG) := v1 := v1+v2; + + public static function operator in(v1, v2: clMemAllocFlagsIMG) := v1.val and v2.val = v1.val; + + public function ToString: string; override; + begin + var res := new StringBuilder; + var left_val := self.val; + if left_val=0 then + begin + Result := 'clMemAllocFlagsIMG[0]'; + exit; + end; + if MEM_ALLOC_RELAX_REQUIREMENTS in self then + begin + res += 'MEM_ALLOC_RELAX_REQUIREMENTS+'; + left_val := left_val and not MEM_ALLOC_RELAX_REQUIREMENTS.val; + end; + if MEM_ALLOC_GPU_WRITE_COMBINE in self then + begin + res += 'MEM_ALLOC_GPU_WRITE_COMBINE+'; + left_val := left_val and not MEM_ALLOC_GPU_WRITE_COMBINE.val; + end; + if MEM_ALLOC_GPU_CACHED in self then + begin + res += 'MEM_ALLOC_GPU_CACHED+'; + left_val := left_val and not MEM_ALLOC_GPU_CACHED.val; + end; + if MEM_ALLOC_CPU_LOCAL in self then + begin + res += 'MEM_ALLOC_CPU_LOCAL+'; + left_val := left_val and not MEM_ALLOC_CPU_LOCAL.val; + end; + if MEM_ALLOC_GPU_LOCAL in self then + begin + res += 'MEM_ALLOC_GPU_LOCAL+'; + left_val := left_val and not MEM_ALLOC_GPU_LOCAL.val; + end; + if MEM_ALLOC_GPU_PRIVATE in self then + begin + res += 'MEM_ALLOC_GPU_PRIVATE+'; + left_val := left_val and not MEM_ALLOC_GPU_PRIVATE.val; + end; + if left_val<>0 then + begin + res += 'clMemAllocFlagsIMG['; + res += self.val.ToString; + res += ']+'; + end; + res.Length -= 1; + Result := res.ToString; + end; + + end; + /// clMemAllocFlagsINTEL = record public val: UInt64;