Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion entries/ghatem-fpc/src/OneBRCproj.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
</General>
<BuildModes Count="3">
<BuildModes Count="4">
<Item1 Name="Default" Default="True"/>
<Item2 Name="Debug">
<CompilerOptions>
Expand Down Expand Up @@ -84,6 +84,30 @@
</Other>
</CompilerOptions>
</Item3>
<Item4 Name="Valgrind">
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="..\..\..\bin\ghatem"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="..\..\..\bin\lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
<TrashVariables Value="True"/>
<UseValgrind Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
<Other>
<CustomOptions Value="-dDEBUG"/>
</Other>
</CompilerOptions>
</Item4>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
Expand Down
12 changes: 10 additions & 2 deletions entries/ghatem-fpc/src/OneBRCproj.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TOneBRCApp = class(TCustomApplication)
private
FFileName: string;
FThreadCount: Integer;
FDictSize: Integer;
procedure RunOneBRC;
protected
procedure DoRun; override;
Expand All @@ -33,7 +34,7 @@ procedure TOneBRCApp.RunOneBRC;
var
vOneBRC: TOneBRC;
begin
vOneBRC := TOneBRC.Create (FThreadCount);
vOneBRC := TOneBRC.Create (FThreadCount, FDictSize);
try
try
vOneBRC.mORMotMMF(FFileName);
Expand Down Expand Up @@ -88,15 +89,17 @@ procedure TOneBRCApp.DoRun;
ErrorMsg: String;
begin
// quick check parameters
ErrorMsg:= CheckOptions(Format('%s%s%s%s:',[
ErrorMsg:= CheckOptions(Format('%s%s%s%s%s:',[
cShortOptHelp,
cShortOptThread,
cShortOptDictSize,
cShortOptVersion,
cShortOptInput
]),
[
cLongOptHelp,
cLongOptThread+':',
cLongOptDictSize+':',
cLongOptVersion,
cLongOptInput+':'
]
Expand Down Expand Up @@ -126,6 +129,11 @@ procedure TOneBRCApp.DoRun;
FThreadCount := StrToInt (GetOptionValue(cShortOptThread, cLongOptThread));
end;

FDictSize := 45003;
if HasOption(cShortOptDictSize, cLongOptDictSize) then begin
FDictSize := StrToInt (GetOptionValue(cShortOptDictSize, cLongOptDictSize));
end;

if HasOption(cShortOptInput, cLongOptInput) then begin
FFileName := GetOptionValue(
cShortOptInput,
Expand Down
2 changes: 2 additions & 0 deletions entries/ghatem-fpc/src/baseline.console.pas
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface
cLongOptInput = 'input-file';
cShortOptThread: Char = 't';
cLongOptThread = 'threads';
cShortOptDictSize: Char = 's';
cLongOptDictSize = 'size';
{$ELSE}
cOptionHelp: array of string = ['-h', '--help'];
cOptionVersion: array of string = ['-v', '--version'];
Expand Down
8 changes: 6 additions & 2 deletions entries/ghatem-fpc/src/onebrc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ interface

function RoundExDouble(const ATemp: Double): Double; inline;

{$WRITEABLECONST ON}
const
cDictSize: Integer = 45003;
{$WRITEABLECONST OFF}

type

Expand Down Expand Up @@ -63,7 +65,7 @@ TOneBRC = class
procedure ExtractLineData(const aStart: Int64; const aEnd: Int64; out aLength: ShortInt; out aTemp: SmallInt); inline;

public
constructor Create (const aThreadCount: UInt16);
constructor Create (const aThreadCount: UInt16; const aDictSize: Integer);
destructor Destroy; override;
function mORMotMMF (const afilename: string): Boolean;
procedure DispatchThreads;
Expand Down Expand Up @@ -249,9 +251,11 @@ procedure TOneBRC.ExtractLineData(const aStart: Int64; const aEnd: Int64; out aL

//---------------------------------------------------

constructor TOneBRC.Create (const aThreadCount: UInt16);
constructor TOneBRC.Create (const aThreadCount: UInt16; const aDictSize: Integer);
var I: UInt16;
begin
cDictSize := aDictSize;

FThreadCount := aThreadCount;
SetLength (FStationsDicts, aThreadCount);
SetLength (FThreads, aThreadCount);
Expand Down