diff --git a/LastPack.log b/LastPack.log index 5cde6614..3f364f41 100644 --- a/LastPack.log +++ b/LastPack.log @@ -1,91 +1,6 @@ -Executing selected stages: -FirstPack + Reference + Dummy + OpenCL + OpenCLABC + OpenGL + OpenGLABC + Compile + Test + Release +Executing default stages: +Reference + Dummy + OpenCL + OpenCLABC + OpenGL + OpenGLABC + Compile + Test + Release Start packing -=================================== First Pack =================================== -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Update Reps ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Compiling "DataScraping/Reps/PullReps.pas" -Compiling: OK -Runing SubReps Update -SubReps Update: Pulling OpenCL -SubReps Update: cmd /c "(echo [checkout] && git checkout custom 2>&1) && (echo [pull] && git pull 0_official main & echo [pull-own]: && git pull SunSerega custom)" -SubReps Update: OpenCL[OUT] : [checkout] -SubReps Update: OpenCL[OUT] : Your branch is up to date with 'SunSerega/custom'. -SubReps Update: OpenCL[OUT] : Already on 'custom' -SubReps Update: OpenCL[OUT] : [pull] -SubReps Update: OpenCL[ERR] : From KhronosGroup/OpenCL-Docs -SubReps Update: OpenCL[ERR] : * branch main -> FETCH_HEAD -SubReps Update: OpenCL[OUT] : Already up to date. -SubReps Update: OpenCL[OUT] : [pull-own]: -SubReps Update: OpenCL[ERR] : From SunSerega/OpenCL-Docs -SubReps Update: OpenCL[ERR] : * branch custom -> FETCH_HEAD -SubReps Update: OpenCL[OUT] : Already up to date. -SubReps Update: Done pulling OpenCL -SubReps Update: Pulling OpenGL -SubReps Update: cmd /c "(echo [checkout] && git checkout custom 2>&1) && (echo [pull] && git pull 0_official main & echo [pull-own]: && git pull SunSerega custom)" -SubReps Update: OpenGL[OUT] : [checkout] -SubReps Update: OpenGL[OUT] : Your branch is up to date with 'SunSerega/custom'. -SubReps Update: OpenGL[OUT] : Already on 'custom' -SubReps Update: OpenGL[OUT] : [pull] -SubReps Update: OpenGL[ERR] : From KhronosGroup/OpenGL-Registry -SubReps Update: OpenGL[ERR] : * branch main -> FETCH_HEAD -SubReps Update: OpenGL[OUT] : Already up to date. -SubReps Update: OpenGL[OUT] : [pull-own]: -SubReps Update: OpenGL[ERR] : From SunSerega/OpenGL-Registry -SubReps Update: OpenGL[ERR] : * branch custom -> FETCH_HEAD -SubReps Update: OpenGL[OUT] : Already up to date. -SubReps Update: Done pulling OpenGL -Finished runing SubReps Update -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Scrap XML ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Compiling "DataScraping/XML/Dummy/ScrapXML.pas" -Compiling: OK -Runing ScrapXML[Dummy] -ScrapXML[Dummy]: Parsing XML -ScrapXML[Dummy]: Constructing named items -ScrapXML[Dummy]: Saving as binary -ScrapXML[Dummy]: Enum: Saved 8 items -ScrapXML[Dummy]: BasicType: Saved 6 items -ScrapXML[Dummy]: Group: Saved 2 items -ScrapXML[Dummy]: Func: Saved 16 items -ScrapXML[Dummy]: Feature: Saved 2 items -ScrapXML[Dummy]: Done -Finished runing ScrapXML[Dummy] -Compiling "DataScraping/XML/OpenCL/ScrapXML.pas" -Compiling: OK -Runing ScrapXML[OpenCL] -ScrapXML[OpenCL]: Parsing "cl" -ScrapXML[OpenCL]: Constructing named items -ScrapXML[OpenCL]: Saving as binary -ScrapXML[OpenCL]: VendorSuffix: Saved 11 items -ScrapXML[OpenCL]: Enum: Saved 1118 items -ScrapXML[OpenCL]: BasicType: Saved 30 items -ScrapXML[OpenCL]: Group: Saved 119 items -ScrapXML[OpenCL]: IdClass: Saved 18 items -ScrapXML[OpenCL]: Struct: Saved 16 items -ScrapXML[OpenCL]: Delegate: Saved 8 items -ScrapXML[OpenCL]: Func: Saved 239 items -ScrapXML[OpenCL]: Feature: Saved 7 items -ScrapXML[OpenCL]: Extension: Saved 104 items -ScrapXML[OpenCL]: Done -Finished runing ScrapXML[OpenCL] -Compiling "DataScraping/XML/OpenGL/ScrapXML.pas" -Compiling: OK -Runing ScrapXML[OpenGL] -ScrapXML[OpenGL]: Parsing "gl" -ScrapXML[OpenGL]: Parsing "wgl" -ScrapXML[OpenGL]: Parsing "glx" -ScrapXML[OpenGL]: Constructing named items -ScrapXML[OpenGL]: Saving as binary -ScrapXML[OpenGL]: VendorSuffix: Saved 35 items -ScrapXML[OpenGL]: Enum: Saved 4763 items -ScrapXML[OpenGL]: BasicType: Saved 116 items -ScrapXML[OpenGL]: Group: Saved 323 items -ScrapXML[OpenGL]: IdClass: Saved 15 items -ScrapXML[OpenGL]: Delegate: Saved 5 items -ScrapXML[OpenGL]: Func: Saved 3573 items -ScrapXML[OpenGL]: Feature: Saved 32 items -ScrapXML[OpenGL]: Extension: Saved 1142 items -ScrapXML[OpenGL]: Done -Finished runing ScrapXML[OpenGL] =================================== References =================================== Compiling "Packing/Reference/ReferencePacker.pas" Compiling: OK @@ -401,9 +316,11 @@ Tester: Compiling "Tests/DebugPCU/OpenCLABC.pas" Tester: Compiling: OK Tester: Compiling "Tests/DebugPCU/OpenGLABC.pas" Tester: Compiling: OK -Tester: Compiling "Tests/Exec/CL/ToString.pas" +Tester: Compiling "Tests/CLContextGen.pas" Tester: Compiling: OK -Tester: Compiling "Tests/Exec/CLABC/gen def context.pas" +Tester: Running Tests/CLContextGen.exe +Tester: Finished running Tests/CLContextGen.exe +Tester: Compiling "Tests/Exec/CL/ToString.pas" Tester: Compiling: OK Tester: Compiling "Tests/Exec/CLABC/01#Wrap/01#CLPlatform/1.pas" Tester: Compiling: OK @@ -609,9 +526,207 @@ Tester: Compiling "Samples/OpenGLABC/!Крутящийся треугольни Tester: Compiling: OK Tester: Compiling "Samples/OpenGLABC/Точки на поле/Точки.pas" Tester: Compiling: OK +Tester: Switched to platform "NVIDIA CUDA" and using 1 devices Tester: Executing Test[Tests/Exec/CL/ToString] Tester: Done executing -Tester: Executing Test[Tests/Exec/CLABC/gen def context] +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/01#CLPlatform/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/02#CLDevice/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/03#CLContext/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/04#Memory/1#CLMemory/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/04#Memory/1#CLMemory/SubSegment1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/04#Memory/2#CLValue/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/04#Memory/3#CLArray/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/04#Memory/3#CLArray/err1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/05#CLKernel/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/06#CLCode/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/06#CLCode/deserialize] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/00#Err/CCQ-Cancel] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/00#Err/ExecutionCancel] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/01#Const/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/02#Parameter/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/02#Parameter/realistic use] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/03#Cast/~00#Err/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/03#Cast/~01#Const/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/04#ThenConvert/ThenConvUse_ConstDelayedFunc] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/04#ThenConvert/~00#Err/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/04#ThenConvert/~00#Err/0c] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/04#ThenConvert/~01#Const/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/04#ThenConvert/~02#Cast/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/05#Multiusable/~00#Err/errоr multiuse] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/05#Multiusable/~00#Err/multi errоr multiuse] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/05#Multiusable/~02#Cast/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/05#Multiusable/~05#Wait/marker.mu] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/05#Multiusable/~05#Wait/multiusable instead of ThenMarkerSignal] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/05#Multiusable/~07#HostExec/Quick+MU] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/06#Wait/ThenWait] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/06#Wait/WaitOrder] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/ExecCache] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/OldClone.Add] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/ThenQueue(self)] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/~00#Err/AddProc] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/~00#Err/AddQueue] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/~00#Err/LazyQuickErr] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/~00#Err/QuickErr] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/~02#Cast/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/07#GPUCommandContainer/~08#HostExec/QuickParOrder] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/08#HostExec/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/08#HostExec/~00#Err/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/08#HostExec/~00#Err/1Q] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/08#HostExec/~00#Err/1T] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/08#HostExec/~05#Wait/QuickUse.ThenWait] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/09#CombineQueues/0] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/09#CombineQueues/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/09#CombineQueues/q count] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/09#CombineQueues/~00#Err/err while async] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/10#WaitMarker/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/10#WaitMarker/combine stress] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/10#WaitMarker/~00#Err/invoke WaitAll] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/10#WaitMarker/~00#Err/marker after err] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/11#Finally+Handle/BranchCancel] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/11#Finally+Handle/BranchUnCancel] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/11#Finally+Handle/~00#Err/finally order] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/11#Finally+Handle/~00#Err/handle only branch] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/11#Finally+Handle/~00#Err/Handle only local] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/02#Выполнение очередей/11#Finally+Handle/~00#Err/marker in finally] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/01#Const/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/02#Parameter/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/03#Cast/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/03#Cast/typed nil] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/04#ThenConvert/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/05#Multiusable/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/06#Wait/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/07#GPUCommandContainer/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/08#HostExec/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/09#CombineQueues/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/09#CombineQueues/conv1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/09#CombineQueues/inline] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/09#CombineQueues/optimize] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/09#CombineQueues/remove last const] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/10#WaitMarker/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/11#Finally+Handle/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/12#CLKernelArg/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/01#CLPlatform/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/02#CLDevice/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/03#CLContext/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/04#Memory/1#CLMemory/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/04#Memory/1#CLMemory/SubSegment1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/04#Memory/2#CLValue/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/04#Memory/3#CLArray/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/05#CLKernel/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/03#ToString/13#Wrap/06#CLCode/1] +Tester: Done executing +Tester: Executing Test[Tests/Exec/CLABC/04#Samples/Игра жизнь/Игра жизнь] +Tester: Done executing +Tester: Executing Test[Tests/Exec/GL/Determinant] +Tester: Done executing +Tester: Executing Test[Tests/Exec/GL/Mtr.Rotate3D] +Tester: Done executing +Tester: Executing Test[Tests/Exec/GL/Mtr.Translate] +Tester: Done executing +Tester: Executing Test[Tests/Exec/GL/Random] +Tester: Done executing +Tester: Executing Test[Tests/Exec/GL/Vec2d.Cross] +Tester: Done executing +Tester: Executing Test[Tests/Exec/GL/Vec3d.Cross] +Tester: Done executing +Tester: Executing Test[Samples/OpenCL/MatrMlt] +Tester: Done executing +Tester: Executing Test[Samples/OpenCL/SimpleAddition] +Tester: Done executing +Tester: Executing Test[Samples/OpenCLABC/0Простейшие примеры/MatrMlt] +Tester: Done executing +Tester: Executing Test[Samples/OpenCLABC/0Простейшие примеры/SimpleAddition] +Tester: Done executing +Tester: Executing Test[Samples/OpenCLABC/Кеширование CLProgramCode/SimpleAddition но с кешем] +Tester: Done executing +Tester: Executing Test[Samples/OpenCLABC/Кеширование CLProgramCode/SimpleAddition но с кешем] +Tester: Done executing +Tester: Switched to platform "Intel(R) OpenCL" and using 1 devices +Tester: Executing Test[Tests/Exec/CL/ToString] Tester: Done executing Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/01#CLPlatform/1] Tester: Done executing diff --git a/Log/Test.log b/Log/Test.log index 7fb5e0f3..e659a253 100644 --- a/Log/Test.log +++ b/Log/Test.log @@ -11,9 +11,11 @@ Tester: Compiling "Tests/DebugPCU/OpenCLABC.pas" Tester: Compiling: OK Tester: Compiling "Tests/DebugPCU/OpenGLABC.pas" Tester: Compiling: OK -Tester: Compiling "Tests/Exec/CL/ToString.pas" +Tester: Compiling "Tests/CLContextGen.pas" Tester: Compiling: OK -Tester: Compiling "Tests/Exec/CLABC/gen def context.pas" +Tester: Running Tests/CLContextGen.exe +Tester: Finished running Tests/CLContextGen.exe +Tester: Compiling "Tests/Exec/CL/ToString.pas" Tester: Compiling: OK Tester: Compiling "Tests/Exec/CLABC/01#Wrap/01#CLPlatform/1.pas" Tester: Compiling: OK @@ -221,8 +223,6 @@ Tester: Compiling "Samples/OpenGLABC/Точки на поле/Точки.pas" Tester: Compiling: OK Tester: Executing Test[Tests/Exec/CL/ToString] Tester: Done executing -Tester: Executing Test[Tests/Exec/CLABC/gen def context] -Tester: Done executing Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/01#CLPlatform/1] Tester: Done executing Tester: Executing Test[Tests/Exec/CLABC/01#Wrap/02#CLDevice/1] diff --git a/Modules.Packed/OpenCLABC.pas b/Modules.Packed/OpenCLABC.pas index 6c2d0fab..2461fe68 100644 --- a/Modules.Packed/OpenCLABC.pas +++ b/Modules.Packed/OpenCLABC.pas @@ -3261,7 +3261,9 @@ CLArrayProperties = class end; - public static procedure GenerateAndCheckDefault(test_size: integer := 1024*24; test_max_seconds: real := 0.5); + public function TestSanity(test_size: integer := 1024*24): TimeSpan?; + + public static function GenerateAndCheckAllPossible(test_size: integer := 1024*24; test_max_seconds: real := 0.5): List>; private static function LoadTestContext: CLContext; @@ -35370,86 +35372,84 @@ function CombineUseAsyncQueueN7(use: {$region CLContext} -static procedure CLContext.GenerateAndCheckDefault(test_size: integer; test_max_seconds: real); +type + CLContextTestData = static class + + private const test_prog = 'kernel void k(global int* v) { v[get_global_id(0)]++; }'; + + public static function MakeTestQueue(test_size: integer): CommandQueue; + begin + // Без кеширования, чтобы у всех + // запусков .TestSanity были равные условия + // что касается внутренних оптимизаций очереди + var rng := new Random; + var test_arr := ArrGen(test_size, i->rng.Next); + var Q_Arr := HFQ(c->new CLArray(c, test_size), false).Multiusable; + Result := + HFQ(c->CLProgramCode.Create(test_prog, c)['k'], false).MakeCCQ + .ThenExec1(test_size, Q_Arr.MakeCCQ + .ThenWriteArray(test_arr) + ) + + Q_Arr.MakeCCQ + .ThenGetArray + .ThenConvert(test_res-> + test_res.Zip(test_arr, (a,b)->a=b+1).All(r->r), false + ); + end; + + end; + +function CLContext.TestSanity(test_size: integer): TimeSpan?; begin - if Interlocked.CompareExchange(default_was_inited, 1, 0)<>0 then - raise new System.InvalidOperationException($'%CLContext:GenerateAndCheckDefault:NotFirst%'); + var Q := CLContextTestData.MakeTestQueue(test_size); + var sw := Stopwatch.StartNew; + + Result := nil; + if not self.SyncInvoke(Q) then exit; - var test_prog := 'kernel void k(global int* v) { v[get_global_id(0)]++; }'; + Result := sw.Elapsed; +end; + +static function CLContext.GenerateAndCheckAllPossible(test_size: integer; test_max_seconds: real): List>; +begin var test_max_time := TimeSpan.FromSeconds(test_max_seconds); + Result := new List>; - var Q_Test: CommandQueue; - var P_Arr := new ParameterQueue>('A'); - var P_Prog := new ParameterQueue('Prog'); - begin - var rng := new Random; - var test_arr := ArrGen(test_size, i->rng.Next); - Q_Test := - CLKernelCCQ.Create(P_Prog.ThenConvert(p->p['k'], false, true)) - .ThenExec1(test_size, P_Arr.MakeCCQ - .ThenWriteArray(test_arr) - ) + - P_Arr.MakeCCQ - .ThenGetArray - .ThenConvert(test_res-> - test_res.Zip(test_arr, (a,b)->a=b+1).All(r->r), false - ); - end; - - var c := CLPlatform.All.SelectMany(pl-> + foreach var pl in CLPlatform.All do begin var dvcs := CLDevice.GetAllFor(pl, clDeviceType.DEVICE_TYPE_ALL).ToList; - System.Threading.Tasks.Parallel.For(0,dvcs.Count, i-> + var keep := new boolean[dvcs.Count]; + var thrs := ArrGen(dvcs.Count, i->new Thread(()-> begin - var del := true; - - var c := new CLContext(dvcs[i]); - var S_Arr := P_Arr.NewSetter(new CLArray(c, test_size)); - var S_Prog := P_Prog.NewSetter(new CLProgramCode(test_prog, c)); - - var thr := new Thread(()-> - begin - del := not c.SyncInvoke(Q_Test, S_Arr, S_Prog); - end); - thr.IsBackground := true; - thr.Start; + keep[i] := nil <> CLContext.Create(dvcs[i]).TestSanity(test_size) + end)); + foreach var thr in thrs do thr.IsBackground := true; + foreach var thr in thrs do thr.Start; + Thread.Sleep(test_max_time); + foreach var thr in thrs do thr.Abort; + + for var i := 0 to dvcs.Count-1 do + if not keep[i] then dvcs[i] := nil; + dvcs.RemoveAll(d->d=nil); + + var chosen := new List(dvcs.Count); + foreach var choise in |true,false|.CartesianPower(dvcs.Count) do + begin + chosen.Clear; + for var i := 0 to dvcs.Count-1 do + if choise[i] then chosen += dvcs[i]; + if chosen.Count=0 then continue; - if not thr.Join(test_max_time) then - thr.Abort; + var c := new CLContext(chosen, chosen[0]); + var time := c.TestSanity(test_size); + if time=nil then continue; - if del then dvcs[i] := nil; - end); - dvcs.RemoveAll(d->d=nil); + Result.Add(ValueTuple.Create(c, time.Value)); + end; - Result := if dvcs.Count=0 then - System.Linq.Enumerable.Empty&<(CLContext,TimeSpan)> else - |true,false|.Cartesian(dvcs.Count) - .Select(choise-> - begin - Result := new List(dvcs.Count); - for var i := 0 to dvcs.Count-1 do - if choise[i] then Result += dvcs[i]; - end) - .Where(l_dvcs->l_dvcs.Count<>0) - .Select(l_dvcs-> - begin - var c := new CLContext(l_dvcs, l_dvcs[0]); - - var sw := Stopwatch.StartNew; - c.SyncInvoke(Q_Test.DiscardResult, - P_Arr.NewSetter(new CLArray(c, test_size)), - P_Prog.NewSetter(new CLProgramCode(test_prog, c)) - ); - sw.Stop; - - Result := (c, sw.Elapsed); - end); - end) - .DefaultIfEmpty((default(CLContext),TimeSpan.Zero)) - .MinBy(t->t[1])[0]; + end; - Interlocked.CompareExchange(_default, c, nil); end; static function CLContext.LoadTestContext: CLContext; @@ -35469,11 +35469,6 @@ function CombineUseAsyncQueueN7(use: var br := new System.IO.BinaryReader(System.IO.File.OpenRead(fname)); try var pl_name := br.ReadString; - if pl_name.Length=0 then - begin - $'Pregenerated context was empty'.Println; - exit; - end; var pl := CLPlatform.All.SingleOrDefault(pl->pl.Properties.Name=pl_name); if pl=nil then diff --git a/Modules/OpenCLABC.pas b/Modules/OpenCLABC.pas index 2cc5d50f..3b5ff739 100644 --- a/Modules/OpenCLABC.pas +++ b/Modules/OpenCLABC.pas @@ -1428,7 +1428,9 @@ EventRetainReleaseData = record end; - public static procedure GenerateAndCheckDefault(test_size: integer := 1024*24; test_max_seconds: real := 0.5); + public function TestSanity(test_size: integer := 1024*24): TimeSpan?; + + public static function GenerateAndCheckAllPossible(test_size: integer := 1024*24; test_max_seconds: real := 0.5): List>; private static function LoadTestContext: CLContext; @@ -9968,86 +9970,84 @@ function HPQ(p: CLContext->(); need_own_thread: boolean) := {$region CLContext} -static procedure CLContext.GenerateAndCheckDefault(test_size: integer; test_max_seconds: real); +type + CLContextTestData = static class + + private const test_prog = 'kernel void k(global int* v) { v[get_global_id(0)]++; }'; + + public static function MakeTestQueue(test_size: integer): CommandQueue; + begin + // Без кеширования, чтобы у всех + // запусков .TestSanity были равные условия + // что касается внутренних оптимизаций очереди + var rng := new Random; + var test_arr := ArrGen(test_size, i->rng.Next); + {%> var Q_Arr := HFQ(c->new CLArray(c, test_size), false).Multiusable;%} + {%> Result :=%} + {%> HFQ(c->CLProgramCode.Create(test_prog, c)['k'], false).MakeCCQ%} + {%> .ThenExec1(test_size, Q_Arr.MakeCCQ%} + {%> .ThenWriteArray(test_arr)%} + {%> ) +%} + {%> Q_Arr.MakeCCQ%} + {%> .ThenGetArray%} + {%> .ThenConvert(test_res->%} + {%> test_res.Zip(test_arr, (a,b)->a=b+1).All(r->r), false%} + {%> )!!}test_arr := test_arr; Result := nil{%}; + end; + + end; + +function CLContext.TestSanity(test_size: integer): TimeSpan?; begin - if Interlocked.CompareExchange(default_was_inited, 1, 0)<>0 then - raise new System.InvalidOperationException($'%CLContext:GenerateAndCheckDefault:NotFirst%'); + var Q := CLContextTestData.MakeTestQueue(test_size); + var sw := Stopwatch.StartNew; + + Result := nil; + if not self.SyncInvoke(Q) then exit; - var test_prog := 'kernel void k(global int* v) { v[get_global_id(0)]++; }'; + Result := sw.Elapsed; +end; + +static function CLContext.GenerateAndCheckAllPossible(test_size: integer; test_max_seconds: real): List>; +begin var test_max_time := TimeSpan.FromSeconds(test_max_seconds); + Result := new List>; - var Q_Test: CommandQueue; - var P_Arr := new ParameterQueue>('A'); - var P_Prog := new ParameterQueue('Prog'); - begin - var rng := new Random; - var test_arr := ArrGen(test_size, i->rng.Next); - {%> Q_Test :=%} - {%> CLKernelCCQ.Create(P_Prog.ThenConvert(p->p['k'], false, true))%} - {%> .ThenExec1(test_size, P_Arr.MakeCCQ%} - {%> .ThenWriteArray(test_arr)%} - {%> ) +%} - {%> P_Arr.MakeCCQ%} - {%> .ThenGetArray%} - {%> .ThenConvert(test_res->%} - {%> test_res.Zip(test_arr, (a,b)->a=b+1).All(r->r), false%} - {%> )!!}test_arr := test_arr{%}; - end; - - var c := CLPlatform.All.SelectMany(pl-> + foreach var pl in CLPlatform.All do begin var dvcs := CLDevice.GetAllFor(pl, clDeviceType.DEVICE_TYPE_ALL).ToList; - System.Threading.Tasks.Parallel.For(0,dvcs.Count, i-> + var keep := new boolean[dvcs.Count]; + var thrs := ArrGen(dvcs.Count, i->new Thread(()-> begin - var del := true; - - var c := new CLContext(dvcs[i]); - var S_Arr := P_Arr.NewSetter(new CLArray(c, test_size)); - var S_Prog := P_Prog.NewSetter(new CLProgramCode(test_prog, c)); - - var thr := new Thread(()-> - begin - del := not c.SyncInvoke(Q_Test, S_Arr, S_Prog); - end); - thr.IsBackground := true; - thr.Start; + keep[i] := nil <> CLContext.Create(dvcs[i]).TestSanity(test_size) + end)); + foreach var thr in thrs do thr.IsBackground := true; + foreach var thr in thrs do thr.Start; + Thread.Sleep(test_max_time); + foreach var thr in thrs do thr.Abort; + + for var i := 0 to dvcs.Count-1 do + if not keep[i] then dvcs[i] := nil; + dvcs.RemoveAll(d->d=nil); + + var chosen := new List(dvcs.Count); + foreach var choise in |true,false|.CartesianPower(dvcs.Count) do + begin + chosen.Clear; + for var i := 0 to dvcs.Count-1 do + if choise[i] then chosen += dvcs[i]; + if chosen.Count=0 then continue; - if not thr.Join(test_max_time) then - thr.Abort; + var c := new CLContext(chosen, chosen[0]); + var time := c.TestSanity(test_size); + if time=nil then continue; - if del then dvcs[i] := nil; - end); - dvcs.RemoveAll(d->d=nil); + Result.Add(ValueTuple.Create(c, time.Value)); + end; - Result := if dvcs.Count=0 then - System.Linq.Enumerable.Empty&<(CLContext,TimeSpan)> else - |true,false|.Cartesian(dvcs.Count) - .Select(choise-> - begin - Result := new List(dvcs.Count); - for var i := 0 to dvcs.Count-1 do - if choise[i] then Result += dvcs[i]; - end) - .Where(l_dvcs->l_dvcs.Count<>0) - .Select(l_dvcs-> - begin - var c := new CLContext(l_dvcs, l_dvcs[0]); - - var sw := Stopwatch.StartNew; - c.SyncInvoke(Q_Test.DiscardResult, - P_Arr.NewSetter(new CLArray(c, test_size)), - P_Prog.NewSetter(new CLProgramCode(test_prog, c)) - ); - sw.Stop; - - Result := (c, sw.Elapsed); - end); - end) - .DefaultIfEmpty((default(CLContext),TimeSpan.Zero)) - .MinBy(t->t[1])[0]; + end; - Interlocked.CompareExchange(_default, c, nil); end; static function CLContext.LoadTestContext: CLContext; @@ -10067,11 +10067,6 @@ function HPQ(p: CLContext->(); need_own_thread: boolean) := var br := new System.IO.BinaryReader(System.IO.File.OpenRead(fname)); try var pl_name := br.ReadString; - if pl_name.Length=0 then - begin - $'Pregenerated context was empty'.Println; - exit; - end; var pl := CLPlatform.All.SingleOrDefault(pl->{%>pl.Properties.Name!!}nil{%}=pl_name); if pl=nil then diff --git a/Packing/Descriptions/OpenCLABC.missing.log b/Packing/Descriptions/OpenCLABC.missing.log index 6823a97b..0aec3647 100644 --- a/Packing/Descriptions/OpenCLABC.missing.log +++ b/Packing/Descriptions/OpenCLABC.missing.log @@ -796,5 +796,3 @@ # Err:Blittable:Source:CLMemory:FillNativeArrayArea -# CLContext:GenerateAndCheckDefault:NotFirst - diff --git a/Packing/Descriptions/OpenCLABC.predoc b/Packing/Descriptions/OpenCLABC.predoc index b2ea47da..35936cf2 100644 --- a/Packing/Descriptions/OpenCLABC.predoc +++ b/Packing/Descriptions/OpenCLABC.predoc @@ -3157,7 +3157,9 @@ type end; - public static procedure GenerateAndCheckDefault(test_size: integer := 1024*24; test_max_seconds: real := 0.5); + public function TestSanity(test_size: integer := 1024*24): TimeSpan?; + + public static function GenerateAndCheckAllPossible(test_size: integer := 1024*24; test_max_seconds: real := 0.5): List>; private static function LoadTestContext: CLContext; @@ -34295,86 +34297,84 @@ end; {$region CLContext} -static procedure CLContext.GenerateAndCheckDefault(test_size: integer; test_max_seconds: real); +type + CLContextTestData = static class + + private const test_prog = 'kernel void k(global int* v) { v[get_global_id(0)]++; }'; + + public static function MakeTestQueue(test_size: integer): CommandQueue; + begin + // Без кеширования, чтобы у всех + // запусков .TestSanity были равные условия + // что касается внутренних оптимизаций очереди + var rng := new Random; + var test_arr := ArrGen(test_size, i->rng.Next); + var Q_Arr := HFQ(c->new CLArray(c, test_size), false).Multiusable; + Result := + HFQ(c->CLProgramCode.Create(test_prog, c)['k'], false).MakeCCQ + .ThenExec1(test_size, Q_Arr.MakeCCQ + .ThenWriteArray(test_arr) + ) + + Q_Arr.MakeCCQ + .ThenGetArray + .ThenConvert(test_res-> + test_res.Zip(test_arr, (a,b)->a=b+1).All(r->r), false + ); + end; + + end; + +function CLContext.TestSanity(test_size: integer): TimeSpan?; begin - if Interlocked.CompareExchange(default_was_inited, 1, 0)<>0 then - raise new System.InvalidOperationException($'%CLContext:GenerateAndCheckDefault:NotFirst%'); + var Q := CLContextTestData.MakeTestQueue(test_size); + var sw := Stopwatch.StartNew; + + Result := nil; + if not self.SyncInvoke(Q) then exit; - var test_prog := 'kernel void k(global int* v) { v[get_global_id(0)]++; }'; + Result := sw.Elapsed; +end; + +static function CLContext.GenerateAndCheckAllPossible(test_size: integer; test_max_seconds: real): List>; +begin var test_max_time := TimeSpan.FromSeconds(test_max_seconds); + Result := new List>; - var Q_Test: CommandQueue; - var P_Arr := new ParameterQueue>('A'); - var P_Prog := new ParameterQueue('Prog'); - begin - var rng := new Random; - var test_arr := ArrGen(test_size, i->rng.Next); - Q_Test := - CLKernelCCQ.Create(P_Prog.ThenConvert(p->p['k'], false, true)) - .ThenExec1(test_size, P_Arr.MakeCCQ - .ThenWriteArray(test_arr) - ) + - P_Arr.MakeCCQ - .ThenGetArray - .ThenConvert(test_res-> - test_res.Zip(test_arr, (a,b)->a=b+1).All(r->r), false - ); - end; - - var c := CLPlatform.All.SelectMany(pl-> + foreach var pl in CLPlatform.All do begin var dvcs := CLDevice.GetAllFor(pl, clDeviceType.DEVICE_TYPE_ALL).ToList; - System.Threading.Tasks.Parallel.For(0,dvcs.Count, i-> + var keep := new boolean[dvcs.Count]; + var thrs := ArrGen(dvcs.Count, i->new Thread(()-> begin - var del := true; - - var c := new CLContext(dvcs[i]); - var S_Arr := P_Arr.NewSetter(new CLArray(c, test_size)); - var S_Prog := P_Prog.NewSetter(new CLProgramCode(test_prog, c)); - - var thr := new Thread(()-> - begin - del := not c.SyncInvoke(Q_Test, S_Arr, S_Prog); - end); - thr.IsBackground := true; - thr.Start; + keep[i] := nil <> CLContext.Create(dvcs[i]).TestSanity(test_size) + end)); + foreach var thr in thrs do thr.IsBackground := true; + foreach var thr in thrs do thr.Start; + Thread.Sleep(test_max_time); + foreach var thr in thrs do thr.Abort; + + for var i := 0 to dvcs.Count-1 do + if not keep[i] then dvcs[i] := nil; + dvcs.RemoveAll(d->d=nil); + + var chosen := new List(dvcs.Count); + foreach var choise in |true,false|.CartesianPower(dvcs.Count) do + begin + chosen.Clear; + for var i := 0 to dvcs.Count-1 do + if choise[i] then chosen += dvcs[i]; + if chosen.Count=0 then continue; - if not thr.Join(test_max_time) then - thr.Abort; + var c := new CLContext(chosen, chosen[0]); + var time := c.TestSanity(test_size); + if time=nil then continue; - if del then dvcs[i] := nil; - end); - dvcs.RemoveAll(d->d=nil); + Result.Add(ValueTuple.Create(c, time.Value)); + end; - Result := if dvcs.Count=0 then - System.Linq.Enumerable.Empty&<(CLContext,TimeSpan)> else - |true,false|.Cartesian(dvcs.Count) - .Select(choise-> - begin - Result := new List(dvcs.Count); - for var i := 0 to dvcs.Count-1 do - if choise[i] then Result += dvcs[i]; - end) - .Where(l_dvcs->l_dvcs.Count<>0) - .Select(l_dvcs-> - begin - var c := new CLContext(l_dvcs, l_dvcs[0]); - - var sw := Stopwatch.StartNew; - c.SyncInvoke(Q_Test.DiscardResult, - P_Arr.NewSetter(new CLArray(c, test_size)), - P_Prog.NewSetter(new CLProgramCode(test_prog, c)) - ); - sw.Stop; - - Result := (c, sw.Elapsed); - end); - end) - .DefaultIfEmpty((default(CLContext),TimeSpan.Zero)) - .MinBy(t->t[1])[0]; + end; - Interlocked.CompareExchange(_default, c, nil); end; static function CLContext.LoadTestContext: CLContext; @@ -34394,11 +34394,6 @@ begin var br := new System.IO.BinaryReader(System.IO.File.OpenRead(fname)); try var pl_name := br.ReadString; - if pl_name.Length=0 then - begin - $'Pregenerated context was empty'.Println; - exit; - end; var pl := CLPlatform.All.SingleOrDefault(pl->pl.Properties.Name=pl_name); if pl=nil then diff --git a/Tests/.gitignore b/Tests/.gitignore index aef8f0cc..3e9b7cc5 100644 --- a/Tests/.gitignore +++ b/Tests/.gitignore @@ -1 +1,7 @@ -/DebugPCU + + + +/DebugPCU/ +/CLContext/ + + diff --git a/Tests/CLContextGen.pas b/Tests/CLContextGen.pas new file mode 100644 index 00000000..634aaaf4 --- /dev/null +++ b/Tests/CLContextGen.pas @@ -0,0 +1,18 @@ +## uses OpenCLABC; + +var dir := 'CLContext'; +if System.IO.Directory.Exists(dir) then + System.IO.Directory.Delete(dir, true); +System.IO.Directory.CreateDirectory(dir); + +foreach var c in CLContext.GenerateAndCheckAllPossible.OrderBy(\(c,time)->time).Select(\(c,time)->c) index i do +begin + var bw := new System.IO.BinaryWriter(System.IO.File.Create($'{dir}/{i}.dat')); + + bw.Write(c.MainDevice.BaseCLPlatform.Properties.Name); + bw.Write(c.AllDevices.Count); + foreach var dvc in c.AllDevices do + bw.Write(dvc.Properties.Name); + + bw.Close; +end; \ No newline at end of file diff --git a/Tests/Exec/CLABC/gen def context.pas b/Tests/Exec/CLABC/gen def context.pas deleted file mode 100644 index d8c4f111..00000000 --- a/Tests/Exec/CLABC/gen def context.pas +++ /dev/null @@ -1,21 +0,0 @@ -## uses OpenCLABC; - -CLContext.GenerateAndCheckDefault; -var c := CLContext.Default; - -var bw := new System.IO.BinaryWriter(System.IO.File.Create('../../../TestContext.dat')); - -if c=nil then - bw.Write('') else -begin - bw.Write(c.MainDevice.BaseCLPlatform.Properties.Name); - bw.Write(c.AllDevices.Count); - foreach var dvc in c.AllDevices do - bw.Write(dvc.Properties.Name); -end; - -bw.Close; - -// Kill all debug output -System.Environment.ExitCode := 0; -System.Diagnostics.Process.GetCurrentProcess.Kill; \ No newline at end of file diff --git a/Tests/Exec/CLABC/gen def context.td b/Tests/Exec/CLABC/gen def context.td deleted file mode 100644 index b349cbe0..00000000 --- a/Tests/Exec/CLABC/gen def context.td +++ /dev/null @@ -1,18 +0,0 @@ - - - -#Delegates -OpenCL.clCreateContextCallback = procedure(errinfo: string; private_info: System.IntPtr; cb: System.UIntPtr; user_data: System.IntPtr) -OpenCL.clEventCallback = procedure(event: cl_event; event_command_status: clCommandExecutionStatus; user_data: System.IntPtr) -OpenCL.clProgramCallback = procedure(program: cl_program; user_data: System.IntPtr) -OpenCLABC.$delegate? = function(ntv: cl_program; var data: clBool; validate: boolean): clErrorCode -OpenCLABC._GetPropValueFunc = function(ntv: cl_program; var data: T): clErrorCode -OpenCLABC_implementation______.EnqFunc = function(prev_res: T; cq: cl_command_queue; ev_l2: EventList): ValueTuple ()> -OpenCLABC_implementation______.InvokeParamsFunc = function(enq_c: integer; o_const: boolean; g: CLTaskGlobalData; enq_evs: DoubleEventListList): ValueTuple> - -#ExpExecOtp - -#ReqModules -OpenCLABC - - diff --git a/Tests/Tester.pas b/Tests/Tester.pas index ec6cac68..8c149a1b 100644 --- a/Tests/Tester.pas +++ b/Tests/Tester.pas @@ -22,6 +22,11 @@ const MaxExecTime = 15000; +var valid_modules := HSet('Dummy', 'OpenCL','OpenCLABC', 'OpenGL','OpenGLABC'); +var allowed_modules := new HashSet(valid_modules.Count); + +var auto_update := false; + type TestCanceledException = sealed class(Exception) end; @@ -332,6 +337,11 @@ private total_debug_pcu_time: TimeSpan; private debug_pcu := new List<(string, SimpleTimer)>; + private cl_context_gen_time: TimeSpan; + private cl_context_gen_comp: SimpleTimer; + private cl_context_gen_exec: SimpleTimer; + private function get_cl_context_gen_time_sum := cl_context_gen_comp.OuterTime+cl_context_gen_exec.OuterTime; + private actual_comp_time: TimeSpan; private body := new TestingFolderTimer; @@ -357,6 +367,13 @@ foreach var (name,t) in debug_pcu do yield t.MakeLogLines(lvl+2, name).Single; + if 'OpenCLABC' in allowed_modules then + begin + yield (lvl+1, 'CLContext', $'{cl_context_gen_time} ({TimeToText(get_cl_context_gen_time_sum)})'); + yield cl_context_gen_comp.MakeLogLines(lvl+2, 'Comp').Single; + yield cl_context_gen_exec.MakeLogLines(lvl+2, 'Exec').Single; + end; + var (total_comp_time, total_exec_time) := body.TotalCompExecTime; yield (lvl+1, 'All comp', $'{TimeToText(total_comp_time)} ({actual_comp_time.TotalSeconds:N4})'); yield (lvl+1, 'All exec', TimeToText(total_exec_time)); @@ -376,10 +393,7 @@ static lk_console_only := new OtpKind('console only'); static lk_pack_stage_unspecific := new OtpKind('pack stage unspecific'); - static valid_modules := HSet('Dummy', 'OpenCL','OpenCLABC', 'OpenGL','OpenGLABC'); - static allowed_modules := new HashSet(valid_modules.Count); - - static auto_update := false; + static cl_contexts: array of string := nil; static all_loaded := new List; static unused_test_files := new HashSet; @@ -393,7 +407,12 @@ own_timer: TestingItemTimer; pas_fname, test_dir, td_fname: string; stop_test := false; - loaded_test: ExecutingTest; + loaded_tests: array of ExecutingTest := nil; + first_test_exec := true; + + multitest_prop_ids := new List; + multitest_prop_sizes := new Dictionary; + multitest_prop_values := new Dictionary; {$endregion core test info} @@ -408,6 +427,8 @@ {$region typed settings} test_comp: boolean; + + static exec_multitest_id := new object; test_exec: integer; req_modules: IList; @@ -420,6 +441,47 @@ {$endregion typed settings} + {$region Multitest} + + procedure DefineMultitestProp(id: object; size: integer); + begin + if loaded_tests<>nil then raise new InvalidOperationException; + if multitest_prop_values.Any then raise new InvalidOperationException; + + multitest_prop_ids += id; + multitest_prop_sizes.Add(id, size); + + end; + + procedure RunWithMultitestValue(id: object; v: integer; act: Action); + begin + if id not in multitest_prop_sizes then raise new InvalidOperationException; + multitest_prop_values.Add(id, v); + + act(); + + if not multitest_prop_values.Remove(id) then + raise new InvalidOperationException; + end; + + function TakeOutMultitestExecution: ExecutingTest; + begin + if multitest_prop_values.Count <> multitest_prop_ids.Count then raise new InvalidOperationException; + + var i := 0; + foreach var id in multitest_prop_ids do + begin + i *= multitest_prop_sizes[id]; + i += multitest_prop_values[id]; + end; + + Result := loaded_tests[i]; + if Result=nil then raise new InvalidOperationException; + loaded_tests[i] := nil; + end; + + {$endregion Multitest} + {$region Load} static procedure LoadCLA; @@ -468,6 +530,29 @@ core_timer.total_debug_pcu_time := sw.Elapsed; end; + static procedure GenCLContext; + begin + if 'OpenCLABC' not in allowed_modules then exit; + + var sw := Stopwatch.StartNew; + CompilePasFile('Tests/CLContextGen.pas', + new_timer->(core_timer.cl_context_gen_comp := new_timer), + nil, nil, + OtpKind.Empty, '/Debug:1', GetFullPath('Tests/DebugPCU') + ); + Otp($'Running Tests/CLContextGen.exe'); + RunFile('Tests/CLContextGen.exe', nil, + new_timer->(core_timer.cl_context_gen_exec := SimpleTimer(new_timer)), + l->exit(), nil + ); + Otp($'Finished running Tests/CLContextGen.exe'); + + cl_contexts := EnumerateFiles('Tests/CLContext').ToArray; + if cl_contexts.Count=0 then + Otp($'WARNING: Valid OpenCLABC context was not found in system', lk_console_only); + + core_timer.cl_context_gen_time := sw.Elapsed; + end; procedure LoadSettingsDict; begin @@ -617,8 +702,12 @@ end; t.delete_before_exec := t.ExtractSettingStr('#DeleteBeforeExec', '').ToWords(#10).ConvertAll(fname->GetFullPath(fname, t.test_dir)); + t.DefineMultitestProp(exec_multitest_id, t.test_exec); end; + if cl_contexts<>nil then + t.DefineMultitestProp(cl_contexts, cl_contexts.Count); + {$endregion Settings} except @@ -638,8 +727,7 @@ begin var sw := Stopwatch.StartNew; - // req_modules становится nil если не подошло - all_loaded.Where(t->(t.req_modules<>nil) and t.test_comp) + all_loaded.Where(t->t.test_comp) .TaskForEach(t-> try var fwoe := GetRelativePath( @@ -742,8 +830,6 @@ end; - if t.test_exec<>0 then - t.loaded_test := new ExecutingTest(System.IO.Path.ChangeExtension(t.pas_fname, '.exe'), MaxExecTime, true); end; except @@ -753,6 +839,7 @@ core_timer.actual_comp_time := sw.Elapsed; end; + {$endregion Comp} {$region Exec} @@ -813,129 +900,183 @@ if stop_test then begin - Otp($'WARNING: Test[{fwoe}] wasn''t executed because of prior errоrs'); + Otp($'WARNING: Test[{fwoe}] wasn''t executed because of prior errоrs or changes to .td'); exit; end; + var exec_lk := if first_test_exec then + OtpKind.Empty else + lk_pack_stage_unspecific; + first_test_exec := false; + foreach var fname in delete_before_exec do if FileExists(fname) then System.IO.File.Delete(fname) else Otp($'WARNING: [{GetRelativePath(fname)}] did not exist, but Test[{GetRelativePath(fwoe)}] asked to delete it', lk_console_only); for var test_i := 0 to self.test_exec-1 do - begin - - Otp($'Executing Test[{GetRelativePath(fwoe)}]'); - var res, err: string; - own_timer.AddExec(new SimpleTimer(()-> - begin - (res, err) := loaded_test.FinishExecution; - end)); - if test_i<>self.test_exec-1 then loaded_test := new ExecutingTest(loaded_test); - Otp($'Done executing'); - - var sn := ''; - if self.test_exec<>1 then sn += test_i; - - if not string.IsNullOrWhiteSpace(err) then + self.RunWithMultitestValue(exec_multitest_id, test_i, ()-> begin - if exec_expected[test_i].err.parts=nil then - case auto_update ? DialogResult.Yes : MessageBox.Show($'In "{fwoe}.exe":{#10*2}{err}{#10*2}Add this to expected errors?', 'Unexpected exec error', MessageBoxButtons.YesNoCancel) of - - DialogResult.Yes: - begin - all_settings['#ExpExecErr'+sn] := InsertAnyTextParts(err); - used_settings += '#ExpExecErr'+sn; - resave_settings := true; - Otp($'%WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); - end; - - DialogResult.No: ; - - DialogResult.Cancel: Halt(-1); - end else - - if not exec_expected[test_i].err.Matches(err) then - case auto_update ? DialogResult.Yes : MessageBox.Show($'In "{fwoe}.exe"{#10}Expected:{#10*2}{exec_expected[test_i].err}{#10*2}Current error:{#10*2}{err}{#10*2}Replace expected error?', 'Wrong exec error', MessageBoxButtons.YesNoCancel) of - - DialogResult.Yes: - begin - all_settings['#ExpExecErr'+sn] := InsertAnyTextParts(err); - used_settings += '#ExpExecErr'+sn; - resave_settings := true; - Otp($'%WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); - end; - - DialogResult.No: ; - - DialogResult.Cancel: Halt(-1); - end; - - if exec_expected[test_i].otp.parts<>nil then + Otp($'Executing Test[{GetRelativePath(fwoe)}]', exec_lk); + var res, err: string; + own_timer.AddExec(new SimpleTimer(()-> begin - if not all_settings.Remove('#ExpExecOtp'+sn) then raise new System.InvalidOperationException; - resave_settings := true; - end; + (res, err) := self.TakeOutMultitestExecution.FinishExecution; + end)); + Otp($'Done executing', exec_lk); - end else - begin + var sn := ''; + if self.test_exec<>1 then sn += test_i; - if exec_expected[test_i].err.parts<>nil then - case auto_update ? DialogResult.Yes : MessageBox.Show($'In "{fwoe}.exe"{#10}Expected:{#10*2}{exec_expected[test_i].err}{#10*2}Remove error from expected?', 'Missing exec error', MessageBoxButtons.YesNoCancel) of - - DialogResult.Yes: - begin - if not all_settings.Remove('#ExpExecErr'+sn) then raise new System.InvalidOperationException; - resave_settings := true; - Otp($'%WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); + if not string.IsNullOrWhiteSpace(err) then + begin + if exec_expected[test_i].err.parts=nil then + begin + case auto_update ? DialogResult.Yes : MessageBox.Show($'In "{fwoe}.exe":{#10*2}{err}{#10*2}Add this to expected errors?', 'Unexpected exec error', MessageBoxButtons.YesNoCancel) of + + DialogResult.Yes: + begin + all_settings['#ExpExecErr'+sn] := InsertAnyTextParts(err); + used_settings += '#ExpExecErr'+sn; + resave_settings := true; + Otp($'%WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); + end; + + DialogResult.No: ; + + DialogResult.Cancel: Halt(-1); end; + stop_test := true; + end else - DialogResult.No: ; - - DialogResult.Cancel: Halt(-1); + if not exec_expected[test_i].err.Matches(err) then + begin + case auto_update ? DialogResult.Yes : MessageBox.Show($'In "{fwoe}.exe"{#10}Expected:{#10*2}{exec_expected[test_i].err}{#10*2}Current error:{#10*2}{err}{#10*2}Replace expected error?', 'Wrong exec error', MessageBoxButtons.YesNoCancel) of + + DialogResult.Yes: + begin + all_settings['#ExpExecErr'+sn] := InsertAnyTextParts(err); + used_settings += '#ExpExecErr'+sn; + resave_settings := true; + Otp($'%WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); + end; + + DialogResult.No: ; + + DialogResult.Cancel: Halt(-1); + end; + stop_test := true; end; - - if exec_expected[test_i].otp.parts=nil then - begin - all_settings['#ExpExecOtp'+sn] := InsertAnyTextParts(res); - used_settings += '#ExpExecOtp'+sn; - resave_settings := true; - Otp($'WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); + + if exec_expected[test_i].otp.parts<>nil then + begin + if not all_settings.Remove('#ExpExecOtp'+sn) then raise new System.InvalidOperationException; + resave_settings := true; + end; + end else - if not exec_expected[test_i].otp.Matches(res) then begin - case auto_update ? DialogResult.Yes : MessageBox.Show($'In "{fwoe}.exe"{#10}Expected:{#10*2}{exec_expected[test_i].otp}{#10*2}Current output:{#10*2}{res}{#10*2}Replace expected output?', 'Wrong output', MessageBoxButtons.YesNoCancel) of - - DialogResult.Yes: - begin - all_settings['#ExpExecOtp'+sn] := InsertAnyTextParts(res); - used_settings += '#ExpExecOtp'+sn; - resave_settings := true; - Otp($'%WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); + if exec_expected[test_i].err.parts<>nil then + begin + case auto_update ? DialogResult.Yes : MessageBox.Show($'In "{fwoe}.exe"{#10}Expected:{#10*2}{exec_expected[test_i].err}{#10*2}Remove error from expected?', 'Missing exec error', MessageBoxButtons.YesNoCancel) of + + DialogResult.Yes: + begin + if not all_settings.Remove('#ExpExecErr'+sn) then raise new System.InvalidOperationException; + resave_settings := true; + Otp($'%WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); + end; + + DialogResult.No: ; + + DialogResult.Cancel: Halt(-1); end; - - DialogResult.No: ; - - DialogResult.Cancel: Halt(-1); - + stop_test := true; + end; + + if exec_expected[test_i].otp.parts=nil then + begin + all_settings['#ExpExecOtp'+sn] := InsertAnyTextParts(res); + used_settings += '#ExpExecOtp'+sn; + resave_settings := true; + Otp($'WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); + stop_test := true; + end else + if not exec_expected[test_i].otp.Matches(res) then + begin + case auto_update ? DialogResult.Yes : MessageBox.Show($'In "{fwoe}.exe"{#10}Expected:{#10*2}{exec_expected[test_i].otp}{#10*2}Current output:{#10*2}{res}{#10*2}Replace expected output?', 'Wrong output', MessageBoxButtons.YesNoCancel) of + + DialogResult.Yes: + begin + all_settings['#ExpExecOtp'+sn] := InsertAnyTextParts(res); + used_settings += '#ExpExecOtp'+sn; + resave_settings := true; + Otp($'%WARNING: Settings updated for "{fwoe}.td"', lk_pack_stage_unspecific); + end; + + DialogResult.No: ; + + DialogResult.Cancel: Halt(-1); + + end; + stop_test := true; end; + end; - end; - - end; + end); except on e: FatalTestingException do Otp(e.ToString); end; - static procedure ExecAll := - foreach var t in all_loaded do - if (t.req_modules<>nil) and (t.test_exec<>0) then - t.Execute; + static procedure ExecAll; + begin + var to_exec := all_loaded.ToList; + to_exec.RemoveAll(t->t.test_exec=0); + + foreach var t in to_exec do + begin + var exe_fname := System.IO.Path.ChangeExtension(t.pas_fname, '.exe'); + t.loaded_tests := ArrGen(t.multitest_prop_sizes.Values.Product, i-> + new ExecutingTest(exe_fname, MaxExecTime, true) + ); + end; + + if cl_contexts=nil then + begin + foreach var t in to_exec do + t.Execute; + end else + foreach var c_fname in cl_contexts index cl_context_i do + begin + var test_context_fname := 'TestContext.dat'; + System.IO.File.Copy(c_fname, test_context_fname, true); + + var br := new System.IO.BinaryReader(System.IO.File.OpenRead(test_context_fname)); + try + var pl_name := br.ReadString.Trim; + var dvc_count := br.ReadInt32; + Otp($'Switched to platform "{pl_name}" and using {dvc_count} devices', lk_pack_stage_unspecific); + loop dvc_count do + begin + var dvc_name := br.ReadString.Trim; + Otp($'Device "{dvc_name}"', lk_console_only); + end; + finally + br.Close; + end; + + foreach var t in to_exec do + t.RunWithMultitestValue(cl_contexts, cl_context_i, t.Execute); + + System.IO.File.Delete(test_context_fname); + end; + + end; {$endregion Exec} @@ -947,6 +1088,9 @@ if System.IO.Directory.Exists('Tests/DebugPCU') then System.IO.Directory.Delete('Tests/DebugPCU', true); + if all_loaded.Any(t->(t.loaded_tests<>nil) and t.loaded_tests.Any(t->t<>nil)) then + Otp($'WARNING: Not all loaded tests were executed'); + foreach var t in all_loaded do if t.resave_settings then begin @@ -994,6 +1138,7 @@ (**) TestInfo.LoadCLA; TestInfo.MakeDebugPCU; + TestInfo.GenCLContext; // TestInfo.LoadAll('Tests/Comp', 'Comp'); TestInfo.LoadAll('Tests/Exec', 'Comp','Exec'); diff --git a/Utils/Testing/Testing.pas b/Utils/Testing/Testing.pas index 413da498..3ace4ae6 100644 --- a/Utils/Testing/Testing.pas +++ b/Utils/Testing/Testing.pas @@ -30,6 +30,7 @@ {$resource TestExecutor.exe} executor := System.IO.Path.ChangeExtension(executable, '.Executor.exe'); + if not FileExists(executor) then begin var executor_f := System.IO.File.Create(executor); GetResourceStream('TestExecutor.exe').CopyTo(executor_f);