diff options
author | Rupert Swarbrick <rswarbrick@gmail.com> | 2022-04-11 11:07:08 +0100 |
---|---|---|
committer | Rupert Swarbrick <rswarbrick@lowrisc.org> | 2022-04-12 11:10:46 +0100 |
commit | 9f0cf3437051b1ff0da9f087d001f768c2242870 (patch) | |
tree | bb0767afe4ea19067db35aea4732018f6f05d766 /spike_main | |
parent | 61b4f61a857de65d1a341f55597bfceeb7b7690d (diff) | |
download | riscv-isa-sim-9f0cf3437051b1ff0da9f087d001f768c2242870.zip riscv-isa-sim-9f0cf3437051b1ff0da9f087d001f768c2242870.tar.gz riscv-isa-sim-9f0cf3437051b1ff0da9f087d001f768c2242870.tar.bz2 |
Remove nprocs from cfg_t
Now we have hartids, we can remove nprocs so that we have a single
source of truth.
Diffstat (limited to 'spike_main')
-rw-r--r-- | spike_main/spike.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/spike_main/spike.cc b/spike_main/spike.cc index 12b8dc0..6395466 100644 --- a/spike_main/spike.cc +++ b/spike_main/spike.cc @@ -272,9 +272,10 @@ int main(int argc, char** argv) .support_haltgroups = true, .support_impebreak = true }; + cfg_arg_t<size_t> nprocs(1); + cfg_t cfg(/*default_initrd_bounds=*/std::make_pair((reg_t)0, (reg_t)0), /*default_bootargs=*/nullptr, - /*default_nprocs=*/1, /*default_isa=*/DEFAULT_ISA, /*default_priv=*/DEFAULT_PRIV, /*default_mem_layout=*/parse_mem_layout("2048"), @@ -332,7 +333,7 @@ int main(int argc, char** argv) #ifdef HAVE_BOOST_ASIO parser.option('s', 0, 0, [&](const char* s){socket = true;}); #endif - parser.option('p', 0, 1, [&](const char* s){cfg.nprocs = atoul_nonzero_safe(s);}); + parser.option('p', 0, 1, [&](const char* s){nprocs = atoul_nonzero_safe(s);}); parser.option('m', 0, 1, [&](const char* s){cfg.mem_layout = parse_mem_layout(s);}); // I wanted to use --halted, but for some reason that doesn't work. parser.option('H', 0, 0, [&](const char* s){halted = true;}); @@ -462,11 +463,11 @@ int main(int argc, char** argv) #endif if (cfg.explicit_hartids) { - if (cfg.nprocs.overridden() && (cfg.nprocs() != cfg.hartids().size())) { + if (nprocs.overridden() && (nprocs() != cfg.nprocs())) { std::cerr << "Number of specified hartids (" - << cfg.hartids().size() + << cfg.nprocs() << ") doesn't match specified number of processors (" - << cfg.nprocs() << ").\n"; + << nprocs() << ").\n"; exit(1); } } else { @@ -474,8 +475,8 @@ int main(int argc, char** argv) // explicit_hartids flag (which means that downstream code can know that // we've only set the number of harts, not explicitly chosen their IDs). std::vector<int> default_hartids; - default_hartids.reserve(cfg.nprocs()); - for (size_t i = 0; i < cfg.nprocs(); ++i) { + default_hartids.reserve(nprocs()); + for (size_t i = 0; i < nprocs(); ++i) { default_hartids.push_back(i); } cfg.hartids = default_hartids; |