Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ target_link_libraries(gpudrive_mgr
PUBLIC
madrona_python_utils
PRIVATE
nlohmann_json::nlohmann_json
madrona_json
gpudrive_cpu_impl
madrona_mw_cpu
madrona_common
Expand Down
18 changes: 13 additions & 5 deletions src/MapReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ madrona_gpudrive::Map *copyToArrayOnHostOrDevice(const madrona_gpudrive::Map *in

namespace madrona_gpudrive {

MapReader::MapReader(const std::string &pathToFile) : in_(pathToFile) {
assert(in_.is_open());
simdjson::dom::parser& MapReader::getParser() {
static simdjson::dom::parser parser;
return parser;
}

MapReader::MapReader(const std::string &pathToFile){
in_ = pathToFile;
map_ = new madrona_gpudrive::Map();
}

Expand All @@ -46,10 +51,13 @@ MapReader::~MapReader() {
}

void MapReader::doParse(float polylineReductionThreshold) {
nlohmann::json rawJson;
in_ >> rawJson;
// Parse with simdjson
auto& parser = getParser();
simdjson::dom::element doc;
auto error = parser.load(in_).get(doc);

from_json(rawJson, *map_, polylineReductionThreshold);
// Parse the document into the map
from_json(doc, *map_, polylineReductionThreshold);
}

madrona_gpudrive::Map* MapReader::parseAndWriteOut(const std::string &path,
Expand Down
5 changes: 3 additions & 2 deletions src/MapReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <fstream>
#include <madrona/exec_mode.hpp>

#include <simdjson.h>
#include "init.hpp"

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

private:
static simdjson::dom::parser& getParser();
MapReader(const std::string &pathToFile);
~MapReader();
void doParse(float polylineReductionThreshold);

std::ifstream in_;
std::string in_;
madrona_gpudrive::Map *map_;
};

Expand Down
4 changes: 1 addition & 3 deletions src/headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ int main(int argc, char *argv[])

uint64_t num_steps = std::stoul(argv[2]);
std::vector<std::string> scenes = {
"../data/processed/examples/tfrecord-00000-of-00150_78.json",
"../data/processed/examples/tfrecord-00043-of-00150_223.json",
"../data/processed/examples/tfrecord-00149-of-00150_111.json"
"../data/processed/examples/tfrecord-00000-of-01000_325.json",
};
uint64_t num_worlds = scenes.size();

Expand Down
Loading