Skip to content

Commit bad32be

Browse files
committed
Merge branch 'stage12unified_attempt2'
2 parents 999a40d + 3ce1dd8 commit bad32be

16 files changed

+196
-350
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ TESTEXECUTABLES=jsoncheck numberparsingcheck stringparsingcheck
2727
COMPARISONEXECUTABLES=minifiercompetition parsingcompetition parseandstatcompetition distinctuseridcompetition allparserscheckfile
2828
SUPPLEMENTARYEXECUTABLES=parse_noutf8validation parse_nonumberparsing parse_nostringparsing
2929

30-
HEADERS= include/simdjson/simdutf8check.h include/simdjson/stringparsing.h include/simdjson/numberparsing.h include/simdjson/jsonparser.h include/simdjson/common_defs.h include/simdjson/jsonioutil.h benchmark/benchmark.h benchmark/linux/linux-perf-events.h include/simdjson/parsedjson.h include/simdjson/stage1_find_marks.h include/simdjson/stage2_flatten.h include/simdjson/stage34_unified.h include/simdjson/jsoncharutils.h include/simdjson/jsonformatutils.h
31-
LIBFILES=src/jsonioutil.cpp src/jsonparser.cpp src/stage1_find_marks.cpp src/stage2_flatten.cpp src/stage34_unified.cpp
30+
HEADERS= include/simdjson/simdutf8check.h include/simdjson/stringparsing.h include/simdjson/numberparsing.h include/simdjson/jsonparser.h include/simdjson/common_defs.h include/simdjson/jsonioutil.h benchmark/benchmark.h benchmark/linux/linux-perf-events.h include/simdjson/parsedjson.h include/simdjson/stage1_find_marks.h include/simdjson/stage2_build_tape.h include/simdjson/jsoncharutils.h include/simdjson/jsonformatutils.h
31+
LIBFILES=src/jsonioutil.cpp src/jsonparser.cpp src/stage1_find_marks.cpp src/stage2_build_tape.cpp
3232
MINIFIERHEADERS=include/simdjson/jsonminifier.h include/simdjson/simdprune_tables.h
3333
MINIFIERLIBFILES=src/jsonminifier.cpp
3434

@@ -106,11 +106,11 @@ jsoncheck:tests/jsoncheck.cpp $(HEADERS) $(LIBFILES)
106106
$(CXX) $(CXXFLAGS) -o jsoncheck $(LIBFILES) tests/jsoncheck.cpp -I. $(LIBFLAGS)
107107

108108
numberparsingcheck:tests/numberparsingcheck.cpp $(HEADERS) $(LIBFILES)
109-
$(CXX) $(CXXFLAGS) -o numberparsingcheck tests/numberparsingcheck.cpp src/jsonioutil.cpp src/jsonparser.cpp src/stage1_find_marks.cpp src/stage2_flatten.cpp -I. $(LIBFLAGS) -DJSON_TEST_NUMBERS
109+
$(CXX) $(CXXFLAGS) -o numberparsingcheck tests/numberparsingcheck.cpp src/jsonioutil.cpp src/jsonparser.cpp src/stage1_find_marks.cpp -I. $(LIBFLAGS) -DJSON_TEST_NUMBERS
110110

111111

112112
stringparsingcheck:tests/stringparsingcheck.cpp $(HEADERS) $(LIBFILES)
113-
$(CXX) $(CXXFLAGS) -o stringparsingcheck tests/stringparsingcheck.cpp src/jsonioutil.cpp src/jsonparser.cpp src/stage1_find_marks.cpp src/stage2_flatten.cpp -I. $(LIBFLAGS) -DJSON_TEST_STRINGS
113+
$(CXX) $(CXXFLAGS) -o stringparsingcheck tests/stringparsingcheck.cpp src/jsonioutil.cpp src/jsonparser.cpp src/stage1_find_marks.cpp -I. $(LIBFLAGS) -DJSON_TEST_STRINGS
114114

115115

116116
minifiercompetition: benchmark/minifiercompetition.cpp $(HEADERS) $(MINIFIERHEADERS) $(LIBFILES) $(MINIFIERLIBFILES)

amalgamation.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ $SCRIPTPATH/src/jsonioutil.cpp
1717
$SCRIPTPATH/src/jsonminifier.cpp
1818
$SCRIPTPATH/src/jsonparser.cpp
1919
$SCRIPTPATH/src/stage1_find_marks.cpp
20-
$SCRIPTPATH/src/stage2_flatten.cpp
21-
$SCRIPTPATH/src/stage34_unified.cpp
20+
$SCRIPTPATH/src/stage2_build_tape.cpp
2221
"
2322

2423
# order matters
@@ -33,10 +32,9 @@ $SCRIPTPATH/include/simdjson/simdutf8check.h
3332
$SCRIPTPATH/include/simdjson/jsonminifier.h
3433
$SCRIPTPATH/include/simdjson/parsedjson.h
3534
$SCRIPTPATH/include/simdjson/stage1_find_marks.h
36-
$SCRIPTPATH/include/simdjson/stage2_flatten.h
3735
$SCRIPTPATH/include/simdjson/stringparsing.h
3836
$SCRIPTPATH/include/simdjson/numberparsing.h
39-
$SCRIPTPATH/include/simdjson/stage34_unified.h
37+
$SCRIPTPATH/include/simdjson/stage2_build_tape.h
4038
$SCRIPTPATH/include/simdjson/jsonparser.h
4139
"
4240

benchmark/parse.cpp

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
#include "simdjson/jsonparser.h"
3636
#include "simdjson/parsedjson.h"
3737
#include "simdjson/stage1_find_marks.h"
38-
#include "simdjson/stage2_flatten.h"
39-
#include "simdjson/stage34_unified.h"
38+
#include "simdjson/stage2_build_tape.h"
4039
using namespace std;
4140

4241
int main(int argc, char *argv[]) {
@@ -166,20 +165,6 @@ int main(int argc, char *argv[]) {
166165
}
167166
unified.start();
168167
#endif
169-
isok = isok && flatten_indexes(p.size(), pj);
170-
#ifndef SQUASH_COUNTERS
171-
unified.end(results);
172-
cy2 += results[0];
173-
cl2 += results[1];
174-
mis2 += results[2];
175-
cref2 += results[3];
176-
cmis2 += results[4];
177-
if (!isok) {
178-
cout << "Failed out during stage 2\n";
179-
break;
180-
}
181-
unified.start();
182-
#endif
183168

184169
isok = isok && unified_machine(p.data(), p.size(), pj);
185170
#ifndef SQUASH_COUNTERS
@@ -249,23 +234,12 @@ int main(int argc, char *argv[]) {
249234
(double)cy1 / (iterations * p.size()));
250235

251236
printf("stage 2 instructions: %10lu cycles: %10lu (%.2f %%) ins/cycles: "
252-
"%.2f mis. branches: %10lu (cycles/mis.branch %.2f) cache "
253-
"accesses: %10lu (failure %10lu)\n",
254-
cl2 / iterations, cy2 / iterations, 100. * cy2 / total,
255-
(double)cl2 / cy2, mis2 / iterations, (double)cy2 / mis2,
256-
cref2 / iterations, cmis2 / iterations);
257-
printf(" stage 2 runs at %.2f cycles per input byte and ",
258-
(double)cy2 / (iterations * p.size()));
259-
printf("%.2f cycles per structural character.\n",
260-
(double)cy2 / (iterations * pj.n_structural_indexes));
261-
262-
printf("stage 3 instructions: %10lu cycles: %10lu (%.2f %%) ins/cycles: "
263237
"%.2f mis. branches: %10lu (cycles/mis.branch %.2f) cache "
264238
"accesses: %10lu (failure %10lu)\n",
265239
cl3 / iterations, cy3 / iterations, 100. * cy3 / total,
266240
(double)cl3 / cy3, mis3 / iterations, (double)cy3 / mis3,
267241
cref3 / iterations, cmis3 / iterations);
268-
printf(" stage 3 runs at %.2f cycles per input byte and ",
242+
printf(" stage 2 runs at %.2f cycles per input byte and ",
269243
(double)cy3 / (iterations * p.size()));
270244
printf("%.2f cycles per structural character.\n",
271245
(double)cy3 / (iterations * pj.n_structural_indexes));

include/simdjson/jsonparser.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#include "simdjson/jsonioutil.h"
66
#include "simdjson/parsedjson.h"
77
#include "simdjson/stage1_find_marks.h"
8-
#include "simdjson/stage2_flatten.h"
9-
#include "simdjson/stage34_unified.h"
8+
#include "simdjson/stage2_build_tape.h"
109

1110

1211

include/simdjson/parsedjson.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct ParsedJson {
2626
// allocate memory
2727
ParsedJson()
2828
: bytecapacity(0), depthcapacity(0), tapecapacity(0), stringcapacity(0),
29-
current_loc(0), structurals(NULL), n_structural_indexes(0),
29+
current_loc(0), n_structural_indexes(0),
3030
structural_indexes(NULL), tape(NULL), containing_scope_offset(NULL),
3131
ret_address(NULL), string_buf(NULL), current_string_buf_loc(NULL), isvalid(false) {}
3232

@@ -45,11 +45,6 @@ struct ParsedJson {
4545
}
4646
isvalid = false;
4747
bytecapacity = 0; // will only set it to len after allocations are a success
48-
structurals = (uint8_t *)aligned_malloc(8, ROUNDUP_N(len, 64) / 8);
49-
if (structurals == NULL) {
50-
std::cerr << "Could not allocate memory for structurals" << std::endl;
51-
return false;
52-
};
5348
n_structural_indexes = 0;
5449
uint32_t max_structures = ROUNDUP_N(len, 64) + 2 + 7;
5550
structural_indexes = new uint32_t[max_structures];
@@ -71,7 +66,6 @@ struct ParsedJson {
7166
if(tape != NULL) delete[] tape;
7267
if(string_buf != NULL) delete[] string_buf;
7368
if(structural_indexes != NULL) delete[] structural_indexes;
74-
aligned_free(structurals);
7569
return false;
7670
}
7771

@@ -98,7 +92,6 @@ struct ParsedJson {
9892
if(tape != NULL) delete[] tape;
9993
if(string_buf != NULL) delete[] string_buf;
10094
if(structural_indexes != NULL) delete[] structural_indexes;
101-
aligned_free(structurals);
10295
isvalid = false;
10396
}
10497

@@ -682,14 +675,12 @@ struct ParsedJson {
682675
};
683676

684677

685-
size_t bytecapacity; // indicates how many bits are meant to be supported by
686-
// structurals
678+
size_t bytecapacity; // indicates how many bits are meant to be supported
687679

688680
size_t depthcapacity; // how deep we can go
689681
size_t tapecapacity;
690682
size_t stringcapacity;
691683
uint32_t current_loc;
692-
uint8_t *structurals;
693684
uint32_t n_structural_indexes;
694685

695686
uint32_t *structural_indexes;
@@ -712,7 +703,6 @@ struct ParsedJson {
712703
tapecapacity(std::move(p.tapecapacity)),
713704
stringcapacity(std::move(p.stringcapacity)),
714705
current_loc(std::move(p.current_loc)),
715-
structurals(std::move(p.structurals)),
716706
n_structural_indexes(std::move(p.n_structural_indexes)),
717707
structural_indexes(std::move(p.structural_indexes)),
718708
tape(std::move(p.tape)),
@@ -721,7 +711,6 @@ struct ParsedJson {
721711
string_buf(std::move(p.string_buf)),
722712
current_string_buf_loc(std::move(p.current_string_buf_loc)),
723713
isvalid(std::move(p.isvalid)) {
724-
p.structurals=NULL;
725714
p.structural_indexes=NULL;
726715
p.tape=NULL;
727716
p.containing_scope_offset=NULL;

include/simdjson/stage2_flatten.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

singleheader/amalgamation_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on Mon Dec 31 11:59:09 EST 2018. Do not edit! */
1+
/* auto-generated on Mon Dec 31 17:13:28 EST 2018. Do not edit! */
22

33
#include <iostream>
44
#include "simdjson.h"

0 commit comments

Comments
 (0)