Skip to content

Commit 480f14e

Browse files
committed
first version with threads
1 parent 5856440 commit 480f14e

File tree

3 files changed

+901
-9
lines changed

3 files changed

+901
-9
lines changed

entries/hgrosser/README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,37 @@
33
**1 billion row Challenge entry**
44

55
## Version
6-
Version 1.61
6+
Version 2.00 (first version with threads)
77

88
## How to compile
99
The program was developed with FPC 3.2.2 and Lazarus 2.2.4
1010

11+
1brc.lpi + 1brc.pas = version without threads
12+
13+
1brc_th.lpi + 1brc_th.pas = version with threads
14+
1115
## How to start
1216
```
13-
Usage: <path to input file> <bit-width for hash-list (16..28)>
14-
Example: hgrosser measurements.txt 16
15-
- input file: must NOT have CR's (only LF's)
16-
- bit-width for hash-list: sets the size of the hash list, e.g. '16' => 65536 entries
17+
Usage: <path to input file> <thread count> [<bit-width for hash-list> [buffer size in KB]]
18+
- thread count: allowed range = [1..32]
19+
- bit-width for hash-list: sets the size of the hash list, e.g. '16' => 65536 entries,
20+
allowed range = [16..28], Default=18
21+
- buffer size in KB: allowed range = [1..2,000,000 KB], Default=128 KB
22+
Example: hgrosser measurements.txt 32 18 128
1723
```
18-
There are no switches like `-i` etc, only 2 values.
24+
There are no switches like `-i` etc, only 2..4 values.
1925

2026
### Optimizing the 2nd command line parameter
27+
This parameter sets the thread count. With my own old CPU I could only test 1..4 threads. Although I expect 32 threads to be the fastest, I would be very interested to see the results for 1, 4, 8, 16 and 32 threads. Please use for this test the defaults for the 3rd and 4th command line parameters.
2128

22-
In theory the program should run faster with greater bit-widths for the hash-list (because of less collisions), but on my own computer (8 GB RAM) in praxis a small value of 16 is the fastest way, allthough this causes many collisions.
29+
### Optimizing the 3rd command line parameter
30+
In theory the program should run faster with greater bit-widths for the hash-list (because of less collisions). On the computer of Gus - without threads - 18 bits was the fastest. Please try the values from 16 to 20 again and use '32' for the 2nd command line parameter and the default for the 4th command line parameter.
2331

24-
Please (if possible) try all values from 16 to 22 (maybe in a for-loop). Thanks a lot.
32+
### Optimizing the 4th command line parameter
33+
After the 2nd and 3rd command line parameters had been optimized, please try with them 64, 96, 128, 192 and 256 KB as the 4th command line parameter. Thanks a lot!
2534

2635
## How the program works
27-
The Program works with 1 thread.
36+
The Program works with multi threads.
2837

2938
To speed things up:
3039

@@ -40,3 +49,5 @@ To speed things up:
4049
- Version 1.51: small improvements in asm function
4150
- Version 1.60: hash-list optimized, some minor improvements, Conditional "noCR" added
4251
- Version 1.61: Conditional "noCR" constantely enabled => input files must NOT have CR's
52+
- Version 2.00: 1st version with threads
53+

entries/hgrosser/src/1brc_th.lpi

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CONFIG>
3+
<ProjectOptions>
4+
<Version Value="12"/>
5+
<PathDelim Value="\"/>
6+
<General>
7+
<Flags>
8+
<MainUnitHasCreateFormStatements Value="False"/>
9+
<MainUnitHasTitleStatement Value="False"/>
10+
<MainUnitHasScaledStatement Value="False"/>
11+
<CompatibilityMode Value="True"/>
12+
</Flags>
13+
<SessionStorage Value="InIDEConfig"/>
14+
<Title Value="1brc_th"/>
15+
<UseAppBundle Value="False"/>
16+
<ResourceType Value="res"/>
17+
</General>
18+
<i18n>
19+
<EnableI18N LFM="False"/>
20+
</i18n>
21+
<BuildModes Count="3">
22+
<Item1 Name="Default" Default="True"/>
23+
<Item2 Name="Debug">
24+
<CompilerOptions>
25+
<Version Value="11"/>
26+
<Target>
27+
<Filename Value="../../../bin/hgrosser"/>
28+
</Target>
29+
<SearchPaths>
30+
<IncludeFiles Value="$(ProjOutDir)"/>
31+
<UnitOutputDirectory Value="../../../bin/lib/$(TargetCPU)-$(TargetOS)"/>
32+
</SearchPaths>
33+
<Parsing>
34+
<SyntaxOptions>
35+
<SyntaxMode Value="tp"/>
36+
<IncludeAssertionCode Value="True"/>
37+
</SyntaxOptions>
38+
</Parsing>
39+
<CodeGeneration>
40+
<Checks>
41+
<IOChecks Value="True"/>
42+
<RangeChecks Value="True"/>
43+
<OverflowChecks Value="True"/>
44+
<StackChecks Value="True"/>
45+
</Checks>
46+
<VerifyObjMethodCallValidity Value="True"/>
47+
</CodeGeneration>
48+
<Linking>
49+
<Debugging>
50+
<DebugInfoType Value="dsDwarf3"/>
51+
<UseHeaptrc Value="True"/>
52+
<TrashVariables Value="True"/>
53+
<UseExternalDbgSyms Value="True"/>
54+
</Debugging>
55+
</Linking>
56+
</CompilerOptions>
57+
</Item2>
58+
<Item3 Name="Release">
59+
<CompilerOptions>
60+
<Version Value="11"/>
61+
<Target>
62+
<Filename Value="../../../bin/hgrosser"/>
63+
</Target>
64+
<SearchPaths>
65+
<IncludeFiles Value="$(ProjOutDir)"/>
66+
<UnitOutputDirectory Value="../../../bin/lib/$(TargetCPU)-$(TargetOS)"/>
67+
</SearchPaths>
68+
<Parsing>
69+
<SyntaxOptions>
70+
<SyntaxMode Value="tp"/>
71+
</SyntaxOptions>
72+
</Parsing>
73+
<CodeGeneration>
74+
<SmartLinkUnit Value="True"/>
75+
<Optimizations>
76+
<OptimizationLevel Value="3"/>
77+
</Optimizations>
78+
</CodeGeneration>
79+
<Linking>
80+
<Debugging>
81+
<GenerateDebugInfo Value="False"/>
82+
</Debugging>
83+
<LinkSmart Value="True"/>
84+
</Linking>
85+
</CompilerOptions>
86+
</Item3>
87+
</BuildModes>
88+
<PublishOptions>
89+
<Version Value="2"/>
90+
</PublishOptions>
91+
<RunParams>
92+
<local>
93+
<LaunchingApplication Use="True" PathPlusParams="\usr\bin\python3 \usr\bin\gnome-terminal -t &apos;Lazarus Run Output&apos; -- $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
94+
</local>
95+
<FormatVersion Value="2"/>
96+
<Modes Count="1">
97+
<Mode0 Name="default">
98+
<local>
99+
<LaunchingApplication Use="True" PathPlusParams="\usr\bin\python3 \usr\bin\gnome-terminal -t &apos;Lazarus Run Output&apos; -- $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
100+
</local>
101+
</Mode0>
102+
</Modes>
103+
</RunParams>
104+
<Units Count="1">
105+
<Unit0>
106+
<Filename Value="1brc_th.pas"/>
107+
<IsPartOfProject Value="True"/>
108+
</Unit0>
109+
</Units>
110+
</ProjectOptions>
111+
<CompilerOptions>
112+
<Version Value="11"/>
113+
<Target>
114+
<Filename Value="../../../bin/hgrosser"/>
115+
</Target>
116+
<SearchPaths>
117+
<IncludeFiles Value="$(ProjOutDir)"/>
118+
<UnitOutputDirectory Value="../../../bin/lib/$(TargetCPU)-$(TargetOS)"/>
119+
</SearchPaths>
120+
<Parsing>
121+
<SyntaxOptions>
122+
<SyntaxMode Value="tp"/>
123+
</SyntaxOptions>
124+
</Parsing>
125+
<CodeGeneration>
126+
<Checks>
127+
<IOChecks Value="True"/>
128+
<RangeChecks Value="True"/>
129+
<OverflowChecks Value="True"/>
130+
<StackChecks Value="True"/>
131+
</Checks>
132+
<VerifyObjMethodCallValidity Value="True"/>
133+
</CodeGeneration>
134+
</CompilerOptions>
135+
<Debugging>
136+
<Exceptions Count="3">
137+
<Item1>
138+
<Name Value="EAbort"/>
139+
</Item1>
140+
<Item2>
141+
<Name Value="ECodetoolError"/>
142+
</Item2>
143+
<Item3>
144+
<Name Value="EFOpenError"/>
145+
</Item3>
146+
</Exceptions>
147+
</Debugging>
148+
</CONFIG>

0 commit comments

Comments
 (0)