forked from sanekgusev/LinX-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitMain.pas
1834 lines (1659 loc) · 65.2 KB
/
UnitMain.pas
1
2
3
4
5
6
7
8
9
10
11
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{$STRINGCHECKS OFF}
unit UnitMain;
interface
uses
Windows, Messages, SysUtils, {Variants,} Classes, Graphics, Controls, Forms,
{Dialogs,} StdCtrls, Menus, ExtCtrls, ComCtrls, MMSystem, IniFiles,
Buttons, UnitLogWatch;
type
TFormMain = class(TForm)
ComboBoxPS: TComboBox;
ComboBoxRuns: TComboBox;
MemoLog: TMemo;
LabelPS: TLabel;
LabelRuns: TLabel;
ComboBoxMem: TComboBox;
LabelMem: TLabel;
TimerMain: TTimer;
MainMenu: TMainMenu;
MIAbout: TMenuItem;
StatusBar: TStatusBar;
MIGraphs: TMenuItem;
ListViewTable: TListView;
SpeedButtonAllMem: TSpeedButton;
MIFile: TMenuItem;
MIScreenshot: TMenuItem;
MILog: TMenuItem;
MISettings: TMenuItem;
TrayIcon: TTrayIcon;
PopupMenuTray: TPopupMenu;
TMMinimize: TMenuItem;
TMStart: TMenuItem;
TMStop: TMenuItem;
TMExit: TMenuItem;
TMSep1: TMenuItem;
TMSep2: TMenuItem;
PopupMenuSettings: TPopupMenu;
SM32: TMenuItem;
SM64: TMenuItem;
SMSep1: TMenuItem;
SMStopOnError: TMenuItem;
SMSounds: TMenuItem;
SMTrayIcon: TMenuItem;
MISep1: TMenuItem;
MIExit: TMenuItem;
SMSavelog: TMenuItem;
ShapeBase: TShape;
SpeedButtonStart: TSpeedButton;
SpeedButtonStop: TSpeedButton;
SMThreads: TMenuItem;
SMSep2: TMenuItem;
ShapeBar: TShape;
LabelStatus: TLabel;
ComboBoxTimesMinutes: TComboBox;
SMFullSettings: TMenuItem;
SMSep4: TMenuItem;
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure Panel1DblClick(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure MIAboutClick(Sender: TObject);
procedure ComboBoxRunsChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SpeedButtonStopClick(Sender: TObject);
procedure TimerMainTimer(Sender: TObject);
procedure ComboBoxMemChange(Sender: TObject);
procedure ComboBoxPSChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpeedButtonStartClick(Sender: TObject);
procedure MIDisplayClick(Sender: TObject);
procedure SpeedButtonAllMemClick(Sender: TObject);
procedure MIScreenshotClick(Sender: TObject);
procedure MILogClick(Sender: TObject);
procedure th1Click(Sender: TObject);
procedure MISettingsClick(Sender: TObject);
procedure TMMinimizeClick(Sender: TObject);
procedure ComboBoxMemCloseUp(Sender: TObject);
procedure ComboBoxPSCloseUp(Sender: TObject);
procedure SMThreadsClick(Sender: TObject);
procedure PopupMenuSettingsPopup(Sender: TObject);
procedure SM32Click(Sender: TObject);
procedure SMStopOnErrorClick(Sender: TObject);
procedure SMSavelogClick(Sender: TObject);
procedure SMSoundsClick(Sender: TObject);
procedure SMTrayIconClick(Sender: TObject);
procedure MIExitClick(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure StatusBarClick(Sender: TObject);
procedure TMStartClick(Sender: TObject);
procedure PopupMenuTrayPopup(Sender: TObject);
procedure TMStopClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure OnMinimize(Sender : TObject);
procedure PSandMem(IsSourceSize : boolean; var PS: integer; showmsg: boolean);
procedure ShowFreeMemory;
procedure ShowEstimatedTime;
procedure ShowElapsedTime;
procedure ShowFinishTime;
procedure ToggleTableLog;
procedure ToggleGlass(enable : boolean);
procedure ComboBoxTimesMinutesKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
procedure WMNCLBUTTONDBLCLK(var msg: TMessage); message WM_NCLBUTTONDBLCLK;
public
{ Public declarations }
end;
dataarray = array of single;
function Monitoring(b_everest, b_speedfan, b_temps, b_fans, b_vcores, b_p12vs,
b_testing : boolean; var infostr : string) : boolean;
function SetWinHeight(curr_count : integer; total_count : integer;
def_items_count, min_items_count,row_height : byte;
def_win_height : integer) : integer;
procedure SaveSettingsToINI;
procedure SaveLogFile;
function GetThreadsString(threads : byte) : string;
const
inputfile_name = 'lininput';
temps_file_name = 'CPU Temp';
fans_file_name = 'CPU Fan speed';
vcores_file_name = 'CPU Vcore';
p12vs_file_name = '+12V';
SFinifile_name = 'Speedfan.ini';
maininifile_name = 'LinX.ini';
localizationfile_name = 'local.lng';
TangoGreen1 = $34e28a;
TangoGreen2 = $16d273;
TangoGreen3 = $069a4e;
TangoBlue1 = $cf9f72;
//TangoBlue2 = $a46534;
TangoBlue3 = $874a20;
TangoRed1 = $2929ef;
//TangoRed2 = $0000cc;
TangoRed3 = $0000a4;
TangoGray1 = $eceeee;
TangoGray2 = $cfd7d3;
TangoGray3 = $b6bdba;
TangoGray6 = $36342e;
TangoYellow1 = $4fe9fc;
//TangoYellow2 = $00d4ed;
TangoYellow3 = $00a0c4;
TangoOrange1 = $3EAFFC;
//TangoOrange2 = $0079F5;
TangoOrange3 = $005CCE;
TangoViolet1 = $A87FAD;
//TangoViolet2 = $7B5075;
TangoViolet3 = $66355C;
progname = 'LinX';
//Where OS matters...
Lin32XP = 16134;
Lin32Vista = 15500;
MinProblemSize = 500;
DefProblemSize = 10000;
DefNumberOfRuns = 20;
DefNumberOfMinutes = 30;
var
FormMain: TFormMain;
LogWatch : TLogWatchThread;
version : string;
sound_time : integer;
StartTime : TDateTime; total_time : integer; run_time : integer;
x64, was_error : boolean; glass: boolean = false; everest_imp : boolean = false; speedfan_imp : boolean = false;
LinpackLog : string;
time_show_mode : byte = 4;
LinpackProcessInfo : TProcessInformation;
win_height : smallint; //Hello, thick vista borders!
table_line_height : byte;
temps, fans, vcores, p12vs : dataarray;
buildtemps : boolean = false; buildfans : boolean = false;
buildvcores : boolean = false; buildp12vs : boolean = false;
max_temp : byte = 0;
SFsettings : array[0..7] of byte;
total_mem : integer;
ProblemSize : integer = DefProblemSize; tmpProblemSize : integer;
NumberOfRuns : integer = DefNumberOfRuns;
NumberOfMinutes : integer = -1;
lin32exe_name : string = 'linpack_xeon32.exe';
lin64exe_name : string = 'linpack_xeon64.exe';
GraphWindows : array[1..4] of TRect;
maxsize_lin32 : integer = Lin32XP;
maxmem_offset : byte = 5;
dataalign : byte = 4;
useoptld : boolean = true;
NumberOfThreads : byte = 0;
NumberOfCPUs : byte = 0;
x64mode : boolean = false;
lin_priority : byte = 2;
stoponerror : boolean = true;
autosavelog : boolean = false;
sounds : boolean = false;
datetimeinnames : boolean = true;
stoponoverheat : boolean = false;
stop_temp : byte = 75;
simplecaption : boolean = false;
Tray0, Tray1, Tray2, Tray3 : TIcon;
str_CPUName : string;
str_PS_LDnum_align : string;
{ Here they go, the strings! }
idle_win_capt : string = 'Simply Linpack';
test_win_capt : string = 'Testing';
err_win_capt : string = 'Error';
hot_win_capt : string = 'CPU Overheat';
done_win_capt : string = 'Finished';
stop_win_capt : string = 'Stopped';
str_temps_capt : string = 'CPU Temperature';
str_fans_capt : string = 'CPU Fan Speed';
str_vcores_capt : string = 'CPU Core Voltage';
str_p12vs_capt : string = '+12 V Voltage';
msg_nomem : string = 'Not enough physical memory! Values corrected.';
msg_noexe : string = 'Some of the Linpack files are missing. LinX will quit now.';
msg_lin_error : string = 'Linpack has stopped unexpectedly (not enough memory?). Press the "Log >" button for details';
msg_exit_prompt : string = 'Testing in progress! Shutdown Linpack and quit anyway?';
msg_mem2048 : string = 'Cannot allocate more than 2 GB of memory due to Linpack32 limitation. Values corrected.';
str_stop : string = 'Stopped on demand after';
str_done : string = 'Finished without errors in';
str_err : string = 'Stopped upon error after';
str_hot : string = 'Stopped upon overheat after';
str_done_err : string = 'Finished with errors in';
str_freemem : string = 'Physical memory available:';
str_CPU : string = 'CPU:'; str_peak : string = 'peak';
str_mib : string = 'MiB'; str_flops : string = 'GFlops';
str_32 : string = '32-bit'; str_64 : string = '64-bit';
str_h : string = 'h'; str_m : string = 'm'; str_s : string = 's';
str_grad : string = '°'; str_volts : string = 'V'; str_mhz : string = 'MHz';
str_sep : string = '|'; str_log : string = 'Log ›'; str_table : string = '‹ Table';
str_rpm : string = 'RPM'; str_celsius : string = '°C';
str_wait : string = 'Please wait…';
str_finish_time : string = 'Estimated finish time:';
str_elapsed : string = 'Elapsed';
str_remaining : string = 'Remaining';
str_thread : string = 'thread'; str_threads : string = 'threads';
str_threadsalt : string = 'threads';
str_custom : string = 'Custom';
str_tray_hide : string = 'Minimize'; str_tray_restore : string = 'Restore';
memo_hint1 : string = 'Double click - show free memory';
memo_hint2 : string = 'Click - cycle time view modes, double click - disable time';
memo_hint3 : string = 'Right mouse click - settings menu';
msg_comline : string = 'All command-line parameters start with a „-“ or a „/“,' + #13#10 +
'e. g. /help or -help. X is any decimal digit.' + #13#10 + #13#10 +
'Supported command-line switches:' + #13#10 + #13#10 +
'?, h, help - displays this message;' + #13#10 +
'psXXXXX - sets the desired Problem size value;' + #13#10 +
'mXXXX - sets the desired Memory to use value in MiB;' + #13#10 +
'nXXX - sets the desired Number of runs value;' + #13#10 +
'tXXX - sets the desired Time to run (in minutes) value;' + #13#10 +
'mm, maxmemory - enable using all available memory;' + #13#10 +
'64 - use 64-bit Linpack (ignored on 32-bit OS);' + #13#10 +
'32 - use 32-bit Linpack (ignored on 32-bit OS);' + #13#10 +
'm, minimized - start minimized;' + #13#10 +
'a, autostart - testing will start immediately.' + #13#10 + #13#10 +
'Any combination of the above switches is acceptable,' + #13#10 +
'however, some switches will override others.';
msg_comline_capt : string = 'LinX command-line switches';
implementation
uses UnitGraph, UnitSett, UnitAbout, LinX_routines;
{$R *.dfm}
procedure TFormMain.WMNCLBUTTONDBLCLK(var msg: TMessage);
begin
if msg.wParam = HTCAPTION then
if FormStyle <> fsStayOnTop then FormStyle := fsStayOnTop
else FormStyle := fsNormal;
inherited;
end;
procedure TFormMain.MIAboutClick(Sender: TObject);
begin
FormAbout := TFormAbout.Create(Self);
with FormAbout do
try
ShowModal;
finally
FreeandNil(FormAbout);
end;
end;
procedure TFormMain.SpeedButtonStopClick(Sender: TObject);
begin
TerminateProcess(LinpackProcessInfo.hProcess, 2);
end;
procedure TFormMain.SpeedButtonStartClick(Sender: TObject);
var LeadingDimensions : integer;
begin
was_error := false;
sound_time := 0;
max_temp := 0;
LinpackLog := '';
run_time := 0;
total_time := 1;
StartTime := Now;
time_show_mode := 1;
temps := nil;
fans := nil;
vcores := nil;
p12vs := nil;
PSandMem(true, ProblemSize, false);
ListviewTable.Clear;
if not listviewTable.Visible then ToggleTableLog;
SpeedButtonStop.Enabled := true;
SpeedButtonStart.Enabled := false;
SpeedButtonAllMem.Enabled := false;
MILog.Enabled := true;
ComboBoxPS.Enabled := false;
ComboBoxRuns.Enabled := false;
ComboBoxMem.Enabled := false;
ComboBoxTimesMinutes.Enabled := false;
LabelStatus.Hint := memo_hint2;
Statusbar.Panels[0].Text := '';
if x64mode then Statusbar.Panels[1].Text := str_64
else Statusbar.Panels[1].Text := str_32;
Statusbar.Panels[2].Text := GetThreadsString(NumberOfThreads);
Statusbar.Panels[3].Text := '';
Statusbar.Panels[5].Text := '';
ShapeBar.Pen.Color := TangoGreen3;
ShapeBar.Visible := false;
if stoponerror then ShapeBar.Brush.Color := TangoGreen1
else ShapeBar.Brush.Color := TangoGray2;
Caption := test_win_capt + ' - ' + version;
TrayIcon.Icon := Tray0;
LeadingDimensions := SetLeadingDimensions(ProblemSize, UseOptLD);
CreateInputFile(inputfile_name, ProblemSize,
LeadingDimensions, NumberOfRuns, DataAlign, Version, x64Mode);
str_PS_LDnum_align := SetOutputString(ProblemSize, LeadingDimensions, DataAlign);
SaveSettingsToINI;
LogWatch := TLogWatchThread.Create(true);
LogWatch.FreeOnTerminate := true;
LogWatch.Resume;
ShowElapsedTime;
end;
procedure TFormMain.ToggleTableLog;
begin
if ListViewTable.Visible then begin
Statusbar.Panels[5].Text := str_table;
ListViewTable.Visible := false;
MemoLog.Text := LinpackLog;
MemoLog.SelStart := 0;
Constraints.MaxHeight := win_height - 10 * table_line_height + MemoLog.Lines.Count * 14 - 10;
if Top + Constraints.MaxHeight < Screen.Height - 40
then Height := Constraints.MaxHeight;
ShapeBar.Constraints.MaxWidth := ShapeBar.Constraints.MaxWidth + 50;
Constraints.MaxWidth := Constraints.MaxWidth + 50; //50 was enough =)
Constraints.MinWidth := Constraints.MaxWidth;
MemoLog.Visible := true;
MemoLog.SetFocus;
end
else begin
Statusbar.Panels[5].Text := str_log;
MemoLog.Visible := false;
Constraints.MinWidth := Constraints.MaxWidth - 50;
Constraints.MaxWidth := Constraints.MaxWidth - 50;
ShapeBar.Constraints.MaxWidth := ShapeBar.Constraints.MaxWidth - 50;
Constraints.MaxHeight := SetWinHeight(ListViewTable.Items.Count,
NumberOfRuns,10,5,table_line_height,win_height);
ListViewTable.Visible := true;
end;
end;
procedure TFormMain.ComboBoxPSChange(Sender: TObject);
begin
PSandMem(true, ProblemSize, true);
end;
procedure TFormMain.ComboBoxPSCloseUp(Sender: TObject);
begin
PSandMem(true, ProblemSize, false);
end;
procedure TFormMain.ComboBoxRunsChange(Sender: TObject);
var number : integer;
begin
number := strtointdef(ComboBoxRuns.Text, 0);
ComboboxRuns.Text := inttostr(number);
if number = 0 then SpeedButtonStart.Enabled := false
else
if (ProblemSize >= MinProblemSize) and (time_show_mode > 3) then SpeedButtonStart.Enabled := true;
if ComboBoxTimesMinutes.ItemIndex = 0 then begin
if ListViewTable.Visible
then Constraints.MaxHeight := SetWinHeight(ListViewTable.Items.Count,
number,10,5,table_line_height,
win_height);
NumberOfRuns := number;
NumberOfMinutes := -1;
end
else begin
if ListViewTable.Visible
then Constraints.MaxHeight := 0;
NumberOfMinutes := number;
NumberOfRuns := high(integer);
end;
end;
procedure TFormMain.MIExitClick(Sender: TObject);
begin
Close;
end;
procedure TFormMain.ComboBoxTimesMinutesKeyPress(Sender: TObject; var Key: Char);
begin
Key := #0;
end;
procedure TFormMain.ComboBoxMemChange(Sender: TObject);
begin
PSandMem(false, ProblemSize, true);
end;
procedure TFormMain.ComboBoxMemCloseUp(Sender: TObject);
begin
PSandMem(false, ProblemSize, false);
end;
procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if time_show_mode < 4 then begin
if MessageBox(Handle, PChar(msg_exit_prompt), PChar(version),
MB_YESNO or MB_ICONQUESTION) = IDYES
then TerminateProcess(LinpackProcessInfo.hProcess, 2)
else Action := caNone;
end;
end;
procedure TFormMain.FormCreate(Sender: TObject);
var maininifile, SFinifile, localizationfile : tinifile;
ok32, ok64 : boolean; h : integer; EXEDirectory : string;
procedure FillComboboxMem(var CB : TCombobox; TotalMemory : integer);
var CurValue, Increment : integer; I : byte;
begin
Increment := 16;
CurValue := 16;
i := 0;
while CurValue <= TotalMemory do begin
CB.Items.Append(Inttostr(CurValue));
if CurValue <= 256 then Increment := CurValue
else
if CurValue >= 2048 then begin
if (i mod 4 = 0) then inc(Increment, Increment);
inc(i);
end;
inc(CurValue, Increment);
end;
end;
procedure FillComboboxSize(var CB : TCombobox; TotalMemory : integer);
var MaxProblemSize : integer; i : byte;
begin
MaxProblemSize := memtosize(TotalMemory);
for I := 1 to (MaxProblemSize div 1000) do
CB.Items.Append(Inttostr(i*1000));
end;
procedure FillPopupMenu(var Menu : TMenuItem; Num : byte);
var Item : TMenuItem; i : byte;
begin
for I := 0 to Num - 1 do begin
item := Tmenuitem.Create(Menu);
item.Caption := GetThreadsString(i + 1);
item.RadioItem := true;
item.AutoCheck := true;
item.OnClick := th1Click;
Menu.Insert(Menu.Count, item);
end;
item := Tmenuitem.Create(Menu);
item.Caption := str_custom;
item.RadioItem := true;
item.Enabled := false;
item.Visible := false;
Menu.Insert(Menu.Count, item);
end;
procedure localize;
begin
With localizationfile do begin
localizationfile := tinifile.Create(EXEDirectory +
localizationfile_name);
LabelPS.Caption:=readstring('Interface','ProblemSize',LabelPS.Caption);
LabelMem.Caption:=readstring('Interface','MemoryToUse',LabelMem.Caption);
SpeedButtonAllMem.Caption:=readstring('Interface','AllMem',SpeedButtonAllMem.Caption);
LabelRuns.Caption:=readstring('Interface','NumberOfTimes',LabelRuns.Caption);
ComboboxTimesMinutes.Items.Strings[0] := readstring('Interface','Times',ComboboxTimesMinutes.Items.Strings[0]);
ComboboxTimesMinutes.Items.Strings[1] := readstring('Interface','Minutes',ComboboxTimesMinutes.Items.Strings[1]);
ComboboxTimesMinutes.ItemIndex := 0;
SpeedButtonStart.Caption:=readstring('Interface','Start',SpeedButtonStart.Caption);
SpeedButtonStop.Caption:=readstring('Interface','Stop',SpeedButtonStop.Caption);
LabelPS.Hint:=readstring('Hints','ProblemSize',LabelPS.Hint);
ComboBoxPS.Hint:=readstring('Hints','ComboboxHint',ComboBoxPS.Hint);
ComboBoxMem.Hint := ComboBoxPS.Hint;
ComboBoxRuns.Hint := ComboBoxPS.Hint;
LabelMem.Hint:=readstring('Hints','MemoryToUse',LabelMem.Hint);
SpeedButtonAllMem.Hint:=readstring('Hints','AllMem',SpeedButtonAllMem.Hint);
LabelRuns.Hint:=readstring('Hints','NumberOfTimes',LabelRuns.Hint);
SpeedButtonStart.Hint:=readstring('Hints','Start',SpeedButtonStart.Hint);
SpeedButtonStop.Hint:=readstring('Hints','Stop',SpeedButtonStop.Hint);
memo_hint1:=readstring('Hints','StatusPanel1',memo_hint1);
memo_hint2:=readstring('Hints','StatusPanel2',memo_hint2);
memo_hint3:=readstring('Hints','StatusPanel3',memo_hint3);
MIFile.Caption:=readstring('MainMenu','File',MIFile.Caption);
MIScreenshot.Caption:=readstring('MainMenu','SaveScreenshot',
MIScreenshot.Caption);
MILog.Caption:=readstring('MainMenu','SaveTextLog',
MILog.Caption);
MIExit.Caption := readstring('MainMenu','Exit',
MIExit.Caption);
MISettings.Caption:=readstring('MainMenu','Settings',MISettings.Caption);
MIGraphs.Caption:=readstring('MainMenu','Graphs',MIGraphs.Caption);
idle_win_capt:= {version + ' - ' +} readstring('WindowCaptions','Idle',idle_win_capt);
test_win_capt:= readstring('WindowCaptions','Test',test_win_capt){ + ' - ' + version};
err_win_capt:= readstring('WindowCaptions','Error',err_win_capt) {+ ' - ' + version};
hot_win_capt:= readstring('WindowCaptions','Overheat',hot_win_capt) {+ ' - ' + version};
done_win_capt:= readstring('WindowCaptions','Done',done_win_capt) {+ ' - ' + version};
stop_win_capt:= readstring('WindowCaptions','Stop',stop_win_capt) {+ ' - ' + version};
str_temps_capt:=readstring('GraphCaptions','Temp',str_temps_capt);
str_fans_capt:=readstring('GraphCaptions','Fan',str_fans_capt);
str_vcores_capt:=readstring('GraphCaptions','VCore',str_vcores_capt);
str_p12vs_capt:=readstring('GraphCaptions','12V',str_p12vs_capt);
msg_noexe:=readstring('Messages','NoEXE',msg_noexe);
msg_nomem:=readstring('Messages','NoMem',msg_nomem);
msg_mem2048:=readstring('Messages','Lin32Lim',msg_mem2048);
msg_exit_prompt:=readstring('Messages','ExitConfirm',msg_exit_prompt);
if readstring('CommandLine','1','') <> ''
then msg_comline:=readstring('CommandLine','1','') + #13#10 +
readstring('CommandLine','2','') + #13#10 + #13#10 +
readstring('CommandLine','3','') + #13#10 + #13#10 +
readstring('CommandLine','4','') + #13#10 +
readstring('CommandLine','5','') + #13#10 +
readstring('CommandLine','6','') + #13#10 +
readstring('CommandLine','7','') + #13#10 +
readstring('CommandLine','8','') + #13#10 +
readstring('CommandLine','9','') + #13#10 +
readstring('CommandLine','10','') + #13#10 +
readstring('CommandLine','11','') + #13#10 +
readstring('CommandLine','12','') + #13#10 +
readstring('CommandLine','13','') + #13#10 + #13#10 +
readstring('CommandLine','14','') + #13#10 +
readstring('CommandLine','15','');
msg_comline_capt := readstring('CommandLine','Caption',msg_comline_capt);
str_freemem:=readstring('StatusPanel','Idle',str_freemem);
str_stop:=readstring('StatusPanel','Stop',str_stop);
str_done:=readstring('StatusPanel','Done',str_done);
str_done_err:=readstring('StatusPanel','DoneWError',str_done_err);
str_err:=readstring('StatusPanel','Error',str_err);
str_hot:=readstring('StatusPanel','Overheat',str_hot);
msg_lin_error:=readstring('StatusPanel','LinStopped',msg_lin_error);
str_elapsed:=readstring('StatusPanel','Elapsed',str_elapsed);
str_remaining:=readstring('StatusPanel','Remaining',str_remaining);
str_finish_time:=readstring('StatusPanel','FinishTime',str_finish_time);
str_wait:=readstring('StatusPanel','Wait',str_wait);
ListViewTable.Columns[0].Caption:=readstring('OutputTable','Number',ListViewTable.Columns[0].Caption);
ListViewTable.Columns[1].Caption:=readstring('OutputTable','Size',ListViewTable.Columns[1].Caption);
ListViewTable.Columns[2].Caption:=readstring('OutputTable','LDA',ListViewTable.Columns[2].Caption);
ListViewTable.Columns[3].Caption:=readstring('OutputTable','Align',ListViewTable.Columns[3].Caption);
ListViewTable.Columns[4].Caption:=readstring('OutputTable','Time',ListViewTable.Columns[4].Caption);
ListViewTable.Columns[5].Caption:=readstring('OutputTable','GFlops',ListViewTable.Columns[5].Caption);
ListViewTable.Columns[6].Caption:=readstring('OutputTable','Residual',ListViewTable.Columns[6].Caption);
ListViewTable.Columns[7].Caption:=readstring('OutputTable','Residual(norm)',ListViewTable.Columns[7].Caption);
str_cpu:=readstring('Statusbar','CPU',str_cpu);
str_peak:=readstring('Statusbar','Peak',str_peak);
str_sep:=readstring('Statusbar','Separator',str_sep);
str_log:=readstring('Statusbar','Log',str_log);
str_table:=readstring('Statusbar','Table',str_table);
str_mib := readstring('MeasUnits','MiB',str_mib);
str_flops:=readstring('MeasUnits','GFlops',str_flops);
str_32 := readstring('MeasUnits','32',str_32);
str_64 := readstring('MeasUnits','64',str_64);
SM32.Caption := str_32;
SM64.Caption := str_64;
str_h:=readstring('MeasUnits','h',str_h);
str_m:=readstring('MeasUnits','m',str_m);
str_s:=readstring('MeasUnits','s',str_s);
str_grad:=readstring('MeasUnits','Grad',str_grad);
str_celsius:=readstring('MeasUnits','Celsius',str_celsius);
str_volts:=readstring('MeasUnits','Volt',str_volts);
str_mhz:=readstring('MeasUnits','MHz',str_mhz);
str_rpm:=readstring('MeasUnits','RPM',str_rpm);
str_tray_hide := readstring('TrayMenu','Minimize',str_tray_hide);
str_tray_restore := readstring('TrayMenu','Restore',str_tray_restore);
TMExit.Caption := readstring('TrayMenu','Exit',TMExit.Caption);
TMStart.Caption := SpeedButtonStart.Caption;
TMStop.Caption := SpeedButtonStop.Caption;
SMFullSettings.Caption := readstring('SettingsMenu','AllSettings',SMFullSettings.Caption);
str_thread := readstring('SettingsMenu','Thread',str_thread);
str_threads := readstring('SettingsMenu','Threads',str_threads);
str_threadsalt := readstring('SettingsMenu','ThreadsAlt',str_threadsalt);
SMThreads.Caption := readstring('SettingsMenu','ThreadsCaption', SMThreads.Caption);
str_custom := readstring('SettingsMenu','Custom',str_custom);
SMStopOnError.Caption := readstring('SettingsMenu','StopOnError',SMStopOnError.Caption);
SMSaveLog.Caption := readstring('SettingsMenu','AutoSaveLog',SMSaveLog.Caption);
SMSounds.Caption := readstring('SettingsMenu','Sounds',SMSounds.Caption);
SMTrayIcon.Caption := readstring('SettingsMenu','TrayIcon',SMTrayIcon.Caption);
free;
end;
end;
procedure ParseCommandLine;
var i : integer; helpshown, autostart, allmem : boolean; s : string;
begin
i := 1;
helpshown := false;
autostart := false;
allmem := SpeedButtonAllMem.Down;
tmpProblemSize := ProblemSize;
while (i <= ParamCount) and ((ParamStr(i)[1] = '-') or (ParamStr(i)[1] = '/'))
do begin
s := ParamStr(i);
delete(s, 1, 1);
if ((s = 'help') or (s = 'h') or (s = '?')) and not helpshown then begin
helpshown := true;
MessageBox(Handle, Pchar(msg_comline), Pchar(msg_comline_capt), MB_OK or MB_ICONINFORMATION);
end
else
if (s = 'mm') or (s = 'maxmemory') then allmem := true
else
if (s = 'm') or (s = 'minimized') and not TrayIcon.Visible
then TMMinimize.Click
else
if pos('ps', s) = 1 then begin
delete(s, 1, 2);
tmpProblemSize := strtointdef(s, ProblemSize);
allmem := false;
end
else
if pos('m', s) = 1 then begin
delete(s, 1, 1);
tmpProblemSize := memtosize(strtointdef(s, sizetomem(ProblemSize)));
allmem := false;
end
else
if pos('n', s) = 1 then begin
delete(s, 1, 1);
NumberOfRuns := strtointdef(s, NumberOfRuns);
NumberOfMinutes := -1;
end
else
if pos('t', s) = 1 then begin
delete(s, 1, 1);
NumberOfRuns := high(integer);
NumberOfMinutes := strtointdef(s, DefNumberOfMinutes);
end
else
if (s = 'a') or (s = 'autostart') then autostart := true
else
if (s = '64') and x64 then x64mode := true
else
if (s = '32') and x64 then x64mode := false
else
if s = 'simpletitle' then begin
version := progname;
simplecaption := true;
Caption := version + ' - ' + idle_win_capt;
end;
inc(i);
end;
if (NumberOfMinutes = -1) then begin
ComboboxRuns.Text := inttostr(NumberOfRuns);
ComboBoxTimesMinutes.ItemIndex := 0;
end
else begin
ComboboxRuns.Text := inttostr(NumberOfMinutes);
ComboBoxTimesMinutes.ItemIndex := 1;
end;
SpeedButtonAllMem.Down := allmem;
SpeedbuttonAllMem.Click;
if autostart then SpeedButtonStart.Click;
end;
begin
version := progname + ' ' + GetVersion(false);
EXEDirectory := ExtractFilePath(Application.ExeName);
SetCurrentDir(EXEDirectory);
localize;
Caption := version + ' - ' + idle_win_capt;
if not fileexists(EXEDirectory + lin32exe_name) then begin
lin32exe_name := EXEDirectory + '32-bit/' + lin32exe_name;
ok32 := fileexists(lin32exe_name);
end
else begin
lin32exe_name := EXEDirectory + lin32exe_name;
ok32 := true;
end;
if not fileexists(EXEDirectory + lin64exe_name) then begin
lin64exe_name := EXEDirectory + '64-bit/' + lin64exe_name;
ok64 := fileexists(lin64exe_name);
end
else begin
lin64exe_name := EXEDirectory + lin64exe_name;
ok64 := true;
end;
x64 := IsX64Supported;
if ok32 or (ok64 and x64) then begin
if x64 then
if not ok32 then begin
x64mode := true;
x64 := false;
end
else
if not ok64 then x64 := false;
if Screen.PixelsPerInch <> PixelsPerInch then begin
ScaleBy(Screen.PixelsPerInch, PixelsPerInch);
end;
if Win32MajorVersion > 5 then begin
ClientHeight := 275;
Constraints.MinHeight := Height - 85;
table_line_height := 17;
end
else begin
ClientHeight := 241;
Constraints.MinHeight := Height - 70;
table_line_height := 14;
end;
win_height := Height;
ClientWidth := 515;
Constraints.MaxWidth := Width;
Constraints.MinWidth := Width;
ComboBoxPS.Left := LabelPS.Left + labelPS.Width + 5;
LabelMem.Left := ComboBoxMem.Left - LabelMem.Width - 5;
LabelRuns.Left := ComboBoxRuns.Left - LabelRuns.Width - 5;
ShapeBar.Constraints.MaxWidth := ShapeBase.Width - 4;
total_mem := GetTotalMemory;
FillComboboxMem(ComboboxMem, total_mem);
FillComboboxSize(ComboboxPS,total_mem);
//FillChar(SA, SizeOf(TSecurityAttributes), #0);
//SA.nLength := SizeOf(TSecurityAttributes);
//SA.bInheritHandle := True;
//LinpackPipeRead := CreateNamedPipe('\\.\pipe\linx', PIPE_ACCESS_INBOUND or
// FILE_FLAG_OVERLAPPED, 0, 2, 1024, 1024, 0, @SA);
//LinpackPipeWrite := CreateFile('\\.\pipe\linx', {GENERIC_READ or} GENERIC_WRITE,
// {FILE_SHARE_READ or FILE_SHARE_WRITE}0, @SA, OPEN_EXISTING,
// FILE_ATTRIBUTE_NORMAL{ or FILE_FLAG_OVERLAPPED}, 0);
LabelStatus.Hint := memo_hint3;
Application.Title := version;
Application.OnMinimize := OnMinimize;
Tray0 := TIcon.Create;
Tray0.Handle := LoadIcon(HInstance, 'Tray0');
Tray1 := TIcon.Create;
Tray1.Handle := LoadIcon(HInstance, 'Tray1');
Tray2 := TIcon.Create;
Tray2.Handle := LoadIcon(HInstance, 'Tray2');
Tray3 := TIcon.Create;
Tray3.Handle := LoadIcon(HInstance, 'Tray3');
TrayIcon.Icon := Tray1;
TrayIcon.Hint := version;
str_CPUName := GetCPUName;
Statusbar.Panels[4].Text := str_CPUName;
Decimalseparator := '.'; //Kiss EConvertError good-bye!
NumberOfCPUs := GetMaxThreadsNumber;
FillPopupMenu(SMThreads,NumberOfCPUs);
if Getdrivetype(Pchar(ExtractFileDrive(Application.EXEName))) = DRIVE_CDROM
then SetCurrentDir(GetTempFolderPath);
With maininifile do begin
maininifile := Tinifile.Create(GetCurrentDir + '\' + maininifile_name);
ClientHeight := readinteger('Window','ClientHeight',ClientHeight);
Top := readinteger('Window','Top',Top);
if Top < 0 then Top := 0
else
if Top > Screen.Height - Height then Top := Screen.Height - Height;
Left := readinteger('Window','Left',Left);
if Left < 0 then Left := 0
else
if Left > Screen.Width - Width then Left := Screen.Width - Width;
SpeedButtonAllMem.Down := readbool('Settings','UseAllMem',SpeedButtonAllMem.Down);
stoponerror := readbool('Settings','StopOnError',stoponerror);
autosavelog := readbool('Settings','AutoSaveLog',autosavelog);
stop_temp := readinteger('Settings','OverheatValue',stop_temp);
sounds := readbool('Settings','EnableSounds',sounds);
datetimeinnames := readbool('Settings','DateTimeInFilenames',datetimeinnames);
ShowHint:= readbool('Settings','ShowHints',ShowHint);
Trayicon.Visible := readbool('Settings','TrayIcon',Trayicon.Visible);
speedfan_imp := readbool('Settings','SpeedfanImport',speedfan_imp);
everest_imp := readbool('Settings','EverestImport',everest_imp);
if speedfan_imp or everest_imp then begin
stoponoverheat := readbool('Settings','StopOnOverheat',stoponoverheat);
end;
buildtemps := readbool('Settings', 'TempGraph', buildtemps);
buildfans := readbool('Settings', 'FanGraph', buildfans);
buildvcores := readbool('Settings', 'VcoreGraph', buildvcores);
buildp12vs := readbool('Settings', 'P12VGraph', buildp12vs);
if Win32MajorVersion >= 6 then begin
maxsize_lin32 := Lin32Vista;
glass := readbool('Settings','GlassEffect', glass);
if CompositingEnabled then begin
if glass then ToggleGlass(true);
end
else glass := false;
end;
maxsize_lin32 := readinteger('Advanced','MaximumSizeForLinpack32',maxsize_lin32);
maxmem_offset := readinteger('Advanced','MaxmemFromFreememOffset',maxmem_offset);
if x64 then x64mode := readbool('Linpack','x64',true);
lin_priority := readinteger('Linpack','Priority',lin_priority);
if lin_priority > 5 then lin_priority := 2;
if NumberOfCPUs = readinteger('Advanced','LastLogicalCPUs',NumberOfCPUs)
then begin
NumberOfThreads := readinteger('Linpack','NumberOfThreads',NumberOfCPUs);
if NumberOfThreads < 1 then NumberOfThreads := NumberOfCPUs;
end
else NumberOfThreads := NumberOfCPUs;
ProblemSize := readinteger('Linpack','ProblemSize',ProblemSize);
if (ProblemSize > 99999) or (ProblemSize < MinProblemSize) then ProblemSize := DefProblemSize;
//ComboBoxPS.Text := inttostr(ProblemSize);
NumberOfMinutes := readinteger('Linpack','MinutesToRun',NumberOfMinutes);
if NumberOfMinutes <> -1 then begin
ComboBoxTimesMinutes.ItemIndex := 1;
if NumberOfMinutes < 1 then NumberOfMinutes := DefNumberOfMinutes;
NumberOfRuns := High(integer);
ComboBoxRuns.Text := inttostr(NumberOfMinutes);
end
else begin
NumberOfRuns := readinteger('Linpack','TimesToRun',NumberOfRuns);
if NumberOfRuns < 1 then NumberOfRuns := DefNumberOfRuns;
ComboBoxRuns.Text := inttostr(NumberOfRuns);
end;
useoptld := readbool('Linpack','UseOptimizedLeadingDimensions',useoptld);
dataalign := readinteger('Linpack','DataAlignment',dataalign);
if dataalign > 64 then dataalign := 4;
h := (screen.Height - 80) div 4;
GraphWindows[1].Left := readinteger('Graphs','TempLeft', 40);
GraphWindows[1].Top := readinteger('Graphs','TempTop', 40);
GraphWindows[1].Right := readinteger('Graphs','TempWidth', 416) +
GraphWindows[1].Left;
GraphWindows[1].Bottom := readinteger('Graphs','TempHeight', h) +
GraphWindows[1].Top;
GraphWindows[2].Left := readinteger('Graphs','FanLeft', 40);
GraphWindows[2].Top := readinteger('Graphs','FanTop', GraphWindows[1].Bottom);
GraphWindows[2].Right := readinteger('Graphs','FanWidth', 416) +
GraphWindows[2].Left;
GraphWindows[2].Bottom := readinteger('Graphs','FanHeight', h) +
GraphWindows[2].Top;
GraphWindows[3].Left := readinteger('Graphs','VcoreLeft', 40);
GraphWindows[3].Top := readinteger('Graphs','VcoreTop', GraphWindows[2].Bottom);
GraphWindows[3].Right := readinteger('Graphs','VcoreWidth', 416) +
GraphWindows[3].Left;
GraphWindows[3].Bottom := readinteger('Graphs','VcoreHeight', h) +
GraphWindows[3].Top;
GraphWindows[4].Left := readinteger('Graphs','12VLeft', 40);
GraphWindows[4].Top := readinteger('Graphs','12VTop', GraphWindows[3].Bottom);
GraphWindows[4].Right := readinteger('Graphs','12VWidth', 416) +
GraphWindows[4].Left;
GraphWindows[4].Bottom := readinteger('Graphs','12VHeight', h) +
GraphWindows[4].Top;
Free;
end;
if fileexists(GetCurrentDir + '\' + SFinifile_name) then with SFinifile do begin
SFinifile := Tinifile.Create(GetCurrentDir + '\' + SFinifile_name);
SFsettings[0] := ReadInteger('Speedfan','CPU_temp_num',0);
SFsettings[1] := ReadInteger('Speedfan','CPU_core0_num',0);
SFsettings[2] := ReadInteger('Speedfan','CPU_core1_num',0);
SFsettings[3] := ReadInteger('Speedfan','CPU_core2_num',0);
SFsettings[4] := ReadInteger('Speedfan','CPU_core3_num',0);
SFsettings[5] := ReadInteger('Speedfan','CPU_fan_num',0);
SFsettings[6] := ReadInteger('Speedfan','CPU_vcore_num',0);
SFsettings[7] := ReadInteger('Speedfan','12V_volt_num',0);
Free;
end;
ComboboxRunsChange(Sender);
//if SpeedButtonAllMem.Down then SpeedButtonAllMem.Click
//else PSandMem(true, ProblemSize, false);
ParseCommandLine;
TimerMain.Enabled := true;
ShowFreeMemory;
end
else begin
MessageBox(Handle, Pchar(msg_noexe),Pchar(progname),MB_OK or MB_ICONSTOP);
Application.Terminate;
end;
end;
procedure TFormMain.FormDestroy(Sender: TObject);
var SFinifile : Tinifile;
begin
if not fileexists(GetCurrentDir + '\' + SFinifile_name) then begin
SFinifile := tinifile.Create(GetCurrentDir + '\' + SFinifile_name);
try
SFinifile.WriteInteger('Speedfan','CPU_temp_num',SFsettings[0]);
SFinifile.WriteInteger('Speedfan','CPU_core0_num',SFsettings[1]);
SFinifile.WriteInteger('Speedfan','CPU_core1_num',SFsettings[2]);
SFinifile.WriteInteger('Speedfan','CPU_core2_num',SFsettings[3]);
SFinifile.WriteInteger('Speedfan','CPU_core3_num',SFsettings[4]);
SFinifile.WriteInteger('Speedfan','CPU_fan_num',SFsettings[5]);
SFinifile.WriteInteger('Speedfan','CPU_vcore_num',SFsettings[6]);
SFinifile.WriteInteger('Speedfan','12V_volt_num',SFsettings[7]);
finally
SFinifile.Free;
end;
end;
if Assigned(FormTemps) then FormTemps.Close;
if Assigned(FormFans) then FormFans.Close;
if Assigned(FormVcores) then FormVcores.Close;
if Assigned(FormP12Vs) then FormP12Vs.Close;
SaveSettingsToINI;
Tray0.Free;
Tray1.Free;
Tray2.Free;
Tray3.Free;
end;
procedure TFormMain.FormKeyPress(Sender: TObject; var Key: Char);
begin
case Key of
'0'..'9', #8 : begin end;
#27 : begin
if SpeedButtonStop.Enabled then SpeedButtonStop.Click;
Key := #0;
end;
#13 : begin
if SpeedButtonStart.Enabled then SpeedButtonStart.Click;
Key := #0;
end
else Key := #0;
end;
end;