Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
Add --quiet option #338
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsavulescu committed Jul 16, 2020
1 parent 7669a53 commit af39380
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
1 change: 1 addition & 0 deletions coreneuron/apps/corenrn_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ corenrn_parameters::corenrn_parameters(){
app.add_option("-e, --tstop", this->tstop, "Stop Time in ms.")
->check(CLI::Range(0., 1e9));
app.add_flag("--show");
app.add_flag("--quiet", this->quiet, "Disable corenrn outputs (handy if launched from NEURON)");

auto sub_gpu = app.add_option_group("GPU", "Commands relative to GPU.");
sub_gpu -> add_option("-W, --nwarp", this->nwarp, "Number of warps to balance.", true)
Expand Down
1 change: 1 addition & 0 deletions coreneuron/apps/corenrn_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct corenrn_parameters {
bool threading=false; /// Enable pthread/openmp
bool gpu=false; /// Enable GPU computation.
bool binqueue=false; /// Use bin queue.
bool quiet=false; /// Disable corenrn outputs (handy if launched from NEURON)

double tstop=100; /// Stop time of simulation in msec
double dt=-1000.0; /// Timestep to use in msec
Expand Down
27 changes: 20 additions & 7 deletions coreneuron/apps/main1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ char* prepare_args(int& argc, char**& argv, int use_mpi, const char* arg) {
if (use_mpi) {
args.append(" --mpi ");
}
args.append(" --quiet ");

// we can't modify string with strtok, make copy
char* first = strdup(args.c_str());
Expand Down Expand Up @@ -147,7 +148,9 @@ void nrn_init_and_load_data(int argc,
Instrumentor::stop_profile();

// memory footprint after mpi initialisation
report_mem_usage("After MPI_Init");
if (!corenrn_param.quiet) {
report_mem_usage("After MPI_Init");
}

// initialise default coreneuron parameters
initnrn();
Expand Down Expand Up @@ -216,7 +219,9 @@ void nrn_init_and_load_data(int argc,
nrn_set_extra_thread0_vdata();
}

report_mem_usage("Before nrn_setup");
if (!corenrn_param.quiet) {
report_mem_usage("Before nrn_setup");
}

// set if need to interleave cells
interleave_permute_type = corenrn_param.cell_interleave_permute;
Expand Down Expand Up @@ -255,7 +260,9 @@ void nrn_init_and_load_data(int argc,
int spkcompress = corenrn_param.spkcompress;
nrnmpi_spike_compress(spkcompress, (spkcompress ? true : false), use_multisend_);

report_mem_usage("After nrn_setup ");
if (!corenrn_param.quiet) {
report_mem_usage("After nrn_setup ");
}

// Invoke PatternStim
if (!corenrn_param.patternstim.empty()) {
Expand All @@ -266,15 +273,17 @@ void nrn_init_and_load_data(int argc,
nrn_set_timeout(200.);

// show all configuration parameters for current run
if (nrnmpi_myid == 0) {
if (nrnmpi_myid == 0 && !corenrn_param.quiet) {
std::cout << corenrn_param << std::endl;
std::cout << " Start time (t) = " << t << std::endl << std::endl;
}

// allocate buffer for mpi communication
mk_spikevec_buffer(corenrn_param.spikebuf);

report_mem_usage("After mk_spikevec_buffer");
if (!corenrn_param.quiet) {
report_mem_usage("After mk_spikevec_buffer");
}

if (corenrn_param.gpu) {
setup_nrnthreads_on_device(nrn_threads, nrn_nthread);
Expand Down Expand Up @@ -459,7 +468,9 @@ extern "C" int run_solve_core(int argc, char** argv) {
std::vector<std::unique_ptr<ReportHandler> > report_handlers;
bool reports_needs_finalize = false;

report_mem_usage("After mk_mech");
if (!corenrn_param.quiet) {
report_mem_usage("After mk_mech");
}

// Create outpath if it does not exist
if (nrnmpi_myid == 0) {
Expand Down Expand Up @@ -532,7 +543,9 @@ extern "C" int run_solve_core(int argc, char** argv) {
nrn_finitialize(v != 1000., v);
}

report_mem_usage("After nrn_finitialize");
if (!corenrn_param.quiet) {
report_mem_usage("After nrn_finitialize");
}

// register all reports into reportinglib
double min_report_dt = INT_MAX;
Expand Down
7 changes: 5 additions & 2 deletions coreneuron/io/mk_mech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <fstream>
#include <sstream>

#include "coreneuron/apps/corenrn_parameters.hpp"
#include "coreneuron/nrnconf.h"
#include "coreneuron/sim/multicore.hpp"
#include "coreneuron/membrane_definitions.h"
Expand All @@ -43,11 +44,13 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include "coreneuron/coreneuron.hpp"
#include "coreneuron/mechanism//eion.hpp"

static char banner[] = "Duke, Yale, and the BlueBrain Project -- Copyright 1984-2019";
static char banner[] = "Duke, Yale, and the BlueBrain Project -- Copyright 1984-2020";

namespace coreneuron {
int nrn_nobanner_;

extern corenrn_parameters corenrn_param;

// NB: this should go away
extern const char* nrn_version(int);

Expand Down Expand Up @@ -177,7 +180,7 @@ static void mk_mech(std::istream& s) {
// printf("%s %d %d\n", mname, nrn_get_mechtype(mname), type);
}

if (nrnmpi_myid < 1 && nrn_nobanner_ == 0) {
if (nrnmpi_myid < 1 && nrn_nobanner_ == 0 && !corenrn_param.quiet) {
fprintf(stderr, " \n");
fprintf(stderr, " %s\n", banner);
fprintf(stderr, " %s\n", nrn_version(1));
Expand Down
4 changes: 3 additions & 1 deletion coreneuron/io/nrn_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <map>
#include <cstring>

#include "coreneuron/apps/corenrn_parameters.hpp"
#include "coreneuron/nrnconf.h"
#include "coreneuron/utils/randoms/nrnran123.h"
#include "coreneuron/sim/multicore.hpp"
Expand Down Expand Up @@ -215,6 +216,7 @@ void (*nrn2core_trajectory_return_)(int tid, int n_pr, int vecsz, void** vpr, do
// files with the first containing output_gids and netcon_srcgid which are
// stored in the nt.presyns array and nt.netcons array respectively
namespace coreneuron {
extern corenrn_parameters corenrn_param;
int nrn_setup_multiple = 1; /* default */
int nrn_setup_extracon = 0; /* default */
static int maxgid;
Expand Down Expand Up @@ -803,7 +805,7 @@ void nrn_setup(const char* filesdat,
delete[] gidgroups;
delete[] imult;

if (nrnmpi_myid == 0) {
if (nrnmpi_myid == 0 && !corenrn_param.quiet) {
printf(" Setup Done : %.2lf seconds \n", nrn_wtime() - time);
}
}
Expand Down
4 changes: 3 additions & 1 deletion coreneuron/utils/nrn_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdio>
#include <climits>
#include <vector>
#include "coreneuron/apps/corenrn_parameters.hpp"
#include "coreneuron/utils/nrn_stats.h"
#include "coreneuron/mpi/nrnmpi.h"
#include "coreneuron/sim/multicore.hpp"
Expand All @@ -44,6 +45,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include "coreneuron/io/output_spikes.hpp"
namespace coreneuron {
extern NetCvode* net_cvode_instance;
extern corenrn_parameters corenrn_param;

const int NUM_STATS = 12;
#if COLLECT_TQueue_STATISTICS
Expand Down Expand Up @@ -155,7 +157,7 @@ void report_cell_stats(void) {
memcpy(gstat_array, stat_array, sizeof(stat_array));
#endif

if (nrnmpi_myid == 0) {
if (nrnmpi_myid == 0 && !corenrn_param.quiet) {
printf("\n\n Simulation Statistics\n");
printf(" Number of cells: %ld\n", gstat_array[0]);
printf(" Number of compartments: %ld\n", gstat_array[10]);
Expand Down

0 comments on commit af39380

Please # to comment.