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

Commit 4ffe156

Browse files
authored
clang-format: check *.h too (#805)
* ring_ref_solution.h: not used, remove
1 parent 6306690 commit 4ffe156

File tree

8 files changed

+98
-107
lines changed

8 files changed

+98
-107
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ set(CORENRN_3RDPARTY_DIR "external")
8989
# Adds .cu with respect to the current default in hpc-coding-conventions, and drops various patterns
9090
# that don't match anything in CoreNEURON.
9191
set(CORENRN_ClangFormat_FILES_RE
92-
"^.*\\\\.cu$$" "^.*\\\\.[chi]pp$$"
92+
"^.*\\\\.cu$$" "^.*\\\\.h$$" "^.*\\\\.[chi]pp$$"
9393
CACHE STRING "List of regular expressions matching C/C++ filenames" FORCE)
9494
set(CORENRN_ClangFormat_EXCLUDES_RE
9595
""

coreneuron/mpi/nrnmpi.h

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,39 @@ struct NRNMPI_Spike {
3333
double spiketime;
3434
};
3535

36-
// Those functions and classes are part of a mechanism to dynamically or statically load mpi functions
36+
// Those functions and classes are part of a mechanism to dynamically or statically load mpi
37+
// functions
3738
struct mpi_function_base;
3839

3940
struct mpi_manager_t {
40-
void register_function(mpi_function_base* ptr) {
41-
m_function_ptrs.push_back(ptr);
42-
}
43-
void resolve_symbols(void* dlsym_handle);
44-
private:
45-
std::vector<mpi_function_base*> m_function_ptrs;
46-
// true when symbols are resolved
41+
void register_function(mpi_function_base* ptr) {
42+
m_function_ptrs.push_back(ptr);
43+
}
44+
void resolve_symbols(void* dlsym_handle);
45+
46+
private:
47+
std::vector<mpi_function_base*> m_function_ptrs;
48+
// true when symbols are resolved
4749
};
4850

4951
inline mpi_manager_t& mpi_manager() {
50-
static mpi_manager_t x;
51-
return x;
52+
static mpi_manager_t x;
53+
return x;
5254
}
5355

5456
struct mpi_function_base {
55-
void resolve(void* dlsym_handle);
56-
operator bool() const { return m_fptr; }
57-
mpi_function_base(const char* name)
58-
: m_name{name} {
59-
mpi_manager().register_function(this);
60-
}
61-
protected:
62-
void* m_fptr{};
63-
const char* m_name;
57+
void resolve(void* dlsym_handle);
58+
operator bool() const {
59+
return m_fptr;
60+
}
61+
mpi_function_base(const char* name)
62+
: m_name{name} {
63+
mpi_manager().register_function(this);
64+
}
65+
66+
protected:
67+
void* m_fptr{};
68+
const char* m_name;
6469
};
6570

6671
// This could be done with a simpler
@@ -72,14 +77,14 @@ struct mpi_function {};
7277
#define cnrn_make_integral_constant_t(x) std::integral_constant<std::decay_t<decltype(x)>, x>
7378

7479
template <typename function_ptr, function_ptr fptr>
75-
struct mpi_function<std::integral_constant<function_ptr, fptr>> : mpi_function_base {
80+
struct mpi_function<std::integral_constant<function_ptr, fptr>>: mpi_function_base {
7681
using mpi_function_base::mpi_function_base;
77-
template <typename... Args> // in principle deducible from `function_ptr`
82+
template <typename... Args> // in principle deducible from `function_ptr`
7883
auto operator()(Args&&... args) const {
7984
#ifdef CORENRN_ENABLE_MPI_DYNAMIC
8085
// Dynamic MPI, m_fptr should have been initialised via dlsym.
8186
assert(m_fptr);
82-
return (*reinterpret_cast<decltype(fptr)>(m_fptr))(std::forward<Args>( args )...);
87+
return (*reinterpret_cast<decltype(fptr)>(m_fptr))(std::forward<Args>(args)...);
8388
#else
8489
// No dynamic MPI, use `fptr` directly. Will produce link errors if libmpi.so is not linked.
8590
return (*fptr)(std::forward<Args>(args)...);

coreneuron/mpi/nrnmpidec.h

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,32 @@ extern "C" void nrnmpi_check_threading_support_impl();
2929
extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_check_threading_support_impl)>
3030
nrnmpi_check_threading_support;
3131
// Write given buffer to a new file using MPI collective I/O
32-
extern "C" void nrnmpi_write_file_impl(const std::string& filename, const char* buffer, size_t length);
32+
extern "C" void nrnmpi_write_file_impl(const std::string& filename,
33+
const char* buffer,
34+
size_t length);
3335
extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_write_file_impl)> nrnmpi_write_file;
3436

3537

3638
/* from mpispike.cpp */
37-
extern "C" int nrnmpi_spike_exchange_impl(int* nin, NRNMPI_Spike* spikeout, int icapacity, NRNMPI_Spike** spikein, int& ovfl, int nout, NRNMPI_Spikebuf* spbufout, NRNMPI_Spikebuf* spbufin);
39+
extern "C" int nrnmpi_spike_exchange_impl(int* nin,
40+
NRNMPI_Spike* spikeout,
41+
int icapacity,
42+
NRNMPI_Spike** spikein,
43+
int& ovfl,
44+
int nout,
45+
NRNMPI_Spikebuf* spbufout,
46+
NRNMPI_Spikebuf* spbufin);
3847
extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_spike_exchange_impl)>
3948
nrnmpi_spike_exchange;
40-
extern "C" int nrnmpi_spike_exchange_compressed_impl(int, unsigned char*&, int, int*, int, unsigned char*, int, unsigned char*, int& ovfl);
49+
extern "C" int nrnmpi_spike_exchange_compressed_impl(int,
50+
unsigned char*&,
51+
int,
52+
int*,
53+
int,
54+
unsigned char*,
55+
int,
56+
unsigned char*,
57+
int& ovfl);
4158
extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_spike_exchange_compressed_impl)>
4259
nrnmpi_spike_exchange_compressed;
4360
extern "C" int nrnmpi_int_allmax_impl(int i);
@@ -47,18 +64,18 @@ extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_int_allgather_impl)> nr
4764
extern "C" void nrnmpi_int_alltoall_impl(int* s, int* r, int n);
4865
extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_int_alltoall_impl)> nrnmpi_int_alltoall;
4966
extern "C" void nrnmpi_int_alltoallv_impl(const int* s,
50-
const int* scnt,
51-
const int* sdispl,
52-
int* r,
53-
int* rcnt,
54-
int* rdispl);
67+
const int* scnt,
68+
const int* sdispl,
69+
int* r,
70+
int* rcnt,
71+
int* rdispl);
5572
extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_int_alltoallv_impl)> nrnmpi_int_alltoallv;
5673
extern "C" void nrnmpi_dbl_alltoallv_impl(double* s,
57-
int* scnt,
58-
int* sdispl,
59-
double* r,
60-
int* rcnt,
61-
int* rdispl);
74+
int* scnt,
75+
int* sdispl,
76+
double* r,
77+
int* rcnt,
78+
int* rdispl);
6279
extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_dbl_alltoallv_impl)> nrnmpi_dbl_alltoallv;
6380
extern "C" double nrnmpi_dbl_allmin_impl(double x);
6481
extern mpi_function<cnrn_make_integral_constant_t(nrnmpi_dbl_allmin_impl)> nrnmpi_dbl_allmin;

coreneuron/nrnoc/md1redef.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
#pragma once
1010

11-
#define v _v
12-
#define area _area
11+
#define v _v
12+
#define area _area
1313
#define thisnode _thisnode
14-
#define GC _GC
15-
#define EC _EC
16-
#define extnode _extnode
17-
#define xain _xain
18-
#define xbout _xbout
19-
#define i _i
20-
#define sec _sec
14+
#define GC _GC
15+
#define EC _EC
16+
#define extnode _extnode
17+
#define xain _xain
18+
#define xbout _xbout
19+
#define i _i
20+
#define sec _sec
2121

2222
#undef Memb_list
2323
#undef nodelist
@@ -31,13 +31,13 @@
3131
#undef weights
3232
#undef weight_index_
3333

34-
#define nodelist _nodelist
35-
#define nodeindices _nodeindices
36-
#define data _data
37-
#define pdata _pdata
38-
#define prop _prop
39-
#define nodecount _nodecount
40-
#define pval _pval
41-
#define id _id
42-
#define weights _weights
34+
#define nodelist _nodelist
35+
#define nodeindices _nodeindices
36+
#define data _data
37+
#define pdata _pdata
38+
#define prop _prop
39+
#define nodecount _nodecount
40+
#define pval _pval
41+
#define id _id
42+
#define weights _weights
4343
#define weight_index_ _weight_index

coreneuron/utils/nrn_assert.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ static void abortf(const char* fmt, ...) {
3232
/** assert()-like macro, independent of NDEBUG status */
3333
#define nrn_assert(x) \
3434
((x) || (abortf("%s:%d: Assertion '%s' failed.\n", __FILE__, __LINE__, #x), 0))
35-

coreneuron/utils/utils_cuda.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,24 @@
1212
#include <cuda_runtime_api.h>
1313

1414
// From Random123 lib
15-
#define CHECKLAST(MSG) do { cudaError_t e = cudaGetLastError(); if (e != cudaSuccess) {fprintf(stderr, "%s:%d: CUDA Error: %s: %s\n", __FILE__, __LINE__, (MSG), cudaGetErrorString(e)); exit(1); }} while(0)
16-
#define CHECKCALL(RET) do { cudaError_t e = (RET); if (e != cudaSuccess) { fprintf(stderr, "%s:%d: CUDA Error: %s\n", __FILE__, __LINE__, cudaGetErrorString(e)); exit(1); } } while(0)
15+
#define CHECKLAST(MSG) \
16+
do { \
17+
cudaError_t e = cudaGetLastError(); \
18+
if (e != cudaSuccess) { \
19+
fprintf(stderr, \
20+
"%s:%d: CUDA Error: %s: %s\n", \
21+
__FILE__, \
22+
__LINE__, \
23+
(MSG), \
24+
cudaGetErrorString(e)); \
25+
exit(1); \
26+
} \
27+
} while (0)
28+
#define CHECKCALL(RET) \
29+
do { \
30+
cudaError_t e = (RET); \
31+
if (e != cudaSuccess) { \
32+
fprintf(stderr, "%s:%d: CUDA Error: %s\n", __FILE__, __LINE__, cudaGetErrorString(e)); \
33+
exit(1); \
34+
} \
35+
} while (0)

coreneuron/utils/vrecitem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ class VecPlayContinuous: public PlayRecord {
8383
std::size_t discon_index_{};
8484
std::size_t ubound_index_{};
8585

86-
PlayRecordEvent* e_ = nullptr; // Need to be a raw pointer for acc
86+
PlayRecordEvent* e_ = nullptr; // Need to be a raw pointer for acc
8787
};
8888
} // namespace coreneuron

tests/integration/ring/ring_ref_solution.h

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)