├── src
├── Compute.pas
├── Compute.Common.pas
├── Compute.Detail.pas
├── Compute.OpenCL.pas
├── Compute.ExprTrees.pas
├── Compute.Functions.pas
├── Compute.Statements.pas
├── Compute.Interpreter.pas
├── Compute.OpenCL.Detail.pas
├── Compute.OpenCL.KernelGenerator.pas
├── Compute.Future.Detail.pas
└── OpenCL
│ ├── OpenCL.inc
│ ├── cl_platform.pas
│ └── cl_ext.pas
├── tests
├── Compute.Dev.Test.pas
├── ComputeDevTest.res
├── ComputeDevTest.dpr
├── ComputeTests.groupproj
├── ComputeDevTest.dproj
└── Compute.Test.pas
├── .gitignore
├── .gitattributes
├── README.md
└── LICENSE
/src/Compute.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.pas
--------------------------------------------------------------------------------
/src/Compute.Common.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.Common.pas
--------------------------------------------------------------------------------
/src/Compute.Detail.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.Detail.pas
--------------------------------------------------------------------------------
/src/Compute.OpenCL.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.OpenCL.pas
--------------------------------------------------------------------------------
/src/Compute.ExprTrees.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.ExprTrees.pas
--------------------------------------------------------------------------------
/src/Compute.Functions.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.Functions.pas
--------------------------------------------------------------------------------
/src/Compute.Statements.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.Statements.pas
--------------------------------------------------------------------------------
/tests/Compute.Dev.Test.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/tests/Compute.Dev.Test.pas
--------------------------------------------------------------------------------
/tests/ComputeDevTest.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/tests/ComputeDevTest.res
--------------------------------------------------------------------------------
/src/Compute.Interpreter.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.Interpreter.pas
--------------------------------------------------------------------------------
/src/Compute.OpenCL.Detail.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.OpenCL.Detail.pas
--------------------------------------------------------------------------------
/src/Compute.OpenCL.KernelGenerator.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lordcrc/Compute/HEAD/src/Compute.OpenCL.KernelGenerator.pas
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ############
2 | # Delphi
3 | ############
4 | __history
5 | *.dcu
6 | *.~*~
7 | *.local
8 | *.identcache
9 | *.drc
10 | *.map
11 | *.exe
12 | *.dll
13 | *.tds
14 | *.rsm
15 | *.dsk
16 | *.~dsk
17 | *.dsm
18 | *.cbk
19 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Delphi
13 | *.dproj merge=union
14 |
15 | # Standard to msysgit
16 | *.doc diff=astextplain
17 | *.DOC diff=astextplain
18 | *.docx diff=astextplain
19 | *.DOCX diff=astextplain
20 | *.dot diff=astextplain
21 | *.DOT diff=astextplain
22 | *.pdf diff=astextplain
23 | *.PDF diff=astextplain
24 | *.rtf diff=astextplain
25 | *.RTF diff=astextplain
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Compute
2 |
3 | Delphi.Compute library, inspired by Boost.Compute.
4 |
5 | Under development!
6 |
7 | The goal is to provide a high-level interface to GPGPU programming
8 | through OpenCL, so one can easily utilize the powers of modern
9 | GPU/APUs in Delphi.
10 |
11 |
12 | ## Example
13 |
14 | ```Pascal
15 | // Add one to each element in input data and take the square root
16 | output_data := Compute.Transform(input_data, sqrt(_1 + 1));
17 | ```
18 |
19 |
20 | ## Running the code
21 | Since this project relies on OpenCL, please make sure you have
22 | OpenCL platform drivers installed.
23 |
24 | AMD GPU: http://support.amd.com/en-us/download
25 |
26 | NVIDIA GPU: http://www.nvidia.com/Download/index.aspx
27 |
28 | Intel CPU: https://software.intel.com/en-us/articles/opencl-drivers
29 |
30 |
31 | ## Additional
32 |
33 | Uses ported OpenCL headers from delphi-opencl project
34 | https://code.google.com/p/delphi-opencl/
35 |
36 | Licensed under the Apache 2.0 license, see LICENSE.txt for details
37 |
--------------------------------------------------------------------------------
/tests/ComputeDevTest.dpr:
--------------------------------------------------------------------------------
1 | program ComputeDevTest;
2 |
3 | {$APPTYPE CONSOLE}
4 |
5 | {$R *.res}
6 |
7 | uses
8 | System.SysUtils,
9 | Compute.Common in '..\src\Compute.Common.pas',
10 | Compute.ExprTrees in '..\src\Compute.ExprTrees.pas',
11 | Compute.Interpreter in '..\src\Compute.Interpreter.pas',
12 | Compute.Statements in '..\src\Compute.Statements.pas',
13 | Compute.Dev.Test in 'Compute.Dev.Test.pas',
14 | cl in '..\src\OpenCL\cl.pas',
15 | cl_ext in '..\src\OpenCL\cl_ext.pas',
16 | cl_platform in '..\src\OpenCL\cl_platform.pas',
17 | Compute.Functions in '..\src\Compute.Functions.pas',
18 | Compute.OpenCL in '..\src\Compute.OpenCL.pas',
19 | Compute.OpenCL.Detail in '..\src\Compute.OpenCL.Detail.pas',
20 | Compute.Test in 'Compute.Test.pas',
21 | Compute in '..\src\Compute.pas',
22 | Compute.OpenCL.KernelGenerator in '..\src\Compute.OpenCL.KernelGenerator.pas',
23 | Compute.Future.Detail in '..\src\Compute.Future.Detail.pas',
24 | Compute.Detail in '..\src\Compute.Detail.pas';
25 |
26 | begin
27 | try
28 | RunDevTests;
29 | RunTests;
30 | except
31 | on E: Exception do
32 | Writeln(E.ClassName, ': ', E.Message);
33 | end;
34 | ReadLn;
35 | end.
36 |
--------------------------------------------------------------------------------
/tests/ComputeTests.groupproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {1E1D4C26-F82B-46FD-8A50-BA48C43739A4}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Default.Personality.12
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/Compute.Future.Detail.pas:
--------------------------------------------------------------------------------
1 | unit Compute.Future.Detail;
2 |
3 | interface
4 |
5 | uses
6 | Compute.OpenCL;
7 |
8 | type
9 | IFuture = interface
10 | function GetDone: boolean;
11 | function GetValue: T;
12 | function GetPeekValue: T;
13 | function GetEvent: CLEvent;
14 |
15 | procedure Wait;
16 |
17 | property Done: boolean read GetDone;
18 | property Value: T read GetValue;
19 | property PeekValue: T read GetPeekValue; // non-blocking, a hack but hey
20 | property Event: CLEvent read GetEvent;
21 | end;
22 |
23 | TReadyFutureImpl = class(TInterfacedObject, IFuture)
24 | strict private
25 | FValue: T;
26 | FEvent: CLEvent;
27 | public
28 | // Value must be reference type
29 | constructor Create(const Value: T);
30 |
31 | function GetDone: boolean;
32 | function GetValue: T;
33 | function GetPeekValue: T;
34 | function GetEvent: CLEvent;
35 |
36 | procedure Wait;
37 | end;
38 |
39 | TOpenCLFutureImpl = class(TInterfacedObject, IFuture)
40 | strict private
41 | FValue: T;
42 | FEvent: CLEvent;
43 | public
44 | // Value must be reference type
45 | constructor Create(const Event: CLEvent; const Value: T);
46 |
47 | function GetDone: boolean;
48 | function GetValue: T;
49 | function GetPeekValue: T;
50 | function GetEvent: CLEvent;
51 |
52 | procedure Wait;
53 |
54 | property Event: CLEvent read FEvent;
55 | end;
56 |
57 | implementation
58 |
59 | { TReadyFutureImpl }
60 |
61 | constructor TReadyFutureImpl.Create(const Value: T);
62 | begin
63 | inherited Create;
64 |
65 | FValue := Value;
66 | end;
67 |
68 | function TReadyFutureImpl.GetDone: boolean;
69 | begin
70 | result := True;
71 | end;
72 |
73 | function TReadyFutureImpl.GetEvent: CLEvent;
74 | begin
75 | result := nil;
76 | end;
77 |
78 | function TReadyFutureImpl.GetPeekValue: T;
79 | begin
80 | result := FValue;
81 | end;
82 |
83 | function TReadyFutureImpl.GetValue: T;
84 | begin
85 | result := FValue;
86 | end;
87 |
88 | procedure TReadyFutureImpl.Wait;
89 | begin
90 |
91 | end;
92 |
93 | { TOpenCLFutureImpl }
94 |
95 | constructor TOpenCLFutureImpl.Create(const Event: CLEvent; const Value: T);
96 | begin
97 | inherited Create;
98 |
99 | FEvent := Event;
100 | FValue := Value;
101 | end;
102 |
103 | function TOpenCLFutureImpl.GetDone: boolean;
104 | begin
105 | result := (Event.CommandExecutionStatus = ExecutionStatusComplete);
106 | end;
107 |
108 | function TOpenCLFutureImpl.GetEvent: CLEvent;
109 | begin
110 | result := Event;
111 | end;
112 |
113 | function TOpenCLFutureImpl.GetPeekValue: T;
114 | begin
115 | result := FValue;
116 | end;
117 |
118 | function TOpenCLFutureImpl.GetValue: T;
119 | var
120 | done: boolean;
121 | begin
122 | done := not GetDone();
123 | if (not done) then
124 | Wait();
125 |
126 | result := FValue;
127 | end;
128 |
129 | procedure TOpenCLFutureImpl.Wait;
130 | begin
131 | Event.Wait;
132 | end;
133 |
134 | end.
135 |
--------------------------------------------------------------------------------
/src/OpenCL/OpenCL.inc:
--------------------------------------------------------------------------------
1 | (********************************************)
2 | (* *)
3 | (* OpenCL1.2 and Delphi and Windows *)
4 | (* *)
5 | (* created by : Maksym Tymkovych *)
6 | (* (niello) *)
7 | (* *)
8 | (* headers versions: 0.07 *)
9 | (* file name : OpenCL.inc *)
10 | (* last modify : 10.12.11 *)
11 | (* license : BSD *)
12 | (* *)
13 | (* Site : www.niello.org.ua *)
14 | (* e-mail : muxamed13@ukr.net *)
15 | (* ICQ : 446-769-253 *)
16 | (* *)
17 | (*********Copyright (c) niello 2008-2011*****)
18 |
19 |
20 | {$IFDEF MSWINDOWS}
21 | {$DEFINE WINDOWS}
22 | {$ENDIF}
23 | {$IFDEF WINDOWS}
24 | {$IF DEFINED(WIN32) or DEFINED(WIN64)}
25 | {$DEFINE WINDESKTOP}
26 | {$ELSE}
27 | {$DEFINE WINMOBILE}
28 | {$IFEND}
29 | {$DEFINE STDCALL}
30 | {$ENDIF}
31 | {$IFDEF LINUX}
32 | {$DEFINE CDECL}
33 | {$ENDIF}
34 | {$IFDEF DARWIN}
35 | {$IF DEFINED(iPHONESIM) or (DEFINED(DARWIN) and DEFINED(CPUARM))}
36 | {$DEFINE iOS}
37 | {$ELSE}
38 | {$DEFINE MACOSX}
39 | {$IFEND}
40 | {$DEFINE CDECL}
41 | {$ENDIF}
42 |
43 |
44 | {$DEFINE USE_LOG} //Use default procedure Writeln()
45 |
46 | //{$DEFINE PURE_OPENCL_1_0}
47 | {$DEFINE PURE_OPENCL_1_1} //Actual now
48 | //{$DEFINE PURE_OPENCL_1_2}
49 | //{$DEFINE PURE_OPENCL_2_0} //TODO: work in progress
50 |
51 | //{$DEFINE WITH_DEPERCATED_OPENCL_1_1}
52 | //{$DEFINE WITH_DEPERCATED_OPENCL_1_2}
53 | //{$DEFINE WITH_DEPERCATED_OPENCL_2_0}
54 |
55 |
56 | //use Defines PURE_OPENCL_1_0 or PURE_OPENCL_1_1 or PURE_OPENCL_1_2
57 | // WITH_DEPERCATED_OPENCL_1_1 or WITH_DEPERCATED_OPENCL_1_2
58 | //{$DEFINE CL_VERSION_1_1}
59 | //{$DEFINE CL_VERSION_1_2} //wait drivers support
60 | //{$DEFINE CL_USE_DEPRECATED_OPENCL_1_0_APIS}
61 | //{$DEFINE CL_USE_DEPRECATED_OPENCL_1_1_APIS}
62 | //{$DEFINE CL_USE_DEPRECATED_OPENCL_1_2_APIS}
63 | //{$DEFINE CL_USE_DEPRECATED_OPENCL_2_0_APIS} //next OpenCL API version
64 |
65 | {$IFDEF PURE_OPENCL_1_0}
66 | {$DEFINE CL_VERSION_1_0}
67 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_0_APIS}
68 |
69 | {$UNDEF CL_VERSION_1_1}
70 | {$UNDEF CL_VERSION_1_2}
71 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_1_APIS}
72 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_2_APIS}
73 | {$UNDEF CL_USE_DEPRECATED_OPENCL_2_0_APIS}
74 | {$ENDIF}
75 |
76 | {$IFDEF PURE_OPENCL_1_1}
77 | {$DEFINE CL_VERSION_1_0}
78 | {$DEFINE CL_VERSION_1_1}
79 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_1_APIS}
80 |
81 | {$UNDEF CL_VERSION_1_2}
82 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_0_APIS}
83 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_2_APIS}
84 | {$UNDEF CL_USE_DEPRECATED_OPENCL_2_0_APIS}
85 | {$ENDIF}
86 |
87 | {$IFDEF PURE_OPENCL_1_2}
88 | {$DEFINE CL_VERSION_1_0}
89 | {$DEFINE CL_VERSION_1_1}
90 | {$DEFINE CL_VERSION_1_2}
91 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_2_APIS}
92 |
93 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_0_APIS}
94 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_1_APIS}
95 | {$UNDEF CL_USE_DEPRECATED_OPENCL_2_0_APIS}
96 | {$ENDIF}
97 |
98 | {$IFDEF PURE_OPENCL_2_0}
99 | {$DEFINE CL_VERSION_1_0}
100 | {$DEFINE CL_VERSION_1_1}
101 | {$DEFINE CL_VERSION_1_2}
102 | {$DEFINE CL_VERSION_2_0}
103 | {$DEFINE CL_USE_DEPRECATED_OPENCL_2_0_APIS}
104 |
105 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_0_APIS}
106 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_1_APIS}
107 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_2_APIS}
108 | {$ENDIF}
109 |
110 | {$IFDEF WITH_DEPERCATED_OPENCL_1_1}
111 | {$DEFINE CL_VERSION_1_0}
112 | {$DEFINE CL_VERSION_1_1}
113 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_1_APIS}
114 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_0_APIS}
115 |
116 | {$UNDEF CL_VERSION_1_2}
117 | {$UNDEF CL_VERSION_2_0}
118 | {$UNDEF CL_USE_DEPRECATED_OPENCL_1_2_APIS}
119 | {$UNDEF CL_USE_DEPRECATED_OPENCL_2_0_APIS}
120 | {$ENDIF}
121 |
122 |
123 | {$IFDEF WITH_DEPERCATED_OPENCL_1_2}
124 | {$DEFINE CL_VERSION_1_0}
125 | {$DEFINE CL_VERSION_1_1}
126 | {$DEFINE CL_VERSION_1_2}
127 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_1_APIS}
128 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_0_APIS}
129 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_2_APIS}
130 |
131 | {$UNDEF CL_VERSION_2_0}
132 | {$UNDEF CL_USE_DEPRECATED_OPENCL_2_0_APIS}
133 | {$ENDIF}
134 |
135 | {$IFDEF WITH_DEPERCATED_OPENCL_2_0}
136 | {$DEFINE CL_VERSION_1_0}
137 | {$DEFINE CL_VERSION_1_1}
138 | {$DEFINE CL_VERSION_1_2}
139 | {$DEFINE CL_VERSION_2_0}
140 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_1_APIS}
141 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_0_APIS}
142 | {$DEFINE CL_USE_DEPRECATED_OPENCL_1_2_APIS}
143 | {$DEFINE CL_USE_DEPRECATED_OPENCL_2_0_APIS}
144 | {$ENDIF}
145 |
146 |
147 |
148 | {$IFDEF FPC}
149 | {$MODE Delphi}
150 | {$ENDIF}
151 |
152 | {$IFNDEF FPC}
153 | {$IFDEF VER110}//Builder 3
154 | {$DEFINE DEFINE_8087CW_NOT_IMPLEMENTED}
155 | {$DEFINE DEFINE_UINT64_EQU_INT64}
156 | {$DEFINE DEFINE_REGION_NOT_IMPLEMENTED}
157 | {$ENDIF}
158 | {$IFDEF VER100}//Delphi3
159 | {$DEFINE DEFINE_8087CW_NOT_IMPLEMENTED}
160 | {$DEFINE DEFINE_UINT64_EQU_INT64}
161 | {$DEFINE DEFINE_REGION_NOT_IMPLEMENTED}
162 | {$ENDIF}
163 | {$IFDEF VER120}//Delphi 4
164 | {$DEFINE DEFINE_8087CW_NOT_IMPLEMENTED}
165 | {$DEFINE DEFINE_UINT64_EQU_INT64}
166 | {$DEFINE DEFINE_REGION_NOT_IMPLEMENTED}
167 | {$ENDIF}
168 | {$IFDEF VER130}//Delphi 5
169 | {$DEFINE DEFINE_UINT64_EQU_INT64}
170 | {$DEFINE DEFINE_UINT64_EQU_INT64}
171 | {$ENDIF}
172 | {$IFDEF VER140}//Delphi 6
173 | {$DEFINE DEFINE_UINT64_EQU_INT64}
174 | {$DEFINE DEFINE_REGION_NOT_IMPLEMENTED}
175 | {$ENDIF}
176 | {$IFDEF VER150}//Delphi 7
177 | {$DEFINE DEFINE_REGION_NOT_IMPLEMENTED}
178 | {$ENDIF}
179 | {$ENDIF}
180 |
181 |
182 |
183 |
184 |
185 |
--------------------------------------------------------------------------------
/tests/ComputeDevTest.dproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {97F70309-B745-405D-B558-C3027DDE0608}
4 | 15.4
5 | None
6 | ComputeDevTest.dpr
7 | True
8 | Release
9 | Win64
10 | 3
11 | Console
12 |
13 |
14 | true
15 |
16 |
17 | true
18 | Base
19 | true
20 |
21 |
22 | true
23 | Base
24 | true
25 |
26 |
27 | true
28 | Base
29 | true
30 |
31 |
32 | true
33 | Cfg_1
34 | true
35 | true
36 |
37 |
38 | true
39 | Base
40 | true
41 |
42 |
43 | true
44 | Cfg_2
45 | true
46 | true
47 |
48 |
49 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)
50 | None
51 | 1044
52 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=
53 | ComputeDevTest
54 | .\dcu\$(Platform)\$(Config)
55 | .\bin
56 | false
57 | false
58 | false
59 | false
60 | false
61 |
62 |
63 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)
64 | 1033
65 | CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=
66 | IndyIPClient;FireDACASADriver;FireDACSqliteDriver;bindcompfmx;FireDACDSDriver;DBXSqliteDriver;vcldbx;FireDACPgDriver;FireDACODBCDriver;RESTBackendComponents;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;inetdb;tethering;inetdbbde;DBXInterBaseDriver;DataSnapClient;DataSnapServer;DataSnapCommon;DBXOdbcDriver;vclFireDAC;DataSnapProviderClient;xmlrtl;DataSnapNativeClient;DBXSybaseASEDriver;DbxCommonDriver;svnui;vclimg;IndyProtocols;dbxcds;DBXMySQLDriver;DatasnapConnectorsFreePascal;FireDACCommonDriver;MetropolisUILiveTile;bindengine;vclactnband;vcldb;bindcompdbx;soaprtl;vcldsnap;bindcompvcl;vclie;fmxFireDAC;FireDACADSDriver;vcltouch;DBXDb2Driver;DBXOracleDriver;CustomIPTransport;vclribbon;VclSmp;FireDACMSSQLDriver;FireDAC;dsnap;DBXInformixDriver;fmxase;vcl;DataSnapConnectors;IndyCore;DataSnapServerMidas;DBXMSSQLDriver;IndyIPCommon;IndyIPServer;dsnapcon;FireDACIBDriver;DBXFirebirdDriver;inet;VCLRESTComponents;DataSnapFireDAC;fmxobj;CloudService;FireDACDBXDriver;FireDACMySQLDriver;soapmidas;vclx;soapserver;inetdbxpress;svn;DBXSybaseASADriver;dsnapxml;FireDACOracleDriver;FireDACInfxDriver;FireDACDb2Driver;fmxdae;RESTComponents;bdertl;FireDACMSAccDriver;dbexpress;DataSnapIndy10ServerTransport;adortl;$(DCC_UsePackage)
67 | true
68 |
69 |
70 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)
71 | 1033
72 | IndyIPClient;FireDACASADriver;FireDACSqliteDriver;bindcompfmx;FireDACDSDriver;DBXSqliteDriver;FireDACPgDriver;FireDACODBCDriver;RESTBackendComponents;fmx;rtl;dbrtl;DbxClientDriver;IndySystem;FireDACCommon;bindcomp;inetdb;tethering;DBXInterBaseDriver;DataSnapClient;DataSnapServer;DataSnapCommon;DBXOdbcDriver;vclFireDAC;DataSnapProviderClient;xmlrtl;DataSnapNativeClient;DBXSybaseASEDriver;DbxCommonDriver;vclimg;IndyProtocols;dbxcds;DBXMySQLDriver;DatasnapConnectorsFreePascal;FireDACCommonDriver;MetropolisUILiveTile;bindengine;vclactnband;vcldb;bindcompdbx;soaprtl;vcldsnap;bindcompvcl;vclie;fmxFireDAC;FireDACADSDriver;vcltouch;DBXDb2Driver;DBXOracleDriver;CustomIPTransport;vclribbon;VclSmp;FireDACMSSQLDriver;FireDAC;dsnap;DBXInformixDriver;fmxase;vcl;DataSnapConnectors;IndyCore;DataSnapServerMidas;DBXMSSQLDriver;IndyIPCommon;IndyIPServer;dsnapcon;FireDACIBDriver;DBXFirebirdDriver;inet;VCLRESTComponents;DataSnapFireDAC;fmxobj;CloudService;FireDACDBXDriver;FireDACMySQLDriver;soapmidas;vclx;soapserver;inetdbxpress;DBXSybaseASADriver;dsnapxml;FireDACOracleDriver;FireDACInfxDriver;FireDACDb2Driver;fmxdae;RESTComponents;FireDACMSAccDriver;dbexpress;DataSnapIndy10ServerTransport;adortl;$(DCC_UsePackage)
73 | true
74 |
75 |
76 | $(BDS)\bin\default_app.manifest
77 | off
78 | DEBUG;$(DCC_Define)
79 | false
80 | true
81 | true
82 | true
83 |
84 |
85 | 1033
86 | false
87 |
88 |
89 | true
90 | RELEASE;$(DCC_Define)
91 |
92 |
93 | 1033
94 |
95 |
96 |
97 | MainSource
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | Cfg_2
117 | Base
118 |
119 |
120 | Base
121 |
122 |
123 | Cfg_1
124 | Base
125 |
126 |
127 |
128 | Delphi.Personality.12
129 |
130 |
131 |
132 |
133 | ComputeDevTest.dpr
134 |
135 |
136 | Microsoft Office 2000 Sample Automation Server Wrapper Components
137 | Microsoft Office XP Sample Automation Server Wrapper Components
138 |
139 |
140 |
141 |
142 | True
143 | True
144 |
145 |
146 | 12
147 |
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/tests/Compute.Test.pas:
--------------------------------------------------------------------------------
1 | unit Compute.Test;
2 |
3 | interface
4 |
5 | procedure RunTests;
6 |
7 | implementation
8 |
9 | uses
10 | System.SysUtils,
11 | System.DateUtils,
12 | System.Math,
13 | Compute,
14 | Compute.Common,
15 | Compute.Functions,
16 | Compute.ExprTrees;
17 |
18 | function ReferenceTransform(const Input: TArray): TArray;
19 | var
20 | i: integer;
21 | x: double;
22 | begin
23 | SetLength(result, Length(input));
24 |
25 | for i := 0 to High(input) do
26 | begin
27 | x := input[i];
28 | result[i] := (1 / 256) * (((((46189 * x * x) - 109395) * x * x + 90090) * x * x - 30030) * x * x + 3465) * x * x - 63;
29 | end;
30 | end;
31 |
32 | function CompareOutputs(const data1, data2: TArray): boolean;
33 | var
34 | i: integer;
35 | err: double;
36 | begin
37 | result := True;
38 | for i := 0 to High(data1) do
39 | begin
40 | err := Abs(data1[i] - data2[i]);
41 | if (err > 1e-6) then
42 | begin
43 | Writeln(Format('%d val %.15g ref %.15g (error: %g)', [i, data1[i], data2[i], err]));
44 | result := False;
45 | exit;
46 | end;
47 | end;
48 | end;
49 |
50 | procedure AsyncTransformTest;
51 | var
52 | logger: TLogProc;
53 | st: TDateTime;
54 | i: integer;
55 | input, output, outputRef: TArray;
56 | f: Future>;
57 | P10: Expr;
58 | sqr: Expr.Func1;
59 | begin
60 | logger :=
61 | procedure(const msg: string)
62 | begin
63 | WriteLn(msg);
64 | end;
65 |
66 | // load OpenCL platform
67 | InitializeCompute(PreferCPUDevice, logger, logger);
68 |
69 |
70 | // initialize input
71 | SetLength(input, 20000000);
72 |
73 | // input values are in [-1, 1]
74 | for i := 0 to High(input) do
75 | input[i] := 2 * i / High(input) - 1;
76 |
77 |
78 | WriteLn('start compute');
79 | st := Now;
80 |
81 | sqr := Func.Sqr;
82 |
83 | // Legendre polynomial P_n(x) for n = 10
84 | P10 :=
85 | (1 / 256) *
86 | (((((46189 * sqr(_1)) - 109395) * sqr(_1) + 90090) * sqr(_1) - 30030) * sqr(_1) + 3465) * sqr(_1) - 63;
87 |
88 | // computes output[i] := P10(input[i])
89 | // by default it tries to select a GPU device
90 | // so this can run async while the CPU does other things
91 | f := Compute.AsyncTransform(input, P10);
92 |
93 | // wait for computations to finish
94 | f.Wait;
95 | // and get the result
96 | output := f.Value;
97 |
98 | WriteLn(Format('done compute, %.3f seconds', [MilliSecondsBetween(Now, st) / 1000]));
99 |
100 |
101 | WriteLn('start reference');
102 | st := Now;
103 |
104 | outputRef := ReferenceTransform(input);
105 |
106 | WriteLn(Format('done reference, %.3f seconds', [MilliSecondsBetween(Now, st) / 1000]));
107 |
108 | if CompareOutputs(output, outputRef) then
109 | WriteLn('data matches')
110 | else
111 | WriteLn('======== DATA DIFFERS ========');
112 | end;
113 |
114 | procedure AsyncTransformBufferTest;
115 | var
116 | st: TDateTime;
117 | i: integer;
118 | input, output, outputRef: TArray;
119 | inputBuf: Buffer;
120 | f: Future>;
121 | P10: Expr;
122 | sqr: Expr.Func1;
123 | begin
124 | // load OpenCL platform
125 | InitializeCompute;
126 |
127 |
128 | // initialize input
129 | SetLength(input, 200000000);
130 |
131 | // input values are in [-1, 1]
132 | for i := 0 to High(input) do
133 | input[i] := 2 * i / High(input) - 1;
134 |
135 |
136 | WriteLn('start compute');
137 | st := Now;
138 |
139 | sqr := Func.Sqr;
140 |
141 | // Legendre polynomial P_n(x) for n = 10
142 | P10 :=
143 | (1 / 256) *
144 | (((((46189 * sqr(_1)) - 109395) * sqr(_1) + 90090) * sqr(_1) - 30030) * sqr(_1) + 3465) * sqr(_1) - 63;
145 |
146 | // initialize buffer
147 | inputBuf := Buffer.Create(input);
148 |
149 | // computes output[i] := P10(input[i])
150 | // by default it tries to select a GPU device
151 | // so this can run async while the CPU does other things
152 | f := Compute.AsyncTransform(inputBuf, P10);
153 |
154 | // wait for computations to finish
155 | f.Wait;
156 | // and get the result
157 | output := f.Value.ToArray();
158 |
159 | WriteLn(Format('done compute, %.3f seconds', [MilliSecondsBetween(Now, st) / 1000]));
160 |
161 |
162 | WriteLn('start reference');
163 | st := Now;
164 |
165 | outputRef := ReferenceTransform(input);
166 |
167 | WriteLn(Format('done reference, %.3f seconds', [MilliSecondsBetween(Now, st) / 1000]));
168 |
169 | if CompareOutputs(output, outputRef) then
170 | WriteLn('data matches')
171 | else
172 | WriteLn('======== DATA DIFFERS ========');
173 | end;
174 |
175 | procedure OutputData(const Filename: string; const radius, mass, rho: TArray);
176 | var
177 | i: integer;
178 | f: TextFile;
179 | begin
180 | Assign(f, Filename);
181 | Rewrite(f);
182 | WriteLn(f, 'r'#9'm'#9'rho');
183 | for i := 0 to High(radius) do
184 | WriteLn(f, Format('%.15g'#9'%.15g'#9'%.15g', [radius[i], mass[i], rho[i]]));
185 | CloseFile(f);
186 | end;
187 |
188 | function gamma_ref(const rho: double): double; inline;
189 | var
190 | x2: double;
191 | begin
192 | x2 := Power(rho, 2.0 / 3.0);
193 | result := x2 / (3 * sqrt(1 + x2));
194 | end;
195 |
196 | procedure dydx_ref(const x: double; const y0, y1: double; out dy0dx, dy1dx: double);
197 | var
198 | rho: double;
199 | x2: double;
200 | begin
201 | x2 := x * x;
202 | rho := Max(1e-9, y1);
203 |
204 | dy0dx := x2 * rho; // dm/dr
205 | dy1dx := -(y0 * rho) / (gamma_ref(rho) * x2); // drho/dr
206 | end;
207 |
208 | procedure euler_ref(const h, y0, dydx: double; out y: double); inline;
209 | begin
210 | y := y0 + h * dydx;
211 | end;
212 |
213 | procedure ODEReference(const N: integer; const r0, h: double; out radius, mass, rho: TArray);
214 | var
215 | i, j: integer;
216 | x, r, rho_c: double;
217 | dy0dx, dy1dx: double;
218 | y0t, y1t: double;
219 | y0, y1: TArray;
220 | done: boolean;
221 | st, ft: double;
222 | begin
223 | WriteLn;
224 | WriteLn('Computing reference');
225 |
226 | radius := nil;
227 | SetLength(radius, N);
228 | mass := nil;
229 | SetLength(mass, N);
230 | rho := nil;
231 | SetLength(rho, N);
232 |
233 | y0 := mass;
234 | y1 := rho;
235 |
236 | // initialize
237 | x := r0;
238 | for i := 0 to N-1 do
239 | begin
240 | rho_c := Power(10, -1 + 7 * (i / (N-1)));
241 | r := r0;
242 |
243 | y0[i] := rho_c * r*r*r / 3;
244 | y1[i] := (gamma_ref(rho_c)*rho_c)/(gamma_ref(rho_c) + r*r*rho_c/3);
245 | end;
246 |
247 | st := Now;
248 |
249 | j := 0;
250 | done := False;
251 | while not done do
252 | begin
253 | done := True;
254 |
255 | for i := 0 to N-1 do
256 | begin
257 | if (radius[i] > 0) then
258 | continue;
259 |
260 | dydx_ref(x, y0[i], y1[i], dy0dx, dy1dx);
261 |
262 | euler_ref(h, y0[i], dy0dx, y0t);
263 | y0[i] := y0t;
264 | euler_ref(h, y1[i], dy1dx, y1t);
265 |
266 | if (y1[i] > 1e-9) and (y1t <= 1e-9) then
267 | begin
268 | radius[i] := x;
269 | end;
270 |
271 | y1[i] := y1t;
272 |
273 | done := done and (y1t <= 1e-9);
274 | end;
275 | x := x + h;
276 | j := j + 1;
277 | end;
278 |
279 | ft := Now;
280 |
281 | WriteLn(Format('Done, steps: %d, time: %.3fs', [j, MilliSecondsBetween(ft, st) / 1000]));
282 | end;
283 |
284 | procedure ODETest;
285 | const
286 | N = 100000;
287 | r0 = 1e-9;
288 | h = 1e-4;
289 | var
290 | logger: TLogProc;
291 | sqr: Expr.Func1;
292 | ifthen: Expr.Func3;
293 | gamma, gamma_x2, get_rho: Expr.Func1;
294 | euler: Expr.Func2;
295 | dy0dx, dy1dx: Expr.Func3;
296 | rho_c: TArray;
297 | i: integer;
298 | max_rho: double;
299 | // state
300 | x: Future>; // r
301 | xt: Future>;
302 | y0, dy0: Future>; // m
303 | y0t: Future>; // temp
304 | y1, dy1: Future>; // rho
305 | y1t: Future>; // temp
306 |
307 | radius, mass, rho: TArray;
308 |
309 | st, ft: double;
310 | begin
311 | logger :=
312 | procedure(const msg: string)
313 | begin
314 | WriteLn(msg);
315 | end;
316 |
317 | // load OpenCL platform
318 | InitializeCompute(PreferCPUDevice, logger, logger);
319 |
320 | sqr := Func.Sqr;
321 | ifthen := Func.IfThen;
322 |
323 | // euler integration step
324 | // _1 = y
325 | // _2 = dydx
326 | euler := Func2('euler', _1 + h * _2);
327 |
328 | // gamma function
329 | gamma_x2 := Func1('gamma_x2', _1 / (3 * Func.Sqrt(1 + _1)));
330 | gamma := Func1('gamma', gamma_x2(Func.Pow(_1, 2.0 / 3.0)));
331 |
332 | // helper
333 | get_rho := Func1('get_rho', Func.Max(1e-9, _1));
334 |
335 | // derivative functions
336 | // _1 = x
337 | // _2 = y0
338 | // _3 = y1
339 | dy0dx := Func3('dy0dx', sqr(_1) * get_rho(_3)); // dm/dr
340 | dy1dx := Func3('dy1dx', -(_2 * get_rho(_3)) / (gamma(get_rho(_3)) * sqr(_1))); // drho/dr
341 |
342 | SetLength(rho_c, N);
343 |
344 | // vary central density \rho_c from 10^-1 to 10^6
345 | for i := 0 to N-1 do
346 | begin
347 | rho_c[i] := Power(10, -1 + 7 * (i / (N-1)));
348 | end;
349 |
350 | // initialize x
351 | x := Buffer.Create(N);
352 |
353 | // simply fill with r0
354 | x := AsyncTransform(x, x, r0);
355 |
356 | // compute initial state from rho_c
357 | y0 := Buffer.Create(rho_c);
358 | y1 := Buffer.Create(rho_c);
359 |
360 | // temporary buffers
361 | xt := Buffer.Create(N);
362 | dy0 := Buffer.Create(N);
363 | y0t := Buffer.Create(N);
364 | dy1 := Buffer.Create(N);
365 | y1t := Buffer.Create(N);
366 |
367 | // y0 = rho_c * r*r*r / 3;
368 | y0 := AsyncTransform(y0, y0, _1 * r0 * r0 * r0 / 3);
369 | // y1 = (gamma(rho_c) * rho_c) / (gamma(rho_c) + r*r * rho_c / 3)
370 | y1 := AsyncTransform(y1, y1, (gamma(_1) * _1) / (gamma(_1) + r0 * r0 * _1 / 3));
371 |
372 | st := Now;
373 |
374 | i := 1;
375 | while True do
376 | begin
377 | // get derivatives
378 | dy0 := AsyncTransform(x, y0, y1, dy0, dy0dx(_1, _2, _3));
379 | dy1 := AsyncTransform(x, y0, y1, dy1, dy1dx(_1, _2, _3));
380 |
381 | // integration step
382 | y0t := AsyncTransform(y0, y1, dy0, y0t, ifthen(_2 < 1e-9, _1, euler(_1, _3))); // y0t = y0 + h*dy0dx
383 | y1t := AsyncTransform(y0, y1, dy1, y1t, ifthen(_2 < 1e-9, _2, euler(_2, _3))); // y1t = y1 + h*dy1dx
384 | xt := AsyncTransform(x, y1, xt, ifthen(_2 < 1e-9, _1, _1 + h));
385 |
386 | // y0t holds new values and y0 is ready
387 | // so swap them for next round
388 | y0t.SwapWith(y0);
389 | y1t.SwapWith(y1);
390 | xt.SwapWith(x);
391 |
392 | // every 1000 steps, check if we're done
393 | if (i mod 1000 = 0) then
394 | begin
395 | WriteLn('step: ', i);
396 |
397 | rho := y1.Value.ToArray();
398 | max_rho := Functional.Reduce(rho,
399 | function(const v1, v2: double): double
400 | begin
401 | result := Max(v1, v2);
402 | end);
403 |
404 | if (max_rho <= 1e-9) then
405 | break;
406 | end;
407 | i := i + 1;
408 | end;
409 |
410 | ft := Now;
411 |
412 | WriteLn(Format('Done, steps: %d, time: %.3fs', [i, MilliSecondsBetween(ft, st) / 1000]));
413 |
414 | radius := x.Value.ToArray();
415 | mass := y0.Value.ToArray();
416 | rho := y1.Value.ToArray();
417 | OutputData('data.txt', radius, mass, rho);
418 |
419 | ODEReference(N, r0, h, radius, mass, rho);
420 | OutputData('data_ref.txt', radius, mass, rho);
421 | end;
422 |
423 | procedure RunTests;
424 | begin
425 | AsyncTransformTest;
426 | // AsyncTransformBufferTest;
427 | // ODETest;
428 | end;
429 |
430 | end.
431 |
--------------------------------------------------------------------------------
/src/OpenCL/cl_platform.pas:
--------------------------------------------------------------------------------
1 | (*******************************************************************************
2 | * Copyright (c) 2008-2010 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | ******************************************************************************)
23 | (********************************************)
24 | (* *)
25 | (* OpenCL1.2 and Delphi and Windows *)
26 | (* *)
27 | (* created by : Maksym Tymkovych *)
28 | (* (niello) *)
29 | (* *)
30 | (* headers versions: 0.07 *)
31 | (* file name : cl_platform.pas *)
32 | (* last modify : 10.12.11 *)
33 | (* license : BSD *)
34 | (* *)
35 | (* Site : www.niello.org.ua *)
36 | (* e-mail : muxamed13@ukr.net *)
37 | (* ICQ : 446-769-253 *)
38 | (* *)
39 | (*********Copyright (c) niello 2008-2011*****)
40 |
41 | //Fixed By Dmitry Belkevich
42 | //Site www.makhaon.com
43 | //E-mail dmitry@makhaon.com
44 | //(c) 2009
45 | //Beta release 1.0
46 |
47 | unit cl_platform;
48 |
49 | interface
50 |
51 | (*
52 | Delphi 6 and down don't support UInt64;
53 | *)
54 |
55 | {$INCLUDE 'OpenCL.inc'}
56 |
57 | type
58 | PCL_char = ^TCL_char;
59 | TCL_char = Shortint;//-127..+128;
60 |
61 | PCL_uchar = ^TCL_uchar;
62 | TCL_uchar = Byte;//0..255;
63 |
64 | PCL_short = ^TCL_short;
65 | TCL_short = Smallint;//- 32767..+32768;
66 |
67 | PCL_ushort = ^TCL_ushort;
68 | TCL_ushort = Word;//0..+65535;
69 |
70 | PCL_int = ^TCL_int;
71 | TCL_int = Longint;//-2147483647..+2147483648;
72 |
73 | PCL_uint = ^TCL_uint;
74 | TCL_uint = Longword;//0..4294967295;
75 |
76 | PCL_long = ^TCL_long;
77 | TCL_long = Int64;
78 |
79 | PCL_ulong = ^TCL_ulong;
80 | //The error is found by Andrew Terekhov
81 | TCL_ulong = {$IFDEF DEFINE_UINT64_EQU_INT64} Int64;{$ELSE} UInt64;{$ENDIF}
82 |
83 | PCL_half = ^TCL_half;
84 | TCL_half = TCL_ushort;
85 |
86 | PCL_float = ^TCL_float;
87 | TCL_float = Single;
88 |
89 | PCL_double = ^TCL_double;
90 | TCL_double = Double;
91 |
92 | PCL_half2 = ^TCL_half2;
93 | TCL_half2 = record
94 | i16 : Array [0..1]of TCL_half;
95 | end;
96 |
97 | PCL_half4 = ^TCL_half4;
98 | TCL_half4 = record
99 | i16 : Array [0..3]of TCL_half;
100 | end;
101 |
102 | PCL_half8 = ^TCL_half8;
103 | TCL_half8 = record
104 | i16 : Array [0..7]of TCL_half;
105 | end;
106 |
107 | PCL_half16 = ^TCL_half16;
108 | TCL_half16 = record
109 | i16 : Array [0..15]of TCL_half;
110 | end;
111 |
112 | PCL_char2 = ^TCL_char2;
113 | TCL_char2 = record
114 | i8 : Array [0..1]of TCL_char;
115 | end;
116 |
117 | PCL_char4 = ^TCL_char4;
118 | TCL_char4 = record
119 | i8 : Array [0..3]of TCL_char;
120 | end;
121 |
122 | PCL_char8 = ^TCL_char8;
123 | TCL_char8 = record
124 | i8 : Array [0..7]of TCL_char;
125 | end;
126 |
127 | PCL_char16 = ^TCL_char16;
128 | TCL_char16 = record
129 | i8 : Array [0..15]of TCL_char;
130 | end;
131 |
132 | PCL_uchar2 = ^TCL_uchar2;
133 | TCL_uchar2 = record
134 | u8 : Array [0..1]of TCL_uchar;
135 | end;
136 |
137 | PCL_uchar4 = ^TCL_uchar4;
138 | TCL_uchar4 = record
139 | u8 : Array [0..3]of TCL_uchar;
140 | end;
141 |
142 | PCL_uchar8 = ^TCL_uchar8;
143 | TCL_uchar8 = record
144 | u8 : Array [0..7]of TCL_uchar;
145 | end;
146 |
147 | PCL_uchar16 = ^TCL_uchar16;
148 | TCL_uchar16 = record
149 | u8 : Array [0..15]of TCL_uchar;
150 | end;
151 |
152 | PCL_short2 = ^TCL_short2;
153 | TCL_short2 = record
154 | i16 : Array [0..1]of TCL_short;
155 | end;
156 |
157 | PCL_short4 = ^TCL_short4;
158 | TCL_short4 = record
159 | i16 : Array [0..3]of TCL_short;
160 | end;
161 |
162 | PCL_short8 = ^TCL_short8;
163 | TCL_short8 = record
164 | i16 : Array [0..7]of TCL_short;
165 | end;
166 |
167 | PCL_short16 = ^TCL_short16;
168 | TCL_short16 = record
169 | i16 : Array [0..15]of TCL_short;
170 | end;
171 |
172 | PCL_ushort2 = ^TCL_ushort2;
173 | TCL_ushort2 = record
174 | u16 : Array [0..1]of TCL_ushort;
175 | end;
176 |
177 | PCL_ushort4 = ^TCL_ushort4;
178 | TCL_ushort4 = record
179 | u16 : Array [0..3]of TCL_ushort;
180 | end;
181 |
182 | PCL_ushort8 = ^TCL_ushort8;
183 | TCL_ushort8 = record
184 | u16 : Array [0..7]of TCL_ushort;
185 | end;
186 |
187 | PCL_ushort16 = ^TCL_ushort16;
188 | TCL_ushort16 = record
189 | u16 : Array [0..15]of TCL_ushort;
190 | end;
191 |
192 | PCL_int2 = ^TCL_int2;
193 | TCL_int2 = record
194 | i32 : Array [0..1]of TCL_int;
195 | end;
196 |
197 | PCL_int4 = ^TCL_int4;
198 | TCL_int4 = record
199 | i32 : Array [0..3]of TCL_int;
200 | end;
201 |
202 | PCL_int8 = ^TCL_int8;
203 | TCL_int8 = record
204 | i32 : Array [0..7]of TCL_int;
205 | end;
206 |
207 | PCL_int16 = ^TCL_int16;
208 | TCL_int16 = record
209 | i32 : Array [0..15]of TCL_int;
210 | end;
211 |
212 | PCL_uint2 = ^TCL_uint2;
213 | TCL_uint2 = record
214 | u32 : Array [0..1]of TCL_uint;
215 | end;
216 |
217 | PCL_uint4 = ^TCL_uint4;
218 | TCL_uint4 = record
219 | u32 : Array [0..3]of TCL_uint;
220 | end;
221 |
222 | PCL_uint8 = ^TCL_uint8;
223 | TCL_uint8 = record
224 | u32 : Array [0..7]of TCL_uint;
225 | end;
226 |
227 | PCL_uint16 = ^TCL_uint16;
228 | TCL_uint16 = record
229 | u32 : Array [0..15]of TCL_uint;
230 | end;
231 |
232 | PCL_long2 = ^TCL_long2;
233 | TCL_long2 = record
234 | i64 : Array [0..1]of TCL_long;
235 | end;
236 |
237 | PCL_long4 = ^TCL_long4;
238 | TCL_long4 = record
239 | i64 : Array [0..3]of TCL_long;
240 | end;
241 |
242 | PCL_long8 = ^TCL_long8;
243 | TCL_long8 = record
244 | i64 : Array [0..7]of TCL_long;
245 | end;
246 |
247 | PCL_long16 = ^TCL_long16;
248 | TCL_long16 = record
249 | i64 : Array [0..15]of TCL_long;
250 | end;
251 |
252 | PCL_ulong2 = ^TCL_ulong2;
253 | TCL_ulong2 = record
254 | u64 : Array [0..1]of TCL_ulong;
255 | end;
256 |
257 | PCL_ulong4 = ^TCL_ulong4;
258 | TCL_ulong4 = record
259 | u64 : Array [0..3]of TCL_ulong;
260 | end;
261 |
262 | PCL_ulong8 = ^TCL_ulong8;
263 | TCL_ulong8 = record
264 | u64 : Array [0..7]of TCL_ulong;
265 | end;
266 |
267 | PCL_ulong16 = ^TCL_ulong16;
268 | TCL_ulong16 = record
269 | u64 : Array [0..15]of TCL_ulong;
270 | end;
271 |
272 | PCL_float2 = ^TCL_float2;
273 | TCL_float2 = record
274 | f32 : Array [0..1]of TCL_float;
275 | end;
276 |
277 | PCL_float4 = ^TCL_float4;
278 | TCL_float4 = record
279 | f32 : Array [0..3]of TCL_float;
280 | end;
281 |
282 | PCL_float8 = ^TCL_float8;
283 | TCL_float8 = record
284 | f32 : Array [0..7]of TCL_float;
285 | end;
286 |
287 | PCL_float16 = ^TCL_float16;
288 | TCL_float16 = record
289 | f32 : Array [0..15]of TCL_float;
290 | end;
291 |
292 | PCL_double2 = ^TCL_double2;
293 | TCL_double2 = record
294 | f64 : Array [0..1]of TCL_double;
295 | end;
296 |
297 | PCL_double4 = ^TCL_double4;
298 | TCL_double4 = record
299 | f64 : Array [0..3]of TCL_double;
300 | end;
301 |
302 | PCL_double8 = ^TCL_double8;
303 | TCL_double8 = record
304 | f64 : Array [0..7]of TCL_double;
305 | end;
306 |
307 | PCL_double16 = ^TCL_double16;
308 | TCL_double16 = record
309 | f64 : Array [0..15]of TCL_double;
310 | end;
311 |
312 | const
313 | CL_CHAR_BIT = 8;
314 | CL_SCHAR_MAX = 127;
315 | CL_SCHAR_MIN = (-127-1);
316 | CL_CHAR_MAX = CL_SCHAR_MAX;
317 | CL_CHAR_MIN = CL_SCHAR_MIN;
318 | CL_UCHAR_MAX = 255;
319 | CL_SHRT_MAX = 32767;
320 | CL_SHRT_MIN = (-32767-1);
321 | CL_USHRT_MAX = 65535;
322 | CL_INT_MAX = 2147483647;
323 | CL_INT_MIN = (-2147483647-1);
324 | CL_UINT_MAX = $ffffffff;
325 | CL_LONG_MAX = TCL_long ($7FFFFFFFFFFFFFFF);
326 | CL_LONG_MIN = TCL_long (-$7FFFFFFFFFFFFFFF) - 1;
327 | CL_ULONG_MAX = TCL_ulong($FFFFFFFFFFFFFFFF);
328 |
329 | CL_FLT_DIG = 6;
330 | CL_FLT_MANT_DIG = 24;
331 | CL_FLT_MAX_10_EXP = +38;
332 | CL_FLT_MAX_EXP = +128;
333 | CL_FLT_MIN_10_EXP = -37;
334 | CL_FLT_MIN_EXP = -125;
335 | CL_FLT_RADIX = 2;
336 | CL_FLT_MAX = 340282346638528859811704183484516925440.0;
337 | CL_FLT_MIN = 1.175494350822287507969e-38;
338 | //CL_FLT_EPSILON = 0x1.0p-23f;
339 |
340 | CL_DBL_DIG = 15;
341 | CL_DBL_MANT_DIG = 53;
342 | CL_DBL_MAX_10_EXP = +308;
343 | CL_DBL_MAX_EXP = +1024;
344 | CL_DBL_MIN_10_EXP = -307;
345 | CL_DBL_MIN_EXP = -1021;
346 | CL_DBL_RADIX = 2;
347 | CL_DBL_MAX = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0;
348 | CL_DBL_MIN = 2.225073858507201383090e-308;
349 | CL_DBL_EPSILON = 2.220446049250313080847e-16;
350 |
351 | CL_M_E = 2.718281828459045090796;
352 | CL_M_LOG2E = 1.442695040888963387005;
353 | CL_M_LOG10E = 0.434294481903251816668;
354 | CL_M_LN2 = 0.693147180559945286227;
355 | CL_M_LN10 = 2.302585092994045901094;
356 | CL_M_PI = 3.141592653589793115998;
357 | CL_M_PI_2 = 1.570796326794896557999;
358 | CL_M_PI_4 = 0.785398163397448278999;
359 | CL_M_1_PI = 0.318309886183790691216;
360 | CL_M_2_PI = 0.636619772367581382433;
361 | CL_M_2_SQRTPI = 1.128379167095512558561;
362 | CL_M_SQRT2 = 1.414213562373095145475;
363 | CL_M_SQRT1_2 = 0.707106781186547572737;
364 |
365 | CL_M_E_F = 2.71828174591064;
366 | CL_M_LOG2E_F = 1.44269502162933;
367 | CL_M_LOG10E_F = 0.43429449200630;
368 | CL_M_LN2_F = 0.69314718246460;
369 | CL_M_LN10_F = 2.30258512496948;
370 | CL_M_PI_F = 3.14159274101257;
371 | CL_M_PI_2_F = 1.57079637050629;
372 | CL_M_PI_4_F = 0.78539818525314;
373 | CL_M_1_PI_F = 0.31830987334251;
374 | CL_M_2_PI_F = 0.63661974668503;
375 | CL_M_2_SQRTPI_F = 1.12837922573090;
376 | CL_M_SQRT2_F = 1.41421353816986;
377 | CL_M_SQRT1_2_F = 0.70710676908493;
378 |
379 |
380 | CL_HUGE_VALF : TCL_float = 1e50;
381 | CL_HUGE_VAL : TCL_double = 1e500;
382 | CL_MAXFLOAT = CL_FLT_MAX;
383 | CL_INFINITY : TCL_float = 1e50; //CL_HUGE_VALF
384 | CL_NAN = 0/0;//(CL_INFINITY - CL_INFINITY);
385 |
386 | implementation
387 |
388 | end.
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/src/OpenCL/cl_ext.pas:
--------------------------------------------------------------------------------
1 | (*******************************************************************************
2 | * Copyright (c) 2008-2010 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | ******************************************************************************)
23 | (************************************************)
24 | (* *)
25 | (* OpenCL1.2 and Delphi and Windows *)
26 | (* *)
27 | (* created by : Maksym Tymkovych *)
28 | (* (niello) *)
29 | (* *)
30 | (* headers versions: 0.07 *)
31 | (* file name : CL_ext.pas *)
32 | (* last modify : 10.12.11 *)
33 | (* license : BSD *)
34 | (* *)
35 | (* Site : www.niello.org.ua *)
36 | (* e-mail : muxamed13@ukr.net *)
37 | (* ICQ : 446-769-253 *)
38 | (* *)
39 | (* updated by : Alexander Kiselev *)
40 | (* (Igroman) *)
41 | (* Site : http://Igroman14.livejournal.com *)
42 | (* e-mail : Igroman14@yandex.ru *)
43 | (* ICQ : 207-381-695 *)
44 | (* (c) 2010 *)
45 | (* *)
46 | (***********Copyright (c) niello 2008-2011*******)
47 |
48 | (* cl_ext.h contains OpenCL extensions which don't have external *)
49 | (* (OpenGL, D3D) dependencies. *)
50 |
51 | unit cl_ext;
52 |
53 | interface
54 |
55 | {$INCLUDE OpenCL.inc}
56 |
57 | uses
58 | cl,
59 | cl_platform;
60 |
61 | const
62 | (* cl_khr_fp64 extension - no extension #define since it has no functions *)
63 | CL_DEVICE_DOUBLE_FP_CONFIG = $1032;
64 |
65 |
66 | (* cl_khr_fp16 extension - no extension #define since it has no functions *)
67 | CL_DEVICE_HALF_FP_CONFIG = $1033;
68 |
69 |
70 | (* Memory object destruction
71 | *
72 | * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
73 | *
74 | * Registers a user callback function that will be called when the memory object is deleted and its resources
75 | * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
76 | * stack associated with memobj. The registered user callback functions are called in the reverse order in
77 | * which they were registered. The user callback functions are called and then the memory object is deleted
78 | * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
79 | * notified when the memory referenced by host_ptr, specified when the memory object is created and used as
80 | * the storage bits for the memory object, can be reused or freed.
81 | *
82 | * The application may not call CL api's with the cl_mem object passed to the pfn_notify.
83 | *
84 | * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
85 | * before using.
86 | *)
87 | const
88 | cl_APPLE_SetMemObjectDestructor = 1;
89 | {$IFDEF CL_VERSION_1_0}
90 | type
91 | TclSetMemObjectDestructorAPPLE = function(
92 | memobj: Tcl_mem; (* memobj *)
93 | pfn_notify: Pointer;(* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/*)
94 | user_data: Pointer(*user_data *)
95 | ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
96 |
97 | var
98 | clSetMemObjectDestructorAPPLE: TclSetMemObjectDestructorAPPLE;
99 | {$ENDIF}
100 |
101 | (* Context Logging Functions
102 | *
103 | * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
104 | * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
105 | * before using.
106 | *
107 | * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
108 | *)
109 | const
110 | cl_APPLE_ContextLoggingFunctions = 1;
111 | {$IFDEF CL_VERSION_1_0}
112 | type
113 | TclLogMessagesToSystemLogAPPLE = function(
114 | const errstr: PAnsiChar; (* errstr *)
115 | const private_info: Pointer; (* private_info *)
116 | cb: TSize_t; (* cb *)
117 | user_data: Pointer (* user_data *)
118 | ): TCL_int;
119 | {$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
120 |
121 | (* clLogMessagesToStdout sends all log messages to the file descriptor stdout *)
122 | TclLogMessagesToStdoutAPPLE = function(
123 | const errstr: PAnsiChar; (* errstr *)
124 | const private_info: Pointer; (* private_info *)
125 | cb: TSize_t; (* cb *)
126 | user_data: Pointer (* user_data *)
127 | ): TCL_int;
128 | {$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
129 |
130 | (* clLogMessagesToStderr sends all log messages to the file descriptor stderr *)
131 | TclLogMessagesToStderrAPPLE = function(
132 | const errstr: PAnsiChar; (* errstr *)
133 | const private_info: Pointer; (* private_info *)
134 | cb: TSize_t; (* cb *)
135 | user_data: Pointer (* user_data *)
136 | ): TCL_int;
137 | {$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
138 |
139 | var
140 | clLogMessagesToSystemLogAPPLE: TclLogMessagesToSystemLogAPPLE;
141 | clLogMessagesToStdoutAPPLE: TclLogMessagesToStdoutAPPLE;
142 | clLogMessagesToStderrAPPLE: TclLogMessagesToStderrAPPLE;
143 | {$ENDIF}
144 |
145 | const
146 | (* cl_khr_icd extension *)
147 | cl_khr_icd = 1;
148 |
149 | (* cl_platform_info *)
150 | (*
151 | Accepted as to the function clGetPlatformInfo
152 | *)
153 | CL_PLATFORM_ICD_SUFFIX_KHR = $0920;
154 |
155 | (* Additional Error Codes *)
156 | (*
157 | Returned by clGetPlatformIDs when no platforms are found
158 | *)
159 | CL_PLATFORM_NOT_FOUND_KHR = -1001;
160 |
161 | type
162 | TclIcdGetPlatformIDsKHR = function (
163 | num_entries: Tcl_uint; (* num_entries *)
164 | platforms: Pcl_platform_id; (* platforms *)
165 | num_platforms: Pcl_uint (* num_platforms *)
166 | ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};// external OpenCL;
167 |
168 |
169 | var
170 | clIcdGetPlatformIDsKHR: TclIcdGetPlatformIDsKHR;
171 |
172 | (******************************************
173 | * cl_nv_device_attribute_query extension *
174 | ******************************************)
175 | (* cl_nv_device_attribute_query extension - no extension #define since it has no functions *)
176 | const
177 | CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = $4000;
178 | CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV = $4001;
179 | CL_DEVICE_REGISTERS_PER_BLOCK_NV = $4002;
180 | CL_DEVICE_WARP_SIZE_NV = $4003;
181 | CL_DEVICE_GPU_OVERLAP_NV = $4004;
182 | CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV = $4005;
183 | CL_DEVICE_INTEGRATED_MEMORY_NV = $4006;
184 |
185 |
186 | (*********************************
187 | * cl_amd_device_attribute_query *
188 | *********************************)
189 | const
190 | (*
191 | Accepted as the parameter of clGetDeviceInfo. Return the
192 | offset in nano-seconds between an event timestamp and Epoch.
193 | *)
194 | CL_DEVICE_PROFILING_TIMER_OFFSET_AMD = $4036;
195 |
196 | {$IFDEF CL_VERSION_1_1}
197 | (***********************************
198 | * cl_ext_device_fission extension *
199 | ***********************************)
200 | const
201 | cl_ext_device_fission = 1;
202 |
203 | type
204 | (*
205 | clReleaseDeviceEXT decrements the reference count. After the
206 | reference count reaches zero, the object shall be destroyed and associated
207 | resources released for reuse by the system.
208 |
209 | clReleaseDeviceEXT returns CL_SUCCESS if the function is executed
210 | successfully or the device is a root level device. It returns
211 | CL_INVALID_DEVICE if the is not a valid device.
212 | *)
213 | TclReleaseDeviceEXT = function( device: TCL_device_id (*device*) ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
214 | var
215 | clReleaseDeviceEXT: TclReleaseDeviceEXT;
216 | (*
217 | clReleaseDeviceEXT returns CL_SUCCESS if the function is executed
218 | successfully or the device is a root level device. It returns
219 | CL_INVALID_DEVICE if the is not a valid device.
220 |
221 | CAUTION: Since root level devices are generally returned by a clGet call
222 | (clGetDeviceIDs) and not a clCreate call, the user generally does not own a
223 | reference count for root level devices. The reference count attached to a
224 | device retured from clGetDeviceIDs is owned by the implementation.
225 | Developers need to be careful when releasing cl_device_ids to always balance
226 | clCreateSubDevicesEXT or clRetainDeviceEXT with each call to
227 | clReleaseDeviceEXT for the device. By convention, software layers that own
228 | a reference count should be themselves responsible for releasing it.
229 | *)
230 | type
231 | TclRetainDeviceEXT = function( device: TCL_device_id (*device*) ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
232 |
233 | var
234 | clRetainDeviceEXT: TclRetainDeviceEXT;
235 | type
236 | Pcl_device_partition_property_ext = ^Tcl_device_partition_property_ext;
237 | Tcl_device_partition_property_ext = Tcl_ulong; //?typedef cl_bitfield cl_device_partition_property_ext;
238 |
239 | (*
240 | lCreateSubDevicesEXT creates an array of sub-devices that each reference a
241 | nonintersecting set of compute units within , according to a
242 | partition scheme given by the list. The
243 | output sub-devices may be used in every way that the root device can be
244 | used, including building programs, further calls to clCreateSubDevicesEXT
245 | and creating command queues. They may also be used within any context
246 | created using the in_device or parent/ancestor thereof. When a command
247 | queue is created against a sub-device, the commands enqueued on that queue
248 | are executed only on the sub-device.
249 |
250 | in_device - The device to be partitioned
251 |
252 | num_entries - The number of cl_device_ids that will fit in the array pointed
253 | to by . If is not NULL, must be
254 | greater than zero.
255 |
256 | out_devices - On output, the array pointed to by will contain
257 | up to sub-devices. If the argument is NULL,
258 | it is ignored. The number of cl_device_ids returned is the minimum of
259 | and the number of devices created by the partition scheme.
260 |
261 | num_devices - On output, the number of devices that the may be
262 | partitioned in to according to the partitioning scheme given by
263 | . If num_devices is NULL, it is ignored.
264 |
265 | properties - A zero terminated list of device fission {property-value,
266 | cl_int[]} pairs that describe how to partition the device into
267 | sub-devices. may not be NULL. Only one of
268 | CL_DEVICE_PARTITION_EQUALLY_EXT, CL_DEVICE_PARTITION_BY_COUNTS_EXT,
269 | CL_DEVICE_PARTITION_BY_NAMES_EXT or
270 | CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT may be used in the same
271 | properties list. Available properties are:
272 |
273 | CL_DEVICE_PARTITION_EQUALLY_EXT - Split the aggregate device into as
274 | many smaller aggregate devices as can be created, each containing N
275 | compute units. The value N is passed as the value accompanying this
276 | property. If N does not divide evenly into
277 | CL_DEVICE_MAX_COMPUTE_UNITS then the remaining compute units are
278 | not used.
279 |
280 | Example: To divide a device containing 16 compute units into two
281 | sub-devices, each containing 8 compute units, pass:
282 |
283 | { CL_DEVICE_PARTITION_EQUALLY_EXT, 8,
284 | CL_PROPERTIES_LIST_END_EXT }
285 |
286 | CL_DEVICE_PARTITION_BY COUNTS_EXT - This property is followed by a
287 | CL_PARTITION_BY_COUNTS_LIST_END_EXT terminated list of compute unit
288 | counts. For each non-zero count M in the list, a sub-device is
289 | created with M compute units in it.
290 | CL_PARTITION_BY_COUNTS_LIST_END_EXT is defined to be 0.
291 |
292 | Example: to split a four compute unit device into two sub-devices,
293 | each containing two compute units, pass:
294 |
295 | { CL_DEVICE_PARTITION_BY_COUNTS_EXT,
296 | 2, 2, CL_PARTITION_BY_COUNTS_LIST_END_EXT,
297 | CL_PROPERTIES_LIST_END_EXT }
298 |
299 | The first 2 means put two compute units in the first sub-device. The
300 | second 2 means put two compute units in the second sub-device.
301 | CL_PARTITION_BY_COUNTS_LIST_END_EXT terminates the list of
302 | sub-devices. CL_PROPERTIES_LIST_END_EXT terminates the list of
303 | properties. The total number of compute units specified may not
304 | exceed the number of compute units in the device.
305 |
306 | CL_DEVICE_PARTITION_BY NAMES_EXT - This property is followed by a list
307 | of compute unit names. Each list starts with a
308 | CL_PARTITION_BY_NAMES_LIST_END_EXT terminated list of compute unit
309 | names. Compute unit names are integers that count up from zero to
310 | the number of compute units less one.
311 | CL_PARTITION_BY_NAMES_LIST_END_EXT is defined to be -1. Only
312 | one sub-device may be created at a time with this selector. An
313 | individual compute unit name may not appear more than once in the
314 | sub-device description.
315 |
316 | Example: To create a three compute unit sub-device using compute
317 | units, { 0, 1, 3 }, pass:
318 |
319 | { CL_DEVICE_PARTITION_BY NAMES_EXT,
320 | 0, 1, 3, CL_PARTITION_BY_NAMES_LIST_END_EXT,
321 | CL_PROPERTIES_LIST_END_EXT }
322 |
323 | The meaning of these numbers are, in order:
324 | 0 the name of the first compute unit in the sub-device
325 | 1 the name of the second compute unit in the sub-device
326 | 3 the name of the third compute unit in the sub-device
327 | CL_PROPERTIES_LIST_END_EXT list terminator for the list of
328 | properties
329 |
330 | CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT - Split the device into
331 | smaller aggregate devices containing one or more compute units
332 | that all share part of a cache hierarchy. The value accompanying
333 | this property may be drawn from the following CL_AFFINITY_DOMAIN
334 | list:
335 |
336 | CL_AFFINITY_DOMAIN_NUMA_EXT - Split the device into sub-devices
337 | comprised of compute units that share a NUMA band.
338 |
339 | CL_AFFINITY_DOMAIN_L4_CACHE_EXT - Split the device into sub-devices
340 | comprised of compute units that share a level 4 data cache.
341 |
342 | CL_AFFINITY_DOMAIN_L3_CACHE_EXT - Split the device into sub-devices
343 | comprised of compute units that share a level 3 data cache.
344 |
345 | CL_AFFINITY_DOMAIN_L2_CACHE_EXT - Split the device into sub-devices
346 | comprised of compute units that share a level 2 data cache.
347 |
348 | CL_AFFINITY_DOMAIN_L1_CACHE_EXT - Split the device into sub-devices
349 | comprised of compute units that share a level 1 data cache.
350 |
351 | CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT - Split the device along the
352 | next fissionable CL_AFFINITY_DOMAIN. The implementation shall
353 | find the first level along which the device or sub-device may be
354 | further subdivided in the order NUMA, L4, L3, L2, L1, and
355 | fission the device into sub-devices comprised of compute units
356 | that share memory sub-systems at this level. The user may
357 | determine what happened by calling
358 | clGetDeviceInfo(CL_DEVICE_PARTITION_STYLE_EXT) on the
359 | sub-devices.
360 |
361 | Example: To split a non-NUMA device along the outermost cache level
362 | (if any), pass:
363 |
364 | { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT,
365 | CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT,
366 | CL_PROPERTIES_LIST_END_EXT }
367 |
368 | CL_PROPERTIES_LIST_END_EXT - A list terminator for a properties list.
369 |
370 |
371 | The following values may be returned by clCreateSubDevicesEXT:
372 |
373 | CL_SUCCESS - The command succeeded.
374 |
375 | CL_INVALID_VALUE - The properties key is unknown, or the indicated partition
376 | style (CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT,
377 | CL_DEVICE_PARTITION_EQUALLY_EXT, CL_DEVICE_PARTITION_BY NAMES_EXT or
378 | CL_DEVICE_PARTITION_BY COUNTS_EXT) is not supported for this device by
379 | the implementation. On an OpenCL 1.1 implementation, these cases return
380 | CL_INVALID_PROPERTY instead, to be consistent with clCreateContext
381 | behavior.
382 |
383 | CL_INVALID_VALUE - num_entries is zero and out_devices is not NULL, or both
384 | out_devices and num_devices are NULL.
385 |
386 | CL_DEVICE_PARTITION_FAILED_EXT - The indicated partition scheme is supported
387 | by the implementation, but the implementation can not further partition
388 | the device in this way. For example,
389 | CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT was requested, but all
390 | compute units in in_device share the same cache at the level requested.
391 |
392 | CL_INVALID_PARTITION_COUNT_EXT - The total number of compute units requested
393 | exceeds CL_DEVICE_MAX_COMPUTE_UNITS, or the number of compute units for
394 | any one sub-device is less than 1, or the number of sub-devices
395 | requested exceeds CL_DEVICE_MAX_COMPUTE_UNITS.
396 |
397 | CL_INVALID_PARTITION_NAME_EXT - A compute unit name appearing in a name list
398 | following CL_DEVICE_PARTITION_BY NAMES_EXT is not in the range
399 | [-1, number of compute units - 1].
400 |
401 | CL_INVALID_DEVICE - The in_device is not a valid device. The in_device is
402 | not a device in context.
403 | *)
404 | TclCreateSubDevicesEXT = function(
405 | in_device: TCL_device_id; (*in_device*)
406 | const properties: Pcl_device_partition_property_ext; (* properties *)
407 | num_entries: TCL_uint; (*num_entries*)
408 | out_devices: PCL_device_id; (*out_devices*)
409 | num_devices: TCL_uint(*num_devices*)
410 | ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
411 | var
412 | clCreateSubDevicesEXT: TclCreateSubDevicesEXT;
413 |
414 |
415 | const
416 |
417 | (*
418 | Accepted as a property name in the parameter of
419 | clCreateSubDeviceEXT:
420 | *)
421 | (* cl_device_partition_property_ext *)
422 | CL_DEVICE_PARTITION_EQUALLY_EXT = $4050;
423 | CL_DEVICE_PARTITION_BY_COUNTS_EXT = $4051;
424 | CL_DEVICE_PARTITION_BY_NAMES_EXT = $4052;
425 | CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = $4053;
426 |
427 | (* clDeviceGetInfo selectors *)
428 | (*
429 | Accepted as a property being queried in the argument of
430 | clGetDeviceInfo:
431 |
432 | clGetDeviceInfo - If the device is a sub-device created by
433 | clCreateSubDevicesEXT, then the value returned for
434 | CL_DEVICE_MAX_COMPUTE_UNITS is the number of compute units in the
435 | sub-device. The CL_DEVICE_VENDOR_ID may be different from the parent
436 | device CL_DEVICE_VENDOR_ID, but should be the same for all devices and
437 | sub-devices that can share a binary executable, such as that returned
438 | from clGetProgramInfo(CL_PROGRAM_BINARIES). Other selectors such as
439 | CL_DEVICE_GLOBAL_MEM_CACHE_SIZE may optionally change value to better
440 | reflect the behavior of the sub-device in an implementation defined
441 | manner.
442 | The following selectors are added for clGetDeviceInfo:
443 | *)
444 |
445 | (*
446 | CL_DEVICE_PARENT_DEVICE_EXT - a selector to get the cl_device_id for
447 | the parent cl_device_id to which the sub-device belongs.
448 | (Sub-division can be multi-level.) If the device is a root level
449 | device, then it will return NULL.
450 | *)
451 | CL_DEVICE_PARENT_DEVICE_EXT = $4054;
452 | (*
453 | CL_DEVICE_PARTITION_TYPES_EXT - a selector to get a list of supported
454 | partition types for partitioning a device. The return type is an
455 | array of cl_device partition property ext values drawn from the
456 | following list:
457 |
458 | CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT
459 | CL_DEVICE_PARTITION_BY COUNTS_EXT
460 | CL_DEVICE_PARTITION_BY NAMES_EXT
461 | CL_DEVICE_PARTITION_EQUALLY_EXT
462 |
463 | The implementation shall return at least one property from the above
464 | list. However, when a partition style is found within this list,
465 | the partition style is not required to work in every case. For
466 | example, a device might support partitioning by affinity domain, but
467 | not along NUMA domains.
468 | *)
469 | CL_DEVICE_PARTITION_TYPES_EXT = $4055;
470 |
471 | (*
472 | CL_DEVICE_AFFINITY_DOMAINS_EXT - a selector to get a list of supported
473 | affinity domains for partitioning the device using the
474 | CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT partition style. The
475 | return type is an array of cl_device_partition_property_ext values.
476 | The values shall come from the list:
477 |
478 | CL_AFFINITY_DOMAIN_L1_CACHE_EXT
479 | CL_AFFINITY_DOMAIN_L2_CACHE_EXT
480 | CL_AFFINITY_DOMAIN_L3_CACHE_EXT
481 | CL_AFFINITY_DOMAIN_L4_CACHE_EXT
482 | CL_AFFINITY_DOMAIN_NUMA_EXT
483 |
484 | If no partition style is supported then the size of the returned
485 | array is zero. Even though a device has a NUMA, or particular
486 | cache level, an implementation may elect not to provide fissioning
487 | at that level.
488 | *)
489 | CL_DEVICE_AFFINITY_DOMAINS_EXT = $4056;
490 | (*
491 | CL_DEVICE_REFERENCE_COUNT_EXT Return the device
492 | reference count. The return type is cl_uint. If the device is a
493 | root level device, a reference count of 1 is returned.
494 | *)
495 | CL_DEVICE_REFERENCE_COUNT_EXT = $4057;
496 | (*
497 | CL_DEVICE_PARTITION_STYLE_EXT - a selector to get the
498 | cl_device_partition_property_ext list used to create the sub-device.
499 | If the device is a root level device then a list consisting of
500 | { CL_PROPERTIES_LIST_END_EXT} is returned. If the property on device
501 | creation was (CL_DEVICE_PARTITION BY_AFFINITY_DOMAIN_EXT,
502 | CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE) then
503 | CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE will be replaced by the symbol
504 | representing the actual CL_AFFINITY DOMAIN used
505 | (e.g. CL_AFFINITY_DOMAIN_NUMA). The returned value is an array of
506 | cl_device_partition_property_ext. The length of the array is
507 | obtained from the size returned by the param size value ret
508 | parameter to the function.
509 | *)
510 | CL_DEVICE_PARTITION_STYLE_EXT = $4058;
511 |
512 | (* error codes *)
513 | (*
514 | Returned by clCreateSubDevicesEXT when the indicated partition scheme is
515 | supported by the implementation, but the implementation can not further
516 | partition the device in this way.
517 | *)
518 | CL_DEVICE_PARTITION_FAILED_EXT =-1057;
519 | (*
520 | Returned by clCreateSubDevicesEXT when the total number of compute units
521 | requested exceeds CL_DEVICE_MAX_COMPUTE_UNITS, or the number of compute
522 | units for any one sub-device is less than 1.
523 | *)
524 | CL_INVALID_PARTITION_COUNT_EXT =-1058;
525 | (*
526 | Returned by clCreateSubDevicesEXT when a compute unit name appearing in a
527 | name list following CL_DEVICE_PARTITION_BY_NAMES_EXT is not in range.
528 | *)
529 | CL_INVALID_PARTITION_NAME_EXT =-1059;
530 |
531 | (*
532 | Accepted as a property name, when accompanying the
533 | CL_DEVICE_PARITION_BY_AFFINITY_DOMAIN_EXT property, in the
534 | parameter of clCreateSubDeviceEXT:
535 | *)
536 | (* CL_AFFINITY_DOMAINs *)
537 | CL_AFFINITY_DOMAIN_L1_CACHE_EXT = $1;
538 | CL_AFFINITY_DOMAIN_L2_CACHE_EXT = $2;
539 | CL_AFFINITY_DOMAIN_L3_CACHE_EXT = $3;
540 | CL_AFFINITY_DOMAIN_L4_CACHE_EXT = $4;
541 | CL_AFFINITY_DOMAIN_NUMA_EXT = $10;
542 | CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = $100;
543 |
544 |
545 | (* cl_device_partition_property_ext list terminators *)
546 |
547 | (*
548 | Accepted as the property list terminator in the parameter of
549 | clCreateSubDeviceEXT:
550 | *)
551 | CL_PROPERTIES_LIST_END_EXT : Tcl_device_partition_property_ext = (0);
552 |
553 | (*
554 | Accepted as the partition counts list terminator in the
555 | parameter of clCreateSubDeviceEXT:
556 | *)
557 | CL_PARTITION_BY_COUNTS_LIST_END_EXT : Tcl_device_partition_property_ext = (0);
558 |
559 | (*
560 | Accepted as the partition names list terminator in the
561 | parameter of clCreateSubDeviceEXT:
562 | *)
563 | CL_PARTITION_BY_NAMES_LIST_END_EXT : Tcl_device_partition_property_ext = Tcl_device_partition_property_ext(-1);
564 |
565 | (* cl_ext_atomic_counters_32 and cl_ext_atomic_counters_64 extensions
566 | * no extension #define since they have no functions
567 | *)
568 | CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT = $4032;
569 |
570 | {$ENDIF} (*CL_VERSION_1_1*)
571 | {$IFDEF CL_VERSION_1_0}
572 | (***********************************
573 | * cl_ext_migrate_memobject extension definitions
574 | ***********************************)
575 | cl_ext_migrate_memobject = 1;
576 |
577 | type
578 |
579 | Pcl_mem_migration_flags_ext = ^Tcl_mem_migration_flags_ext;
580 | Tcl_mem_migration_flags_ext = TCL_bitfield;
581 |
582 | const
583 | (*
584 | Besides a value of zero, the following cl_mem_migration_flags_ext values are
585 | allowed:
586 | *)
587 | CL_MIGRATE_MEM_OBJECT_HOST_EXT = $1;
588 | (*
589 | Returned in the parameter of the clGetEventInfo when
590 | is CL_EVENT_COMMAND_TYPE:
591 | *)
592 | CL_COMMAND_MIGRATE_MEM_OBJECT_EXT = $4040;
593 |
594 | type
595 | TclEnqueueMigrateMemObjectEXT = function(
596 | command_queue: Tcl_command_queue; (* command_queue *)
597 | num_mem_objects: Tcl_uint; (* num_mem_objects *)
598 | const mem_objects: Pcl_mem; (* mem_objects *)
599 | flags: Tcl_mem_migration_flags_ext; (* flags *)
600 | num_events_in_wait_list: Tcl_uint; (* num_events_in_wait_list *)
601 | const event_wait_list: Pcl_event; (* event_wait_list *)
602 | event: Pcl_event (* event *)
603 | ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
604 |
605 | var
606 | clEnqueueMigrateMemObjectEXT: TclEnqueueMigrateMemObjectEXT;
607 | {$ENDIF}
608 |
609 | {$IFDEF CL_VERSION_1_1}
610 | (*********************************
611 | * cl_qcom_ext_host_ptr extension
612 | *********************************)
613 |
614 | const
615 |
616 | CL_MEM_EXT_HOST_PTR_QCOM = (1 shl 29);
617 |
618 | CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM = $40A0;
619 | CL_DEVICE_PAGE_SIZE_QCOM = $40A1;
620 | CL_IMAGE_ROW_ALIGNMENT_QCOM = $40A2;
621 | CL_IMAGE_SLICE_ALIGNMENT_QCOM = $40A3;
622 | CL_MEM_HOST_UNCACHED_QCOM = $40A4;
623 | CL_MEM_HOST_WRITEBACK_QCOM = $40A5;
624 | CL_MEM_HOST_WRITETHROUGH_QCOM = $40A6;
625 | CL_MEM_HOST_WRITE_COMBINING_QCOM = $40A7;
626 |
627 | type
628 | TCL_image_pitch_info_qcom = TCL_uint;
629 | PCL_image_pitch_info_qcom = ^TCL_image_pitch_info_qcom;
630 |
631 |
632 | TclGetDeviceImageInfoQCOM = function(
633 | device: PCL_device_id;
634 | image_width: TSize_t;
635 | image_height: TSize_t;
636 | const image_format: PCL_image_format;
637 | param_name: PCL_image_pitch_info_qcom;
638 | param_value_size: TSize_t;
639 | param_value: Pointer;
640 | param_value_size_ret: PSize_t
641 | ): TCL_int;
642 | {$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
643 |
644 | var
645 | clGetDeviceImageInfoQCOM: TclGetDeviceImageInfoQCOM;
646 |
647 | type
648 |
649 | TCL_mem_ext_host_ptr = packed record
650 | (* Type of external memory allocation. *)
651 | (* Legal values will be defined in layered extensions. *)
652 | allocation_type: TCL_uint;
653 | (* Host cache policy for this external memory allocation. *)
654 | host_cache_policy: TCL_uint;
655 | end;
656 | PCL_mem_ext_host_ptr = ^TCL_mem_ext_host_ptr;
657 |
658 | (*********************************
659 | * cl_qcom_ion_host_ptr extension
660 | *********************************)
661 | const
662 | CL_MEM_ION_HOST_PTR_QCOM = $40A8;
663 |
664 | type
665 | TCL_mem_ion_host_ptr = packed record
666 | (* Type of external memory allocation. *)
667 | (* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. *)
668 | ext_host_ptr: PCL_mem_ext_host_ptr;
669 | (* ION file descriptor *)
670 | ion_filedesc: Integer;
671 | (* Host pointer to the ION allocated memory *)
672 | ion_hostptr: Pointer;
673 | end;
674 |
675 | PCL_mem_ion_host_ptr = ^TCL_mem_ion_host_ptr;
676 |
677 | {$ENDIF}
678 |
679 |
680 |
681 | function InitCL_EXT: Boolean;
682 |
683 | implementation
684 |
685 | function InitCL_EXT: Boolean;
686 | begin
687 | Result := False;
688 | if OCL_LibHandle <> nil then
689 | begin
690 |
691 | //clIcdGetPlatformIDsKHR := oclGetProcAddress('clIcdGetPlatformIDsKHR', OCL_LibHandle));
692 | clIcdGetPlatformIDsKHR := TclIcdGetPlatformIDsKHR(oclGetProcAddress('clIcdGetPlatformIDsKHR', OCL_LibHandle));
693 |
694 | {$IFDEF CL_VERSION_1_0}
695 | clSetMemObjectDestructorAPPLE := TclSetMemObjectDestructorAPPLE(oclGetProcAddress('clSetMemObjectDestructorAPPLE', OCL_LibHandle));
696 | clLogMessagesToSystemLogAPPLE := TclLogMessagesToSystemLogAPPLE(oclGetProcAddress('clLogMessagesToSystemLogAPPLE', OCL_LibHandle));
697 | clLogMessagesToStdoutAPPLE := TclLogMessagesToStdoutAPPLE(oclGetProcAddress('clLogMessagesToStdoutAPPLE', OCL_LibHandle));
698 | clLogMessagesToStderrAPPLE := TclLogMessagesToStderrAPPLE(oclGetProcAddress('clLogMessagesToStderrAPPLE', OCL_LibHandle));
699 | {$ENDIF}
700 | {$IFDEF CL_VERSION_1_1}
701 | clReleaseDeviceEXT := TclReleaseDeviceEXT(oclGetProcAddress('clReleaseDeviceEXT', OCL_LibHandle));
702 | clRetainDeviceEXT := TclRetainDeviceEXT(oclGetProcAddress('clRetainDeviceEXT', OCL_LibHandle));
703 | clCreateSubDevicesEXT := TclCreateSubDevicesEXT(oclGetProcAddress('clCreateSubDevicesEXT', OCL_LibHandle));
704 | {$ENDIF}
705 | {$IFDEF CL_VERSION_1_0}
706 | clEnqueueMigrateMemObjectEXT := TclEnqueueMigrateMemObjectEXT(oclGetProcAddress('clEnqueueMigrateMemObjectEXT', OCL_LibHandle));
707 | {$ENDIF}
708 |
709 | {$IFDEF CL_VERSION_1_1}
710 | clGetDeviceImageInfoQCOM := TclGetDeviceImageInfoQCOM(oclGetProcAddress('clGetDeviceImageInfoQCOM', OCL_LibHandle));
711 | {$ENDIF}
712 |
713 | Result := True;
714 | end;
715 | end;
716 |
717 | end.
718 |
--------------------------------------------------------------------------------