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
3 changes: 2 additions & 1 deletion entries/ocoddo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ Hope you find this interesting.
- Make sure you set build mode to `Release`
- Build
- Run as `./ocoddo ./input.txt`
- You can try different parameters for your hardware: `./ocoddo ./input.txt --jumper-count=192 --part-size=192`. Try values from `128`, `192`, `256`, and up
- You can try different parameters for your hardware: `./ocoddo ./input.txt --jumper-count=192 --part-size=192 --processor-count=32`. Try values from `128`, `192`, `256`, and up



Made by O

70 changes: 47 additions & 23 deletions entries/ocoddo/src/Project1.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
var
JumperCount: UPS;
PartSize: UPS;
ProcessorCount: U8;

type
THash = U32;
Expand Down Expand Up @@ -240,11 +241,6 @@ TStationSummary = record

procedure Process(out AStations: TStationResultArray); overload;

function ProcessorCount: U8;
begin
Result := LogicalProcessorCount;
end;

procedure Initialize(out AContext: TContext);
var
I: Ind;
Expand Down Expand Up @@ -368,27 +364,55 @@ TStationSummary = record
WriteLn(ToStr(RST));
end;

var
I: Ind;
N: Str;
V: I64;
begin
if Length(Parameters) = 0 then
Exit;
function HandleParameters(out AFilePath: TFilePath): Bool;
var
I: Ind;
N: Str;
V: I64;
begin
Result := False;
if Length(Parameters) = 0 then
begin
WriteLn;
WriteLn('1BRC');
WriteLn('----');
WriteLn('Made by O');
WriteLn;
WriteLn('Usage:');
WriteLn('./ocoddo ./input.txt [Options]');
WriteLn;
WriteLn('Options:');
WriteLn('--jumper-count=[Value]. Use 128, 192, 256, etc');
WriteLn('--part-size=[Value]. Use 128, 192, 256, etc');
WriteLn('--processor-count=[Value]. Use 1 or more');
WriteLn;
Exit;
end;

JumperCount := 256 * 1024;
PartSize := 192 * 1024 - ReadMargin;
ProcessorCount := LogicalProcessorCount;
JumperCount := 256 * 1024;
PartSize := 192 * 1024 - ReadMargin;

for I := 1 to High(Parameters) do
begin
N := Name(Parameters[I]);
ToI64(Value(Parameters[I]), V);
for I := 1 to High(Parameters) do
begin
N := Name(Parameters[I]);
ToI64(Value(Parameters[I]), V);

if N = 'jumper-count' then
JumperCount := V * 1024
else if N = 'part-size' then
PartSize := (V * 1024) - ReadMargin
else if N = 'processor-count' then
ProcessorCount := V;
end;

if N = 'jumper-count' then
JumperCount := V * 1024
else if N = 'part-size' then
PartSize := (V * 1024) - ReadMargin;
AFilePath := Fix(Value(Parameters[0]));
Result := True;
end;

Run(&File(Fix(Value(Parameters[0]))));
var
FN: TFilePath;
begin
if HandleParameters(FN) then
Run(&File(FN));
end.