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

Commit a3cc31c

Browse files
pramodkNicolas Cornu
andauthored
clang-format for missing header files (#471)
* clang-format for missing header files - #465 applied clang-format to the project but many header files were missed. - the reason for this was that include directory from build folder was added from which headers were included - considering how hpc-coding-convention exclude files (see BlueBrain/hpc-coding-conventions/pull/92), these header were ignored from the clang-format - In this PR we now add project directory into include prior to build directories - Perform clang-format on previously missing files * Fix clang-format for tests - make clang-format format files compiled by the project - when boost is not found, tests are not compiled and hence those files are not formatted - update github CI to install boost so that unit tests are also compiled Co-authored-by: Nicolas Cornu <[email protected]>
1 parent 7d80ff8 commit a3cc31c

Some content is hidden

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

47 files changed

+635
-586
lines changed

.github/workflows/clang_cmake_format_check.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ jobs:
1010
- name: Fetch repository
1111
uses: actions/checkout@v2
1212
- name: Install clang-format 11
13-
run: sudo apt-get install clang-format-11 python3-pip
13+
run: |
14+
sudo apt-get update
15+
sudo apt-get install clang-format-11 python3-pip libboost-all-dev libopenmpi-dev openmpi-bin
1416
- name: Install cmake-format 0.6.13
1517
run: python3 -m pip install cmake-format==0.6.13
1618
- name: Configure
@@ -19,11 +21,11 @@ jobs:
1921
run: |
2022
export PATH=/home/runner/.local/bin:$PATH
2123
mkdir BUILD && cd BUILD
22-
cmake -DCORENRN_CLANG_FORMAT=ON -DCORENRN_CMAKE_FORMAT=ON -DCORENRN_ENABLE_MPI=OFF -DCORENRN_ENABLE_OPENMP=OFF -DClangFormat_EXECUTABLE=$(which clang-format-11) -DCMakeFormat_EXECUTABLE=$(which cmake-format) ..
24+
cmake -DCORENRN_CLANG_FORMAT=ON -DCORENRN_CMAKE_FORMAT=ON -DCORENRN_ENABLE_MPI=ON -DCORENRN_ENABLE_OPENMP=OFF -DClangFormat_EXECUTABLE=$(which clang-format-11) -DCMakeFormat_EXECUTABLE=$(which cmake-format) ..
2325
- name: Run clang-format
2426
shell: bash
2527
working-directory: ${{runner.workspace}}/CoreNeuron/BUILD
26-
run: make check-clang-format
28+
run: make check-clang-format VERBOSE=1
2729
- name: Run cmake-format
2830
shell: bash
2931
working-directory: ${{runner.workspace}}/CoreNeuron/BUILD

coreneuron/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
# =============================================================================
66

77
# commonly included directories
8-
include_directories(utils/randoms ${MPI_INCLUDE_PATH} ${PROJECT_BINARY_DIR}/coreneuron
9-
${CMAKE_BINARY_DIR}/coreneuron ${CMAKE_BINARY_DIR}/include)
8+
include_directories(
9+
utils/randoms ${MPI_INCLUDE_PATH} ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/coreneuron
10+
${CMAKE_BINARY_DIR}/coreneuron ${CMAKE_BINARY_DIR}/include)
1011

1112
# put libraries (e.g. dll) in bin directory
1213
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

coreneuron/apps/corenrn_parameters.hpp

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -36,74 +36,71 @@
3636
namespace coreneuron {
3737

3838
struct corenrn_parameters {
39-
40-
enum verbose_level : std::uint32_t
41-
{
42-
NONE = 0,
43-
ERROR = 1,
44-
INFO = 2,
45-
DEBUG = 3,
46-
DEFAULT = INFO
47-
};
48-
49-
const int report_buff_size_default=4;
50-
51-
unsigned spikebuf=100'000; /// Internal buffer used on every rank for spikes
52-
int prcellgid=-1; /// Gid of cell for prcellstate
53-
unsigned ms_phases=2; /// Number of multisend phases, 1 or 2
54-
unsigned ms_subint=2; /// Number of multisend interval. 1 or 2
55-
unsigned spkcompress=0; /// Spike Compression
56-
unsigned cell_interleave_permute=0; /// Cell interleaving permutation
57-
unsigned nwarp=0; /// Number of warps to balance for cell_interleave_permute == 2
58-
unsigned report_buff_size=report_buff_size_default; ///Size in MB of the report buffer.
59-
int seed=-1; /// Initialization seed for random number generator (int)
60-
61-
bool mpi_enable=false; /// Enable MPI flag.
62-
bool skip_mpi_finalize=false; /// Skip MPI finalization
63-
bool multisend=false; /// Use Multisend spike exchange instead of Allgather.
64-
bool threading=false; /// Enable pthread/openmp
65-
bool gpu=false; /// Enable GPU computation.
66-
bool binqueue=false; /// Use bin queue.
67-
68-
bool show_version=false; /// Print version and exit.
69-
70-
bool count_mechs=false; /// Print mechanism counts after initialization
71-
72-
verbose_level verbose{verbose_level::DEFAULT}; /// Verbosity-level
73-
74-
double tstop=100; /// Stop time of simulation in msec
75-
double dt=-1000.0; /// Timestep to use in msec
76-
double dt_io=0.1; /// I/O timestep to use in msec
77-
double dt_report; /// I/O timestep to use in msec for reports
78-
double celsius=-1000.0; /// Temperature in degC.
79-
double voltage=-65.0; /// Initial voltage used for nrn_finitialize(1, v_init).
80-
double forwardskip=0.; /// Forward skip to TIME.
81-
double mindelay=10.; /// Maximum integration interval (likely reduced by minimum NetCon delay).
82-
83-
std::string patternstim; /// Apply patternstim using the specified spike file.
84-
std::string datpath="."; /// Directory path where .dat files
85-
std::string outpath="."; /// Directory where spikes will be written
86-
std::string filesdat="files.dat"; /// Name of file containing list of gids dat files read in
87-
std::string restorepath; /// Restore simulation from provided checkpoint directory.
88-
std::string reportfilepath; /// Reports configuration file.
89-
std::string checkpointpath; /// Enable checkpoint and specify directory to store related files.
90-
std::string writeParametersFilepath; /// Write parameters to this file
91-
92-
CLI::App app{"CoreNeuron - Optimised Simulator Engine for NEURON."}; ///CLI app that performs CLI parsing
93-
94-
corenrn_parameters(); ///Constructor that initializes the CLI11 app.
95-
96-
void parse(int argc, char* argv[]); /// Runs the CLI11_PARSE macro.
97-
98-
inline bool is_quiet() { return verbose == verbose_level::NONE; }
99-
39+
enum verbose_level : std::uint32_t { NONE = 0, ERROR = 1, INFO = 2, DEBUG = 3, DEFAULT = INFO };
40+
41+
const int report_buff_size_default = 4;
42+
43+
unsigned spikebuf = 100'000; /// Internal buffer used on every rank for spikes
44+
int prcellgid = -1; /// Gid of cell for prcellstate
45+
unsigned ms_phases = 2; /// Number of multisend phases, 1 or 2
46+
unsigned ms_subint = 2; /// Number of multisend interval. 1 or 2
47+
unsigned spkcompress = 0; /// Spike Compression
48+
unsigned cell_interleave_permute = 0; /// Cell interleaving permutation
49+
unsigned nwarp = 0; /// Number of warps to balance for cell_interleave_permute == 2
50+
unsigned report_buff_size = report_buff_size_default; /// Size in MB of the report buffer.
51+
int seed = -1; /// Initialization seed for random number generator (int)
52+
53+
bool mpi_enable = false; /// Enable MPI flag.
54+
bool skip_mpi_finalize = false; /// Skip MPI finalization
55+
bool multisend = false; /// Use Multisend spike exchange instead of Allgather.
56+
bool threading = false; /// Enable pthread/openmp
57+
bool gpu = false; /// Enable GPU computation.
58+
bool binqueue = false; /// Use bin queue.
59+
60+
bool show_version = false; /// Print version and exit.
61+
62+
bool count_mechs = false; /// Print mechanism counts after initialization
63+
64+
verbose_level verbose{verbose_level::DEFAULT}; /// Verbosity-level
65+
66+
double tstop = 100; /// Stop time of simulation in msec
67+
double dt = -1000.0; /// Timestep to use in msec
68+
double dt_io = 0.1; /// I/O timestep to use in msec
69+
double dt_report; /// I/O timestep to use in msec for reports
70+
double celsius = -1000.0; /// Temperature in degC.
71+
double voltage = -65.0; /// Initial voltage used for nrn_finitialize(1, v_init).
72+
double forwardskip = 0.; /// Forward skip to TIME.
73+
double mindelay = 10.; /// Maximum integration interval (likely reduced by minimum NetCon
74+
/// delay).
75+
76+
std::string patternstim; /// Apply patternstim using the specified spike file.
77+
std::string datpath = "."; /// Directory path where .dat files
78+
std::string outpath = "."; /// Directory where spikes will be written
79+
std::string filesdat = "files.dat"; /// Name of file containing list of gids dat files read in
80+
std::string restorepath; /// Restore simulation from provided checkpoint directory.
81+
std::string reportfilepath; /// Reports configuration file.
82+
std::string checkpointpath; /// Enable checkpoint and specify directory to store related files.
83+
std::string writeParametersFilepath; /// Write parameters to this file
84+
85+
CLI::App app{"CoreNeuron - Optimised Simulator Engine for NEURON."}; /// CLI app that performs
86+
/// CLI parsing
87+
88+
corenrn_parameters(); /// Constructor that initializes the CLI11 app.
89+
90+
void parse(int argc, char* argv[]); /// Runs the CLI11_PARSE macro.
91+
92+
inline bool is_quiet() {
93+
return verbose == verbose_level::NONE;
94+
}
10095
};
10196

102-
std::ostream& operator<<(std::ostream& os, const corenrn_parameters& corenrn_param); /// Printing method.
97+
std::ostream& operator<<(std::ostream& os,
98+
const corenrn_parameters& corenrn_param); /// Printing method.
10399

104-
extern corenrn_parameters corenrn_param; /// Declaring global corenrn_parameters object for this instance of CoreNeuron.
105-
extern int nrn_nobanner_; /// Global no banner setting
100+
extern corenrn_parameters corenrn_param; /// Declaring global corenrn_parameters object for this
101+
/// instance of CoreNeuron.
102+
extern int nrn_nobanner_; /// Global no banner setting
106103

107104
} // namespace coreneuron
108105

109-
#endif //CN_PARAMETERS_H
106+
#endif // CN_PARAMETERS_H

coreneuron/coreneuron.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
#include <vector>
2222
#include <array>
2323

24-
#include "coreneuron/utils/randoms/nrnran123.h" //Random Number Generator
24+
#include "coreneuron/utils/randoms/nrnran123.h" //Random Number Generator
2525
#include "coreneuron/sim/scopmath/newton_struct.h" //Newton Struct
26-
#include "coreneuron/membrane_definitions.h" //static definitions
27-
#include "coreneuron/mechanism/mechanism.hpp" //Memb_list and mechs info
26+
#include "coreneuron/membrane_definitions.h" //static definitions
27+
#include "coreneuron/mechanism/mechanism.hpp" //Memb_list and mechs info
2828

2929
#include "coreneuron/utils/memory.h" //Memory alignments and padding
3030
#include "coreneuron/nrnconf.h"
@@ -54,7 +54,6 @@ using DependencyTable = std::vector<std::vector<int>>;
5454
* this class.
5555
*/
5656
class CoreNeuron {
57-
5857
/**
5958
* map if mech is a point process
6059
* In the future only a field of Mechanism class
@@ -128,7 +127,6 @@ class CoreNeuron {
128127
std::vector<bbcore_write_t> nrn_bbcore_write;
129128

130129
public:
131-
132130
auto& get_memb_funcs() {
133131
return memb_funcs;
134132
}
@@ -212,7 +210,6 @@ class CoreNeuron {
212210
auto& get_bbcore_write() {
213211
return nrn_bbcore_write;
214212
}
215-
216213
};
217214

218215
extern CoreNeuron corenrn;

coreneuron/io/core2nrn_data_return.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ namespace coreneuron {
1616
extern void core2nrn_data_return();
1717

1818
} // namespace coreneuron
19-
#endif // _H_CORENRNDATARETURN_
20-
19+
#endif // _H_CORENRNDATARETURN_

coreneuron/io/mech_report.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <string>
1313

1414
namespace coreneuron {
15-
/// write mechanism counts to stdout
16-
void write_mech_report();
17-
}
15+
/// write mechanism counts to stdout
16+
void write_mech_report();
17+
} // namespace coreneuron
1818

1919
#endif

coreneuron/io/nrn2core_direct.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ extern void (*nrn2core_trajectory_values_)(int tid, int n_pr, void** vpr, double
107107
/* Filled the Vector data arrays and send back the sizes at end of run */
108108
extern void (*nrn2core_trajectory_return_)(int tid, int n_pr, int vecsz, void** vpr, double t);
109109

110-
/* send all spikes vectors to NEURON */
111-
extern int (*nrn2core_all_spike_vectors_return_)(std::vector<double>& spikevec, std::vector<int>& gidvec);
110+
/* send all spikes vectors to NEURON */
111+
extern int (*nrn2core_all_spike_vectors_return_)(std::vector<double>& spikevec,
112+
std::vector<int>& gidvec);
112113

113114
/* send all weights to NEURON */
114115
extern void (*nrn2core_all_weights_return_)(std::vector<double*>& weights);
115116

116117
/* get data array pointer from NEURON to copy into. */
117-
extern size_t (*nrn2core_type_return_)(int type, int tid, double*& data,
118-
double**& mdata);
119-
} // extern "C"
118+
extern size_t (*nrn2core_type_return_)(int type, int tid, double*& data, double**& mdata);
119+
} // extern "C"
120120

121121
#endif /* nrn2core_direct_h */

coreneuron/io/nrn_checkpoint.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ class FileHandler;
1717

1818
extern bool nrn_checkpoint_arg_exists;
1919

20-
void write_checkpoint(NrnThread* nt,
21-
int nb_threads,
22-
const char* dir);
20+
void write_checkpoint(NrnThread* nt, int nb_threads, const char* dir);
2321

2422
void checkpoint_restore_tqueue(NrnThread&, const Phase2& p2);
2523

@@ -88,7 +86,6 @@ struct NrnThreadChkpnt {
8886
int* mtype;
8987
int* vecplay_ix;
9088
#endif // CHKPNTDEBUG
91-
9289
};
9390

9491
extern NrnThreadChkpnt* nrnthread_chkpnt;

coreneuron/io/nrn_filehandler.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ class FileHandler {
4848
FileHandler& operator=(const FileHandler&);
4949

5050
public:
51-
FileHandler() : chkpnt(0), stored_chkpnt(0) {
52-
}
51+
FileHandler()
52+
: chkpnt(0)
53+
, stored_chkpnt(0) {}
5354

5455
explicit FileHandler(const std::string& filename);
5556

@@ -166,7 +167,7 @@ class FileHandler {
166167
F.seekg(count * sizeof(T), std::ios_base::cur);
167168
break;
168169
case read:
169-
F.read((char*)p, count * sizeof(T));
170+
F.read((char*) p, count * sizeof(T));
170171
break;
171172
}
172173

@@ -204,7 +205,7 @@ class FileHandler {
204205
nrn_assert(F.is_open());
205206
nrn_assert(current_mode & std::ios::out);
206207
write_checkpoint();
207-
F.write((const char*)p, nb_elements * (sizeof(T)));
208+
F.write((const char*) p, nb_elements * (sizeof(T)));
208209
nrn_assert(!F.fail());
209210
}
210211

@@ -232,7 +233,7 @@ class FileHandler {
232233
}
233234
// AoS never use padding, SoA is translated above, so one write
234235
// operation is enought in both cases
235-
F.write((const char*)temp_cpy, nb_elements * sizeof(T) * nb_lines);
236+
F.write((const char*) temp_cpy, nb_elements * sizeof(T) * nb_lines);
236237
nrn_assert(!F.fail());
237238
delete[] temp_cpy;
238239
}

coreneuron/io/nrn_setup.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ inline void* phase_wrapper_w(NrnThread* nt, UserParams& userParams, bool in_memo
9999
data_dir = userParams.restore_path;
100100
}
101101

102-
std::string fname = std::string(data_dir) + "/" + std::to_string(userParams.gidgroups[i]) + "_" + getPhaseName<P>() + ".dat";
102+
std::string fname = std::string(data_dir) + "/" +
103+
std::to_string(userParams.gidgroups[i]) + "_" + getPhaseName<P>() +
104+
".dat";
103105

104106
// Avoid trying to open the gid_gap.dat file if it doesn't exist when there are no
105107
// gap junctions in this gid

0 commit comments

Comments
 (0)