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

Commit d1da3e1

Browse files
pramodkNicolas Cornualexsavulescu
authored
Apply clang-format consistently to the project source (#465)
* Enable GitHub Actions CI for clang-format * Apply clang-format for code using v11.0.0 * Update CMake/hpc-coding-conventions Co-authored-by: Nicolas Cornu <[email protected]> Co-authored-by: Alexandru Savulescu <[email protected]>
1 parent 11abacf commit d1da3e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1708
-1276
lines changed

.clang-format.changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SortIncludes: false
2+
IndentCaseLabels: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: clang-format-check
2+
on:
3+
push:
4+
5+
jobs:
6+
build:
7+
name: clang-format-check
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- name: Fetch repository
11+
uses: actions/checkout@v2
12+
- name: Install clang-format 11
13+
run: sudo apt-get install clang-format-11
14+
- name: Configure
15+
shell: bash
16+
working-directory: ${{runner.workspace}}/CoreNeuron
17+
run: |
18+
mkdir BUILD && cd BUILD
19+
cmake -DCORENRN_CLANG_FORMAT=ON -DCORENRN_ENABLE_MPI=OFF -DCORENRN_ENABLE_OPENMP=OFF -DClangFormat_EXECUTABLE=$(which clang-format-11) ..
20+
- name: Run clang-format
21+
shell: bash
22+
working-directory: ${{runner.workspace}}/CoreNeuron/BUILD
23+
run: make check-clang-format

coreneuron/apps/corenrn_parameters.cpp

Lines changed: 151 additions & 87 deletions
Large diffs are not rendered by default.

coreneuron/apps/main1.cpp

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ char* prepare_args(int& argc, char**& argv, int use_mpi, const char* arg) {
114114
// return actual data to be freed
115115
return first;
116116
}
117-
118117
}
119118

120119
namespace coreneuron {
@@ -148,9 +147,9 @@ void nrn_init_and_load_data(int argc,
148147

149148
#if _OPENACC
150149
if (!corenrn_param.gpu && corenrn_param.cell_interleave_permute == 2) {
151-
fprintf(
152-
stderr,
153-
"compiled with _OPENACC does not allow the combination of --cell-permute=2 and missing --gpu\n");
150+
fprintf(stderr,
151+
"compiled with _OPENACC does not allow the combination of --cell-permute=2 and "
152+
"missing --gpu\n");
154153
exit(1);
155154
}
156155
#endif
@@ -166,8 +165,7 @@ void nrn_init_and_load_data(int argc,
166165
std::string filesdat(corenrn_param.datpath + "/" + corenrn_param.filesdat);
167166

168167
// read the global variable names and set their values from globals.dat
169-
set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed>=0),
170-
corenrn_param.seed);
168+
set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed >= 0), corenrn_param.seed);
171169

172170
// set global variables for start time, timestep and temperature
173171
std::string restore_path = corenrn_param.restorepath;
@@ -181,7 +179,7 @@ void nrn_init_and_load_data(int argc,
181179

182180
corenrn_param.dt = dt;
183181

184-
rev_dt = (int)(1. / dt);
182+
rev_dt = (int) (1. / dt);
185183

186184
if (corenrn_param.celsius != -1000.) { // command line arg highest precedence
187185
celsius = corenrn_param.celsius;
@@ -233,8 +231,12 @@ void nrn_init_and_load_data(int argc,
233231
use_phase2_ = (corenrn_param.ms_phases == 2) ? 1 : 0;
234232

235233
// reading *.dat files and setting up the data structures, setting mindelay
236-
nrn_setup(filesdat.c_str(), is_mapping_needed, run_setup_cleanup,
237-
corenrn_param.datpath.c_str(), restore_path.c_str(), &corenrn_param.mindelay);
234+
nrn_setup(filesdat.c_str(),
235+
is_mapping_needed,
236+
run_setup_cleanup,
237+
corenrn_param.datpath.c_str(),
238+
restore_path.c_str(),
239+
&corenrn_param.mindelay);
238240

239241
// Allgather spike compression and bin queuing.
240242
nrn_use_bin_queue_ = corenrn_param.binqueue;
@@ -347,8 +349,8 @@ void get_nrn_trajectory_requests(int bsize) {
347349

348350
// bsize is passed by reference, the return value will determine if
349351
// per step return or entire trajectory return.
350-
(*nrn2core_get_trajectory_requests_)(tid, bsize, n_pr, vpr, n_trajec, types, indices,
351-
pvars, varrays);
352+
(*nrn2core_get_trajectory_requests_)(
353+
tid, bsize, n_pr, vpr, n_trajec, types, indices, pvars, varrays);
352354
delete_trajectory_requests(nt);
353355
if (n_trajec) {
354356
TrajectoryRequests* tr = new TrajectoryRequests;
@@ -389,10 +391,11 @@ std::unique_ptr<ReportHandler> create_report_handler(ReportConfiguration& config
389391
report_handler = std::make_unique<BinaryReportHandler>(config);
390392
} else if (config.format == "SONATA") {
391393
report_handler = std::make_unique<SonataReportHandler>(config);
392-
}
393-
else {
394+
} else {
394395
if (nrnmpi_myid == 0) {
395-
printf(" WARNING : Report name '%s' has unknown format: '%s'.\n", config.name.data(), config.format.data());
396+
printf(" WARNING : Report name '%s' has unknown format: '%s'.\n",
397+
config.name.data(),
398+
config.format.data());
396399
}
397400
return nullptr;
398401
}
@@ -441,7 +444,7 @@ extern "C" int run_solve_core(int argc, char** argv) {
441444
Instrumentor::phase_begin("main");
442445

443446
std::vector<ReportConfiguration> configs;
444-
std::vector<std::unique_ptr<ReportHandler> > report_handlers;
447+
std::vector<std::unique_ptr<ReportHandler>> report_handlers;
445448
std::string spikes_population_name;
446449
bool reports_needs_finalize = false;
447450

@@ -485,7 +488,8 @@ extern "C" int run_solve_core(int argc, char** argv) {
485488
bool compute_gpu = corenrn_param.gpu;
486489
bool skip_mpi_finalize = corenrn_param.skip_mpi_finalize;
487490

488-
// clang-format off
491+
// clang-format off
492+
489493
#pragma acc data copyin(celsius, secondorder) if (compute_gpu)
490494
// clang-format on
491495
{
@@ -496,7 +500,8 @@ extern "C" int run_solve_core(int argc, char** argv) {
496500

497501
if (tstop < t && nrnmpi_myid == 0) {
498502
printf("Error: Stop time (%lf) < Start time (%lf), restoring from checkpoint? \n",
499-
tstop, t);
503+
tstop,
504+
t);
500505
abort();
501506
}
502507

@@ -524,7 +529,7 @@ extern "C" int run_solve_core(int argc, char** argv) {
524529
double min_report_dt = INT_MAX;
525530
for (size_t i = 0; i < configs.size(); i++) {
526531
std::unique_ptr<ReportHandler> report_handler = create_report_handler(configs[i]);
527-
if(report_handler) {
532+
if (report_handler) {
528533
report_handler->create_report(dt, tstop, delay);
529534
report_handlers.push_back(std::move(report_handler));
530535
}
@@ -578,16 +583,15 @@ extern "C" int run_solve_core(int argc, char** argv) {
578583

579584
// copy weights back to NEURON NetCon
580585
if (nrn2core_all_weights_return_) {
581-
582586
// first update weights from gpu
583587
update_weights_from_gpu(nrn_threads, nrn_nthread);
584588

585589
// store weight pointers
586590
std::vector<double*> weights(nrn_nthread, NULL);
587591

588592
// could be one thread more (empty) than in NEURON but does not matter
589-
for (int i=0; i < nrn_nthread; ++i) {
590-
weights[i] = nrn_threads[i].weights;
593+
for (int i = 0; i < nrn_nthread; ++i) {
594+
weights[i] = nrn_threads[i].weights;
591595
}
592596
(*nrn2core_all_weights_return_)(weights);
593597
}

0 commit comments

Comments
 (0)