Skip to content

Commit e556da7

Browse files
authored
Merge branch 'main' into feature/uv
2 parents 2ed9f9e + 074c664 commit e556da7

6 files changed

Lines changed: 466 additions & 163 deletions

File tree

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "external/madrona"]
22
path = external/madrona
33
url = https://github.com/m-naumann/madrona.git
4-
[submodule "external/json"]
5-
path = external/json
6-
url = https://github.com/nlohmann/json.git

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ target_link_libraries(gpudrive_mgr
3333
PUBLIC
3434
madrona_python_utils
3535
PRIVATE
36-
nlohmann_json::nlohmann_json
36+
madrona_json
3737
gpudrive_cpu_impl
3838
madrona_mw_cpu
3939
madrona_common

src/MapReader.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ madrona_gpudrive::Map *copyToArrayOnHostOrDevice(const madrona_gpudrive::Map *in
3636

3737
namespace madrona_gpudrive {
3838

39-
MapReader::MapReader(const std::string &pathToFile) : in_(pathToFile) {
40-
assert(in_.is_open());
39+
simdjson::dom::parser& MapReader::getParser() {
40+
static simdjson::dom::parser parser;
41+
return parser;
42+
}
43+
44+
MapReader::MapReader(const std::string &pathToFile){
45+
in_ = pathToFile;
4146
map_ = new madrona_gpudrive::Map();
4247
}
4348

@@ -46,10 +51,13 @@ MapReader::~MapReader() {
4651
}
4752

4853
void MapReader::doParse(float polylineReductionThreshold) {
49-
nlohmann::json rawJson;
50-
in_ >> rawJson;
54+
// Parse with simdjson
55+
auto& parser = getParser();
56+
simdjson::dom::element doc;
57+
auto error = parser.load(in_).get(doc);
5158

52-
from_json(rawJson, *map_, polylineReductionThreshold);
59+
// Parse the document into the map
60+
from_json(doc, *map_, polylineReductionThreshold);
5361
}
5462

5563
madrona_gpudrive::Map* MapReader::parseAndWriteOut(const std::string &path,
@@ -60,4 +68,4 @@ madrona_gpudrive::Map* MapReader::parseAndWriteOut(const std::string &path,
6068
return copyToArrayOnHostOrDevice(reader.map_, executionMode);
6169

6270
}
63-
} // namespace madrona_gpudrive
71+
} // namespace madrona_gpudrive

src/MapReader.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <fstream>
44
#include <madrona/exec_mode.hpp>
5-
5+
#include <simdjson.h>
66
#include "init.hpp"
77

88
namespace madrona_gpudrive {
@@ -14,12 +14,13 @@ class MapReader {
1414
static madrona_gpudrive::Map* parseAndWriteOut(const std::string &path, madrona::ExecMode executionMode, float polylineReductionThreshold);
1515

1616
private:
17+
static simdjson::dom::parser& getParser();
1718
MapReader(const std::string &pathToFile);
1819
~MapReader();
1920
void doParse(float polylineReductionThreshold);
2021

21-
std::ifstream in_;
22+
std::string in_;
2223
madrona_gpudrive::Map *map_;
2324
};
2425

25-
} // namespace madrona_gpudrive
26+
} // namespace madrona_gpudrive

0 commit comments

Comments
 (0)